// ThresholdDialog.cpp : implementation file
//

#include "stdafx.h"

#ifdef STRICT							// Already defined by stdafx,
#undef STRICT							// so we avoid warning linking msg
#endif
#ifdef _MBCS							// The same as above
#undef _MBCS
#endif

#include "ThresholdDialog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// ThresholdDialog dialog


ThresholdDialog::ThresholdDialog(CWnd* pParent /*=NULL*/)
	: CDialog(ThresholdDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(ThresholdDialog)
	m_deleteOriginal = FALSE;
	m_offsetX = 8.0f;
	m_offsetY = 0.0f;
	m_offsetZ = 0.0f;
	m_offsetModelFlag = TRUE;
	//}}AFX_DATA_INIT
}


void ThresholdDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(ThresholdDialog)
	DDX_Check(pDX, IDC_DELETE_CHECK, m_deleteOriginal);
	DDX_Text(pDX, IDC_OFFSET_X, m_offsetX);
	DDX_Text(pDX, IDC_OFFSET_Y, m_offsetY);
	DDX_Text(pDX, IDC_OFFSET_Z, m_offsetZ);
	DDX_Check(pDX, IDC_OFFSET_CHECK, m_offsetModelFlag);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(ThresholdDialog, CDialog)
	//{{AFX_MSG_MAP(ThresholdDialog)
	ON_BN_CLICKED(IDC_OFFSET_CHECK, OnOffsetCheck)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// ThresholdDialog message handlers

void ThresholdDialog::OnOffsetCheck() 
{
	CButton *check_button = (CButton*)GetDlgItem(IDC_OFFSET_CHECK);


	//GetDlgItem(IDC_START_BUTTON)->EnableWindow(false);
	if (check_button->GetCheck() == 1)
	{
		GetDlgItem(IDC_X_TEXT)->EnableWindow(true);
		GetDlgItem(IDC_Y_TEXT)->EnableWindow(true);
		GetDlgItem(IDC_Z_TEXT)->EnableWindow(true);
		GetDlgItem(IDC_OFFSET_X)->EnableWindow(true);
		GetDlgItem(IDC_OFFSET_Y)->EnableWindow(true);
		GetDlgItem(IDC_OFFSET_Z)->EnableWindow(true);
	}
	else
	{
		GetDlgItem(IDC_X_TEXT)->EnableWindow(false);
		GetDlgItem(IDC_Y_TEXT)->EnableWindow(false);
		GetDlgItem(IDC_Z_TEXT)->EnableWindow(false);
		GetDlgItem(IDC_OFFSET_X)->EnableWindow(false);
		GetDlgItem(IDC_OFFSET_Y)->EnableWindow(false);
		GetDlgItem(IDC_OFFSET_Z)->EnableWindow(false);
	}
}

BOOL ThresholdDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	if (m_offsetModelFlag)
	{
		GetDlgItem(IDC_X_TEXT)->EnableWindow(true);
		GetDlgItem(IDC_Y_TEXT)->EnableWindow(true);
		GetDlgItem(IDC_Z_TEXT)->EnableWindow(true);
		GetDlgItem(IDC_OFFSET_X)->EnableWindow(true);
		GetDlgItem(IDC_OFFSET_Y)->EnableWindow(true);
		GetDlgItem(IDC_OFFSET_Z)->EnableWindow(true);
	}
	else
	{
		GetDlgItem(IDC_X_TEXT)->EnableWindow(false);
		GetDlgItem(IDC_Y_TEXT)->EnableWindow(false);
		GetDlgItem(IDC_Z_TEXT)->EnableWindow(false);
		GetDlgItem(IDC_OFFSET_X)->EnableWindow(false);
		GetDlgItem(IDC_OFFSET_Y)->EnableWindow(false);
		GetDlgItem(IDC_OFFSET_Z)->EnableWindow(false);
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
