#include "stdafx.h" #include "LinkHydrantDlg.h" #include "DbEquipment.h" #include "AcDbObjectPtr.h" #include "globalFunc.h" #include "TRegProperty.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif IMPLEMENT_DYNAMIC(CLinkHydrantDlg, CDialog) CLinkHydrantDlg::CLinkHydrantDlg(int iType, CWnd* pParent /*=NULL*/) : CDialog(CLinkHydrantDlg::IDD, pParent) { //{{AFX_DATA_INIT(CLinkHydrantDlg) m_nType = iType; m_bChangeMode = false; m_nHydrantLinkType_VPipe = 0; m_dEle2Pipe1_VPipe = 0.8; m_dEle2Pipe2_VPipe = 1.1; m_dDnPipe_VPipe = 65; m_dDnVPipe_VPipe = 100; m_nHydrantLinkType_Pipe = 0; m_nPipeLinkType_Pipe = 0; m_dDistPipe2Hy_Pipe = 0.5; m_dDnVPipe_Pipe = 100; m_nVPipePos_Pipe = 0; m_dEle2Pipe1_Pipe = 0.8; m_dEle2Pipe2_Pipe = 1.1; m_dDn2Pipe_Pipe = 65; m_dElePipe_Pipe = 2.8; m_dDnPipe_Pipe = 100; m_bIsVisible = TRUE; //}}AFX_DATA_INIT } void CLinkHydrantDlg::GetDlgDataFromReg() { TRegProperty regProp(_T("SoftWare\\SHANGHUASOFT\\2023"), _T("SHS-WTConfig")); regProp.SetTopRootKey(HKEY_CURRENT_USER); regProp.GetValue(_T("HydrantLinkType_VPipe"), m_nHydrantLinkType_VPipe); regProp.GetValue(_T("Ele2Pipe1_VPipe"), m_dEle2Pipe1_VPipe); regProp.GetValue(_T("Ele2Pipe2_VPipe"), m_dEle2Pipe2_VPipe); regProp.GetValue(_T("DnPipe_VPipe"), m_dDnPipe_VPipe); regProp.GetValue(_T("DnVPipe_VPipe"), m_dDnVPipe_VPipe); regProp.GetValue(_T("HydrantLinkType_Pipe"), m_nHydrantLinkType_Pipe); regProp.GetValue(_T("PipeLinkType_Pipe"), m_nPipeLinkType_Pipe); regProp.GetValue(_T("DistPipe2Hy_Pipe"), m_dDistPipe2Hy_Pipe); regProp.GetValue(_T("DnVPipe_Pipe"), m_dDnVPipe_Pipe); regProp.GetValue(_T("VPipePos_Pipe"), m_nVPipePos_Pipe); regProp.GetValue(_T("Ele2Pipe1_Pipe"), m_dEle2Pipe1_Pipe); regProp.GetValue(_T("Ele2Pipe2_Pipe"), m_dEle2Pipe2_Pipe); regProp.GetValue(_T("Dn2Pipe_Pipe"), m_dDn2Pipe_Pipe); regProp.GetValue(_T("ElePipe_Pipe"), m_dElePipe_Pipe); regProp.GetValue(_T("DnPipe_Pipe"), m_dDnPipe_Pipe); } void CLinkHydrantDlg::UpdataDlgData() { m_dlgLinkVPipe.UpdateData(TRUE); m_nHydrantLinkType_VPipe = m_dlgLinkVPipe.m_nHydrantLinkType; if (m_nHydrantLinkType_VPipe == 0) { m_dlgLinkVPipe.m_dEle2Pipe1 = m_dlgLinkVPipe.m_dEle; } else { m_dlgLinkVPipe.m_dEle2Pipe2 = m_dlgLinkVPipe.m_dEle; } m_dEle2Pipe1_VPipe = m_dlgLinkVPipe.m_dEle2Pipe1; m_dEle2Pipe2_VPipe = m_dlgLinkVPipe.m_dEle2Pipe2; m_dDnPipe_VPipe = m_dlgLinkVPipe.m_dDnPipe; m_dDnVPipe_VPipe = m_dlgLinkVPipe.m_dDnVPipe; m_dlgLinkPipe.UpdateData(TRUE); m_nHydrantLinkType_Pipe = m_dlgLinkPipe.m_nHydrantLinkType; if (m_nHydrantLinkType_Pipe == 0) { m_dlgLinkPipe.m_dEle2Pipe1 = m_dlgLinkPipe.m_dEle; } else { m_dlgLinkPipe.m_dEle2Pipe2 = m_dlgLinkPipe.m_dEle; } m_nPipeLinkType_Pipe = m_dlgLinkPipe.m_nPipeLinkType; m_dEle2Pipe1_Pipe = m_dlgLinkPipe.m_dEle2Pipe1; m_dEle2Pipe2_Pipe = m_dlgLinkPipe.m_dEle2Pipe2; m_dDistPipe2Hy_Pipe = m_dlgLinkPipe.m_dDistPipe2Hy; m_dDnVPipe_Pipe = m_dlgLinkPipe.m_dDnVPipe; m_nVPipePos_Pipe = m_dlgLinkPipe.m_nVPipePos; m_dDn2Pipe_Pipe = m_dlgLinkPipe.m_dDn2Pipe; m_dElePipe_Pipe = m_dlgLinkPipe.m_dElePipe; m_dDnPipe_Pipe = m_dlgLinkPipe.m_dDnPipe; } void CLinkHydrantDlg::SetRegDataFromDlg() { UpdataDlgData(); TRegProperty regProp(_T("SoftWare\\SHANGHUASOFT\\2023"), _T("SHS-WTConfig")); regProp.SetTopRootKey(HKEY_CURRENT_USER); regProp.SetValue(_T("HydrantLinkType_VPipe"), m_nHydrantLinkType_VPipe); regProp.SetValue(_T("Ele2Pipe1_VPipe"), m_dEle2Pipe1_VPipe); regProp.SetValue(_T("Ele2Pipe2_VPipe"), m_dEle2Pipe2_VPipe); regProp.SetValue(_T("DnPipe_VPipe"), m_dDnPipe_VPipe); regProp.SetValue(_T("DnVPipe_VPipe"), m_dDnVPipe_VPipe); regProp.SetValue(_T("HydrantLinkType_Pipe"), m_nHydrantLinkType_Pipe); regProp.SetValue(_T("PipeLinkType_Pipe"), m_nPipeLinkType_Pipe); regProp.SetValue(_T("DistPipe2Hy_Pipe"), m_dDistPipe2Hy_Pipe); regProp.SetValue(_T("DnVPipe_Pipe"), m_dDnVPipe_Pipe); regProp.SetValue(_T("VPipePos_Pipe"), m_nVPipePos_Pipe); regProp.SetValue(_T("Ele2Pipe1_Pipe"), m_dEle2Pipe1_Pipe); regProp.SetValue(_T("Ele2Pipe2_Pipe"), m_dEle2Pipe2_Pipe); regProp.SetValue(_T("Dn2Pipe_Pipe"), m_dDn2Pipe_Pipe); regProp.SetValue(_T("ElePipe_Pipe"), m_dElePipe_Pipe); regProp.SetValue(_T("DnPipe_Pipe"), m_dDnPipe_Pipe); } void CLinkHydrantDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CLinkHydrantDlg) DDX_Control(pDX, IDC_TAB_LINK_TYPE, m_wndTabLinkType); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CLinkHydrantDlg, CDialog) //{{AFX_MSG_MAP(CLinkHydrantDlg) ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_LINK_TYPE, OnSelchangeTabLinkType) ON_WM_CLOSE() ON_WM_TIMER() ON_MESSAGE(WM_ACAD_KEEPFOCUS, onAcadKeepFocus) //}}AFX_MSG_MAP END_MESSAGE_MAP() BOOL CLinkHydrantDlg::OnInitDialog() { CDialog::OnInitDialog(); m_wndTabLinkType.InsertItem(0, _T("立消连接")); m_wndTabLinkType.InsertItem(1, _T("干消连接")); GetDlgDataFromReg(); m_wndTabLinkType.SetCurSel(m_nType); if (m_nType == 0) { m_dlgLinkVPipe.ShowWindow(SW_SHOW); } else { m_dlgLinkPipe.ShowWindow(SW_SHOW); } m_dlgLinkVPipe.m_nHydrantLinkType = m_nHydrantLinkType_VPipe; m_dlgLinkVPipe.m_dEle2Pipe1 = m_dEle2Pipe1_VPipe; m_dlgLinkVPipe.m_dEle2Pipe2 = m_dEle2Pipe2_VPipe; m_dlgLinkVPipe.m_dDnPipe = m_dDnPipe_VPipe; m_dlgLinkVPipe.m_dDnVPipe = m_dDnVPipe_VPipe; m_dlgLinkPipe.m_nHydrantLinkType = m_nHydrantLinkType_Pipe; m_dlgLinkPipe.m_dEle2Pipe1 = m_dEle2Pipe1_Pipe; m_dlgLinkPipe.m_dEle2Pipe2 = m_dEle2Pipe2_Pipe; m_dlgLinkPipe.m_dDnPipe = m_dDnPipe_Pipe; m_dlgLinkPipe.m_dDnVPipe = m_dDnVPipe_Pipe; m_dlgLinkPipe.m_nPipeLinkType = m_nPipeLinkType_Pipe; m_dlgLinkPipe.m_dDistPipe2Hy = m_dDistPipe2Hy_Pipe; m_dlgLinkPipe.m_nVPipePos = m_nVPipePos_Pipe; m_dlgLinkPipe.m_dDn2Pipe = m_dDn2Pipe_Pipe; m_dlgLinkPipe.m_dElePipe = m_dElePipe_Pipe; m_dlgLinkVPipe.Create(IDD_LINK_HYDRANT_VPIPE, &m_wndTabLinkType); m_dlgLinkPipe.Create(IDD_LINK_HYDRANT_PIPE, &m_wndTabLinkType); CRect rect; m_wndTabLinkType.GetClientRect(&rect); rect.right += 20; m_wndTabLinkType.MoveWindow(&rect); m_dlgLinkPipe.GetClientRect(&rect); rect.left += 7; rect.top += 25; rect.right += 7; rect.bottom += 25; m_dlgLinkPipe.MoveWindow(&rect); m_dlgLinkVPipe.GetClientRect (&rect); rect.left += 7; rect.top += 25; rect.right += 7; rect.bottom += 25; m_dlgLinkVPipe.MoveWindow(&rect); UpdateData(FALSE); ModifyWndRect(); #if (ADS == 15) SetTimer(1, 2000, NULL); #else SetTimer(1, 200, NULL); #endif return TRUE; } void CLinkHydrantDlg::OnTimer(UINT_PTR nIDEvent) { UpdateData(); ShowEq(m_bIsVisible); m_bIsVisible = !m_bIsVisible; CDialog::OnTimer(nIDEvent); } BOOL CLinkHydrantDlg::DestroyWindow() { EndHydrantBlink(); return CDialog::DestroyWindow(); } void CLinkHydrantDlg::OnClose() { CDialog::OnClose(); acedPostCommand(_T("\33\33")); } LONG_PTR CLinkHydrantDlg::onAcadKeepFocus(UINT_PTR, LONG_PTR) { POINT pt; ::GetCursorPos(&pt); CRect rect; GetWindowRect(&rect); if (!(rect.PtInRect(pt))) { return FALSE; } return TRUE; } void CLinkHydrantDlg::EndHydrantBlink() { KillTimer(1); ShowEq(TRUE); } void CLinkHydrantDlg::ShowEq(BOOL bShow) { for (long l = 0; l < m_ssSet.Length(); l++) { Entity entEq = m_ssSet[l]; AcApDocument* pDoc = acDocManager->curDocument(); acDocManager->lockDocument(pDoc, AcAp::kWrite); OPENOBJ_BEGIN(entEq, AcDb::kForRead, CDbEquipment, pEquip); if(pEquip != NULL && pEquip->upgradeOpen() == Acad::eOk) { if (bShow) { pEquip->setVisibility(AcDb::kVisible); } else { pEquip->setVisibility(AcDb::kInvisible); } } OPENOBJ_END(); acedUpdateDisplay(); actrTransactionManager->flushGraphics(); acDocManager->unlockDocument(pDoc); } } double CLinkHydrantDlg::GetElev() { if (m_nType == 0) { return m_dlgLinkVPipe.m_dEle; } else { return m_dlgLinkPipe.m_dEle; } } void CLinkHydrantDlg::SetUnLinkedEq(PickSet &ss) { m_ssSet = ss; } void CLinkHydrantDlg::OnSelchangeTabLinkType(NMHDR* pNMHDR, LRESULT* pResult) { UpdateData(TRUE); m_nType = m_wndTabLinkType.GetCurSel(); ModifyWndRect(); m_bChangeMode = true; *pResult = 0; GlobalFunc::PostCommand(_T(" "), false); acedGetAcadDwgView()->SetFocus(); } void CLinkHydrantDlg::ModifyWndRect() { static CRect rectPipe, rectVPipe; if (rectPipe.IsRectEmpty()) { m_dlgLinkPipe.GetWindowRect(&rectPipe); m_dlgLinkVPipe.GetWindowRect(&rectVPipe); } switch(m_wndTabLinkType.GetCurSel()) { case 0: { m_dlgLinkVPipe.ShowWindow(SW_SHOW); m_dlgLinkPipe.ShowWindow(SW_HIDE); // 调整对话框大小,以适应属性页 CRect rect; GetClientRect(&rect); double dW1 = 0.0, dW2 = 0.0, dH1 = 0.0, dH2 = 0.0; dW1 = rectVPipe.Width(); dW2 = rect.Width(); dH1 = rectVPipe.Height(); dH2 = rect.Height(); GetWindowRect(&rect); rect.right += dW1 - dW2 + 25; rect.bottom += dH1 - dH2 + 40; MoveWindow(&rect); // 调整tab大小 m_wndTabLinkType.GetClientRect(&rect); dW1 = rectVPipe.Width(); dW2 = rect.Width(); dH1 = rectVPipe.Height(); dH2 = rect.Height(); rect.left += 5; rect.top += 5; rect.right += dW1 - dW2 + 20; rect.bottom += dH1 - dH2 + 35; m_wndTabLinkType.MoveWindow(&rect); break; } case 1: { m_dlgLinkPipe.ShowWindow(SW_SHOW); m_dlgLinkVPipe.ShowWindow(SW_HIDE); // 调整对话框大小,以适应属性页 CRect rect; GetClientRect(&rect); double dW1 = 0.0, dW2 = 0.0, dH1 = 0.0, dH2 = 0.0; dW1 = rectPipe.Width(); dW2 = rect.Width(); dH1 = rectPipe.Height(); dH2 = rect.Height(); GetWindowRect(&rect); rect.right += dW1 - dW2 + 23; rect.bottom += dH1 - dH2 + 40; MoveWindow(&rect); // 调整tab大小 m_wndTabLinkType.GetClientRect(&rect); dW1 = rectPipe.Width(); dW2 = rect.Width(); dH1 = rectPipe.Height(); dH2 = rect.Height(); rect.left += 5; rect.top += 5; rect.right += dW1 - dW2 + 18; rect.bottom += dH1 - dH2 + 35; m_wndTabLinkType.MoveWindow(&rect); break; } } }