实时过程中禁用图像预览窗体的滚轮缩放功能
This commit is contained in:
@@ -176,6 +176,20 @@ namespace XP.ImageProcessing.RoiControl.Controls
|
||||
control.UpdateAdorner();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否允许滚轮缩放(默认允许)。
|
||||
/// 实时图像显示过程中可设为 false 以禁用滚轮缩放。
|
||||
/// </summary>
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user