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

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

#include "PublicObj.h"

// CMenuImageInfoSetting_Dlg 对话框

IMPLEMENT_DYNAMIC(CMenuImageInfoSetting_Dlg, CDialogEx)

CMenuImageInfoSetting_Dlg::CMenuImageInfoSetting_Dlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_DIALOG_TEXT_INFO, pParent)
	, m_strFontInfo(_T(""))
	, m_nCapturePos(0)
{
	m_pControl = NULL;
}

CMenuImageInfoSetting_Dlg::~CMenuImageInfoSetting_Dlg()
{
}

void CMenuImageInfoSetting_Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_MFCCOLORBUTTON_TEXT, m_txt_color);
	DDX_Text(pDX, IDC_EDIT_FONT, m_strFontInfo);
	DDX_Radio(pDX, IDC_RADIO_TEXT_POS, m_nCapturePos);
}


BEGIN_MESSAGE_MAP(CMenuImageInfoSetting_Dlg, CDialogEx)
	ON_BN_CLICKED(IDC_MFCCOLORBUTTON_TEXT, &CMenuImageInfoSetting_Dlg::OnBnClickedMfccolorbuttonText)
	ON_BN_CLICKED(IDC_BUTTON_FONT, &CMenuImageInfoSetting_Dlg::OnBnClickedButtonFont)
	ON_BN_CLICKED(IDOK, &CMenuImageInfoSetting_Dlg::OnBnClickedOk)
	ON_BN_CLICKED(IDC_RADIO_TEXT_POS, &CMenuImageInfoSetting_Dlg::OnBnClickedRadioTextPos)
	ON_BN_CLICKED(IDC_RADIO2, &CMenuImageInfoSetting_Dlg::OnBnClickedRadio2)
	ON_BN_CLICKED(IDC_RADIO3, &CMenuImageInfoSetting_Dlg::OnBnClickedRadio3)
	ON_BN_CLICKED(IDC_RADIO4, &CMenuImageInfoSetting_Dlg::OnBnClickedRadio4)
	ON_BN_CLICKED(IDC_CHECK_IDX, &CMenuImageInfoSetting_Dlg::OnBnClickedCheckIdx)
	ON_BN_CLICKED(IDC_CHECK_SIZE, &CMenuImageInfoSetting_Dlg::OnBnClickedCheckSize)
	ON_BN_CLICKED(IDC_CHECK_RATE, &CMenuImageInfoSetting_Dlg::OnBnClickedCheckRate)
	ON_BN_CLICKED(IDC_CHECK_PT, &CMenuImageInfoSetting_Dlg::OnBnClickedCheckPt)
	ON_BN_CLICKED(IDC_CHECK_PIC_POS, &CMenuImageInfoSetting_Dlg::OnBnClickedCheckPicPos)
	ON_BN_CLICKED(IDC_CHECK_EXT_INFO, &CMenuImageInfoSetting_Dlg::OnBnClickedCheckExtInfo)
	ON_BN_CLICKED(IDC_CHECK_EXT_TIME, &CMenuImageInfoSetting_Dlg::OnBnClickedCheckExtTime)
	ON_BN_CLICKED(IDC_CHECK_KM, &CMenuImageInfoSetting_Dlg::OnBnClickedCheckKm)
	ON_BN_CLICKED(IDCANCEL, &CMenuImageInfoSetting_Dlg::OnBnClickedCancel)
	ON_BN_CLICKED(IDC_CHECK_MODE, &CMenuImageInfoSetting_Dlg::OnBnClickedCheckMode)
END_MESSAGE_MAP()


// CMenuImageInfoSetting_Dlg 消息处理程序


BOOL CMenuImageInfoSetting_Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	COLORREF _crText;
	m_pControl->GetImageBaseInfoColor(_crText);
	m_txt_color.SetColor(_crText);


	std::string  _txtFont;
	int          _txtSize;
	m_pControl->GetImageBaseInfoFont(_txtFont);
	m_pControl->GetImageBaseInfoFontSize(_txtSize);


	std::wstring _wstring;
	CPublicObj::Ansi2Unicode(_txtFont, _wstring);
	m_strFontInfo.Format(_T("%s:%d"), _wstring.c_str(), _txtSize);


	emADVInfoPos _POS = m_pControl->GetImageBaseInfoPos();
	switch (_POS)
	{
	case POS_LEFT_TOP:
		m_nCapturePos = 0;
		break;
	case POS_RIGHT_TOP:
		m_nCapturePos = 1;
		break;
	case POS_LEFT_BOTTOM:
		m_nCapturePos = 2;
		break;
	case POS_RIGHT_BOTTOM:
		m_nCapturePos = 3;
		break;


	}

	/*
	#define  PIC_INFO_TEXT_IMAGE_IDX   0x01   //图像序号
	#define  PIC_INFO_TEXT_IMAGE_SIZE  0x02   //图像尺寸
	#define  PIC_INFO_TEXT_ZOOM_VALUE  0x04   //缩放比例
	#define  PIC_INFO_TEXT_MOUSE_PT	   0x08   //鼠标位置。（屏幕位置）
	#define  PIC_INFO_TEXT_PIC_POS     0x10   //图像当前位置
	#define  PIC_INFO_TEXT_IMAGE_EXT   0X20   //图像扩展信息
	*/
	DWORD dwRet = m_pControl->GetImageBaseInfoStatus();
	if ((dwRet&PIC_INFO_TEXT_IMAGE_IDX) == PIC_INFO_TEXT_IMAGE_IDX)
	{
		CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_IDX);
		pBtn->SetCheck(TRUE);
	}
	if ((dwRet&PIC_INFO_TEXT_IMAGE_SIZE) == PIC_INFO_TEXT_IMAGE_SIZE)
	{
		CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_SIZE);
		pBtn->SetCheck(TRUE);
	}
	if ((dwRet&PIC_INFO_TEXT_ZOOM_VALUE) == PIC_INFO_TEXT_ZOOM_VALUE)
	{
		CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_RATE);
		pBtn->SetCheck(TRUE);
	}

	if ((dwRet&PIC_INFO_TEXT_MOUSE_PT) == PIC_INFO_TEXT_MOUSE_PT)
	{
		CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_PT);
		pBtn->SetCheck(TRUE);
	}
	if ((dwRet&PIC_INFO_TEXT_PIC_POS) == PIC_INFO_TEXT_PIC_POS)
	{
		CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_PIC_POS);
		pBtn->SetCheck(TRUE);
	}
	if ((dwRet&PIC_INFO_TEXT_IMAGE_EXT) == PIC_INFO_TEXT_IMAGE_EXT)
	{
		CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_EXT_INFO);
		pBtn->SetCheck(TRUE);
	}
	if ((dwRet&PIC_INFO_TEXT_IMAGE_TIME) == PIC_INFO_TEXT_IMAGE_TIME)
	{
		CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_EXT_TIME);
		pBtn->SetCheck(TRUE);
	}

	if ((dwRet&PIC_INFO_TEXT_IMAGE_KM) == PIC_INFO_TEXT_IMAGE_KM)
	{
		CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_KM);
		pBtn->SetCheck(TRUE);
	}
	if ((dwRet&PIC_INFO_TEXT_CURRENT_MODE) == PIC_INFO_TEXT_CURRENT_MODE)
	{
		CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_MODE);
		pBtn->SetCheck(TRUE);
	}



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


void CMenuImageInfoSetting_Dlg::OnBnClickedMfccolorbuttonText()
{
	m_pControl->SetImageBaseInfoColor(m_txt_color.GetColor());
}


void CMenuImageInfoSetting_Dlg::OnBnClickedButtonFont()
{
	LOGFONT lf;
	memset(&lf, 0, sizeof(LOGFONT));

	std::string _titleString;
	m_pControl->GetImageBaseInfoFont(_titleString);
#ifdef _UNICODE
	std::wstring _wtitleString;
	CPublicObj::Ansi2Unicode(_titleString, _wtitleString);
	_tcscpy_s(lf.lfFaceName, LF_FACESIZE, _wtitleString.c_str());
#else
	strcpy(lf.lfFaceName, _titleString.c_str());
#endif
	int nSize = 20;
	m_pControl->GetImageBaseInfoFontSize(nSize);
	lf.lfHeight = nSize;
	CFontDialog dlg(&lf);
	if (IDOK == dlg.DoModal())
	{
#ifdef _UNICODE
		_wtitleString = dlg.m_cf.lpLogFont->lfFaceName;
		CPublicObj::Unicode2Ansi(_wtitleString, _titleString);
		m_pControl->SetImageBaseInfoFont(_titleString);
		m_strFontInfo.Format(_T("%s:%d"), _wtitleString.c_str(), dlg.m_cf.lpLogFont->lfHeight);
#else
		m_pControl->SetImageBaseInfoFont(dlg.m_cf.lpLogFont->lfFaceName);
		m_strFontInfo.Format(_T("%s:%d"), dlg.m_cf.lpLogFont->lfFaceName, dlg.m_cf.lpLogFont->lfHeight);
#endif
		m_pControl->SetImageBaseInfoFontSize(dlg.m_cf.lpLogFont->lfHeight);


		
		UpdateData(FALSE);
	}
}


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


void CMenuImageInfoSetting_Dlg::OnBnClickedRadioTextPos()
{
	// TODO: 在此添加控件通知处理程序代码
	m_pControl->SetImageBaseInfoPos(POS_LEFT_TOP);
}


void CMenuImageInfoSetting_Dlg::OnBnClickedRadio2()
{
	m_pControl->SetImageBaseInfoPos(POS_RIGHT_TOP);
}


void CMenuImageInfoSetting_Dlg::OnBnClickedRadio3()
{
	m_pControl->SetImageBaseInfoPos(POS_LEFT_BOTTOM);
}


void CMenuImageInfoSetting_Dlg::OnBnClickedRadio4()
{
	m_pControl->SetImageBaseInfoPos(POS_RIGHT_BOTTOM);
}
/*
#define  PIC_INFO_TEXT_IMAGE_IDX   0x01   //图像序号
#define    0x02   //图像尺寸
#define    0x04   //缩放比例
#define  	   0x08   //鼠标位置。（屏幕位置）
#define       0x10   //图像当前位置
#define  PIC_INFO_TEXT_IMAGE_EXT   0X20   //图像扩展信息
*/

void CMenuImageInfoSetting_Dlg::OnBnClickedCheckIdx()
{
	DWORD dwRet = m_pControl->GetImageBaseInfoStatus();
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_IDX);
	if (pBtn->GetCheck() == TRUE)
	{
		dwRet |= PIC_INFO_TEXT_IMAGE_IDX;
	}
	else
	{
		dwRet &= ~PIC_INFO_TEXT_IMAGE_IDX;
	}

	m_pControl->SetImageBaseInfoStatus(dwRet);
}


void CMenuImageInfoSetting_Dlg::OnBnClickedCheckSize()
{
	DWORD dwRet = m_pControl->GetImageBaseInfoStatus();
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_SIZE);
	if (pBtn->GetCheck() == TRUE)
	{
		dwRet |= PIC_INFO_TEXT_IMAGE_SIZE;
	}
	else
	{
		dwRet &= ~PIC_INFO_TEXT_IMAGE_SIZE;
	}

	m_pControl->SetImageBaseInfoStatus(dwRet);
}


void CMenuImageInfoSetting_Dlg::OnBnClickedCheckRate()
{
	DWORD dwRet = m_pControl->GetImageBaseInfoStatus();
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_RATE);
	if (pBtn->GetCheck() == TRUE)
	{
		dwRet |= PIC_INFO_TEXT_ZOOM_VALUE;
	}
	else
	{
		dwRet &= ~PIC_INFO_TEXT_ZOOM_VALUE;
	}

	m_pControl->SetImageBaseInfoStatus(dwRet);
}


void CMenuImageInfoSetting_Dlg::OnBnClickedCheckPt()
{
	DWORD dwRet = m_pControl->GetImageBaseInfoStatus();
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_PT);
	if (pBtn->GetCheck() == TRUE)
	{
		dwRet |= PIC_INFO_TEXT_MOUSE_PT;
	}
	else
	{
		dwRet &= ~PIC_INFO_TEXT_MOUSE_PT;
	}

	m_pControl->SetImageBaseInfoStatus(dwRet);
}


void CMenuImageInfoSetting_Dlg::OnBnClickedCheckPicPos()
{
	DWORD dwRet = m_pControl->GetImageBaseInfoStatus();
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_PIC_POS);
	if (pBtn->GetCheck() == TRUE)
	{
		dwRet |= PIC_INFO_TEXT_PIC_POS;
	}
	else
	{
		dwRet &= ~PIC_INFO_TEXT_PIC_POS;
	}

	m_pControl->SetImageBaseInfoStatus(dwRet);
}


void CMenuImageInfoSetting_Dlg::OnBnClickedCheckExtInfo()
{
	DWORD dwRet = m_pControl->GetImageBaseInfoStatus();
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_EXT_INFO);
	if (pBtn->GetCheck() == TRUE)
	{
		dwRet |= PIC_INFO_TEXT_IMAGE_EXT;
	}
	else
	{
		dwRet &= ~PIC_INFO_TEXT_IMAGE_EXT;
	}

	m_pControl->SetImageBaseInfoStatus(dwRet);
}


void CMenuImageInfoSetting_Dlg::OnBnClickedCheckExtTime()
{
	DWORD dwRet = m_pControl->GetImageBaseInfoStatus();
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_EXT_TIME);
	if (pBtn->GetCheck() == TRUE)
	{
		dwRet |= PIC_INFO_TEXT_IMAGE_TIME;
	}
	else
	{
		dwRet &= ~PIC_INFO_TEXT_IMAGE_TIME;
	}

	m_pControl->SetImageBaseInfoStatus(dwRet);
}


void CMenuImageInfoSetting_Dlg::OnBnClickedCheckKm()
{
	DWORD dwRet = m_pControl->GetImageBaseInfoStatus();
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_KM);
	if (pBtn->GetCheck() == TRUE)
	{
		dwRet |= PIC_INFO_TEXT_IMAGE_KM;
	}
	else
	{
		dwRet &= ~PIC_INFO_TEXT_IMAGE_KM;
	}

	m_pControl->SetImageBaseInfoStatus(dwRet);
}


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


void CMenuImageInfoSetting_Dlg::OnBnClickedCheckMode()
{
	DWORD dwRet = m_pControl->GetImageBaseInfoStatus();
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_MODE);
	if (pBtn->GetCheck() == TRUE)
	{
		dwRet |= PIC_INFO_TEXT_CURRENT_MODE;
	}
	else
	{
		dwRet &= ~PIC_INFO_TEXT_CURRENT_MODE;
	}

	m_pControl->SetImageBaseInfoStatus(dwRet);
}
