From ad1fdb02304cc3947202004da4eb09380fdcd553 Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Mon, 1 Jun 2026 15:07:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E6=97=B6=E8=BF=87=E7=A8=8B=E4=B8=AD?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E5=9B=BE=E5=83=8F=E9=A2=84=E8=A7=88=E7=AA=97?= =?UTF-8?q?=E4=BD=93=E7=9A=84=E6=BB=9A=E8=BD=AE=E7=BC=A9=E6=94=BE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controls/PolygonRoiCanvas.xaml.cs | 21 +++++++++++++++++++ .../ViewModels/Main/ViewportPanelViewModel.cs | 9 ++++++++ XplorePlane/Views/Main/ViewportPanelView.xaml | 1 + 3 files changed, 31 insertions(+) diff --git a/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs b/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs index 1ddedc0..d1cd13a 100644 --- a/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs +++ b/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs @@ -176,6 +176,20 @@ namespace XP.ImageProcessing.RoiControl.Controls control.UpdateAdorner(); } + /// + /// 是否允许滚轮缩放(默认允许)。 + /// 实时图像显示过程中可设为 false 以禁用滚轮缩放。 + /// + public static readonly DependencyProperty IsWheelZoomEnabledProperty = + DependencyProperty.Register(nameof(IsWheelZoomEnabled), typeof(bool), typeof(PolygonRoiCanvas), + new PropertyMetadata(true)); + + public bool IsWheelZoomEnabled + { + get => (bool)GetValue(IsWheelZoomEnabledProperty); + set => SetValue(IsWheelZoomEnabledProperty, value); + } + public static readonly DependencyProperty PanOffsetXProperty = DependencyProperty.Register(nameof(PanOffsetX), typeof(double), typeof(PolygonRoiCanvas), new PropertyMetadata(0.0, OnPanOffsetChanged)); @@ -2209,6 +2223,13 @@ namespace XP.ImageProcessing.RoiControl.Controls private void Canvas_MouseWheel(object sender, MouseWheelEventArgs e) { + // 实时显示过程中禁用滚轮缩放 + if (!IsWheelZoomEnabled) + { + e.Handled = true; + return; + } + double oldZoom = ZoomScale; double newZoom = e.Delta > 0 ? oldZoom * ZoomStep : oldZoom / ZoomStep; newZoom = Math.Max(0.1, Math.Min(10.0, newZoom)); diff --git a/XplorePlane/ViewModels/Main/ViewportPanelViewModel.cs b/XplorePlane/ViewModels/Main/ViewportPanelViewModel.cs index 44ef8da..744e02a 100644 --- a/XplorePlane/ViewModels/Main/ViewportPanelViewModel.cs +++ b/XplorePlane/ViewModels/Main/ViewportPanelViewModel.cs @@ -94,10 +94,18 @@ namespace XplorePlane.ViewModels set { if (SetProperty(ref _isRealtimeEnabled, value)) + { _mainViewportService.SetRealtimeDisplayEnabled(value); + RaisePropertyChanged(nameof(IsWheelZoomEnabled)); + } } } + /// + /// 是否允许滚轮缩放:实时显示过程中禁用,停止实时后可缩放。 + /// + public bool IsWheelZoomEnabled => !_isRealtimeEnabled; + // Task 5.3: IsDetectorConnected property (read-only, private setter) public bool IsDetectorConnected { @@ -227,6 +235,7 @@ namespace XplorePlane.ViewModels // Task 5.8: Sync IsRealtimeEnabled from service _isRealtimeEnabled = _mainViewportService.IsRealtimeDisplayEnabled; RaisePropertyChanged(nameof(IsRealtimeEnabled)); + RaisePropertyChanged(nameof(IsWheelZoomEnabled)); // Task 5.8: Sync _isCncRunning from service and raise IsAnimatedSwitchEnabled _isCncRunning = _mainViewportService.IsCncRunning; diff --git a/XplorePlane/Views/Main/ViewportPanelView.xaml b/XplorePlane/Views/Main/ViewportPanelView.xaml index 95ca774..dea579a 100644 --- a/XplorePlane/Views/Main/ViewportPanelView.xaml +++ b/XplorePlane/Views/Main/ViewportPanelView.xaml @@ -35,6 +35,7 @@ x:Name="RoiCanvas" Background="White" ImageSource="{Binding ImageSource}" + IsWheelZoomEnabled="{Binding IsWheelZoomEnabled}" ScaleBarMmPerPixel="0.139" ShowScaleBar="{Binding DataContext.IsScaleBarVisible, RelativeSource={RelativeSource AncestorType=Window}}" />