📄 homeconf.cpp
字号:
// homeconf.cpp : implementation file
//
#include "stdafx.h"
#include "mastercontrol.h"
#include "homeconf.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// homeconf property page
IMPLEMENT_DYNCREATE(homeconf, CPropertyPage)
homeconf::homeconf() : CPropertyPage(homeconf::IDD)
{
//{{AFX_DATA_INIT(homeconf)
m_TCX = 0.0;
m_TCY = 0.0;
m_TCZ = 0.0;
//}}AFX_DATA_INIT
CString buffer;
buffer = AfxGetApp( )->GetProfileString("Preferences", "m_TCX" , " 100.0");
m_TCX = atof( (LPCTSTR) buffer);
buffer = AfxGetApp( )->GetProfileString("Preferences", "m_TCY" , " 0.0");
m_TCY = atof( (LPCTSTR) buffer);
buffer = AfxGetApp( )->GetProfileString("Preferences", "m_TCZ" , " 5.0");
m_TCZ = atof( (LPCTSTR) buffer);
SeekHome = (BOOL) AfxGetApp( )->GetProfileInt("Preferences", "SeekHome" , 0 ); // false by default
ToolChange = (BOOL) AfxGetApp( )->GetProfileInt("Preferences", "ToolChange" , 0 ); // false by default
Inches = (BOOL) AfxGetApp( )->GetProfileInt("Preferences", "Inches" , 0 ); // false by default
SwapX = (BOOL) AfxGetApp( )->GetProfileInt("Preferences", "SwapX" , 0 ); // false by default
SwapY = (BOOL) AfxGetApp( )->GetProfileInt("Preferences", "SwapY" , 0 ); // false by default
SwapZ = (BOOL) AfxGetApp( )->GetProfileInt("Preferences", "SwapZ" , 0 ); // false by default
}
homeconf::~homeconf()
{
}
void homeconf::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(homeconf)
DDX_Text(pDX, IDC_TCX, m_TCX);
DDX_Text(pDX, IDC_TCY, m_TCY);
DDX_Text(pDX, IDC_TCZ, m_TCZ);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(homeconf, CPropertyPage)
//{{AFX_MSG_MAP(homeconf)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_SEEKHOME, OnSeekhome)
ON_BN_CLICKED(IDC_MILLS, OnMills)
ON_BN_CLICKED(IDC_INCHES, OnInches)
ON_BN_CLICKED(IDC_ASSUMEHOME, OnAssumehome)
ON_BN_CLICKED(IDC_TCGOTO, OnTcgoto)
ON_BN_CLICKED(IDC_TCWARN, OnTcwarn)
ON_EN_UPDATE(IDC_TCX, OnUpdateTcx)
ON_EN_UPDATE(IDC_TCY, OnUpdateTcy)
ON_EN_UPDATE(IDC_TCZ, OnUpdateTcz)
ON_BN_CLICKED(IDC_SWAPX, OnSwapx)
ON_BN_CLICKED(IDC_SWAPY, OnSwapy)
ON_BN_CLICKED(IDC_SWAPZ, OnSwapz)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// homeconf message handlers
BOOL homeconf::OnKillActive()
{
UpdateData(TRUE);
CString dummy;
CString value = _gcvt( m_TCX, 8, dummy.GetBuffer(25) );
AfxGetApp( )->WriteProfileString("Preferences", "m_TCX" , (LPCTSTR) dummy);
value = _gcvt( m_TCY, 8, dummy.GetBuffer(25));
AfxGetApp( )->WriteProfileString("Preferences", "m_TCY" , (LPCTSTR) dummy);
value = _gcvt( m_TCZ, 8, dummy.GetBuffer(25) );
AfxGetApp( )->WriteProfileString("Preferences", "m_TCZ" , (LPCTSTR) dummy);
AfxGetApp( )->WriteProfileInt("Preferences", "SeekHome" , (int)SeekHome ); // false by default
AfxGetApp( )->WriteProfileInt("Preferences", "SwapX" , (int)SwapX ); // false by default
AfxGetApp( )->WriteProfileInt("Preferences", "SwapY" , (int)SwapY ); // false by default
AfxGetApp( )->WriteProfileInt("Preferences", "SwapZ" , (int)SwapZ ); // false by default
AfxGetApp( )->WriteProfileInt("Preferences", "ToolChange" , (int)ToolChange ); // false by default
AfxGetApp( )->WriteProfileInt("Preferences", "Inches" , (int)Inches ); // false by default
return CPropertyPage::OnKillActive();
}
void homeconf::OnPaint()
{
CPaintDC dc(this); // device context for painting
CEdit* TCX = (CEdit*)GetDlgItem(IDC_TCX);
CEdit* TCY = (CEdit*)GetDlgItem(IDC_TCY);
CEdit* TCZ = (CEdit*)GetDlgItem(IDC_TCZ);
CButton *ASSUME = (CButton*)GetDlgItem( IDC_ASSUMEHOME );
CButton *SEEK = (CButton*)GetDlgItem( IDC_SEEKHOME );
CButton *INCHES = (CButton*)GetDlgItem( IDC_INCHES );
CButton *MILLS = (CButton*)GetDlgItem( IDC_MILLS );
CButton *GOTO = (CButton*)GetDlgItem( IDC_TCGOTO );
CButton *WARN = (CButton*)GetDlgItem( IDC_TCWARN );
CButton *SWAPX = (CButton*)GetDlgItem( IDC_SWAPX );
CButton *SWAPY = (CButton*)GetDlgItem( IDC_SWAPY );
CButton *SWAPZ = (CButton*)GetDlgItem( IDC_SWAPZ );
if( SwapX ) SWAPX->SetCheck( 1 ); else SWAPX->SetCheck( 0 );
if( SwapY ) SWAPY->SetCheck( 1 ); else SWAPY->SetCheck( 0 );
if( SwapZ ) SWAPZ->SetCheck( 1 ); else SWAPZ->SetCheck( 0 );
if( ToolChange )
{
GOTO->SetCheck( 1 );
WARN->SetCheck( 0 );
TCX->EnableWindow(TRUE);
TCY->EnableWindow(TRUE);
TCZ->EnableWindow(TRUE);
}
else
{
GOTO->SetCheck( 0 );
WARN->SetCheck( 1 );
TCX->EnableWindow(FALSE);
TCY->EnableWindow(FALSE);
TCZ->EnableWindow(FALSE);
}
if( SeekHome )
{
ASSUME->SetCheck(0);
SEEK->SetCheck(1);
}
else
{
ASSUME->SetCheck(1);
SEEK->SetCheck(0);
}
if( Inches )
{
INCHES->SetCheck(1);
MILLS->SetCheck(0);
}
else
{
INCHES->SetCheck(0);
MILLS->SetCheck(1);
}
}
void homeconf::OnSeekhome()
{
SetModified(TRUE);
SeekHome = TRUE;
Invalidate(FALSE);
}
void homeconf::OnMills()
{
SetModified(TRUE);
if(Inches)
{
m_TCX *= 25.4;
m_TCY *= 25.4;
m_TCZ *= 25.4; // auto switch from inches to mills and back
}
Inches = FALSE;
UpdateData( FALSE );
Invalidate(FALSE);
}
void homeconf::OnInches()
{
SetModified(TRUE);
if( !Inches)
{
m_TCX /= 25.4;
m_TCY /= 25.4;
m_TCZ /= 25.4;
}
Inches = TRUE;
UpdateData( FALSE );
Invalidate(FALSE);
}
void homeconf::OnAssumehome()
{
SetModified(TRUE);
SeekHome = FALSE;
Invalidate(FALSE);
}
void homeconf::OnTcgoto()
{
SetModified(TRUE);
ToolChange = TRUE;
Invalidate(FALSE);
}
void homeconf::OnTcwarn()
{
ToolChange = FALSE;
Invalidate(FALSE);
}
BOOL homeconf::OnApply()
{
UpdateData(TRUE);
return CPropertyPage::OnApply();
}
void homeconf::OnUpdateTcx()
{
SetModified(TRUE);
}
void homeconf::OnUpdateTcy()
{
SetModified(TRUE);
}
void homeconf::OnUpdateTcz()
{
SetModified(TRUE);
}
void homeconf::OnOK()
{
OnKillActive();
CPropertyPage::OnOK();
}
void homeconf::OnSwapx()
{
SetModified(TRUE);
SwapX = !SwapX;
Invalidate(FALSE);
}
void homeconf::OnSwapy()
{
SetModified(TRUE);
SwapY = !SwapY;
Invalidate(FALSE);
}
void homeconf::OnSwapz()
{
SetModified(TRUE);
SwapZ = !SwapZ;
Invalidate(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -