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

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


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

IMPLEMENT_DYNAMIC(CMenuFullScreenSetting_Dlg, CDialogEx)

CMenuFullScreenSetting_Dlg::CMenuFullScreenSetting_Dlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD, pParent)
	, m_nFullType(0)
	, m_strImage(_T(""))
{
	m_pControl = NULL;
}

CMenuFullScreenSetting_Dlg::~CMenuFullScreenSetting_Dlg()
{
}

void CMenuFullScreenSetting_Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Radio(pDX, IDC_RADIO_ALL, m_nFullType);
	DDX_Text(pDX, IDC_EDIT_FILE, m_strImage);
}


BEGIN_MESSAGE_MAP(CMenuFullScreenSetting_Dlg, CDialogEx)
	ON_BN_CLICKED(IDC_RADIO_ALL, &CMenuFullScreenSetting_Dlg::OnBnClickedRadioAll)
	ON_BN_CLICKED(IDC_RADIO2, &CMenuFullScreenSetting_Dlg::OnBnClickedRadio2)
	ON_BN_CLICKED(IDC_RADIO3, &CMenuFullScreenSetting_Dlg::OnBnClickedRadio3)
	ON_BN_CLICKED(IDC_CHECK_EXIT, &CMenuFullScreenSetting_Dlg::OnBnClickedCheckExit)
	ON_BN_CLICKED(IDC_BUTTON_FILE, &CMenuFullScreenSetting_Dlg::OnBnClickedButtonFile)
	ON_BN_CLICKED(IDC_BUTTON_FULL, &CMenuFullScreenSetting_Dlg::OnBnClickedButtonFull)
	ON_BN_CLICKED(IDOK, &CMenuFullScreenSetting_Dlg::OnBnClickedOk)
	ON_BN_CLICKED(IDCANCEL, &CMenuFullScreenSetting_Dlg::OnBnClickedCancel)
END_MESSAGE_MAP()


// CMenuFullScreenSetting_Dlg 消息处理程序


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

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

	IAdvImageShowControl::emFullScreenMonitorStatus _full_status;
	m_pControl->GetFullScreenMode(_full_status);
	if (_full_status == IAdvImageShowControl::MONITOR_ALL)
		m_nFullType = 0;
	else if (_full_status == IAdvImageShowControl::MONITOR_DEFAULT)
		m_nFullType = 1;
	else
		m_nFullType = 2;

	CButton* pCheck = (CButton*)GetDlgItem(IDC_CHECK_EXIT);
	pCheck->SetCheck(m_pControl->IsEnableFullCloseImages());
	OnBnClickedCheckExit();
	
	
	std::string _strFile;
	m_pControl->GetFullCloseImage(_strFile);
	std::wstring _wstrFile;
	CPublicObj::Ansi2Unicode(_strFile, _wstrFile);


	m_strImage = CString(_wstrFile.c_str());


	
	UpdateData(FALSE);

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


void CMenuFullScreenSetting_Dlg::OnBnClickedRadioAll()
{
	m_pControl->SetFullScreenMode(IAdvImageShowControl::MONITOR_ALL);
}


void CMenuFullScreenSetting_Dlg::OnBnClickedRadio2()
{
	m_pControl->SetFullScreenMode(IAdvImageShowControl::MONITOR_DEFAULT);
}


void CMenuFullScreenSetting_Dlg::OnBnClickedRadio3()
{
	m_pControl->SetFullScreenMode(IAdvImageShowControl::MONITOR_CURRENT);
}


void CMenuFullScreenSetting_Dlg::OnBnClickedCheckExit()
{
	CButton* pCheck = (CButton*)GetDlgItem(IDC_CHECK_EXIT);
	if (pCheck->GetCheck() == TRUE)
	{
		GetDlgItem(IDC_BUTTON_FILE)->EnableWindow(TRUE);
	}
	else
	{
		GetDlgItem(IDC_BUTTON_FILE)->EnableWindow(FALSE);
	}
	m_pControl->EnableFullCloseImage(pCheck->GetCheck());
}
void CMenuFullScreenSetting_Dlg::OnBnClickedButtonFile()
{

	UpdateData(TRUE);
	TCHAR szFilter[] = _T("JPG(*.jpg)|*.jpg|PNG(*.png)|*.png|BMP(*.bmp)|*.bmp||");
	CFileDialog fileDlg(TRUE, _T("png"), NULL, 0, szFilter, this);
	 
	if (fileDlg.DoModal() == IDOK)
	{
		m_strImage = fileDlg.GetPathName();
		
#ifdef _UNICODE
		std::string  _ansi_text;
		CPublicObj::Unicode2Ansi(std::wstring(m_strImage.GetBuffer()), _ansi_text);
		m_strImage.ReleaseBuffer();
		m_pControl->SetFullCloseImage(_ansi_text);
#else
		m_pControl->SetFullCloseImage(m_strImage.GetBuffer());
		m_strImage.ReleaseBuffer();
#endif
		UpdateData(FALSE);
	}
}


void CMenuFullScreenSetting_Dlg::OnBnClickedButtonFull()
{
	CDialog::OnCancel();
	m_pControl->SetFullScreen(TRUE);
}


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


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