diff --git a/VPet.ModMaker/SimpleObservable/ObservableValue.cs b/VPet.ModMaker/SimpleObservable/ObservableValue.cs index 5ae1f0c..8b73beb 100644 --- a/VPet.ModMaker/SimpleObservable/ObservableValue.cs +++ b/VPet.ModMaker/SimpleObservable/ObservableValue.cs @@ -13,7 +13,10 @@ namespace HKW.HKWViewModels.SimpleObservable; /// /// [DebuggerDisplay("{Value}")] -public class ObservableValue : INotifyPropertyChanging, INotifyPropertyChanged +public class ObservableValue + : INotifyPropertyChanging, + INotifyPropertyChanged, + IEquatable> { [DebuggerBrowsable(DebuggerBrowsableState.Never)] private T _value = default!; @@ -81,14 +84,6 @@ public class ObservableValue : INotifyPropertyChanging, INotifyPropertyChange } #endregion - #region Overwrite - /// - public override string ToString() - { - return Value?.ToString()!; - } - #endregion - #region NotifyReceiver /// /// 添加通知属性改变后接收器 @@ -132,6 +127,57 @@ public class ObservableValue : INotifyPropertyChanging, INotifyPropertyChange NotifyReceived?.Invoke(ref temp); Value = temp; } + + #endregion + + + #region Other + /// + public override string ToString() + { + return Value?.ToString() ?? string.Empty; + } + + /// + public override bool Equals(object? obj) + { + return Equals(obj as ObservableValue); + } + + /// + public override int GetHashCode() + { + return Value?.GetHashCode() ?? 0; + } + + /// + public bool Equals(ObservableValue? other) + { + return Value?.Equals(other) is true; + } + + /// + /// 判断 相等 + /// + /// 左值 + /// 右值 + /// 相等为 否则为 + public static bool operator ==(ObservableValue value1, ObservableValue value2) + { + return value1.Value?.Equals(value2.Value) is true; + } + + /// + /// 判断 不相等 + /// + /// 左值 + /// 右值 + /// 不相等为 否则为 + public static bool operator !=(ObservableValue value1, ObservableValue value2) + { + return value1.Value?.Equals(value2.Value) is not true; + } + #endregion #region Event diff --git a/VPet.ModMaker/Styles.xaml b/VPet.ModMaker/Styles.xaml index 48cfcc4..ffb414f 100644 --- a/VPet.ModMaker/Styles.xaml +++ b/VPet.ModMaker/Styles.xaml @@ -19,6 +19,20 @@ TargetType="TextBlock"> + + + + @@ -83,57 +84,38 @@ - - - - + SortMemberPath="Id.Value" /> - - - - + SortMemberPath="Id.Value" /> - - - - + SortMemberPath="Id.Value" /> - - - - + SortMemberPath="Id.Value" /> - - - - - + SortMemberPath="Id.Value" />