Files
envi-code/SourceCode/Code2026/ThunderProof/ThunderSetDlg.cpp
T
2026-09-28 15:28:50 +08:00

299 lines
7.0 KiB
C++

#include "stdafx.h"
#include "ThunderSetDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CThunderSetDlg::CThunderSetDlg(CWnd* pParent)
: CDialog(CThunderSetDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CThunderSetDlg)
m_nLineThink = 1.0;
//}}AFX_DATA_INIT
}
void CThunderSetDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CThunderSetDlg)
DDX_Control(pDX, IDC_SPIN_FONT_HEIGHT, m_spnFontHtCtrl);
DDX_Control(pDX, IDC_EDIT_FONE_HEIGHT, m_edtFontHeight);
DDX_Control(pDX, IDC_CHECK_UNION_HEIGHT, m_chkUniProHeight);
DDX_Control(pDX, IDC_CHECK_SAFE_RANGE, m_chkProRange);
DDX_Control(pDX, IDC_CHECK_SAFE_HEIGHT, m_chkSinProHeight);
DDX_Control(pDX, IDC_CHECK_SAFE_DIS, m_chkSpaBetween);
DDX_Control(pDX, IDC_CHECK_CON_RADIU, m_chkHorProRadiu);
DDX_Control(pDX, IDC_COMBO_UNI_COLOR, m_cmbUniColor);
DDX_Control(pDX, IDC_COMBO_FONT_COLOR, m_cmbFontColor);
DDX_Control(pDX, IDC_COM_SIN_COLOR, m_cmbSinColor);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CThunderSetDlg, CDialog)
//{{AFX_MSG_MAP(CThunderSetDlg)
ON_WM_CLOSE()
ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus)
ON_BN_CLICKED(IDC_BUTTON_YES, OnBtnRegisterInfor)
ON_BN_CLICKED(IDC_BUTTON_CANCEL, OnButtonCancel)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_FONT_HEIGHT, OnDeltaposSpinFontHeight)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
LONG_PTR CThunderSetDlg::OnAcadKeepFocus(UINT_PTR, LONG_PTR)
{
CPoint pt;
GetCursorPos(&pt);
CRect rc;
GetWindowRect(&rc);
return (rc.PtInRect(pt) ? TRUE : FALSE);
}
BOOL CThunderSetDlg::OnInitDialog()
{
CDialog::OnInitDialog();
InitAllControls();
return TRUE;
}
void CThunderSetDlg::OnBtnRegisterInfor()
{
OnOK();
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
regProp.SetTopRootKey(HKEY_CURRENT_USER);
BOOL bRetValue = FALSE;
// 单针保护颜色
int iIdexSinPin = m_cmbSinColor.GetCurrentItemColorIndex();
bRetValue = regProp.SetValue(KEY_SINGLEPRO_COLOR, iIdexSinPin);
if (!bRetValue)
{
acutPrintf(_T("\n 数据设置失败!"));
return;
}
// 双针保护颜色
int iIdexDblPin = m_cmbUniColor.GetCurrentItemColorIndex();
bRetValue = regProp.SetValue(KEY_UNIONPRO_COLOR, iIdexDblPin);
if (!bRetValue)
{
acutPrintf(_T("\n 数据设置失败!"));
return;
}
// 水平保护半径
bRetValue = regProp.SetValue(KEY_HORPRO_RADIU, m_chkHorProRadiu.GetCheck());
if (!bRetValue)
{
acutPrintf(_T("\n 数据设置失败!"));
return;
}
// 单针保护:被保护物高度
bRetValue = regProp.SetValue(KEY_SINGLEPRO_HEIGHT, m_chkSinProHeight.GetCheck());
if (!bRetValue)
{
acutPrintf(_T("\n 数据设置失败!"));
return;
}
// 字高
CString strHeight = _T("");
m_edtFontHeight.GetWindowText(strHeight);
bRetValue = regProp.SetValue(KEY_FONTLABLE_HEIGHT, strHeight);
if (!bRetValue)
{
acutPrintf(_T("\n 数据设置失败!"));
return;
}
// 联合保护标注内容
// 两避雷针之间的距离
bRetValue = regProp.SetValue(KEY_SPACE_BETWEEN, m_chkSpaBetween.GetCheck());
if (!bRetValue)
{
acutPrintf(_T("\n 数据设置失败!"));
return;
}
// 联合保护:被保护物高度
bRetValue = regProp.SetValue(KEY_UNIONPRO_HEIGHT, m_chkUniProHeight.GetCheck());
if (!bRetValue)
{
acutPrintf(_T("\n 数据设置失败!"));
return;
}
// 水平面保护范围
// 两避雷针之间的距离
bRetValue = regProp.SetValue(KEY_HORPRO_RANGE, m_chkProRange.GetCheck());
if (!bRetValue)
{
acutPrintf(_T("\n 数据设置失败!"));
return;
}
int iIdexFont = m_cmbFontColor.GetCurrentItemColorIndex();
bRetValue = regProp.SetValue(KEY_FONTLABLE_COLOR, iIdexFont);
if (!bRetValue)
{
acutPrintf(_T("\n 数据设置失败!"));
return;
}
}
void CThunderSetDlg::OnButtonCancel()
{
OnOK();
}
void CThunderSetDlg::OnClose()
{
CDialog::OnClose();
}
void CThunderSetDlg::InitAllControls()
{
m_spnFontHtCtrl.SetRange32(0, 100);
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
regProp.SetTopRootKey(HKEY_CURRENT_USER);
int iIdex = ERR_VALUE;
// 读取单针保护颜色
regProp.GetValue(KEY_SINGLEPRO_COLOR, iIdex);
if (iIdex != ERR_VALUE)
m_cmbSinColor.SetCurSel(iIdex + 1);
else
m_cmbSinColor.SetCurSel(0);
// 读取双针保护颜色
regProp.GetValue(KEY_UNIONPRO_COLOR, iIdex);
if (iIdex != ERR_VALUE)
m_cmbUniColor.SetCurSel(iIdex + 1);
else
m_cmbUniColor.SetCurSel(0);
// 读取标注字体颜色
regProp.GetValue(KEY_FONTLABLE_COLOR, iIdex);
if (iIdex != ERR_VALUE)
m_cmbFontColor.SetCurSel(iIdex + 1);
else
m_cmbFontColor.SetCurSel(0);
// 字高
CString strHeight = _T("3.0");
regProp.GetValue(KEY_FONTLABLE_HEIGHT, strHeight);
m_edtFontHeight.SetWindowText(strHeight);
// 水平保护半径
regProp.GetValue(KEY_HORPRO_RADIU, iIdex);
m_chkHorProRadiu.SetCheck(iIdex);
// 单针保护:被保护物高度
regProp.GetValue(KEY_SINGLEPRO_HEIGHT, iIdex);
m_chkSinProHeight.SetCheck(iIdex);
// 联合保护标注内容
// 两避雷针之间的距离
regProp.GetValue(KEY_SPACE_BETWEEN, iIdex);
m_chkSpaBetween.SetCheck(iIdex);
// 联合保护:被保护物高度
regProp.GetValue(KEY_UNIONPRO_HEIGHT, iIdex);
m_chkUniProHeight.SetCheck(iIdex);
// 水平面保护范围
// 两避雷针之间的距离
regProp.GetValue(KEY_HORPRO_RANGE, iIdex);
m_chkProRange.SetCheck(iIdex);
//线型和线宽
ReadDlgData();
CString nTemp;
nTemp.Format(_T("%.2f"),m_nLineThink);
GetDlgItem(IDC_EDT_LINEWEIGHT)->SetWindowText(nTemp);
}
void CThunderSetDlg::OnDeltaposSpinFontHeight(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
TCHAR szText[10] = {0};
GetDlgItemText(IDC_EDIT_FONE_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_EDIT_FONE_HEIGHT, szText);
*pResult = 1;
}
void CThunderSetDlg::ReadDlgData()
{
//读取设置
CString strLineThink;
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
regProp.SetTopRootKey(HKEY_CURRENT_USER);
regProp.GetValue(KEY_LINETHINK,strLineThink); //线宽
if (!strLineThink.IsEmpty())
{
m_nLineThink = _tstof(strLineThink);
}
}
void CThunderSetDlg::SaveDlgData()
{
//保存设置
CString strLineThink;
GetDlgItem(IDC_EDT_LINEWEIGHT)->GetWindowText(strLineThink);
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
regProp.SetTopRootKey(HKEY_CURRENT_USER);
regProp.SetValue(KEY_LINETHINK,strLineThink); //线宽
}
void CThunderSetDlg::OnOK()
{
SaveDlgData();
CDialog::OnOK();
}
BOOL CThunderSetDlg::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);
}