From 6365b1d493ca23688fa1fb9a8fc51513dc6bb6d8 Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期一, 25 十一月 2024 18:10:46 +0800
Subject: [PATCH] 1.完成上下切换轴 2.补全未追踪的文件

---
 SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp |   70 ++++++++++++++++++++++++++---------
 1 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
index 2079bf2..5cdc22f 100644
--- a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
@@ -190,6 +190,19 @@
 	label.UpdateWindow();            // 绔嬪嵆鍒锋柊
 }
 
+int CAxisSettingsDlg::getCurrentSelectedAxisID()
+{
+	int currentIndex = m_comboAxisNO.GetCurSel();
+	if (currentIndex == CB_ERR) {
+		AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
+		return -1;
+	}
+
+	CString axisIDStr;
+	m_comboAxisNO.GetLBText(currentIndex, axisIDStr);
+	return _ttoi(axisIDStr);
+}
+
 void CAxisSettingsDlg::initializeAxisIDCombo()
 {
 	// 鑾峰彇鎵�鏈夎酱鐨勮酱NO
@@ -214,15 +227,7 @@
 void CAxisSettingsDlg::refreshAxisDetails()
 {
 	// 鑾峰彇褰撳墠閫変腑鐨勮酱ID
-	int currentIndex = m_comboAxisNO.GetCurSel();
-	if (currentIndex == CB_ERR) {
-		AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
-		return;
-	}
-
-	CString axisIDStr;
-	m_comboAxisNO.GetLBText(currentIndex, axisIDStr);
-	int axisId = _ttoi(axisIDStr);
+	int axisId = getCurrentSelectedAxisID();
 
 	// 鑾峰彇杞翠俊鎭�
 	auto axisDetails = AxisManager::getInstance().getAxis(axisId);
@@ -255,15 +260,7 @@
 	const int pageSize = 5;
 
 	// 鑾峰彇褰撳墠閫変腑鐨勮酱ID
-	int currentIndex = m_comboAxisNO.GetCurSel();
-	if (currentIndex == CB_ERR) {
-		AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
-		return;
-	}
-
-	CString axisIDStr;
-	m_comboAxisNO.GetLBText(currentIndex, axisIDStr);
-	int axisId = _ttoi(axisIDStr);
+	int axisId = getCurrentSelectedAxisID();
 
 	// 鑾峰彇瀹氫綅鐐规暟鎹�
 	auto positions = AxisManager::getInstance().getPositions(axisId, pageNumber, pageSize);
@@ -311,6 +308,27 @@
 			if (pPosition) pPosition->SetWindowText(_T(""));
 		}
 	}
+}
+
+void CAxisSettingsDlg::updateAxisSelection(int offset)
+{
+	int currentIndex = m_comboAxisNO.GetCurSel();
+	if (currentIndex == CB_ERR) {
+		AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
+		return;
+	}
+
+	int newIndex = currentIndex + offset;
+	if (newIndex < 0 || newIndex >= m_comboAxisNO.GetCount()) {
+		CString error;
+		error.Format(_T("宸茬粡鍒拌揪%s涓�涓酱锛�"), offset < 0 ? _T("涓�") : _T("涓�"));
+		AfxMessageBox(error);
+		return;
+	}
+
+	m_comboAxisNO.SetCurSel(newIndex);
+	refreshAxisDetails();
+	refreshPositionDetails(1);
 }
 
 BEGIN_MESSAGE_MAP(CAxisSettingsDlg, CDialogEx)
@@ -465,11 +483,27 @@
 void CAxisSettingsDlg::OnBnClickedButtonAxisLast()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	try {
+		updateAxisSelection(-1);
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鑾峰彇涓嬩竴涓酱澶辫触锛�%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+	}
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisNext()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	try {
+		updateAxisSelection(1);
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鑾峰彇涓婁竴涓酱澶辫触锛�%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+	}
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup1()

--
Gitblit v1.9.3