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

#include "stdafx.h"
#include "SilkModule.h"
#include "SetParam.h"


// CSetParam 对话框

IMPLEMENT_DYNAMIC(CSetParam, CDialog)

CSetParam::CSetParam(CWnd* pParent /*=NULL*/)
	: CDialog(CSetParam::IDD, pParent)
{

}

CSetParam::~CSetParam()
{
}

void CSetParam::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CSetParam, CDialog)
	//ON_BN_CLICKED(IDOK, &CSetParam::OnOK)
	ON_BN_CLICKED(IDCANCEL, &CSetParam::OnCancel)
	ON_BN_CLICKED(IDOK, &CSetParam::OnBnClickedOk)
END_MESSAGE_MAP()


// CSetParam 消息处理程序

void CSetParam::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码
	//m_gpioLevel = IsDlgButtonChecked(IDC_CHECK_GPIO_LEVEL);
	m_saveLog = IsDlgButtonChecked(IDC_CHECK_SAVE_LOG);
	m_autoAck = IsDlgButtonChecked(IDC_CHECK_AUTO_ACK);
	CString str;
	GetDlgItem(IDC_EDIT_TIMEOUT)->GetWindowText(str);
	m_timeOut = atoi(str);
	m_WorkMode = ((CComboBox *)GetDlgItem(IDC_COMBO_WORKMODE))->GetCurSel();
	m_TmpFormat = ((CComboBox *)GetDlgItem(IDC_COMBO_TMP_FORMAT))->GetCurSel() + 1;
	
	int color = ((CComboBox *)GetDlgItem(IDC_COMBO_LAMP_COLOR))->GetCurSel();
	switch (color)
	{
	case 0:
		m_LampColor = 0x40;
		break;
	case 1:
		m_LampColor = 0x80;
		break;
	case 2:
		m_LampColor = 0xC0;
		break;
	}
	
	m_LampTime = ((CComboBox *)GetDlgItem(IDC_COMBO_LAST_TIME))->GetCurSel() * 2 + 1;
	OnOK();
}

BOOL CSetParam::OnInitDialog()
{
	CDialog::OnInitDialog();
	((CComboBox *)GetDlgItem(IDC_COMBO_WORKMODE))->InsertString(0, "验证");
	((CComboBox *)GetDlgItem(IDC_COMBO_WORKMODE))->InsertString(1, "读头(图片)");
	((CComboBox *)GetDlgItem(IDC_COMBO_WORKMODE))->InsertString(2, "读头(模板)");
	((CComboBox *)GetDlgItem(IDC_COMBO_WORKMODE))->SetCurSel(0);

	((CComboBox *)GetDlgItem(IDC_COMBO_TMP_FORMAT))->InsertString(0, "ZK");
	((CComboBox *)GetDlgItem(IDC_COMBO_TMP_FORMAT))->InsertString(1, "Ansi 378");
	((CComboBox *)GetDlgItem(IDC_COMBO_TMP_FORMAT))->InsertString(2, "ISO 19794-2");
	((CComboBox *)GetDlgItem(IDC_COMBO_TMP_FORMAT))->SetCurSel(0);
	
	((CComboBox *)GetDlgItem(IDC_COMBO_LAMP_COLOR))->InsertString(0, "红灯");
	((CComboBox *)GetDlgItem(IDC_COMBO_LAMP_COLOR))->InsertString(1, "绿灯");
	((CComboBox *)GetDlgItem(IDC_COMBO_LAMP_COLOR))->InsertString(2, "黄灯");
	((CComboBox *)GetDlgItem(IDC_COMBO_LAMP_COLOR))->SetCurSel(0);

	((CComboBox *)GetDlgItem(IDC_COMBO_LAST_TIME))->InsertString(0, "1");
	((CComboBox *)GetDlgItem(IDC_COMBO_LAST_TIME))->InsertString(1, "3");
	((CComboBox *)GetDlgItem(IDC_COMBO_LAST_TIME))->InsertString(2, "5");
	((CComboBox *)GetDlgItem(IDC_COMBO_LAST_TIME))->SetCurSel(0);
	GetDlgItem(IDC_EDIT_TIMEOUT)->SetWindowText("12");
	return TRUE;
}