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

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


#include "PublicObj.h"
// CMenuMarkModeSetting_Dlg 对话框

IMPLEMENT_DYNAMIC(CMenuMarkModeSetting_Dlg, CDialogEx)

CMenuMarkModeSetting_Dlg::CMenuMarkModeSetting_Dlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_DIALOG_MARK_MODE, pParent)
	//, m_strFontText(_T(""))
{
	m_pControl = NULL;
}

CMenuMarkModeSetting_Dlg::~CMenuMarkModeSetting_Dlg()
{
}

void CMenuMarkModeSetting_Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_CHECK_MODE, m_btnEnable);
	DDX_Control(pDX, IDC_CHECK_SHOW, m_btnShow);
//	DDX_Control(pDX, IDC_MFCCOLORBUTTON_TEXT, m_btnTextColor);
//	DDX_Text(pDX, IDC_EDIT_FONT, m_strFontText);
	DDX_Control(pDX, IDC_MFCCOLORBUTTON_SELECT, m_btnSelect);
	DDX_Control(pDX, IDC_MFCCOLORBUTTON_OK, m_btnOk);
	DDX_Control(pDX, IDC_MFCCOLORBUTTON_DIE, m_btnDie);
	DDX_Control(pDX, IDC_MFCCOLORBUTTON_WAIT, m_btnWait);
}


BEGIN_MESSAGE_MAP(CMenuMarkModeSetting_Dlg, CDialogEx)
	ON_BN_CLICKED(IDC_CHECK_MODE, &CMenuMarkModeSetting_Dlg::OnBnClickedCheckMode)
//	ON_BN_CLICKED(IDC_BUTTON_FONT, &CMenuMarkModeSetting_Dlg::OnBnClickedButtonFont)
	ON_BN_CLICKED(IDCANCEL, &CMenuMarkModeSetting_Dlg::OnBnClickedCancel)
	ON_BN_CLICKED(IDC_CHECK_SHOW, &CMenuMarkModeSetting_Dlg::OnBnClickedCheckShow)
//	ON_BN_CLICKED(IDC_MFCCOLORBUTTON_TEXT, &CMenuMarkModeSetting_Dlg::OnBnClickedMfccolorbuttonText)
	ON_BN_CLICKED(IDC_MFCCOLORBUTTON_SELECT, &CMenuMarkModeSetting_Dlg::OnBnClickedMfccolorbuttonSelect)
	ON_BN_CLICKED(IDC_MFCCOLORBUTTON_OK, &CMenuMarkModeSetting_Dlg::OnBnClickedMfccolorbuttonOk)
	ON_BN_CLICKED(IDC_MFCCOLORBUTTON_DIE, &CMenuMarkModeSetting_Dlg::OnBnClickedMfccolorbuttonDie)
	ON_BN_CLICKED(IDC_MFCCOLORBUTTON_WAIT, &CMenuMarkModeSetting_Dlg::OnBnClickedMfccolorbuttonWait)
END_MESSAGE_MAP()


// CMenuMarkModeSetting_Dlg 消息处理程序


void CMenuMarkModeSetting_Dlg::OnBnClickedCheckMode()
{
	m_pControl->SetMarkMode(m_btnEnable.GetCheck());
}


BOOL CMenuMarkModeSetting_Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	
	m_btnEnable.SetCheck(m_pControl->GetMarkMode());
	m_btnShow.SetCheck(m_pControl->GetMarkShowStatus());

	COLORREF _color;
//	m_pControl->GetMarkInfoFontColor(_color);
//	m_btnTextColor.SetColor(_color);

//	std::string _strAnsi;
//	int         _nFontSize;
	//m_pControl->GetMarkInfoFontName(_strAnsi);
//	m_pControl->GetMarkInfoFontSize(_nFontSize);

//	std::wstring _strUnicode;
	//CPublicObj::Ansi2Unicode(_strAnsi, _strUnicode);

//	m_strFontText.Format(_T("%s:%d"), _strUnicode.c_str(), _nFontSize);

 
	m_pControl->GetMarkStatusColor(_MARK_STATUS_SELECT, _color);
	m_btnSelect.SetColor(_color);

	m_pControl->GetMarkStatusColor(_MARK_STATUS_VALID, _color);
	m_btnOk.SetColor(_color);

	m_pControl->GetMarkStatusColor(_MARK_STATUS_INVALID, _color);
	m_btnDie.SetColor(_color);

	m_pControl->GetMarkStatusColor(_MARK_STATUS_UNKONWN, _color);
	m_btnWait.SetColor(_color);



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

/*
void CMenuMarkModeSetting_Dlg::OnBnClickedButtonFont()
{
	UpdateData(TRUE);
	LOGFONT lf;
	memset(&lf, 0, sizeof(LOGFONT));

	std::string _titleString;
	m_pControl->GetMarkInfoFontName(_titleString);
	std::wstring _wtitleString;
	CPublicObj::Ansi2Unicode(_titleString, _wtitleString);

	_tcscpy_s(lf.lfFaceName, LF_FACESIZE, _wtitleString.c_str());
	int nSize = 20;
	m_pControl->GetMarkInfoFontSize(nSize);
	lf.lfHeight = nSize;
	CFontDialog dlg(&lf);
	if (IDOK == dlg.DoModal())
	{
		_wtitleString = dlg.m_cf.lpLogFont->lfFaceName;
		CPublicObj::Unicode2Ansi(_wtitleString, _titleString);
		m_pControl->SetMarkInfoFontName(_titleString);
		m_pControl->SetMarkInfoFontSize(dlg.m_cf.lpLogFont->lfHeight);


		m_strFontText.Format(_T("%s:%d"), _wtitleString.c_str(), dlg.m_cf.lpLogFont->lfHeight);
		UpdateData(FALSE);
	}
}
*/

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


void CMenuMarkModeSetting_Dlg::OnBnClickedCheckShow()
{
	m_pControl->SetMarkShowStatus(m_btnShow.GetCheck());
}

/*
void CMenuMarkModeSetting_Dlg::OnBnClickedMfccolorbuttonText()
{
	m_pControl->SetMarkInfoFontColor(m_btnTextColor.GetColor());

}
 */
void CMenuMarkModeSetting_Dlg::OnBnClickedMfccolorbuttonSelect()
{
	m_pControl->SetMarkStatusColor(_MARK_STATUS_SELECT,m_btnSelect.GetColor());
}


void CMenuMarkModeSetting_Dlg::OnBnClickedMfccolorbuttonOk()
{
	m_pControl->SetMarkStatusColor(_MARK_STATUS_VALID, m_btnOk.GetColor());
}


void CMenuMarkModeSetting_Dlg::OnBnClickedMfccolorbuttonDie()
{
	m_pControl->SetMarkStatusColor(_MARK_STATUS_INVALID, m_btnDie.GetColor());
}


void CMenuMarkModeSetting_Dlg::OnBnClickedMfccolorbuttonWait()
{
	m_pControl->SetMarkStatusColor(_MARK_STATUS_UNKONWN, m_btnWait.GetColor());
}
