// demoShowSettingWindowDlg.cpp : 实现文件
//

#include "stdafx.h"
#include "demoShowSettingWindowDlg.h"
#include "afxdialogex.h"
#include "demo.h"
#include "demoTools.h"
#include "HwmSdkAgent.h"


// demoShowSettingWindowDlg 对话框

IMPLEMENT_DYNAMIC(demoShowSettingWindowDlg, CDialogEx)

demoShowSettingWindowDlg::demoShowSettingWindowDlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_SHOW_SETTING_WINDOW, pParent)
{

}

demoShowSettingWindowDlg::~demoShowSettingWindowDlg()
{
}

void demoShowSettingWindowDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_COMBO_SETTING_PAGE, m_settingPage);
}


BEGIN_MESSAGE_MAP(demoShowSettingWindowDlg, CDialogEx)
    ON_BN_CLICKED(IDC_BUTTON_SHOW, &demoShowSettingWindowDlg::OnBnClickedButtonShow)
    ON_BN_CLICKED(IDC_BUTTON_CLOSE, &demoShowSettingWindowDlg::OnBnClickedButtonClose)
END_MESSAGE_MAP()


// demoShowSettingWindowDlg 消息处理程序


void demoShowSettingWindowDlg::OnBnClickedButtonShow()
{
    // TODO: 在此添加控件通知处理程序代码
    hwmsdkagent::HwmSettingPage settingPage = hwmsdkagent::HwmSettingPage::SETTING_PAGE_NORMAL;
    int iPage = m_settingPage.GetCurSel();
    if (iPage < hwmsdkagent::HwmSettingPage::SETTING_PAGE_NORMAL || iPage >= hwmsdkagent::HwmSettingPage::SETTING_PAGE_COUNT)
    {
        iPage = 0;
    }
    settingPage = static_cast<hwmsdkagent::HwmSettingPage>(iPage);
    hwmsdkagent::HwmShowSettingWindowInfo showInfo{};
    showInfo.isShow = true;
    showInfo.defaultPage = settingPage;

    int ret = hwmsdkagent::ShowSettingWindow(&showInfo);
}


BOOL demoShowSettingWindowDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();

    // TODO:  在此添加额外的初始化

    m_settingPage.SetWindowText(_T("Normal"));
    m_settingPage.InsertString(0, _T("Normal"));
    m_settingPage.InsertString(1, _T("Video"));
    m_settingPage.InsertString(2, _T("Audio"));
    m_settingPage.InsertString(3, _T("Record"));
    m_settingPage.InsertString(4, _T("Hotkey"));
    m_settingPage.InsertString(5, _T("Screen"));

    return TRUE;  // return TRUE unless you set the focus to a control
                  // 异常: OCX 属性页应返回 FALSE
}


void demoShowSettingWindowDlg::OnBnClickedButtonClose()
{
    // TODO: 在此添加控件通知处理程序代码
    hwmsdkagent::HwmSettingPage settingPage = hwmsdkagent::HwmSettingPage::SETTING_PAGE_NORMAL;
    int iPage = m_settingPage.GetCurSel();
    if (iPage < 0 || iPage > 4)
    {
        iPage = 0;
    }
    settingPage = static_cast<hwmsdkagent::HwmSettingPage>(iPage);
    hwmsdkagent::HwmShowSettingWindowInfo showInfo{};
    showInfo.isShow = false;
    showInfo.defaultPage = settingPage;

    int ret = hwmsdkagent::ShowSettingWindow(&showInfo);
}
