修复实时模式下图像预览区仍可拖动的问题;非实时模式下鼠标跟随蓝色十字线功能

This commit is contained in:
zhengxuan.zhang
2026-06-30 13:51:21 +08:00
parent e86d2381e8
commit 7f2dd8f822
4 changed files with 122 additions and 3 deletions
@@ -190,6 +190,20 @@ namespace XP.ImageProcessing.RoiControl.Controls
set => SetValue(IsWheelZoomEnabledProperty, value);
}
/// <summary>
/// 是否允许拖动画布平移图像(默认允许)。
/// 实时图像显示过程中可设为 false 以禁止图像拖动。
/// </summary>
public static readonly DependencyProperty IsImagePanEnabledProperty =
DependencyProperty.Register(nameof(IsImagePanEnabled), typeof(bool), typeof(PolygonRoiCanvas),
new PropertyMetadata(true));
public bool IsImagePanEnabled
{
get => (bool)GetValue(IsImagePanEnabledProperty);
set => SetValue(IsImagePanEnabledProperty, value);
}
public static readonly DependencyProperty PanOffsetXProperty =
DependencyProperty.Register(nameof(PanOffsetX), typeof(double), typeof(PolygonRoiCanvas),
new PropertyMetadata(0.0, OnPanOffsetChanged));
@@ -2355,6 +2369,10 @@ namespace XP.ImageProcessing.RoiControl.Controls
lastMousePosition = e.GetPosition(imageDisplayGrid);
isDragging = false;
if (!IsImagePanEnabled)
{
return;
}
mainCanvas.CaptureMouse();
}
@@ -2447,7 +2465,7 @@ namespace XP.ImageProcessing.RoiControl.Controls
return;
}
if (e.LeftButton == MouseButtonState.Pressed && mainCanvas.IsMouseCaptured)
if (IsImagePanEnabled && e.LeftButton == MouseButtonState.Pressed && mainCanvas.IsMouseCaptured)
{
Point currentPosition = e.GetPosition(imageDisplayGrid);
Vector delta = currentPosition - lastMousePosition;
@@ -2733,4 +2751,4 @@ namespace XP.ImageProcessing.RoiControl.Controls
#endregion Events
}
}
}