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

#include "stdafx.h"
#include "Verbpo.h"
#include "DialogECGSetARRA.h"
#include "afxdialogex.h"
#include "VerbpoDlg.h"

// CDialogECGSetARRA 对话框

IMPLEMENT_DYNAMIC(CDialogECGSetARRA, CDialogEx)

CDialogECGSetARRA::CDialogECGSetARRA(CWnd* pParent /*=NULL*/)
	: CDialogEx(CDialogECGSetARRA::IDD, pParent)
{

}

CDialogECGSetARRA::~CDialogECGSetARRA()
{
}

void CDialogECGSetARRA::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_COMBO_ECG_SET_ARRA_SW, m_CComboBoxARRASW);
	DDX_Control(pDX, IDC_COMBO_ECG_SET_ARRA_ALM_SW, m_CComboBoxAlmSW);
	DDX_Control(pDX, IDC_COMBO_ECG_SET_ARRA_ALM_LEVEL, m_CComboBoxAlmLevel);
	DDX_Control(pDX, IDC_COMBO_ECG_SET_ARRA_ALM_REC, m_CComboBoxAlmRec);
	DDX_Control(pDX, IDC_EDIT_ECG_SET_ARRA_PVCS_H, m_CEditPVCsH);
}


BOOL CDialogECGSetARRA::OnInitDialog()
{
	CString a_cs;
	INT i;

	CDialogEx::OnInitDialog();

	// TODO:  在此添加额外的初始化
	m_CComboBoxARRASW.AddString(CString(_T("关")));
	m_CComboBoxARRASW.AddString(CString(_T("开")));
	m_CComboBoxARRASW.SetCurSel(theApp.m_Data->m_i32ParaECGARRASW);

	m_CComboBoxAlmSW.AddString(CString(_T("关")));
	m_CComboBoxAlmSW.AddString(CString(_T("开")));
	m_CComboBoxAlmSW.SetCurSel(theApp.m_Data->m_i32ParaECGARRA_ALM_SW);

	m_CComboBoxAlmLevel.AddString(CString(_T("低")));
	m_CComboBoxAlmLevel.AddString(CString(_T("中")));
	m_CComboBoxAlmLevel.AddString(CString(_T("高")));
	m_CComboBoxAlmLevel.SetCurSel(theApp.m_Data->m_i32ParaECGARRA_ALM_LEVEL);

	m_CComboBoxAlmRec.AddString(CString(_T("关")));
	m_CComboBoxAlmRec.AddString(CString(_T("开")));
	m_CComboBoxAlmRec.SetCurSel(theApp.m_Data->m_i32ParaECGARRA_ALM_REC);

	i = theApp.m_Data->m_i32ParaECGARRA_PVCS_ALM_H;
	a_cs.Format(_T("%d"), i);
	m_CEditPVCsH.SetWindowTextW(a_cs);

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


BOOL CDialogECGSetARRA::PreTranslateMessage(MSG* pMsg)
{
	// TODO:  在此添加专用代码和/或调用基类
	CRect     rect;
	int i = 0;

	CString a_cs;
	// TODO:  在此添加专用代码和/或调用基类

	if (WM_LBUTTONDOWN == pMsg->message&& m_CEditPVCsH.GetSafeHwnd() == pMsg->hwnd)
	{
		m_CEditPVCsH.GetWindowTextW(a_cs);
		m_CEditPVCsH.GetWindowRect(&rect);       //获得文本框矩形,左上角坐标(0,0)   
		((CVerbpoDlg *)theApp.m_pMainWnd)->m_CDialogNumInput.set_type(NUM_INPUT_DOT | NUM_INPUT_SYMBOL);
		((CVerbpoDlg *)theApp.m_pMainWnd)->m_CDialogNumInput.set_title(CString(_T("PVCs上限")));
		((CVerbpoDlg *)theApp.m_pMainWnd)->m_CDialogNumInput.set_result(a_cs);
		((CVerbpoDlg *)theApp.m_pMainWnd)->m_CDialogNumInput.set_pos(rect.left, rect.top);
		((CVerbpoDlg *)theApp.m_pMainWnd)->m_CDialogNumInput.DoModal();
		((CVerbpoDlg *)theApp.m_pMainWnd)->m_CDialogNumInput.get_result(a_cs);
		
		a_cs = input_PVCsAlmH_check(a_cs);
		i = _ttoi(a_cs);

		theApp.m_Data->m_i32ParaECGARRA_PVCS_ALM_H = i;
		theApp.m_Data->m_CParameterSet.set_ECGARRAPVCsH(i);
		m_CEditPVCsH.SetWindowTextW(a_cs);
		return TRUE;
	}
	
	return CDialogEx::PreTranslateMessage(pMsg);
}

BEGIN_MESSAGE_MAP(CDialogECGSetARRA, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON_ECG_SET_ARRA_LEARN, &CDialogECGSetARRA::OnBnClickedButtonEcgSetArraLearn)
	ON_CBN_SELCHANGE(IDC_COMBO_ECG_SET_ARRA_SW, &CDialogECGSetARRA::OnCbnSelchangeComboEcgSetArraSw)
	ON_CBN_SELCHANGE(IDC_COMBO_ECG_SET_ARRA_ALM_SW, &CDialogECGSetARRA::OnCbnSelchangeComboEcgSetArraAlmSw)
	ON_CBN_SELCHANGE(IDC_COMBO_ECG_SET_ARRA_ALM_LEVEL, &CDialogECGSetARRA::OnCbnSelchangeComboEcgSetArraAlmLevel)
	ON_CBN_SELCHANGE(IDC_COMBO_ECG_SET_ARRA_ALM_REC, &CDialogECGSetARRA::OnCbnSelchangeComboEcgSetArraAlmRec)
END_MESSAGE_MAP()


// CDialogECGSetARRA 消息处理程序


void CDialogECGSetARRA::OnBnClickedButtonEcgSetArraLearn()
{
	// TODO:  在此添加控件通知处理程序代码
}


CString CDialogECGSetARRA::input_PVCsAlmH_check(CString & cs)
{
	int a = 0;
	CString a_cs;
	
	a = _ttoi(cs);
	
	if (a > ECG_PVCS_ALM_H_MAX)
	{
		a = ECG_PVCS_ALM_H_MAX;
	}
	a_cs.Format(_T("%d"), a);

	return a_cs;
}

void CDialogECGSetARRA::OnCbnSelchangeComboEcgSetArraSw()
{
	// TODO:  在此添加控件通知处理程序代码
	theApp.m_Data->m_i32ParaECGARRASW = m_CComboBoxARRASW.GetCurSel();
	theApp.m_Data->m_CParameterSet.set_ECGARRASW(theApp.m_Data->m_i32ParaECGARRASW);

	if (theApp.m_Data->m_i32ParaECGARRASW == 0)
	{
		//报警 从 开 到 关
		theApp.m_Data->Del_ECG_Alm_ALL(ALM_TYPE_ARRA, DEL_ALL);
	}
	else
	{
	}
}


void CDialogECGSetARRA::OnCbnSelchangeComboEcgSetArraAlmSw()
{
	// TODO:  在此添加控件通知处理程序代码
	theApp.m_Data->m_i32ParaECGARRA_ALM_SW = m_CComboBoxAlmSW.GetCurSel();
	theApp.m_Data->m_CParameterSet.set_ECGARRAAlmSw(theApp.m_Data->m_i32ParaECGARRA_ALM_SW);

	if (theApp.m_Data->m_i32ParaECGARRA_ALM_SW == 0)
	{
		//报警 从 开 到 关
		theApp.m_Data->Del_ECG_Alm_ALL(ALM_TYPE_ARRA, DEL_ALL);
	}
	else
	{
	}
}


void CDialogECGSetARRA::OnCbnSelchangeComboEcgSetArraAlmLevel()
{
	// TODO:  在此添加控件通知处理程序代码
	theApp.m_Data->m_i32ParaECGARRA_ALM_LEVEL = m_CComboBoxAlmLevel.GetCurSel();
	theApp.m_Data->m_CParameterSet.set_ECGAlmLevel(theApp.m_Data->m_i32ParaECGARRA_ALM_LEVEL);
}


void CDialogECGSetARRA::OnCbnSelchangeComboEcgSetArraAlmRec()
{
	// TODO:  在此添加控件通知处理程序代码
	theApp.m_Data->m_i32ParaECGARRA_ALM_REC = m_CComboBoxAlmRec.GetCurSel();
	theApp.m_Data->m_CParameterSet.set_ECGAlmLevel(theApp.m_Data->m_i32ParaECGARRA_ALM_REC);
}
