From 6c9349bd065a99bf2066b6ae3f09691270720c9b Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期一, 22 十二月 2025 13:48:27 +0800
Subject: [PATCH] 解决了手动绘制边界的bug,所有返回按钮采用公用方法创建

---
 src/zhuye/Shouye.java |   47 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/src/zhuye/Shouye.java b/src/zhuye/Shouye.java
index 22f8fc6..27a166d 100644
--- a/src/zhuye/Shouye.java
+++ b/src/zhuye/Shouye.java
@@ -35,6 +35,7 @@
 import java.awt.geom.Point2D;
 
 import publicway.Gpstoxuzuobiao;
+import publicway.Fanhuibutton;
 
 /**
  * 棣栭〉鐣岄潰 - 閫傞厤6.5瀵哥珫灞忥紝浣跨敤鐙珛鐨凪apRenderer杩涜缁樺埗
@@ -561,7 +562,7 @@
 	private void showSettingsReturnButton() {
 		ensureFloatingButtonInfrastructure();
 		if (settingsReturnButton == null) {
-			settingsReturnButton = createFloatingTextButton("杩斿洖");
+			settingsReturnButton = Fanhuibutton.createReturnButton(null);
 			settingsReturnButton.setToolTipText("杩斿洖绯荤粺璁剧疆");
 			settingsReturnButton.addActionListener(e -> {
 				// 鍏抽棴鎵�鏈夌浉鍏虫ā寮�
@@ -1411,6 +1412,8 @@
 		remoteBtn.addActionListener(e -> showRemoteControlDialog());
 		areaSelectBtn.addActionListener(e -> {
 			// 鐐瑰嚮鈥滃湴鍧椻�濈洿鎺ユ墦寮�鍦板潡绠$悊瀵硅瘽妗嗭紙鑻ラ渶瑕佸彲浼犲叆鐗瑰畾鍦板潡缂栧彿锛�
+//			Dikuaiguanli.showDikuaiManagement(this, null);
+			// 鐩存帴杩涘叆鍦板潡绠$悊鐣岄潰
 			Dikuaiguanli.showDikuaiManagement(this, null);
 		});
 		baseStationBtn.addActionListener(e -> showBaseStationDialog());
@@ -2125,7 +2128,12 @@
 			updateStopButtonIcon();
 		}
 		if (statusLabel != null) {
-			statusLabel.setText(storedStatusBeforeDrawing != null ? storedStatusBeforeDrawing : "寰呮満");
+			// 濡傛灉鏄線杩旇矾寰勭粯鍒讹紝閫�鍑烘椂鎭㈠涓�"寰呮満"
+			if (returnPathDrawer != null && returnPathDrawer.isActive()) {
+				statusLabel.setText("寰呮満");
+			} else {
+				statusLabel.setText(storedStatusBeforeDrawing != null ? storedStatusBeforeDrawing : "寰呮満");
+			}
 		}
 		storedStatusBeforeDrawing = null;
 	}
@@ -2437,6 +2445,12 @@
 		mapRenderer.setHandheldMowerIconActive(active);
 	}
 
+	public void setStatusLabelText(String text) {
+		if (statusLabel != null) {
+			statusLabel.setText(text);
+		}
+	}
+
 	public boolean startMowerBoundaryCapture() {
 		if (mapRenderer == null) {
 			return false;
@@ -3080,7 +3094,11 @@
 		if (drawingControlModeActive) {
 			updateDrawingControlButtonLabels();
 			if (statusLabel != null) {
-				statusLabel.setText(paused ? "缁樺埗鏆傚仠" : "缁樺埗涓�");
+				if (returnPathDrawer != null && returnPathDrawer.isActive()) {
+					statusLabel.setText("姝e湪缁樺埗寰�杩旇矾寰�");
+				} else {
+					statusLabel.setText(paused ? "缁樺埗鏆傚仠" : "缁樺埗涓�");
+				}
 			}
 		}
 	}
@@ -3100,12 +3118,15 @@
 		enterDrawingControlMode();
 		
 		// 闅愯棌杩斿洖璁剧疆鎸夐挳锛堝鏋滄樉绀虹粯鍒舵寜閽紝鍒欎笉搴旇鏄剧ず杩斿洖鎸夐挳锛�
-		if (settingsReturnButton != null) {
-			settingsReturnButton.setVisible(false);
-		}
+//		if (settingsReturnButton != null) {
+//			settingsReturnButton.setVisible(false);
+//		}
 		
 		// 鏄剧ず"姝e湪缁樺埗杈圭晫"鎻愮ず
 		if (drawingBoundaryLabel != null) {
+			// 濡傛灉鏄線杩旇矾寰勭粯鍒讹紝涓嶆樉绀烘鏍囩锛堢姸鎬佹爮宸叉樉绀�"姝e湪缁樺埗寰�杩旇矾寰�"锛�
+//			boolean isReturnPathDrawing = returnPathDrawer != null && returnPathDrawer.isActive();
+//			drawingBoundaryLabel.setVisible(!isReturnPathDrawing);
 			drawingBoundaryLabel.setVisible(true);
 		}
 
@@ -3823,9 +3844,8 @@
 			endDrawingButton.setVisible(false);
 		}
 		if (pathPreviewReturnButton == null) {
-			pathPreviewReturnButton = createFloatingTextButton("杩斿洖");
+			pathPreviewReturnButton = Fanhuibutton.createReturnButton(e -> handlePathPreviewReturn());
 			pathPreviewReturnButton.setToolTipText("杩斿洖鏂板鍦板潡姝ラ");
-			pathPreviewReturnButton.addActionListener(e -> handlePathPreviewReturn());
 		}
 		pathPreviewReturnButton.setVisible(true);
 		if (floatingButtonPanel != null) {
@@ -4149,13 +4169,14 @@
     /**
      * 鍚姩寰�杩旇矾寰勭粯鍒�
      * @param finishCallback 瀹屾垚缁樺埗鏃剁殑鍥炶皟
+     * @param isHandheld 鏄惁浣跨敤鎵嬫寔璁惧妯″紡
      * @return 鏄惁鎴愬姛鍚姩
      */
-    public boolean startReturnPathDrawing(Runnable finishCallback) {
+    public boolean startReturnPathDrawing(Runnable finishCallback, boolean isHandheld) {
         if (returnPathDrawer == null) {
             return false;
         }
-        return returnPathDrawer.start(finishCallback);
+        return returnPathDrawer.start(finishCallback, isHandheld);
     }
     
     /**
@@ -4223,12 +4244,12 @@
         
         // 鍒涘缓鎴栨樉绀鸿繑鍥炴寜閽�
         if (pathPreviewReturnButton == null) {
-            pathPreviewReturnButton = publicway.buttonset.createStyledButton("杩斿洖", null);
-            pathPreviewReturnButton.setToolTipText("杩斿洖缁樺埗椤甸潰");
-            pathPreviewReturnButton.addActionListener(e -> {
+            // 浣跨敤 Fanhuibutton 鍒涘缓杩斿洖鎸夐挳
+            pathPreviewReturnButton = publicway.Fanhuibutton.createReturnButton(e -> {
                 // 鍋滄棰勮
                 stopReturnPathPreview();
             });
+            pathPreviewReturnButton.setToolTipText("杩斿洖缁樺埗椤甸潰");
         }
         
         // 闅愯棌鍏朵粬鎮诞鎸夐挳

--
Gitblit v1.10.0