From 8cd1ad310c5e559435ff38e518b8fad89852b55f Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 10 十月 2025 13:38:02 +0800
Subject: [PATCH] 1.ControlJob属性页设置 ;

---
 SourceCode/Bond/Servo/resource.h                |    0 
 SourceCode/Bond/Servo/CControlJob.cpp           |    6 +++
 SourceCode/Bond/Servo/CControlJob.h             |    1 
 SourceCode/Bond/Servo/Servo.rc                  |    0 
 SourceCode/Bond/Servo/CCjPage3.h                |    4 ++
 SourceCode/Bond/Servo/CControlJobManagerDlg.h   |    1 
 SourceCode/Bond/Servo/CControlJobManagerDlg.cpp |   20 +++++++++
 SourceCode/Bond/Servo/CCjPage3.cpp              |   36 ++++++++++++++++++
 8 files changed, 67 insertions(+), 1 deletions(-)

diff --git a/SourceCode/Bond/Servo/CCjPage3.cpp b/SourceCode/Bond/Servo/CCjPage3.cpp
index 6576f00..aac7455 100644
--- a/SourceCode/Bond/Servo/CCjPage3.cpp
+++ b/SourceCode/Bond/Servo/CCjPage3.cpp
@@ -29,6 +29,7 @@
 
 BEGIN_MESSAGE_MAP(CCjPage3, CCjPageBase)
 	ON_WM_DESTROY()
+    ON_EN_CHANGE(IDC_EDIT_CJ_ID, &CCjPage3::OnEnChangeEditCjId)
 END_MESSAGE_MAP()
 
 
@@ -69,5 +70,40 @@
 
 int CCjPage3::OnApply()
 {
+    // SERVO::CControlJob*
+    if (m_pContext == nullptr) return -1;
+    SERVO::CControlJob* pControlJob = (SERVO::CControlJob*)m_pContext;
+
+    // 鏇存柊鍚嶇О
+    BOOL bOkName = TRUE;
+    char szBuffer[256];
+    GetDlgItemText(IDC_EDIT_CJ_ID, szBuffer, 256);
+    pControlJob->setId(std::string(szBuffer));
+
+
+    ContentChanged(1);
     return 0;
+}
+
+void CCjPage3::OnSetContext(void* pContext)
+{
+    UpdateCjData();
+}
+
+void CCjPage3::UpdateCjData()
+{
+    if (m_pContext == nullptr) return;
+
+    m_bContentChangedLock = TRUE;
+
+    SERVO::CControlJob* pControlJob = (SERVO::CControlJob*)m_pContext;
+    SetDlgItemText(IDC_EDIT_CJ_ID, pControlJob->id().c_str());
+
+
+    m_bContentChangedLock = FALSE;
+}
+
+void CCjPage3::OnEnChangeEditCjId()
+{
+    ContentChanged(0);
 }
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/CCjPage3.h b/SourceCode/Bond/Servo/CCjPage3.h
index 4c4472a..95764b3 100644
--- a/SourceCode/Bond/Servo/CCjPage3.h
+++ b/SourceCode/Bond/Servo/CCjPage3.h
@@ -1,5 +1,6 @@
 锘�#pragma once
 #include "CCjPageBase.h"
+#include "CControlJob.h"
 
 
 // CPjPage1 瀵硅瘽妗�
@@ -15,6 +16,8 @@
 protected:
 	void Resize();
 	virtual int OnApply();
+	virtual void OnSetContext(void* pContext);
+	void UpdateCjData();
 
 // 瀵硅瘽妗嗘暟鎹�
 #ifdef AFX_DESIGN_TIME
@@ -28,4 +31,5 @@
 public:
 	virtual BOOL OnInitDialog();
 	afx_msg void OnDestroy();
+	afx_msg void OnEnChangeEditCjId();
 };
diff --git a/SourceCode/Bond/Servo/CControlJob.cpp b/SourceCode/Bond/Servo/CControlJob.cpp
index 39726f8..cb1e794 100644
--- a/SourceCode/Bond/Servo/CControlJob.cpp
+++ b/SourceCode/Bond/Servo/CControlJob.cpp
@@ -38,6 +38,12 @@
         m_tEnd = src.m_tEnd;
     }
 
+    void CControlJob::setId(std::string& id)
+    {
+        m_cjId = trimCopy(id);
+        clampString(m_cjId, MAX_ID_LEN);
+    }
+
     bool CControlJob::addPJ(const std::string& pjId) {
         if (pjId.empty()) return false;
         auto id = pjId;
diff --git a/SourceCode/Bond/Servo/CControlJob.h b/SourceCode/Bond/Servo/CControlJob.h
index 30e4184..1c391e1 100644
--- a/SourceCode/Bond/Servo/CControlJob.h
+++ b/SourceCode/Bond/Servo/CControlJob.h
@@ -42,6 +42,7 @@
 
         // —— 基本属性 —— //
         const std::string& id()     const noexcept { return m_cjId; }
+        void setId(std::string& id);
         CJState            state()  const noexcept { return m_state; }
         uint8_t            priority() const noexcept { return m_priority; }
         void               setPriority(uint8_t p) noexcept { m_priority = p; }
diff --git a/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp b/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp
index 037b595..2e2d92c 100644
--- a/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp
+++ b/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp
@@ -78,6 +78,9 @@
 			if (contextType == 1) {
 				UpProcessJobId((PJWarp*)pContext);
 			}
+			else if (contextType == 2) {
+				UpControlJobId((SERVO::CControlJob*)pContext);
+			}
 		}
 	};
 
@@ -307,7 +310,8 @@
 			SERVO::CControlJob* cj = (SERVO::CControlJob*)m_tree.GetItemData(hSel);
 			ASSERT(m_pages.size() == 3);
 			if (0 == ShowPage(2)) {
-
+				SERVO::CControlJob* pControlJob = (SERVO::CControlJob*)m_tree.GetItemData(hSel);
+				m_pages[2]->SetContext(pControlJob, 2);
 			}
 		}
 		else if (m_tree.GetParentItem(hParent) == nullptr) {
@@ -406,6 +410,20 @@
 	}
 }
 
+void CControlJobManagerDlg::UpControlJobId(SERVO::CControlJob* pControlJob)
+{
+	// 鏇存柊鏍戞帶浠�
+	// 閬嶅巻鏍硅妭鐐�
+	HTREEITEM hRoot = m_tree.GetRootItem();
+	if (hRoot != nullptr) {
+		DWORD_PTR data = m_tree.GetItemData(hRoot);
+		if ((void*)data == pControlJob) {
+			m_tree.SetItemText(hRoot, pControlJob->id().c_str());
+			return; // 鎵惧埌灏辫繑鍥�
+		}
+	}
+}
+
 void CControlJobManagerDlg::LoadState()
 {
 	if (!m_bHasState) return;
diff --git a/SourceCode/Bond/Servo/CControlJobManagerDlg.h b/SourceCode/Bond/Servo/CControlJobManagerDlg.h
index 2407c30..031ed7c 100644
--- a/SourceCode/Bond/Servo/CControlJobManagerDlg.h
+++ b/SourceCode/Bond/Servo/CControlJobManagerDlg.h
@@ -25,6 +25,7 @@
 	bool AddPorcessJob(SERVO::CProcessJob* pj);
 	bool RemovePorcessJob(SERVO::CProcessJob* pj);
 	void UpProcessJobId(PJWarp* pjWarp);
+	void UpControlJobId(SERVO::CControlJob* pControlJob);
 	void InitData();
 	void LoadState();
 	void SaveState();
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index 3a00a2f..c915b8d 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 1d1a388..6b7817f 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ

--
Gitblit v1.9.3