From 18fbc60f878f9230445e1536412c4f949f5ea30e Mon Sep 17 00:00:00 2001 From: Hakoyu Date: Tue, 31 Oct 2023 23:48:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SimpleObservable/ObservableValue.cs | 64 +++++++-- VPet.ModMaker/Styles.xaml | 28 ++++ .../ViewModels/ModEdit/ModEditWindowVM.cs | 59 +++++---- .../Views/ModEdit/AnimeEdit/AnimePage.xaml | 58 +++------ .../ModEdit/ClickTextEdit/ClickTextPage.xaml | 114 ++++++---------- .../Views/ModEdit/FoodEdit/FoodPage.xaml | 109 ++++++---------- .../ModEdit/LowTextEdit/LowTextPage.xaml | 38 ++---- .../Views/ModEdit/MoveEdit/MovePage.xaml | 56 +++----- .../ModEdit/PetEdit/PetEditWindow.xaml.cs | 10 ++ .../Views/ModEdit/PetEdit/PetPage.xaml | 32 ++--- .../SelectTextEdit/SelectTextPage.xaml | 123 +++++++----------- .../Views/ModEdit/WorkEdit/WorkPage.xaml | 104 ++++++--------- 12 files changed, 354 insertions(+), 441 deletions(-) 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" />