From 19261d011387ec57d646decc945aadaf8913eeab Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 10 三月 2025 09:05:54 +0800
Subject: [PATCH] Merge branch 'clh'
---
SourceCode/Bond/Servo/CPanelAttributes.cpp | 192 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 192 insertions(+), 0 deletions(-)
diff --git a/SourceCode/Bond/Servo/CPanelAttributes.cpp b/SourceCode/Bond/Servo/CPanelAttributes.cpp
new file mode 100644
index 0000000..fb2200b
--- /dev/null
+++ b/SourceCode/Bond/Servo/CPanelAttributes.cpp
@@ -0,0 +1,192 @@
+锘�// CPanelAttributes.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "Servo.h"
+#include "CPanelAttributes.h"
+#include "afxdialogex.h"
+#include "common.h"
+#include "VerticalLine.h"
+
+
+// CPanelAttributes 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CPanelAttributes, CDialogEx)
+
+CPanelAttributes::CPanelAttributes(CWnd* pParent /*=nullptr*/)
+ : CDialogEx(IDD_PANEL_ATTRIBUTES, pParent)
+{
+ m_crBkgnd = PANEL_ATTRIBUTES_BACKGROUND_COLOR;
+ m_hbrBkgnd = nullptr;
+ m_nPanelWidth = 188;
+}
+
+CPanelAttributes::~CPanelAttributes()
+{
+}
+
+void CPanelAttributes::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_MFCPROPERTYGRID1, m_gridCtrl);
+}
+
+
+BEGIN_MESSAGE_MAP(CPanelAttributes, CDialogEx)
+ ON_WM_CTLCOLOR()
+ ON_WM_DESTROY()
+ ON_WM_SIZE()
+ ON_NOTIFY(BYVERTICALLINE_MOVEX, IDC_LINE1, &CPanelAttributes::OnVLineMoveX)
+ ON_BN_CLICKED(IDC_BUTTON_CLOSE, &CPanelAttributes::OnBnClickedButtonClose)
+END_MESSAGE_MAP()
+
+
+// CPanelAttributes 娑堟伅澶勭悊绋嬪簭
+
+
+int CPanelAttributes::getPanelWidth()
+{
+ return m_nPanelWidth;
+}
+
+void CPanelAttributes::loadDataFromStep(SERVO::CStep* pStep)
+{
+ // 鍏堟竻绌烘墍鏈�
+ m_gridCtrl.RemoveAll();
+
+
+ // 鍔犺浇鏁版嵁
+ SetDlgItemText(IDC_LABEL_TITLE, pStep->getName().c_str());
+ SERVO::CAttributeVector attrubutes;
+ pStep->getAttributeVector(attrubutes);
+ unsigned int nSize = attrubutes.size();
+ for (unsigned int i = 0; i < nSize; i++) {
+ SERVO::CAttribute* pAttribute = attrubutes.getAttribute(i);
+ CMFCPropertyGridProperty* pProperty = new CMFCPropertyGridProperty(
+ pAttribute->getName().c_str(),
+ pAttribute->getValue().c_str(),
+ pAttribute->getDescription().c_str());
+ pProperty->AllowEdit(TRUE);
+ m_gridCtrl.AddProperty(pProperty);
+ }
+}
+
+BOOL CPanelAttributes::OnInitDialog()
+{
+ CDialogEx::OnInitDialog();
+
+
+ // 鍏抽棴鎸夐挳
+ CString strIcon1;
+ strIcon1.Format(_T("%s\\Res\\panel_close_24_b.ico"), theApp.m_strAppDir);
+ HICON hIcon1 = (HICON)::LoadImage(AfxGetInstanceHandle(),
+ strIcon1, IMAGE_ICON, 24, 24,
+ LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
+ m_btnClose.SubclassDlgItem(IDC_BUTTON_CLOSE, this);
+ m_btnClose.SetIcon(hIcon1, hIcon1, 24);
+ m_btnClose.SetFaceColor(m_crBkgnd);
+ m_btnClose.SetFrameColor(m_crBkgnd);
+ m_btnClose.SetFrameColor(BS_HOVER, RGB(218, 218, 218));
+ m_btnClose.SetFrameColor(BS_PRESS, RGB(168, 168, 168));
+
+ CVerticalLine* pLine1 = CVerticalLine::Hook(GetDlgItem(IDC_LINE1)->GetSafeHwnd());
+ pLine1->SetBkgndColor(RGB(225, 225, 225));
+ pLine1->SetLineColor(RGB(198, 198, 198));
+ pLine1->EnableResize();
+
+
+ // 璇诲彇闈㈡澘瀹�
+ CString strIniFile;
+ strIniFile.Format(_T("%s\\%s.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, (LPTSTR)(LPCTSTR)theApp.m_strAppFile);
+ m_nPanelWidth = GetPrivateProfileInt(_T("App"), _T("AttributesPanelWidth"),
+ int((double)GetSystemMetrics(SM_CXSCREEN) * 0.25), (LPTSTR)(LPCTSTR)strIniFile);
+
+
+
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+
+HBRUSH CPanelAttributes::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+ HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
+
+ if (nCtlColor == CTLCOLOR_STATIC) {
+ pDC->SetBkColor(m_crBkgnd);
+ pDC->SetTextColor(RGB(0, 0, 0));
+ }
+
+ if (m_hbrBkgnd == nullptr) {
+ m_hbrBkgnd = CreateSolidBrush(m_crBkgnd);
+ }
+
+ return m_hbrBkgnd;
+}
+
+void CPanelAttributes::OnDestroy()
+{
+ CDialogEx::OnDestroy();
+
+ if (m_hbrBkgnd != nullptr) {
+ ::DeleteObject(m_hbrBkgnd);
+ }
+}
+
+void CPanelAttributes::OnSize(UINT nType, int cx, int cy)
+{
+ CDialogEx::OnSize(nType, cx, cy);
+ if (GetDlgItem(IDC_LINE1) == nullptr) return;
+
+ CWnd* pItem;
+ CRect rcClient, rcItem;
+
+ GetClientRect(&rcClient);
+ pItem = GetDlgItem(IDC_LINE1);
+ pItem->MoveWindow(rcClient.right - 3, 0, 3, rcClient.Height());
+
+ int x2 = rcClient.right - 6;
+ int y = 3;
+ pItem = GetDlgItem(IDC_BUTTON_CLOSE);
+ pItem->GetWindowRect(&rcItem);
+ pItem->MoveWindow(x2 - rcItem.Width(), y, rcItem.Width(), rcItem.Height());
+ x2 -= rcItem.Width();
+ x2 -= 3;
+
+ pItem = GetDlgItem(IDC_LABEL_TITLE);
+ pItem->GetWindowRect(&rcItem);
+ pItem->MoveWindow(5, y, x2 - 5, rcItem.Height());
+ y += rcItem.Height();
+ y += 8;
+
+
+ GetDlgItem(IDC_MFCPROPERTYGRID1)->MoveWindow(5, y, rcClient.Width() - 13, rcClient.Height() - 3 - y);
+}
+
+#define ATTRIBUTES_PANEL_MIN_WIDTH 88
+#define ATTRIBUTES_PANEL_MAX_WIDTH 588
+void CPanelAttributes::OnVLineMoveX(NMHDR* nmhdr, LRESULT* result)
+{
+ BYVERTICALLINE_NMHDR* pNmhdrex = (BYVERTICALLINE_NMHDR*)nmhdr;
+ int x = pNmhdrex->dwData;
+ m_nPanelWidth += x;
+ m_nPanelWidth = max(m_nPanelWidth, ATTRIBUTES_PANEL_MIN_WIDTH);
+ m_nPanelWidth = min(m_nPanelWidth, ATTRIBUTES_PANEL_MAX_WIDTH);
+ GetParent()->SendMessage(ID_MSG_PANEL_RESIZE, m_nPanelWidth, 0);
+
+ CString strIniFile, strValue;
+ strIniFile.Format(_T("%s\\%s.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, (LPTSTR)(LPCTSTR)theApp.m_strAppFile);
+ strValue.Format(_T("%d"), m_nPanelWidth);
+ WritePrivateProfileString(_T("App"), _T("AttributesPanelWidth"),
+ (LPTSTR)(LPCTSTR)strValue, (LPTSTR)(LPCTSTR)strIniFile);
+ OnSize(0, 0, 0);
+
+ *result = 0;
+}
+
+void CPanelAttributes::OnBnClickedButtonClose()
+{
+ ShowWindow(SW_HIDE);
+ GetParent()->SendMessage(ID_MSG_PANEL_RESIZE, m_nPanelWidth, 0);
+}
--
Gitblit v1.9.3