修复注释乱码
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using XP.ImageProcessing.RoiControl.Models;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
@@ -7,7 +8,6 @@ using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using XP.ImageProcessing.RoiControl.Models;
|
||||
|
||||
namespace XP.ImageProcessing.RoiControl.Controls
|
||||
{
|
||||
@@ -75,14 +75,14 @@ namespace XP.ImageProcessing.RoiControl.Controls
|
||||
|
||||
private void Points_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
// 只在删除或添加顶点时更新Adorner,拖拽时的Replace操作不触发更�?
|
||||
// 只在删除或添加顶点时更新Adorner,拖拽时的Replace操作不触发更新
|
||||
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
|
||||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
// Points集合变化时,如果当前选中的是多边形ROI,更新Adorner
|
||||
if (SelectedROI is PolygonROI polygonROI && sender == polygonROI.Points)
|
||||
{
|
||||
// 使用Dispatcher延迟更新,确保UI已经处理完Points的变�?
|
||||
// 使用Dispatcher延迟更新,确保UI已经处理完Points的变化
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
UpdateAdorner();
|
||||
@@ -219,7 +219,7 @@ namespace XP.ImageProcessing.RoiControl.Controls
|
||||
{
|
||||
var control = (PolygonRoiCanvas)d;
|
||||
|
||||
// 更新IsSelected状�?
|
||||
// 更新IsSelected状态
|
||||
if (e.OldValue is ROIShape oldROI)
|
||||
{
|
||||
oldROI.IsSelected = false;
|
||||
@@ -288,7 +288,7 @@ namespace XP.ImageProcessing.RoiControl.Controls
|
||||
// 尝试获取容器
|
||||
var container = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as ContentPresenter;
|
||||
|
||||
// 如果容器还没生成,尝试强制生�?
|
||||
// 如果容器还没生成,尝试强制生成
|
||||
if (container == null)
|
||||
{
|
||||
// 强制生成容器
|
||||
@@ -298,7 +298,7 @@ namespace XP.ImageProcessing.RoiControl.Controls
|
||||
|
||||
if (container != null)
|
||||
{
|
||||
// 查找实际的形状元素(只支持多边形�?
|
||||
// 查找实际的形状元素(只支持多边形)
|
||||
if (roi is PolygonROI)
|
||||
{
|
||||
return FindVisualChild<Polygon>(container);
|
||||
@@ -334,10 +334,10 @@ namespace XP.ImageProcessing.RoiControl.Controls
|
||||
|
||||
private void Canvas_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
// 获取鼠标�?imageDisplayGrid 中的位置
|
||||
// 获取鼠标在 imageDisplayGrid 中的位置
|
||||
Point mousePos = e.GetPosition(imageDisplayGrid);
|
||||
|
||||
// 获取鼠标�?Canvas 中的位置(缩放前�?
|
||||
// 获取鼠标在 Canvas 中的位置(缩放前)
|
||||
Point mousePosOnCanvas = e.GetPosition(mainCanvas);
|
||||
|
||||
double oldZoom = ZoomScale;
|
||||
@@ -364,7 +364,7 @@ namespace XP.ImageProcessing.RoiControl.Controls
|
||||
ZoomScale = newZoom;
|
||||
|
||||
// 调整平移偏移,使鼠标位置保持不变
|
||||
// 新的偏移 = 旧偏�?+ 鼠标位置 - 鼠标位置 * 缩放比例
|
||||
// 新的偏移 = 旧偏移 + 鼠标位置 - 鼠标位置 * 缩放比例
|
||||
PanOffsetX = mousePos.X - (mousePos.X - PanOffsetX) * scale;
|
||||
PanOffsetY = mousePos.Y - (mousePos.Y - PanOffsetY) * scale;
|
||||
}
|
||||
@@ -412,7 +412,7 @@ namespace XP.ImageProcessing.RoiControl.Controls
|
||||
|
||||
private void Canvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
// 右键点击完成多边�?
|
||||
// 右键点击完成多边形
|
||||
OnRightClick();
|
||||
e.Handled = true;
|
||||
}
|
||||
@@ -440,10 +440,10 @@ namespace XP.ImageProcessing.RoiControl.Controls
|
||||
|
||||
if (imageDisplayGrid != null && CanvasWidth > 0 && CanvasHeight > 0)
|
||||
{
|
||||
// 使用 Dispatcher 延迟执行,确保布局已完�?
|
||||
// 使用 Dispatcher 延迟执行,确保布局已完成
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
// 获取图像显示区域的实际尺�?
|
||||
// 获取图像显示区域的实际尺寸
|
||||
double viewportWidth = imageDisplayGrid.ActualWidth;
|
||||
double viewportHeight = imageDisplayGrid.ActualHeight;
|
||||
|
||||
@@ -453,10 +453,10 @@ namespace XP.ImageProcessing.RoiControl.Controls
|
||||
double scaleX = viewportWidth / CanvasWidth;
|
||||
double scaleY = viewportHeight / CanvasHeight;
|
||||
|
||||
// 选择较小的缩放比例,确保图像完全显示在窗口内(保持宽高比�?
|
||||
// 选择较小的缩放比例,确保图像完全显示在窗口内(保持宽高比)
|
||||
ZoomScale = Math.Min(scaleX, scaleY);
|
||||
|
||||
// 居中显示�?Grid �?HorizontalAlignment �?VerticalAlignment 自动处理
|
||||
// 居中显示由 Grid 的 HorizontalAlignment 和 VerticalAlignment 自动处理
|
||||
PanOffsetX = 0;
|
||||
PanOffsetY = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user