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

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

// demotartShareDlg 对话框

IMPLEMENT_DYNAMIC(demoEnablePairDlg, CDialogEx)

demoEnablePairDlg::demoEnablePairDlg(CWnd* pParent /*=NULL*/)
    : CDialogEx(IDD_ENABLE_PAIR_DIALOG, pParent)
{

}

demoEnablePairDlg::~demoEnablePairDlg()
{
}

void demoEnablePairDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_COMBO_IS_ENABLE, m_isEnableCombo);
}

BOOL demoEnablePairDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    
    m_isEnableCombo.SetWindowText(_T("Yes"));
    m_isEnableCombo.InsertString(0, _T("Yes"));
    m_isEnableCombo.InsertString(1,_T("No"));

    return TRUE;
}

BEGIN_MESSAGE_MAP(demoEnablePairDlg, CDialogEx)
    ON_BN_CLICKED(IDOK, &demoEnablePairDlg::OnBnClickedOk)
    ON_BN_CLICKED(IDCANCEL, &demoEnablePairDlg::OnBnClickedCancel)
END_MESSAGE_MAP()


int demoEnablePairDlg::clickEnablePair()
{
    bool isEnablePair = TRUE;
    //开启或关闭配对功能
    CString strIsEnable;
    m_isEnableCombo.GetWindowText(strIsEnable);
    if(_T("Yes") == strIsEnable)
    {
        isEnablePair = TRUE;
    }
    else if(_T("No") == strIsEnable)
    {
        isEnablePair = FALSE;
    }

    int ret = hwmsdkagent::EnablePair(isEnablePair);
    return ret;
}

void demoEnablePairDlg::OnBnClickedOk()
{
    int ret = clickEnablePair();
    if (hwmsdk::HWM_COMMON_SUCCESS != ret)
    {
        CTools::OutputRetStr("EnablePair error");
        return;
    }
    CDialogEx::OnOK();
}


void demoEnablePairDlg::OnBnClickedCancel()
{
    // TODO: 在此添加控件通知处理程序代码
    CDialogEx::OnCancel();
}

