namespace HKW.HKWUtils; public class ObservableRect : ObservableClass, IEquatable { private double _x; public double X { get => _x; set => SetProperty(ref _x, value); } private double _y; public double Y { get => _y; set => SetProperty(ref _y, value); } private double _width; public double Width { get => _width; set => SetProperty(ref _width, value); } private double _heigth; public double Height { get => _heigth; set => SetProperty(ref _heigth, value); } public ObservableRect() { } public ObservableRect(double x, double y, double width, double hetght) { X = x; Y = y; Width = width; Height = hetght; } /// /// 复制一个新的对象 /// /// 新对象 public ObservableRect Copy() { return new(X, Y, Width, Height); } #region Other /// public override int GetHashCode() { return HashCode.Combine(X, Y, Width, Height); } /// public override bool Equals(object? obj) { return obj is ObservableRect temp && EqualityComparer.Default.Equals(X, temp.X) && EqualityComparer.Default.Equals(Y, temp.Y) && EqualityComparer.Default.Equals(Width, temp.Width) && EqualityComparer.Default.Equals(Height, temp.Height); } /// public bool Equals(ObservableRect? other) { return Equals(obj: other); } /// public static bool operator ==(ObservableRect a, ObservableRect b) { return Equals(a, b); } /// public static bool operator !=(ObservableRect a, ObservableRect b) { return Equals(a, b) is not true; } #endregion }