修复注释乱码

This commit is contained in:
李伟
2026-04-14 17:11:31 +08:00
parent b8bcefc84b
commit cd03e30bb8
58 changed files with 761 additions and 767 deletions
@@ -5,7 +5,7 @@ using System.Windows.Controls.Primitives;
namespace XP.ImageProcessing.RoiControl
{
/// <summary>
/// ROI控制?
/// ROI控制
/// </summary>
public class ControlThumb : Thumb
{
@@ -21,7 +21,7 @@ namespace XP.ImageProcessing.RoiControl
}
catch
{
// 如果样式加载失败,使用默认样?
// 如果样式加载失败,使用默认样
thumbStyle = null;
}
}
@@ -1,10 +1,10 @@
using XP.ImageProcessing.RoiControl.Models;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using XP.ImageProcessing.RoiControl.Models;
namespace XP.ImageProcessing.RoiControl.Controls
{
@@ -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;
}
@@ -68,7 +68,7 @@ namespace XP.ImageProcessing.RoiControl.Models
}
/// <summary>
/// 用于JSON序列化的Points列表(不参与UI绑定?
/// 用于JSON序列化的Points列表(不参与UI绑定
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("PointsList")]
public List<Point> PointsList
@@ -47,7 +47,7 @@ namespace XP.ImageProcessing.RoiControl
}
/// <summary>
/// 索引转换为位置标?
/// 索引转换为位置标
/// </summary>
public class IndexToPositionConverter : IValueConverter
{
@@ -13,7 +13,7 @@ namespace XP.ImageProcessing.RoiControl
/// </summary>
public class PolygonAdorner : Adorner
{
private List<ControlThumb> vertexThumbs = new List<ControlThumb>(); // 顶点控制?
private List<ControlThumb> vertexThumbs = new List<ControlThumb>(); // 顶点控制
private VisualCollection visualChildren;
private double scaleFactor = 1;
private Models.PolygonROI? polygonROI;
@@ -28,7 +28,7 @@ namespace XP.ImageProcessing.RoiControl
// 使用ROI模型的Points数量而不是Polygon的Points
int pointCount = polygonROI?.Points.Count ?? 0;
// 创建顶点控制?
// 创建顶点控制
for (int i = 0; i < pointCount; i++)
{
var thumb = new ControlThumb();
@@ -80,7 +80,7 @@ namespace XP.ImageProcessing.RoiControl
private void HandleRightClick(object sender, MouseButtonEventArgs e)
{
// 右键删除顶点(至少保?个顶点)
// 右键删除顶点(至少保留3个顶点)
if (polygonROI != null && polygonROI.Points.Count > 3)
{
Thumb? hitThumb = sender as Thumb;
@@ -104,7 +104,7 @@ namespace XP.ImageProcessing.RoiControl
{
double thumbSize = 12 * scaleFactor;
// 布局顶点控制?
// 布局顶点控制
for (int i = 0; i < vertexThumbs.Count && i < polygonROI.Points.Count; i++)
{
vertexThumbs[i].Arrange(new Rect(
@@ -58,7 +58,7 @@ namespace XP.ImageProcessing.RoiControl
// 保存引用以便后续清理
_attachedCollections[polygon] = newCollection;
// 监听Polygon卸载事件以清理资?
// 监听Polygon卸载事件以清理资
polygon.Unloaded += (s, args) =>
{
if (_attachedCollections.TryGetValue(polygon, out var collection))
@@ -1,10 +1,10 @@
using XP.ImageProcessing.RoiControl.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Windows;
using XP.ImageProcessing.RoiControl.Models;
namespace XP.ImageProcessing.RoiControl
{
@@ -38,7 +38,7 @@ namespace XP.ImageProcessing.RoiControl
}
/// <summary>
/// 序列化ROI列表为JSON字符?
/// 序列化ROI列表为JSON字符
/// </summary>
public static string Serialize(IEnumerable<ROIShape> roiList)
{
@@ -55,7 +55,7 @@ namespace XP.ImageProcessing.RoiControl
}
/// <summary>
/// Point类型的JSON转换?
/// Point类型的JSON转换
/// </summary>
public class PointConverter : JsonConverter<Point>
{
@@ -102,7 +102,7 @@ namespace XP.ImageProcessing.RoiControl
}
/// <summary>
/// ROIShape多态类型的JSON转换?
/// ROIShape多态类型的JSON转换
/// </summary>
public class ROIShapeConverter : JsonConverter<ROIShape>
{
@@ -1,8 +1,8 @@
using XP.ImageProcessing.RoiControl.Models;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using XP.ImageProcessing.RoiControl.Models;
namespace XP.ImageProcessing.RoiControl.Converters
{
@@ -1,7 +1,8 @@
<ResourceDictionary
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:XP.ImageProcessing.RoiControl.Controls">
xmlns:local="clr-namespace:XP.ImageProcessing.RoiControl.Controls"
xmlns:models="clr-namespace:XP.ImageProcessing.RoiControl.Models">
<!-- ControlThumb样式 - 14*14灰色矩形 -->
<Style x:Key="AreaControlThumbStyle" TargetType="{x:Type Thumb}">