优化更新

This commit is contained in:
Hakoyu 2023-11-20 21:26:04 +08:00
parent 5709e36e8e
commit 733380c012
26 changed files with 256 additions and 108 deletions

View File

@ -44,11 +44,11 @@ public class I18nModel<T>
/// </summary>
/// <param name="oldValue"></param>
/// <param name="newValue"></param>
private void CultureChanged(string oldValue, string newValue)
private void CultureChanged(ObservableValue<string> sender, ValueChangedEventArgs<string> e)
{
if (newValue is null)
if (e.NewValue is null)
CurrentI18nData.Value = null;
else if (I18nDatas.TryGetValue(newValue, out var result))
else if (I18nDatas.TryGetValue(e.NewValue, out var result))
CurrentI18nData.Value = result;
}

View File

@ -34,9 +34,9 @@ public class FoodLocationModel
public FoodLocationModel()
{
Rect.Width.ValueChanged += (o, n) =>
Rect.Width.ValueChanged += (s, e) =>
{
Rect.Height.Value = n;
Rect.Height.Value = e.NewValue;
};
}

View File

@ -35,7 +35,7 @@ public class ObservableRange<T>
SetValue(min, max);
}
private void ValueChanged(T oldValue, T newValue)
private void ValueChanged(ObservableValue<T> sender, ValueChangedEventArgs<T> e)
{
Info.Value = $"({Min.Value}, {Max.Value})";
}

View File

@ -35,12 +35,15 @@ public class ObservableCommand : ICommand
CurrentCanExecute.ValueChanging += CurrentCanExecute_ValueChanging;
}
private void CurrentCanExecute_ValueChanging(bool oldValue, bool newValue, ref bool cancel)
private void CurrentCanExecute_ValueChanging(
ObservableValue<bool> sender,
ValueChangingEventArgs<bool> e
)
{
if (newValue is true && CanExecuteProperty.Value is false)
cancel = true;
if (e.NewValue is true && CanExecuteProperty.Value is false)
e.Cancel = true;
else
cancel = false;
e.Cancel = false;
}
private void InvokeCanExecuteChanged(object? sender, PropertyChangedEventArgs e)

View File

@ -35,12 +35,15 @@ public class ObservableCommand<T> : ICommand
CurrentCanExecute.ValueChanging += CurrentCanExecute_ValueChanging;
}
private void CurrentCanExecute_ValueChanging(bool oldValue, bool newValue, ref bool cancel)
private void CurrentCanExecute_ValueChanging(
ObservableValue<bool> sender,
ValueChangingEventArgs<bool> e
)
{
if (newValue is true && CanExecuteProperty.Value is false)
cancel = true;
if (e.NewValue is true && CanExecuteProperty.Value is false)
e.Cancel = true;
else
cancel = false;
e.Cancel = false;
}
private void InvokeCanExecuteChanged(object? sender, PropertyChangedEventArgs e)

View File

@ -62,7 +62,6 @@ public class ObservableValue<T>
/// <inheritdoc/>
/// <param name="value">初始值</param>
public ObservableValue(T value)
: this()
{
_value = value;
}
@ -80,7 +79,7 @@ public class ObservableValue<T>
PropertyChanging?.Invoke(this, new(nameof(Value)));
var cancel = false;
// 若全部事件取消改变 则取消改变
ValueChanging?.Invoke(oldValue, newValue, ref cancel);
ValueChanging?.Invoke(this, new(oldValue, newValue));
return cancel;
}
@ -92,7 +91,7 @@ public class ObservableValue<T>
private void NotifyPropertyChanged(T oldValue, T newValue)
{
PropertyChanged?.Invoke(this, new(nameof(Value)));
ValueChanged?.Invoke(oldValue, newValue);
ValueChanged?.Invoke(this, new(oldValue, newValue));
}
#endregion
@ -244,19 +243,24 @@ public class ObservableValue<T>
#region Delegate
/// <summary>
/// 值改变事件
/// 值改变事件
/// </summary>
/// <param name="oldValue">旧值</param>
/// <param name="newValue">新值</param>
/// <param name="cancel">取消</param>
public delegate void ValueChangingEventHandler(T oldValue, T newValue, ref bool cancel);
/// <param name="sender">发送者</param>
/// <param name="e">参数</param>
public delegate void ValueChangingEventHandler(
ObservableValue<T> sender,
ValueChangingEventArgs<T> e
);
/// <summary>
/// 值改变后事件
/// </summary>
/// <param name="oldValue">旧值</param>
/// <param name="newValue">新值</param>
public delegate void ValueChangedEventHandler(T oldValue, T newValue);
/// <param name="sender">发送者</param>
/// <param name="e">参数</param>
public delegate void ValueChangedEventHandler(
ObservableValue<T> sender,
ValueChangedEventArgs<T> e
);
/// <summary>
/// 通知发送者属性改变接收器
@ -269,3 +273,55 @@ public class ObservableValue<T>
);
#endregion
}
/// <summary>
/// 值改变前事件参数
/// </summary>
/// <typeparam name="T">值类型</typeparam>
public class ValueChangingEventArgs<T> : CancelEventArgs
{
/// <summary>
/// 旧值
/// </summary>
public T? OldValue { get; }
/// <summary>
/// 新值
/// </summary>
public T? NewValue { get; }
/// <inheritdoc/>
/// <param name="oldValue">旧值</param>
/// <param name="newValue">新值</param>
public ValueChangingEventArgs(T? oldValue, T? newValue)
{
OldValue = oldValue;
NewValue = newValue;
}
}
/// <summary>
/// 值改变后事件参数
/// </summary>
/// <typeparam name="T">值类型</typeparam>
public class ValueChangedEventArgs<T> : EventArgs
{
/// <summary>
/// 旧值
/// </summary>
public T OldValue { get; }
/// <summary>
/// 新值
/// </summary>
public T NewValue { get; }
/// <inheritdoc/>
/// <param name="oldValue">旧值</param>
/// <param name="newValue">新值</param>
public ValueChangedEventArgs(T oldValue, T newValue)
{
OldValue = oldValue;
NewValue = newValue;
}
}

View File

@ -34,7 +34,7 @@ public class ObservableValueGroup<T> : IEnumerable<ObservableValue<T>?>
/// 在添加的时候改变值 (如果分组中存在值)
/// </summary>
[DefaultValue(false)]
public bool ChangeOnAdd { get; set; } = true;
public bool ChangeOnAdd { get; set; } = false;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly Dictionary<Guid, WeakReference<ObservableValue<T>>> _bindingValues = new();
@ -52,7 +52,7 @@ public class ObservableValueGroup<T> : IEnumerable<ObservableValue<T>?>
private void AddToGroup(ObservableValue<T> item)
{
if (item.Group is not null)
throw new ArgumentException("item.Group must be null", nameof(item));
throw new ArgumentException("item Group must be null", nameof(item));
_bindingValues.Add(item.Guid, new(item));
item.ValueChanged -= Item_ValueChanged;
if (ChangeOnAdd)
@ -132,7 +132,7 @@ public class ObservableValueGroup<T> : IEnumerable<ObservableValue<T>?>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private bool _onChange = false;
private void Item_ValueChanged(T oldValue, T newValue)
private void Item_ValueChanged(ObservableValue<T> sender, ValueChangedEventArgs<T> e)
{
if (_onChange)
return;
@ -140,7 +140,7 @@ public class ObservableValueGroup<T> : IEnumerable<ObservableValue<T>?>
foreach (var bindingValue in _bindingValues.AsEnumerable())
{
if (bindingValue.Value.TryGetTarget(out var target))
target.Value = newValue;
target.Value = e.NewValue!;
else
_bindingValues.Remove(bindingValue.Key);
}

View File

@ -48,9 +48,12 @@ public class AddCultureWindowVM
Culture.ValueChanged += Culture_ValueChanged;
}
private void Culture_ValueChanged(string oldValue, string newValue)
private void Culture_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
CultureFullName.Value = UnknownCulture;
return;
@ -58,7 +61,7 @@ public class AddCultureWindowVM
CultureInfo info = null!;
try
{
info = CultureInfo.GetCultureInfo(newValue);
info = CultureInfo.GetCultureInfo(e.NewValue);
}
catch
{
@ -70,16 +73,19 @@ public class AddCultureWindowVM
}
}
private void Search_ValueChanged(string oldValue, string newValue)
private void Search_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
ShowCultures.Value = AllCultures;
}
else
{
ShowCultures.Value = new(
AllCultures.Where(s => s.Contains(newValue, StringComparison.OrdinalIgnoreCase))
AllCultures.Where(s => s.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase))
);
}
}

View File

@ -135,9 +135,12 @@ public class AnimeEditWindowVM
}
#region LoadAnime
private void Anime_ValueChanged(AnimeTypeModel oldValue, AnimeTypeModel newValue)
private void Anime_ValueChanged(
ObservableValue<AnimeTypeModel> sender,
ValueChangedEventArgs<AnimeTypeModel> e
)
{
CheckGraphType(newValue);
CheckGraphType(e.NewValue);
}
private void CheckGraphType(AnimeTypeModel model)
@ -297,13 +300,16 @@ public class AnimeEditWindowVM
}
#endregion
#region Player
private void CurrentAnimeModel_ValueChanged(AnimeModel oldValue, AnimeModel newValue)
private void CurrentAnimeModel_ValueChanged(
ObservableValue<AnimeModel> sender,
ValueChangedEventArgs<AnimeModel> e
)
{
StopCommand_ExecuteEvent();
if (oldValue is not null)
oldValue.Images.CollectionChanged -= Images_CollectionChanged;
if (newValue is not null)
newValue.Images.CollectionChanged += Images_CollectionChanged;
if (e.OldValue is not null)
e.OldValue.Images.CollectionChanged -= Images_CollectionChanged;
if (e.NewValue is not null)
e.NewValue.Images.CollectionChanged += Images_CollectionChanged;
}
private void Images_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)

View File

@ -101,15 +101,21 @@ public class AnimePageVM
AllAnimes[AllAnimes.IndexOf(e.OldItems[0])] = e.NewItems[0];
}
private void CurrentPet_ValueChanged(PetModel oldValue, PetModel newValue)
private void CurrentPet_ValueChanged(
ObservableValue<PetModel> sender,
ValueChangedEventArgs<PetModel> e
)
{
InitializeAllAnimes();
ShowAnimes.Value = AllAnimes;
}
private void Search_ValueChanged(string oldValue, string newValue)
private void Search_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
ShowAnimes.Value = AllAnimes;
}
@ -120,12 +126,12 @@ public class AnimePageVM
{
if (m is AnimeTypeModel animeTypeModel)
return animeTypeModel.Id.Value.Contains(
newValue,
e.NewValue,
StringComparison.OrdinalIgnoreCase
);
else if (m is FoodAnimeTypeModel foodAnimeTypeModel)
return foodAnimeTypeModel.Id.Value.Contains(
newValue,
e.NewValue,
StringComparison.OrdinalIgnoreCase
);
else

View File

@ -253,7 +253,7 @@ public class FoodAnimeEditWindowVM
}
//#region LoadAnime
//private void Anime_ValueChanged(FoodAnimeTypeModel oldValue, FoodAnimeTypeModel newValue)
//private void Anime_ValueChanged(ObservableValue<FoodAnimeTypeModel> sender, ValueChangedEventArgs<FoodAnimeTypeModel> e)
//{
// CheckGraphType(newValue);
//}
@ -509,20 +509,23 @@ public class FoodAnimeEditWindowVM
}
#endregion
#region FrontPlayer
private void CurrentAnimeModel_ValueChanged(FoodAnimeModel oldValue, FoodAnimeModel newValue)
private void CurrentAnimeModel_ValueChanged(
ObservableValue<FoodAnimeModel> sender,
ValueChangedEventArgs<FoodAnimeModel> e
)
{
StopCommand_ExecuteEvent();
if (oldValue is not null)
if (e.OldValue is not null)
{
oldValue.FrontImages.CollectionChanged -= Images_CollectionChanged;
oldValue.BackImages.CollectionChanged -= Images_CollectionChanged;
oldValue.FoodLocations.CollectionChanged -= Images_CollectionChanged;
e.OldValue.FrontImages.CollectionChanged -= Images_CollectionChanged;
e.OldValue.BackImages.CollectionChanged -= Images_CollectionChanged;
e.OldValue.FoodLocations.CollectionChanged -= Images_CollectionChanged;
}
if (newValue is not null)
if (e.NewValue is not null)
{
newValue.FrontImages.CollectionChanged += Images_CollectionChanged;
newValue.BackImages.CollectionChanged += Images_CollectionChanged;
newValue.FoodLocations.CollectionChanged += Images_CollectionChanged;
e.NewValue.FrontImages.CollectionChanged += Images_CollectionChanged;
e.NewValue.BackImages.CollectionChanged += Images_CollectionChanged;
e.NewValue.FoodLocations.CollectionChanged += Images_CollectionChanged;
}
}

View File

@ -56,9 +56,12 @@ public class ClickTextPageVM
RemoveCommand.ExecuteEvent += Remove;
}
private void Search_ValueChanged(string oldValue, string newValue)
private void Search_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
ShowClickTexts.Value = ClickTexts;
}
@ -66,7 +69,7 @@ public class ClickTextPageVM
{
ShowClickTexts.Value = new(
ClickTexts.Where(
m => m.Id.Value.Contains(newValue, StringComparison.OrdinalIgnoreCase)
m => m.Id.Value.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase)
)
);
}

View File

@ -39,19 +39,25 @@ public class FoodEditWindowVM
Food.Value.ReferencePrice.ValueChanged += ReferencePrice_ValueChanged;
}
private void AutoSetReferencePrice_ValueChanged(bool oldValue, bool newValue)
private void AutoSetReferencePrice_ValueChanged(
ObservableValue<bool> sender,
ValueChangedEventArgs<bool> e
)
{
if (newValue)
if (e.NewValue)
{
SetReferencePriceToPrice(Food.Value.ReferencePrice.Value);
}
}
private void ReferencePrice_ValueChanged(double oldValue, double newValue)
private void ReferencePrice_ValueChanged(
ObservableValue<double> sender,
ValueChangedEventArgs<double> e
)
{
if (AutoSetReferencePrice.Value)
{
SetReferencePriceToPrice(newValue);
SetReferencePriceToPrice(e.NewValue);
}
}

View File

@ -36,16 +36,21 @@ public class FoodPageVM
RemoveCommand.ExecuteEvent += Remove;
}
private void Search_ValueChanged(string oldValue, string newValue)
private void Search_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
ShowFoods.Value = Foods;
}
else
{
ShowFoods.Value = new(
Foods.Where(m => m.Id.Value.Contains(newValue, StringComparison.OrdinalIgnoreCase))
Foods.Where(
m => m.Id.Value.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase)
)
);
}
}

View File

@ -54,9 +54,12 @@ public class I18nEditWindowVM
/// </summary>
/// <param name="oldValue"></param>
/// <param name="newValue"></param>
private void Search_ValueChanged(string oldValue, string newValue)
private void Search_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
ShowI18nDatas.Value = I18nDatas;
}
@ -64,7 +67,8 @@ public class I18nEditWindowVM
{
ShowI18nDatas.Value = new(
I18nDatas.Where(
m => m.Id.Value?.Contains(newValue, StringComparison.OrdinalIgnoreCase) is true
m =>
m.Id.Value?.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase) is true
)
);
}
@ -75,7 +79,7 @@ public class I18nEditWindowVM
I18nDatas.Where(
m =>
m.Datas[cultureIndex].Value?.Contains(
newValue,
e.NewValue,
StringComparison.OrdinalIgnoreCase
)
is true
@ -367,11 +371,11 @@ public class I18nEditWindowVM
/// </summary>
/// <param name="oldValue"></param>
/// <param name="newValue"></param>
private void IdChange(string oldValue, string newValue)
private void IdChange(ObservableValue<string> sender, ValueChangedEventArgs<string> e)
{
var sourceData = AllI18nDatas[oldValue];
var sourceData = AllI18nDatas[e.OldValue];
sourceData.Id.Group?.Remove(sourceData.Id);
if (AllI18nDatas.TryGetValue(oldValue, out var outData))
if (AllI18nDatas.TryGetValue(e.OldValue, out var outData))
{
foreach (var culture in I18nHelper.Current.CultureNames.Enumerate())
{
@ -384,9 +388,9 @@ public class I18nEditWindowVM
}
else
{
sourceData.Id.Value = newValue;
AllI18nDatas.Remove(oldValue);
AllI18nDatas.Add(newValue, sourceData);
sourceData.Id.Value = e.NewValue;
AllI18nDatas.Remove(e.OldValue);
AllI18nDatas.Add(e.NewValue, sourceData);
}
}

View File

@ -37,9 +37,12 @@ public class LowTextPageVM
RemoveCommand.ExecuteEvent += Remove;
}
private void Search_ValueChanged(string oldValue, string newValue)
private void Search_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
ShowLowTexts.Value = LowTexts;
}
@ -47,7 +50,7 @@ public class LowTextPageVM
{
ShowLowTexts.Value = new(
LowTexts.Where(
m => m.Id.Value.Contains(newValue, StringComparison.OrdinalIgnoreCase)
m => m.Id.Value.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase)
)
);
}

View File

@ -32,7 +32,10 @@ public class MoveEditWindowVM
Image.ValueChanged += Image_ValueChanged;
}
private void Image_ValueChanged(BitmapImage oldValue, BitmapImage newValue)
private void Image_ValueChanged(
ObservableValue<BitmapImage> sender,
ValueChangedEventArgs<BitmapImage> e
)
{
//LengthRatio.EnumValue = BorderLength.EnumValue / value.PixelWidth;
}

View File

@ -38,14 +38,20 @@ public class MovePageVM
RemoveCommand.ExecuteEvent += Remove;
}
private void CurrentPet_ValueChanged(PetModel oldValue, PetModel newValue)
private void CurrentPet_ValueChanged(
ObservableValue<PetModel> sender,
ValueChangedEventArgs<PetModel> e
)
{
ShowMoves.Value = newValue.Moves;
ShowMoves.Value = e.NewValue.Moves;
}
private void Search_ValueChanged(string oldValue, string newValue)
private void Search_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
ShowMoves.Value = Moves;
}
@ -53,7 +59,7 @@ public class MovePageVM
{
ShowMoves.Value = new(
Moves.Where(
m => m.Graph.Value.Contains(newValue, StringComparison.OrdinalIgnoreCase)
m => m.Graph.Value.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase)
)
);
}

View File

@ -32,7 +32,10 @@ public class PetEditWindowVM
Image.ValueChanged += Image_ValueChanged;
}
private void Image_ValueChanged(BitmapImage oldValue, BitmapImage newValue)
private void Image_ValueChanged(
ObservableValue<BitmapImage> sender,
ValueChangedEventArgs<BitmapImage> e
)
{
//LengthRatio.EnumValue = BorderLength.EnumValue / value.PixelWidth;
}

View File

@ -34,16 +34,19 @@ public class PetPageVM
RemoveCommand.ExecuteEvent += Remove;
}
private void Search_ValueChanged(string oldValue, string newValue)
private void Search_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
ShowPets.Value = Pets;
}
else
{
ShowPets.Value = new(
Pets.Where(m => m.Id.Value.Contains(newValue, StringComparison.OrdinalIgnoreCase))
Pets.Where(m => m.Id.Value.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase))
);
}
}

View File

@ -40,12 +40,18 @@ public class SaveTranslationModWindowVM
SaveCommand.ExecuteEvent += Save;
}
private void CheckAll_ValueChanged(bool? oldValue, bool? newValue)
private void CheckAll_ValueChanged(ObservableValue<bool?> sender, ValueChangedEventArgs<bool?> e)
{
if (newValue is null)
if (e.NewValue is null)
{
if (CheckCultures.All(m => m.IsChecked.Value))
CheckAll.Value = false;
else if (CheckCultures.All(m => m.IsChecked.Value is false))
CheckAll.Value = true;
return;
}
foreach (var model in CheckCultures)
model.IsChecked.Value = newValue.Value;
model.IsChecked.Value = e.NewValue.Value;
}
private void CheckAll_SenderPropertyChanged(ObservableValue<bool?> source, INotifyPropertyChanged sender)

View File

@ -34,9 +34,12 @@ public class SelectTextPageVM
RemoveCommand.ExecuteEvent += Remove;
}
private void Search_ValueChanged(string oldValue, string newValue)
private void Search_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
ShowSelectTexts.Value = SelectTexts;
}
@ -44,7 +47,7 @@ public class SelectTextPageVM
{
ShowSelectTexts.Value = new(
SelectTexts.Where(
m => m.Id.Value.Contains(newValue, StringComparison.OrdinalIgnoreCase)
m => m.Id.Value.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase)
)
);
}

View File

@ -33,7 +33,10 @@ public class WorkEditWindowVM
Image.ValueChanged += Image_ValueChanged;
}
private void Image_ValueChanged(BitmapImage oldValue, BitmapImage newValue)
private void Image_ValueChanged(
ObservableValue<BitmapImage> sender,
ValueChangedEventArgs<BitmapImage> e
)
{
//LengthRatio.EnumValue = BorderLength.EnumValue / value.PixelWidth;
}

View File

@ -38,21 +38,29 @@ public class WorkPageVM
RemoveCommand.ExecuteEvent += Remove;
}
private void CurrentPet_ValueChanged(PetModel oldValue, PetModel newValue)
private void CurrentPet_ValueChanged(
ObservableValue<PetModel> sender,
ValueChangedEventArgs<PetModel> e
)
{
ShowWorks.Value = newValue.Works;
ShowWorks.Value = e.NewValue.Works;
}
private void Search_ValueChanged(string oldValue, string newValue)
private void Search_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrWhiteSpace(newValue))
if (string.IsNullOrWhiteSpace(e.NewValue))
{
ShowWorks.Value = Works;
}
else
{
ShowWorks.Value = new(
Works.Where(m => m.Id.Value.Contains(newValue, StringComparison.OrdinalIgnoreCase))
Works.Where(
m => m.Id.Value.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase)
)
);
}
}

View File

@ -74,12 +74,15 @@ public class ModMakerWindowVM
HistoriesSearchText.ValueChanged += HistoriesSearchText_ValueChanged;
}
private void HistoriesSearchText_ValueChanged(string oldValue, string newValue)
private void HistoriesSearchText_ValueChanged(
ObservableValue<string> sender,
ValueChangedEventArgs<string> e
)
{
if (string.IsNullOrEmpty(newValue))
if (string.IsNullOrEmpty(e.NewValue))
ShowHistories.Value = Histories;
else
ShowHistories.Value = new(Histories.Where(i => i.Id.Contains(newValue)));
ShowHistories.Value = new(Histories.Where(i => i.Id.Contains(e.NewValue)));
}
#region History

View File

@ -40,15 +40,21 @@ public partial class SelectGraphTypeWindow : Window
};
}
private void GraphType_ValueChanged(GraphInfo.GraphType oldValue, GraphInfo.GraphType newValue)
private void GraphType_ValueChanged(
ObservableValue<GraphInfo.GraphType> sender,
ValueChangedEventArgs<GraphInfo.GraphType> e
)
{
if (newValue.IsHasNameAnime())
if (e.NewValue.IsHasNameAnime())
HasNameAnime.Value = true;
else
HasNameAnime.Value = false;
}
private void CurrentPet_ValueChanged(PetModel oldValue, PetModel newValue)
private void CurrentPet_ValueChanged(
ObservableValue<PetModel> sender,
ValueChangedEventArgs<PetModel> e
)
{
GraphTypes.Value = new(
AnimeTypeModel.GraphTypes.Except(CurrentPet.Value.Animes.Select(m => m.GraphType.Value))