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

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


// CMenuThumbnail_Dlg 对话框

IMPLEMENT_DYNAMIC(CMenuThumbnail_Dlg, CDialogEx)

CMenuThumbnail_Dlg::CMenuThumbnail_Dlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_DIALOG_IMAGE_MAP, pParent)
	, m_nThumPos(0)
	, m_nThumWidth(50)
{
	m_pControl = NULL;
}

CMenuThumbnail_Dlg::~CMenuThumbnail_Dlg()
{

}

void CMenuThumbnail_Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Radio(pDX, IDC_RADIO_MAP_POS, m_nThumPos);
	DDX_Control(pDX, IDC_MFCCOLORBUTTON_OUT, m_btn_out_color);
	DDX_Control(pDX, IDC_MFCCOLORBUTTON_RECT, m_btn_inner_color);
	DDX_Text(pDX, IDC_EDIT_WIDTH, m_nThumWidth);
}


BEGIN_MESSAGE_MAP(CMenuThumbnail_Dlg, CDialogEx)
	ON_BN_CLICKED(IDC_CHECK_ENABLE, &CMenuThumbnail_Dlg::OnBnClickedCheckEnable)
	ON_BN_CLICKED(IDC_RADIO_MAP_POS, &CMenuThumbnail_Dlg::OnBnClickedRadioMapPos)
	ON_BN_CLICKED(IDC_RADIO2, &CMenuThumbnail_Dlg::OnBnClickedRadio2)
	ON_BN_CLICKED(IDC_RADIO3, &CMenuThumbnail_Dlg::OnBnClickedRadio3)
	ON_BN_CLICKED(IDC_RADIO4, &CMenuThumbnail_Dlg::OnBnClickedRadio4)
	ON_BN_CLICKED(IDCANCEL, &CMenuThumbnail_Dlg::OnBnClickedCancel)
	ON_BN_CLICKED(IDC_MFCCOLORBUTTON_OUT, &CMenuThumbnail_Dlg::OnBnClickedMfccolorbuttonOut)
	ON_BN_CLICKED(IDC_MFCCOLORBUTTON_RECT, &CMenuThumbnail_Dlg::OnBnClickedMfccolorbuttonRect)
	ON_BN_CLICKED(IDC_BUTTON_WIDTH, &CMenuThumbnail_Dlg::OnBnClickedButtonWidth)
	ON_BN_CLICKED(IDC_CHECK_LOC, &CMenuThumbnail_Dlg::OnBnClickedCheckLoc)
	ON_BN_CLICKED(IDC_CHECK_LOC2, &CMenuThumbnail_Dlg::OnBnClickedCheckLoc2)
END_MESSAGE_MAP()


// CMenuThumbnail_Dlg 消息处理程序


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

	// TODO:  在此添加额外的初始化

	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_ENABLE);
	pBtn->SetCheck(m_pControl->GetThumbnailStatus());


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


	}

	COLORREF _cr;
	m_pControl->GetThumbnailBorderColor(_cr);
	m_btn_out_color.SetColor(_cr);

	m_pControl->GetThumbnailRectColor(_cr);
	m_btn_inner_color.SetColor(_cr);



	m_nThumWidth = m_pControl->GetThumbnailWidth();


	pBtn = (CButton*)GetDlgItem(IDC_CHECK_LOC);
	BOOL bEnable = FALSE;
	m_pControl->GetThumbnailLocation(bEnable);
	pBtn->SetCheck(bEnable);



	pBtn = (CButton*)GetDlgItem(IDC_CHECK_LOC2);
	m_pControl->GetThumnailUseImage(bEnable);
	pBtn->SetCheck(bEnable);
	UpdateData(FALSE);

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


void CMenuThumbnail_Dlg::OnBnClickedCheckEnable()
{
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_ENABLE);
	BOOL bEnable = pBtn->GetCheck();

	m_pControl->SetThumbnailStatus(bEnable);
	
}


void CMenuThumbnail_Dlg::OnBnClickedRadioMapPos()
{
	 
	m_pControl->SetThumbnailPositon(POS_LEFT_TOP);
}


void CMenuThumbnail_Dlg::OnBnClickedRadio2()
{
	m_pControl->SetThumbnailPositon(POS_RIGHT_TOP);

}
void CMenuThumbnail_Dlg::OnBnClickedRadio3()
{
	m_pControl->SetThumbnailPositon(POS_LEFT_BOTTOM);
}


void CMenuThumbnail_Dlg::OnBnClickedRadio4()
{
	m_pControl->SetThumbnailPositon(POS_RIGHT_BOTTOM);
}


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


void CMenuThumbnail_Dlg::OnBnClickedMfccolorbuttonOut()
{
	m_pControl->SetThumbnailBorderColor(m_btn_out_color.GetColor());
}


void CMenuThumbnail_Dlg::OnBnClickedMfccolorbuttonRect()
{
	// TODO: 在此添加控件通知处理程序代码
	m_pControl->SetThumbnailRectColor(m_btn_inner_color.GetColor());
}


void CMenuThumbnail_Dlg::OnBnClickedButtonWidth()
{
	if (FALSE == UpdateData(TRUE))
		return;

	if (m_nThumWidth < 20)
		m_nThumWidth = 20;
	if (m_nThumWidth > 1200)
		m_nThumWidth = 1200;

	m_pControl->SetThumbnailWidth(m_nThumWidth);

	UpdateData(FALSE);

}


void CMenuThumbnail_Dlg::OnBnClickedCheckLoc()
{
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_LOC);
	m_pControl->SetThumbnailLocation(pBtn->GetCheck());
}


void CMenuThumbnail_Dlg::OnBnClickedCheckLoc2()
{
	CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECK_LOC2);
	m_pControl->SetThumnailUseImage(pBtn->GetCheck());
}
