// imp_configwindow.cpp : implementation file
//

#include "stdafx.h"
#include "bloadfile.h"
#include "imp_configwindow.h"
#include "imp_block.h"


// CImpBlockConfigWindow dialog

IMPLEMENT_DYNAMIC(CImpBlockConfigWindow, CDialog)

CImpBlockConfigWindow::CImpBlockConfigWindow(CWnd* pParent /*=NULL*/, IUnknown* pUnkOuter)
	: CDialog(CImpBlockConfigWindow::IDD, pParent)
	, m_strName(_T(""))
	, m_bCheckFile(FALSE)
	, m_bSkipEmptyLayers(FALSE)
	, m_bDisableInput(FALSE)
{
	m_pImpBlock = (CImpBlock*)pUnkOuter;
}

CImpBlockConfigWindow::~CImpBlockConfigWindow()
{
}

void CImpBlockConfigWindow::DoDataExchange(CDataExchange* pDX)
{
	EnterCriticalSection(&m_pImpBlock->m_cs);

	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_NAME, m_pImpBlock->m_strName);
	DDX_Check(pDX, IDC_CHECKFILE, m_pImpBlock->m_bCheckFile);
//	DDX_Check(pDX, IDC_CHECKSKIPEMPTYLAYERS, m_pImpBlock->m_bSkipEmptyLayers);
	DDX_Check(pDX, IDC_CHECKDISABLEINPUT, m_pImpBlock->m_bDisableInput);

	LeaveCriticalSection(&m_pImpBlock->m_cs);

	if ( pDX->m_bSaveAndValidate )
		m_pImpBlock->SetModifiedFlag(TRUE);
}


BEGIN_MESSAGE_MAP(CImpBlockConfigWindow, CDialog)
	ON_BN_CLICKED(IDC_APPLY, &CImpBlockConfigWindow::OnBnClickedApply)
	ON_BN_CLICKED(IDC_BROWSE, &CImpBlockConfigWindow::OnBnClickedBrowse)
END_MESSAGE_MAP()


// CImpBlockConfigWindow message handlers

void CImpBlockConfigWindow::OnCancel()
{
	CDialog::OnCancel();
	DestroyWindow();
}

void CImpBlockConfigWindow::OnOK()
{
	CDialog::OnOK();
	DestroyWindow();
}

void CImpBlockConfigWindow::OnBnClickedApply()
{
	CDataExchange dx(this, TRUE);
	DoDataExchange(&dx);
}

void CImpBlockConfigWindow::OnBnClickedBrowse()
{
	CFileDialog fDlg(TRUE);
	if ( IDOK == fDlg.DoModal() )
	{
		CEdit* pEdit = (CEdit*)GetDlgItem(IDC_NAME);
		pEdit->SetWindowText(fDlg.GetPathName());
	}
}
