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

#include "stdafx.h"
#include "CombineSubjectDrawTest.h"
#include "MenuLRectZoom_Dlg.h"
#include "afxdialogex.h"


// CMenuLRectZoom_Dlg 对话框

IMPLEMENT_DYNAMIC(CMenuLRectZoom_Dlg, CDialogEx)

CMenuLRectZoom_Dlg::CMenuLRectZoom_Dlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_DIALOG_LBUTTON_ZOOM, pParent)
{
	m_pControl = NULL;
}

CMenuLRectZoom_Dlg::~CMenuLRectZoom_Dlg()
{
}

void CMenuLRectZoom_Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_COMBO_LINE, m_line_cbx);
	DDX_Control(pDX, IDC_MFCCOLORBUTTON_COLOR, m_btn_color);
}


BEGIN_MESSAGE_MAP(CMenuLRectZoom_Dlg, CDialogEx)
	ON_BN_CLICKED(IDC_CHECK_ENABLE, &CMenuLRectZoom_Dlg::OnBnClickedCheckEnable)
	ON_CBN_SELCHANGE(IDC_COMBO_LINE, &CMenuLRectZoom_Dlg::OnCbnSelchangeComboLine)
	ON_BN_CLICKED(IDC_MFCCOLORBUTTON_COLOR, &CMenuLRectZoom_Dlg::OnBnClickedMfccolorbuttonColor)
	ON_BN_CLICKED(IDOK, &CMenuLRectZoom_Dlg::OnBnClickedOk)
END_MESSAGE_MAP()


// CMenuLRectZoom_Dlg 消息处理程序


void CMenuLRectZoom_Dlg::OnBnClickedCheckEnable()
{
	CButton* pCheck = (CButton*)GetDlgItem(IDC_CHECK_ENABLE);
	m_line_cbx.EnableWindow(pCheck->GetCheck());
	m_btn_color.EnableWindow(pCheck->GetCheck());



	m_pControl->EnableMouseRectZoom(pCheck->GetCheck());
}


void CMenuLRectZoom_Dlg::OnCbnSelchangeComboLine()
{
	// TODO: 在此添加控件通知处理程序代码
	int nSel = m_line_cbx.GetCurSel();
	int nWidth = m_line_cbx.GetItemData(nSel);
	m_pControl->SetMouseRectZoomLineWidth(nWidth);
}


void CMenuLRectZoom_Dlg::OnBnClickedMfccolorbuttonColor()
{
	m_pControl->SetMouseRectZoomLineColor(m_btn_color.GetColor());
	

}
BOOL CMenuLRectZoom_Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  在此添加额外的初始化
	CString strValue;
	int nItem = 0;
	for (int i = 1; i < 5; i++)
	{
		strValue.Format(_T("%d"), i);
		nItem = m_line_cbx.AddString(strValue);
		m_line_cbx.SetItemData(nItem, i);
	}
	m_line_cbx.SetCurSel(0);

	int nWidth = 1;
	m_pControl->GetMouseRectZoomLineWidth(nWidth);

	for (int i = 1; i < m_line_cbx.GetCount(); i++)
	{
		if (m_line_cbx.GetItemData(i) == nWidth)
		{
			m_line_cbx.SetCurSel(i);
			break;
		}
	}

	//
	CMFCColorButton * pColorBtn = (CMFCColorButton*)GetDlgItem(IDC_MFCCOLORBUTTON_COLOR);
	COLORREF _color;
	m_pControl->GetMouseRectZoomLineColor(_color);
	pColorBtn->SetColor(_color);
	//
	CButton* pCheck = (CButton*)GetDlgItem(IDC_CHECK_ENABLE);
	pCheck->SetCheck(m_pControl->IsEnableMouseRectZoom());
	 
	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}


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