313 lines
7.2 KiB
C++
313 lines
7.2 KiB
C++
#include "stdafx.h"
|
|
#include "FoldSetDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
// 构造
|
|
CFoldSetDlg::CFoldSetDlg(CWnd* pParent /*= NULL*/)
|
|
: CDialog(CFoldSetDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CFoldSetDlg)
|
|
m_dLineThink = 1.0;
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
CFoldSetDlg::~CFoldSetDlg(void)
|
|
{
|
|
}
|
|
|
|
// 数据交换
|
|
void CFoldSetDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CFoldSetDlg)
|
|
DDX_Control(pDX, IDC_CMB_SINGLE_CLR, m_cmbSinClr);
|
|
DDX_Control(pDX, IDC_CMB_UNION_CLR, m_cmbUniClr);
|
|
DDX_Control(pDX, IDC_CHK_HORPRO_RADIU, m_chkSinHorProRadiu);
|
|
DDX_Control(pDX, IDC_CHK_SINPROED_HEIGHT, m_chkSinProHeight);
|
|
DDX_Control(pDX, IDC_CHK_BTWROD_DIS, m_chkUniSpaBetween);
|
|
DDX_Control(pDX, IDC_CHK_UNIPROED_HEIGHT, m_chkUniProHeight);
|
|
DDX_Control(pDX, IDC_CHK_HORPRO_RANGE, m_chkUniProRange);
|
|
DDX_Control(pDX, IDC_CMB_FONT_CLR, m_cmbFontClr);
|
|
DDX_Control(pDX, IDC_EDT_FONT_HEIGHT, m_edtFontHeight);
|
|
DDX_Control(pDX, IDC_SPIN_FONT_HEIGHT, m_spnFontHtCtrl);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
// 消息映射
|
|
BEGIN_MESSAGE_MAP(CFoldSetDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CFoldSetDlg)
|
|
ON_WM_CLOSE()
|
|
ON_MESSAGE(WM_ACAD_KEEPFOCUS, onAcadKeepFocus)
|
|
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_FONT_HEIGHT, OnDeltaposSpinFontHeight)
|
|
ON_BN_CLICKED(IDOK, OnBnRegisterInfor)
|
|
ON_BN_CLICKED(IDCANCEL,OnBnClickedCancel)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
//
|
|
LONG_PTR CFoldSetDlg::onAcadKeepFocus(UINT_PTR, LONG_PTR)
|
|
{
|
|
CPoint pt;
|
|
GetCursorPos(&pt);
|
|
CRect rc;
|
|
GetWindowRect(&rc);
|
|
return (rc.PtInRect(pt) ? TRUE : FALSE);
|
|
}
|
|
|
|
// 对话框初始
|
|
BOOL CFoldSetDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
InitAllControls(); // 初始化控件
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// 初始化控件
|
|
void CFoldSetDlg::InitAllControls()
|
|
{
|
|
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
int iIdex = ERR_VALUE;
|
|
|
|
// 读取单针保护颜色
|
|
regProp.GetValue(KEY_FOLD_SINGLEPRO_COLOR, iIdex);
|
|
if (iIdex != ERR_VALUE)
|
|
m_cmbSinClr.SetCurSel(iIdex + 1);
|
|
else
|
|
m_cmbSinClr.SetCurSel(0);
|
|
|
|
// 读取双针保护颜色
|
|
regProp.GetValue(KEY_FOLD_UNIONPRO_COLOR, iIdex);
|
|
if (iIdex != ERR_VALUE)
|
|
m_cmbUniClr.SetCurSel(iIdex + 1);
|
|
else
|
|
m_cmbUniClr.SetCurSel(0);
|
|
|
|
//线型和线宽
|
|
ReadDlgData();
|
|
CString csTemp;
|
|
csTemp.Format(_T("%.2f"),m_dLineThink);
|
|
GetDlgItem(IDC_EDT_LINETHINK)->SetWindowText(csTemp);
|
|
|
|
// 单针-水平保护半径
|
|
regProp.GetValue(KEY_FOLD_HORPRO_RADIU, iIdex);
|
|
m_chkSinHorProRadiu.SetCheck(iIdex);
|
|
// 单针保护-被保护物高度
|
|
regProp.GetValue(KEY_FOLD_SINGLEPRO_HEIGHT, iIdex);
|
|
m_chkSinProHeight.SetCheck(iIdex);
|
|
|
|
// 联合保护标注内容
|
|
// 联合-两避雷针之间的距离
|
|
regProp.GetValue(KEY_FOLD_SPACE_BETWEEN, iIdex);
|
|
m_chkUniSpaBetween.SetCheck(iIdex);
|
|
|
|
// 联合保护-被保护物高度
|
|
regProp.GetValue(KEY_FOLD_UNIONPRO_HEIGHT, iIdex);
|
|
m_chkUniProHeight.SetCheck(iIdex);
|
|
|
|
// 联合-水平面保护范围
|
|
regProp.GetValue(KEY_FOLD_HORPRO_RANGE, iIdex);
|
|
m_chkUniProRange.SetCheck(iIdex);
|
|
|
|
// 读取标注字体颜色
|
|
regProp.GetValue(KEY_FOLD_FONTLABLE_COLOR, iIdex);
|
|
if (iIdex != ERR_VALUE)
|
|
m_cmbFontClr.SetCurSel(iIdex + 1);
|
|
else
|
|
m_cmbFontClr.SetCurSel(0);
|
|
|
|
// 字高
|
|
CString strHeight = _T("3.0");
|
|
regProp.GetValue(KEY_FOLD_FONTLABLE_HEIGHT, strHeight);
|
|
m_edtFontHeight.SetWindowText(strHeight);
|
|
// m_spnFontHtCtrl.SetRange32(0, 100); // 字高微调
|
|
|
|
}
|
|
// 读取对话框数据
|
|
void CFoldSetDlg::ReadDlgData()
|
|
{
|
|
//读取设置
|
|
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
|
|
CString csLineThink;
|
|
//线宽
|
|
regProp.GetValue(KEY_FOLD_LINETHINK,csLineThink);
|
|
if (!csLineThink.IsEmpty())
|
|
{
|
|
m_dLineThink = _tstof(csLineThink);
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
// 保存对话框数据
|
|
void CFoldSetDlg::SaveDlgData()
|
|
{
|
|
UpdateData();
|
|
|
|
//保存设置
|
|
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
|
|
//线宽
|
|
CString csLineThink;
|
|
GetDlgItem(IDC_EDT_LINETHINK)->GetWindowText(csLineThink);
|
|
regProp.SetValue(KEY_FOLD_LINETHINK,csLineThink);
|
|
}
|
|
|
|
void CFoldSetDlg::OnClose()
|
|
{
|
|
CDialog::OnClose();
|
|
}
|
|
void CFoldSetDlg::OnOK()
|
|
{
|
|
SaveDlgData();
|
|
CDialog::OnOK();
|
|
}
|
|
void CFoldSetDlg::OnBnClickedCancel()
|
|
{
|
|
OnOK();
|
|
}
|
|
|
|
BOOL CFoldSetDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
if(pMsg->message == WM_CHAR)
|
|
{
|
|
//限制输入.只能输入数字和小数点
|
|
CWnd* pWnd1 = NULL;
|
|
CWnd* pFocu = NULL;
|
|
pWnd1 = GetDlgItem(IDC_EDT_LINEWEIGHT);
|
|
pFocu = this->GetFocus();
|
|
|
|
if (pFocu == pWnd1)
|
|
{
|
|
CString strValue = _T("");
|
|
pFocu->GetWindowText(strValue);
|
|
BOOL bIsDouble = strValue.Find(_T(".")) == -1 ? FALSE : TRUE;
|
|
if ((pMsg->wParam < 48 || pMsg->wParam >57)
|
|
&& pMsg->wParam != 46
|
|
&& pMsg->wParam != 8)
|
|
{
|
|
return TRUE;
|
|
}
|
|
if (pMsg->wParam == 46 && bIsDouble)
|
|
{
|
|
//控制小数点的个数为1
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
void CFoldSetDlg::OnDeltaposSpinFontHeight(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
|
|
TCHAR szText[10] = {0};
|
|
GetDlgItemText(IDC_EDT_FONT_HEIGHT,szText, 10);
|
|
double dTemp = _tstof(szText);
|
|
|
|
// 当数据为0继续减少时数据保持为0
|
|
if (dTemp <= 0.0 && pNMUpDown->iDelta == -1)
|
|
{
|
|
dTemp = 0.0;
|
|
_stprintf(szText, _T("%.1f"), dTemp);
|
|
}
|
|
else
|
|
{
|
|
_stprintf(szText, _T("%.1f"), dTemp + 0.5 * pNMUpDown->iDelta);
|
|
}
|
|
SetDlgItemText(IDC_EDT_FONT_HEIGHT, szText);
|
|
|
|
*pResult = 1;
|
|
}
|
|
|
|
void CFoldSetDlg::OnBnRegisterInfor()
|
|
{
|
|
OnOK();
|
|
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
BOOL bRetValue = FALSE;
|
|
|
|
// 单针保护颜色
|
|
int iIdexSinPin = m_cmbSinClr.GetCurrentItemColorIndex();
|
|
bRetValue = regProp.SetValue(KEY_FOLD_SINGLEPRO_COLOR, iIdexSinPin);
|
|
if (!bRetValue)
|
|
{
|
|
acutPrintf(_T("\n 数据设置失败!"));
|
|
return;
|
|
}
|
|
// 双针保护颜色
|
|
int iIdexDblPin = m_cmbUniClr.GetCurrentItemColorIndex();
|
|
bRetValue = regProp.SetValue(KEY_FOLD_UNIONPRO_COLOR, iIdexDblPin);
|
|
if (!bRetValue)
|
|
{
|
|
acutPrintf(_T("\n 数据设置失败!"));
|
|
return;
|
|
}
|
|
|
|
// 单针水平保护半径
|
|
bRetValue = regProp.SetValue(KEY_FOLD_HORPRO_RADIU, m_chkSinHorProRadiu.GetCheck());
|
|
if (!bRetValue)
|
|
{
|
|
acutPrintf(_T("\n 数据设置失败!"));
|
|
return;
|
|
}
|
|
// 单针保护:被保护物高度
|
|
bRetValue = regProp.SetValue(KEY_FOLD_SINGLEPRO_HEIGHT, m_chkSinProHeight.GetCheck());
|
|
if (!bRetValue)
|
|
{
|
|
acutPrintf(_T("\n 数据设置失败!"));
|
|
return;
|
|
}
|
|
|
|
// 联合保护标注内容
|
|
// 联合-两避雷针之间的距离
|
|
bRetValue = regProp.SetValue(KEY_FOLD_SPACE_BETWEEN, m_chkUniSpaBetween.GetCheck());
|
|
if (!bRetValue)
|
|
{
|
|
acutPrintf(_T("\n 数据设置失败!"));
|
|
return;
|
|
}
|
|
// 联合-被保护物高度
|
|
bRetValue = regProp.SetValue(KEY_FOLD_UNIONPRO_HEIGHT, m_chkUniProHeight.GetCheck());
|
|
if (!bRetValue)
|
|
{
|
|
acutPrintf(_T("\n 数据设置失败!"));
|
|
return;
|
|
}
|
|
// 联合-水平面保护范围
|
|
bRetValue = regProp.SetValue(KEY_FOLD_HORPRO_RANGE, m_chkUniProRange.GetCheck());
|
|
if (!bRetValue)
|
|
{
|
|
acutPrintf(_T("\n 数据设置失败!"));
|
|
return;
|
|
}
|
|
|
|
// 标注字体颜色
|
|
int iIdexFont = m_cmbFontClr.GetCurrentItemColorIndex();
|
|
bRetValue = regProp.SetValue(KEY_FOLD_FONTLABLE_COLOR, iIdexFont);
|
|
if (!bRetValue)
|
|
{
|
|
acutPrintf(_T("\n 数据设置失败!"));
|
|
return;
|
|
}
|
|
// 字高
|
|
CString strHeight = _T("");
|
|
m_edtFontHeight.GetWindowText(strHeight);
|
|
bRetValue = regProp.SetValue(KEY_FOLD_FONTLABLE_HEIGHT, strHeight);
|
|
if (!bRetValue)
|
|
{
|
|
acutPrintf(_T("\n 数据设置失败!"));
|
|
return;
|
|
}
|
|
|
|
}
|