规范类名及命名空间名称
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
|
||||
namespace XP.ImageProcessing.RoiControl.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// ROI形状类型
|
||||
/// </summary>
|
||||
public enum ROIType
|
||||
{
|
||||
Polygon
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ROI基类
|
||||
/// </summary>
|
||||
public abstract class ROIShape : INotifyPropertyChanged
|
||||
{
|
||||
private bool _isSelected;
|
||||
private string _id = Guid.NewGuid().ToString();
|
||||
private string _color = "Red";
|
||||
|
||||
public string Id
|
||||
{
|
||||
get => _id;
|
||||
set { _id = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set { _isSelected = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public string Color
|
||||
{
|
||||
get => _color;
|
||||
set { _color = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public abstract ROIType ROIType { get; }
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 多边形ROI
|
||||
/// </summary>
|
||||
public class PolygonROI : ROIShape
|
||||
{
|
||||
private ObservableCollection<Point> _points = new ObservableCollection<Point>();
|
||||
|
||||
public override ROIType ROIType => ROIType.Polygon;
|
||||
|
||||
public ObservableCollection<Point> Points
|
||||
{
|
||||
get => _points;
|
||||
set { _points = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于JSON序列化的Points列表(不参与UI绑定�?
|
||||
/// </summary>
|
||||
[System.Text.Json.Serialization.JsonPropertyName("PointsList")]
|
||||
public List<Point> PointsList
|
||||
{
|
||||
get => new List<Point>(_points);
|
||||
set
|
||||
{
|
||||
_points = new ObservableCollection<Point>(value ?? new List<Point>());
|
||||
OnPropertyChanged(nameof(Points));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user