This commit is contained in:
Hakoyu
2023-12-03 23:24:35 +08:00
parent ca1dc6d9dc
commit 1d4a0c4797
67 changed files with 392 additions and 316 deletions

View File

@ -1,10 +1,11 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input;
namespace VPet.ModMaker.Models; namespace VPet.ModMaker.Models;
@ -44,8 +45,8 @@ public class ObservableEnumFlags<T>
{ {
if (Attribute.IsDefined(EnumType, typeof(FlagsAttribute)) is false) if (Attribute.IsDefined(EnumType, typeof(FlagsAttribute)) is false)
throw new Exception("此枚举类型未使用特性 [Flags]"); throw new Exception("此枚举类型未使用特性 [Flags]");
AddCommand.ExecuteEvent += AddCommand_ExecuteEvent; AddCommand.ExecuteCommand += AddCommand_ExecuteEvent;
RemoveCommand.ExecuteEvent += RemoveCommand_ExecuteEvent; RemoveCommand.ExecuteCommand += RemoveCommand_ExecuteEvent;
} }
public ObservableEnumFlags(T value) public ObservableEnumFlags(T value)

View File

@ -15,7 +15,7 @@ using System.Windows.Media.Imaging;
using VPet.ModMaker.Models.ModModel; using VPet.ModMaker.Models.ModModel;
using VPet_Simulator.Core; using VPet_Simulator.Core;
namespace VPet.ModMaker.Models; namespace HKW.Models;
/// <summary> /// <summary>
/// 拓展 /// 拓展
@ -275,12 +275,26 @@ public static class Extensions
/// <typeparam name="T">值类型</typeparam> /// <typeparam name="T">值类型</typeparam>
/// <param name="collection">集合</param> /// <param name="collection">集合</param>
/// <returns>带有索引的枚举值</returns> /// <returns>带有索引的枚举值</returns>
public static IEnumerable<ItemInfo<T>> Enumerate<T>(this IEnumerable<T> collection) public static IEnumerable<ItemInfo<T>> EnumerateIndex<T>(this IEnumerable<T> collection)
{ {
var index = 0; var index = 0;
foreach (var item in collection) foreach (var item in collection)
yield return new(index++, item); yield return new(index++, item);
} }
public static void SetDataContext<T>(this Window window)
where T : new()
{
window.DataContext = new T();
window.Closed += (s, e) =>
{
try
{
window.DataContext = null;
}
catch { }
};
}
} }
/// <summary> /// <summary>

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
using LinePutScript; using HKW.Models;
using LinePutScript;
using LinePutScript.Converter; using LinePutScript.Converter;
using LinePutScript.Dictionary; using LinePutScript.Dictionary;
using System; using System;

View File

@ -1,4 +1,5 @@
using LinePutScript.Converter; using HKW.Models;
using LinePutScript.Converter;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@ -9,6 +9,7 @@ using System.Windows.Controls;
using System.Windows; using System.Windows;
using VPet_Simulator.Windows.Interface; using VPet_Simulator.Windows.Interface;
using VPet.ModMaker.Views; using VPet.ModMaker.Views;
using HKW.Models;
namespace VPet.ModMaker.Models; namespace VPet.ModMaker.Models;
@ -37,7 +38,7 @@ public class ModMaker : MainPlugin
Setting(); Setting();
}; };
modset.Items.Add(menuset); modset.Items.Add(menuset);
Application.Current.Resources.MergedDictionaries.Add(Utils.ModMakerStyles); Application.Current.Resources.MergedDictionaries.Add(ModMakerInfo.NativeStyles);
} }
public override void Setting() public override void Setting()

View File

@ -36,4 +36,9 @@ public static class ModMakerInfo
/// 本体的宠物 /// 本体的宠物
/// </summary> /// </summary>
public static List<PetModel> Pets { get; } = new(); public static List<PetModel> Pets { get; } = new();
/// <summary>
/// 本地风格
/// </summary>
public static NativeStyles NativeStyles { get; } = new();
} }

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -614,7 +615,7 @@ public class AnimeTypeModel
static void SaveAnimes(string animePath, ObservableCollection<AnimeModel> animes) static void SaveAnimes(string animePath, ObservableCollection<AnimeModel> animes)
{ {
Directory.CreateDirectory(animePath); Directory.CreateDirectory(animePath);
foreach (var anime in animes.Enumerate()) foreach (var anime in animes.EnumerateIndex())
SaveImages(Path.Combine(animePath, anime.Index.ToString()), anime.Value); SaveImages(Path.Combine(animePath, anime.Index.ToString()), anime.Value);
} }
} }
@ -627,7 +628,7 @@ public class AnimeTypeModel
static void SaveImages(string imagesPath, AnimeModel model) static void SaveImages(string imagesPath, AnimeModel model)
{ {
Directory.CreateDirectory(imagesPath); Directory.CreateDirectory(imagesPath);
foreach (var image in model.Images.Enumerate()) foreach (var image in model.Images.EnumerateIndex())
{ {
image.Value.Image.Value.SaveToPng( image.Value.Image.Value.SaveToPng(
Path.Combine( Path.Combine(

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Converter; using LinePutScript.Converter;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using LinePutScript; using LinePutScript;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript; using LinePutScript;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using System; using System;
@ -304,7 +305,7 @@ public class FoodAnimeTypeModel
) )
{ {
var modeAnimePath = Path.Combine(animePath, mode.ToString()); var modeAnimePath = Path.Combine(animePath, mode.ToString());
foreach (var anime in animes.Enumerate()) foreach (var anime in animes.EnumerateIndex())
{ {
var indexPath = Path.Combine(modeAnimePath, anime.Index.ToString()); var indexPath = Path.Combine(modeAnimePath, anime.Index.ToString());
Directory.CreateDirectory(indexPath); Directory.CreateDirectory(indexPath);
@ -329,7 +330,7 @@ public class FoodAnimeTypeModel
var backLayPath = Path.Combine(indexPath, BackLayName); var backLayPath = Path.Combine(indexPath, BackLayName);
Directory.CreateDirectory(frontLayPath); Directory.CreateDirectory(frontLayPath);
Directory.CreateDirectory(backLayPath); Directory.CreateDirectory(backLayPath);
foreach (var frontImage in anime.FrontImages.Enumerate()) foreach (var frontImage in anime.FrontImages.EnumerateIndex())
{ {
frontImage.Value.Image.Value.SaveToPng( frontImage.Value.Image.Value.SaveToPng(
Path.Combine( Path.Combine(
@ -338,7 +339,7 @@ public class FoodAnimeTypeModel
) )
); );
} }
foreach (var backImage in anime.BackImages.Enumerate()) foreach (var backImage in anime.BackImages.EnumerateIndex())
{ {
backImage.Value.Image.Value.SaveToPng( backImage.Value.Image.Value.SaveToPng(
Path.Combine( Path.Combine(
@ -377,7 +378,7 @@ public class FoodAnimeTypeModel
new Sub("mode", mode.ToString()), new Sub("mode", mode.ToString()),
new Sub("graph", Name.Value) new Sub("graph", Name.Value)
}; };
foreach (var foodLocation in anime.FoodLocations.Enumerate()) foreach (var foodLocation in anime.FoodLocations.EnumerateIndex())
{ {
var sub = new Sub($"a{foodLocation.Index}"); var sub = new Sub($"a{foodLocation.Index}");
sub.info = foodLocation.Value.ToString(); sub.info = foodLocation.Value.ToString();

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript; using LinePutScript;
using LinePutScript.Converter; using LinePutScript.Converter;
using System; using System;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript; using LinePutScript;
using LinePutScript.Converter; using LinePutScript.Converter;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript; using LinePutScript;
using LinePutScript.Converter; using LinePutScript.Converter;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View File

@ -1,6 +1,6 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
namespace VPet.ModMaker.Models; namespace HKW.Models;
/// <summary> /// <summary>
/// 可观察的范围 /// 可观察的范围

View File

@ -4,11 +4,10 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using VPet.ModMaker;
namespace VPet.ModMaker.Models; namespace HKW.Models;
/// <summary> /// <summary>
/// 工具 /// 工具
@ -26,8 +25,6 @@ public static class Utils
public const int DecodePixelHeight = 250; public const int DecodePixelHeight = 250;
public static char[] Separator { get; } = new char[] { '_' }; public static char[] Separator { get; } = new char[] { '_' };
public static ModMakerStyles ModMakerStyles { get; } = new ModMakerStyles();
//public static BitmapImage LoadImageToStream(string imagePath) //public static BitmapImage LoadImageToStream(string imagePath)
//{ //{
// BitmapImage bitmapImage = new(); // BitmapImage bitmapImage = new();

View File

@ -7,9 +7,9 @@ using System.Windows;
namespace VPet.ModMaker; namespace VPet.ModMaker;
public partial class ModMakerStyles : ResourceDictionary public partial class NativeStyles : ResourceDictionary
{ {
public ModMakerStyles() public NativeStyles()
{ {
InitializeComponent(); InitializeComponent();
} }

View File

@ -1,5 +1,5 @@
<ResourceDictionary <ResourceDictionary
x:Class="VPet.ModMaker.ModMakerStyles" x:Class="VPet.ModMaker.NativeStyles"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>

View File

@ -0,0 +1,16 @@
using System;
using System.Threading.Tasks;
using System.Windows.Input;
namespace HKW.HKWUtils.Observable;
/// <summary>
/// 异步执行命令事件
/// </summary>
public delegate Task AsyncExecuteEventHandler();
/// <summary>
/// 异步执行命令事件
/// </summary>
/// <param name="parameter">值</param>
public delegate Task AsyncExecuteEventHandler<T>(T parameter);

View File

@ -0,0 +1,15 @@
using System;
using System.Windows.Input;
namespace HKW.HKWUtils.Observable;
/// <summary>
/// 执行事件
/// </summary>
public delegate void ExecuteEventHandler();
/// <summary>
/// 执行事件
/// </summary>
/// <param name="parameter">参数</param>
public delegate void ExecuteEventHandler<T>(T parameter);

View File

@ -0,0 +1,11 @@
using System.ComponentModel;
using System.Windows.Input;
namespace HKW.HKWUtils.Observable;
/// <summary>
/// 通知接收器
/// </summary>
/// <param name="sender">发送者</param>
/// <param name="e">参数</param>
public delegate void NotifyReceivedEventHandler(ICommand sender, CancelEventArgs e);

View File

@ -1,20 +1,16 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
namespace HKW.HKWViewModels.SimpleObservable; namespace HKW.HKWUtils.Observable;
/// <summary> /// <summary>
/// 可观察命令 /// 可观察命令
/// </summary> /// </summary>
[DebuggerDisplay( [DebuggerDisplay("\\{ObservableCommand, CanExecute = {CanExecuteProperty.Value}\\}")]
"CanExecute = {CanExecuteProperty.Value}, EventCount = {ExecuteEvent.GetInvocationList().Length}, AsyncEventCount = {AsyncExecuteEvent.GetInvocationList().Length}"
)]
public class ObservableCommand : ICommand public class ObservableCommand : ICommand
{ {
/// <summary> /// <summary>
@ -68,7 +64,7 @@ public class ObservableCommand : ICommand
/// <param name="parameter">参数</param> /// <param name="parameter">参数</param>
public async void Execute(object? parameter) public async void Execute(object? parameter)
{ {
ExecuteEvent?.Invoke(); ExecuteCommand?.Invoke();
await ExecuteAsync(); await ExecuteAsync();
} }
@ -78,11 +74,13 @@ public class ObservableCommand : ICommand
/// <returns>等待</returns> /// <returns>等待</returns>
private async Task ExecuteAsync() private async Task ExecuteAsync()
{ {
if (AsyncExecuteEvent is null) if (AsyncExecuteCommand is null)
return; return;
CurrentCanExecute.Value = false; CurrentCanExecute.Value = false;
foreach ( foreach (
var asyncEvent in AsyncExecuteEvent.GetInvocationList().Cast<AsyncExecuteHandler>() var asyncEvent in AsyncExecuteCommand
.GetInvocationList()
.Cast<AsyncExecuteEventHandler>()
) )
await asyncEvent.Invoke(); await asyncEvent.Invoke();
CurrentCanExecute.Value = true; CurrentCanExecute.Value = true;
@ -128,9 +126,9 @@ public class ObservableCommand : ICommand
private void Notify_PropertyChanged(object? sender, PropertyChangedEventArgs e) private void Notify_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{ {
var temp = CanExecuteProperty.Value; var args = new CancelEventArgs();
NotifyCanExecuteReceived?.Invoke(ref temp); NotifyCanExecuteReceived?.Invoke(this, args);
CanExecuteProperty.Value = temp; CanExecuteProperty.Value = args.Cancel;
} }
#endregion #endregion
@ -143,35 +141,16 @@ public class ObservableCommand : ICommand
/// <summary> /// <summary>
/// 执行事件 /// 执行事件
/// </summary> /// </summary>
public event ExecuteHandler? ExecuteEvent; public event ExecuteEventHandler? ExecuteCommand;
/// <summary> /// <summary>
/// 异步执行事件 /// 异步执行事件
/// </summary> /// </summary>
public event AsyncExecuteHandler? AsyncExecuteEvent; public event AsyncExecuteEventHandler? AsyncExecuteCommand;
/// <summary> /// <summary>
/// 可执行通知接收器事件 /// 可执行通知接收器事件
/// </summary> /// </summary>
public event NotifyReceivedHandler? NotifyCanExecuteReceived; public event NotifyReceivedEventHandler? NotifyCanExecuteReceived;
#endregion
#region Delegate
/// <summary>
/// 执行
/// </summary>
public delegate void ExecuteHandler();
/// <summary>
/// 异步执行
/// </summary>
/// <returns></returns>
public delegate Task AsyncExecuteHandler();
/// <summary>
/// 通知接收器
/// </summary>
/// <param name="value">引用值</param>
public delegate void NotifyReceivedHandler(ref bool value);
#endregion #endregion
} }

View File

@ -1,21 +1,17 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
namespace HKW.HKWViewModels.SimpleObservable; namespace HKW.HKWUtils.Observable;
/// <summary> /// <summary>
/// 带参数的可观察命令 /// 带参数的可观察命令
/// </summary> /// </summary>
/// <typeparam name="T">参数类型</typeparam> /// <typeparam name="T">参数类型</typeparam>
[DebuggerDisplay( [DebuggerDisplay("\\{ObservableCommand, CanExecute = {CanExecuteProperty.Value}\\}")]
"CanExecute = {CanExecuteProperty.Value}, EventCount = {ExecuteEvent.GetInvocationList().Length}, AsyncEventCount = {AsyncExecuteEvent.GetInvocationList().Length}"
)]
public class ObservableCommand<T> : ICommand public class ObservableCommand<T> : ICommand
where T : notnull where T : notnull
{ {
@ -61,19 +57,21 @@ public class ObservableCommand<T> : ICommand
/// <inheritdoc cref="ObservableCommand.Execute(object?)"/> /// <inheritdoc cref="ObservableCommand.Execute(object?)"/>
public async void Execute(object? parameter) public async void Execute(object? parameter)
{ {
ExecuteEvent?.Invoke((T?)parameter!); ExecuteCommand?.Invoke((T)parameter!);
await ExecuteAsync((T?)parameter!); await ExecuteAsync((T)parameter!);
} }
/// <inheritdoc cref="ObservableCommand.ExecuteAsync"/> /// <inheritdoc cref="ObservableCommand.ExecuteAsync"/>
/// <param name="parameter">参数</param> /// <param name="parameter">参数</param>
private async Task ExecuteAsync(T parameter) private async Task ExecuteAsync(T parameter)
{ {
if (AsyncExecuteEvent is null) if (AsyncExecuteCommand is null)
return; return;
CurrentCanExecute.Value = false; CurrentCanExecute.Value = false;
foreach ( foreach (
var asyncEvent in AsyncExecuteEvent.GetInvocationList().Cast<AsyncExecuteHandler>() var asyncEvent in AsyncExecuteCommand
.GetInvocationList()
.Cast<AsyncExecuteEventHandler<T>>()
) )
await asyncEvent.Invoke(parameter); await asyncEvent.Invoke(parameter);
CurrentCanExecute.Value = true; CurrentCanExecute.Value = true;
@ -97,9 +95,9 @@ public class ObservableCommand<T> : ICommand
private void Notify_PropertyChanged(object? sender, PropertyChangedEventArgs e) private void Notify_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{ {
var temp = CanExecuteProperty.Value; var args = new CancelEventArgs();
NotifyCanExecuteReceived?.Invoke(ref temp); NotifyCanExecuteReceived?.Invoke(this, args);
CanExecuteProperty.Value = temp; CanExecuteProperty.Value = args.Cancel;
} }
#endregion #endregion
@ -107,29 +105,13 @@ public class ObservableCommand<T> : ICommand
/// <inheritdoc cref="ObservableCommand.CanExecuteChanged"/> /// <inheritdoc cref="ObservableCommand.CanExecuteChanged"/>
public event EventHandler? CanExecuteChanged; public event EventHandler? CanExecuteChanged;
/// <inheritdoc cref="ObservableCommand.ExecuteEvent"/> /// <inheritdoc cref="ObservableCommand.ExecuteCommand"/>
public event ExecuteHandler? ExecuteEvent; public event ExecuteEventHandler<T>? ExecuteCommand;
/// <inheritdoc cref="ObservableCommand.AsyncExecuteEvent"/> /// <inheritdoc cref="ObservableCommand.AsyncExecuteCommand"/>
public event AsyncExecuteHandler? AsyncExecuteEvent; public event AsyncExecuteEventHandler<T>? AsyncExecuteCommand;
/// <inheritdoc cref="ObservableCommand.NotifyCanExecuteReceived"/> /// <inheritdoc cref="ObservableCommand.NotifyCanExecuteReceived"/>
public event NotifyReceivedHandler? NotifyCanExecuteReceived; public event NotifyReceivedEventHandler? NotifyCanExecuteReceived;
#endregion
#region Delegate
/// <inheritdoc cref="ObservableCommand.ExecuteHandler"/>
/// <param name="value">值</param>
public delegate void ExecuteHandler(T value);
/// <inheritdoc cref="ObservableCommand.AsyncExecuteHandler"/>
/// <param name="value">值</param>
public delegate Task AsyncExecuteHandler(T value);
/// <summary>
/// 通知接收器
/// </summary>
/// <param name="value">引用值</param>
public delegate void NotifyReceivedHandler(ref bool value);
#endregion #endregion
} }

View File

@ -0,0 +1,13 @@
using System.ComponentModel;
namespace HKW.HKWUtils.Observable;
/// <summary>
/// 通知发送者属性改变接收器
/// </summary>
/// <param name="sender">发送者</param>
/// <param name="eventSender">属性改变事件发送者</param>
public delegate void NotifySenderPropertyChangedHandler<T>(
ObservableValue<T> sender,
INotifyPropertyChanged? eventSender
);

View File

@ -1,13 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HKW.HKWViewModels.SimpleObservable; namespace HKW.HKWUtils.Observable;
/// <summary> /// <summary>
/// 可观察值 /// 可观察值
@ -77,9 +73,11 @@ public class ObservableValue<T>
private bool NotifyPropertyChanging(T oldValue, T newValue) private bool NotifyPropertyChanging(T oldValue, T newValue)
{ {
PropertyChanging?.Invoke(this, new(nameof(Value))); PropertyChanging?.Invoke(this, new(nameof(Value)));
// 若全部事件取消改变 则取消改变
var args = new ValueChangingEventArgs<T>(oldValue, newValue); var args = new ValueChangingEventArgs<T>(oldValue, newValue);
ValueChanging?.Invoke(this, args); ValueChanging?.Invoke(this, args);
// 取消改变后通知UI更改
if (args.Cancel)
PropertyChanged?.Invoke(this, new(nameof(Value)));
return args.Cancel; return args.Cancel;
} }
@ -188,6 +186,16 @@ public class ObservableValue<T>
return Guid.Equals(other?.Guid) is true; return Guid.Equals(other?.Guid) is true;
} }
/// <summary>
/// 值相等
/// </summary>
/// <param name="other">其它可观察值</param>
/// <returns>相等为 <see langword="true"/> 否则为 <see langword="false"/></returns>
public bool ValueEquals(ObservableValue<T> other)
{
return Value?.Equals(other.Value) is true;
}
/// <summary> /// <summary>
/// 判断 <see cref="Value"/> 相等 /// 判断 <see cref="Value"/> 相等
/// </summary> /// </summary>
@ -227,101 +235,16 @@ public class ObservableValue<T>
/// <summary> /// <summary>
/// 值改变前事件 /// 值改变前事件
/// </summary> /// </summary>
public event ValueChangingEventHandler? ValueChanging; public event ValueChangingEventHandler<T>? ValueChanging;
/// <summary> /// <summary>
/// 值改变后事件 /// 值改变后事件
/// </summary> /// </summary>
public event ValueChangedEventHandler? ValueChanged; public event ValueChangedEventHandler<T>? ValueChanged;
/// <summary> /// <summary>
/// 通知接收事件 /// 通知接收事件
/// </summary> /// </summary>
public event NotifySenderPropertyChangedHandler? SenderPropertyChanged; public event NotifySenderPropertyChangedHandler<T>? SenderPropertyChanged;
#endregion
#region Delegate
/// <summary>
/// 值改变前事件
/// </summary>
/// <param name="sender">发送者</param>
/// <param name="e">参数</param>
public delegate void ValueChangingEventHandler(
ObservableValue<T> sender,
ValueChangingEventArgs<T> e
);
/// <summary>
/// 值改变后事件
/// </summary>
/// <param name="sender">发送者</param>
/// <param name="e">参数</param>
public delegate void ValueChangedEventHandler(
ObservableValue<T> sender,
ValueChangedEventArgs<T> e
);
/// <summary>
/// 通知发送者属性改变接收器
/// </summary>
/// <param name="source">源</param>
/// <param name="sender">发送者</param>
public delegate void NotifySenderPropertyChangedHandler(
ObservableValue<T> source,
INotifyPropertyChanged? sender
);
#endregion #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

@ -4,10 +4,8 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HKW.HKWViewModels.SimpleObservable; namespace HKW.HKWUtils.Observable;
/// <summary> /// <summary>
/// 可观察值组合 /// 可观察值组合

View File

@ -0,0 +1,29 @@
using System;
namespace HKW.HKWUtils.Observable;
/// <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

@ -0,0 +1,11 @@
namespace HKW.HKWUtils.Observable;
/// <summary>
/// 值改变后事件
/// </summary>
/// <param name="sender">发送者</param>
/// <param name="e">参数</param>
public delegate void ValueChangedEventHandler<T>(
ObservableValue<T> sender,
ValueChangedEventArgs<T> e
);

View File

@ -0,0 +1,29 @@
using System.ComponentModel;
namespace HKW.HKWUtils.Observable;
/// <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;
}
}

View File

@ -0,0 +1,11 @@
namespace HKW.HKWUtils.Observable;
/// <summary>
/// 值改变前事件
/// </summary>
/// <param name="sender">发送者</param>
/// <param name="e">参数</param>
public delegate void ValueChangingEventHandler<T>(
ObservableValue<T> sender,
ValueChangingEventArgs<T> e
);

View File

@ -133,9 +133,19 @@
<Compile Include="Models\ModModel\SelectTextModel.cs" /> <Compile Include="Models\ModModel\SelectTextModel.cs" />
<Compile Include="Models\ModModel\WorkModel.cs" /> <Compile Include="Models\ModModel\WorkModel.cs" />
<Compile Include="Resources\NativeResources.cs" /> <Compile Include="Resources\NativeResources.cs" />
<Compile Include="SimpleObservable\ObservableCommandT.cs" /> <Compile Include="NativeStyles.cs" />
<Compile Include="ModMakerStyles.cs" /> <Compile Include="SimpleObservable\ObservableCommand\AsyncExecuteEventHandler.cs" />
<Compile Include="SimpleObservable\ObservableValueGroup.cs" /> <Compile Include="SimpleObservable\ObservableCommand\ExecuteEventHandler.cs" />
<Compile Include="SimpleObservable\ObservableCommand\NotifyReceivedEventHandler.cs" />
<Compile Include="SimpleObservable\ObservableCommand\ObservableCommand.cs" />
<Compile Include="SimpleObservable\ObservableCommand\ObservableCommandT.cs" />
<Compile Include="SimpleObservable\ObservableValue\NotifySenderPropertyChangedHandler.cs" />
<Compile Include="SimpleObservable\ObservableValue\ObservableValue.cs" />
<Compile Include="SimpleObservable\ObservableValue\ObservableValueGroup.cs" />
<Compile Include="SimpleObservable\ObservableValue\ValueChangedEventArgs.cs" />
<Compile Include="SimpleObservable\ObservableValue\ValueChangedEventHandler.cs" />
<Compile Include="SimpleObservable\ObservableValue\ValueChangingEventArgs.cs" />
<Compile Include="SimpleObservable\ObservableValue\ValueChangingEventHandler.cs" />
<Compile Include="ViewModels\ModEdit\AddCultureWindowVM.cs" /> <Compile Include="ViewModels\ModEdit\AddCultureWindowVM.cs" />
<Compile Include="ViewModels\ModEdit\AnimeEdit\FoodAnimeEditWindowVM.cs" /> <Compile Include="ViewModels\ModEdit\AnimeEdit\FoodAnimeEditWindowVM.cs" />
<Compile Include="ViewModels\ModEdit\AnimeEdit\AnimeEditWindowVM.cs" /> <Compile Include="ViewModels\ModEdit\AnimeEdit\AnimeEditWindowVM.cs" />
@ -205,8 +215,6 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Compile Include="SimpleObservable\ObservableCommand.cs" />
<Compile Include="SimpleObservable\ObservableValue.cs" />
<Compile Include="Models\Utils.cs" /> <Compile Include="Models\Utils.cs" />
<Compile Include="Views\ModEdit\FoodEdit\FoodEditWindow.xaml.cs"> <Compile Include="Views\ModEdit\FoodEdit\FoodEditWindow.xaml.cs">
<DependentUpon>FoodEditWindow.xaml</DependentUpon> <DependentUpon>FoodEditWindow.xaml</DependentUpon>
@ -260,7 +268,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</ApplicationDefinition> </ApplicationDefinition>
<Page Include="Properties\DesignTimeResources.xaml"> <Page Include="NativeStyles.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
<ContainsDesignTimeResources>true</ContainsDesignTimeResources> <ContainsDesignTimeResources>true</ContainsDesignTimeResources>
@ -385,5 +393,6 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\food.png" /> <EmbeddedResource Include="Resources\food.png" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
@ -122,14 +123,14 @@ public class AnimeEditWindowVM
CurrentAnimeModel.ValueChanged += CurrentAnimeModel_ValueChanged; CurrentAnimeModel.ValueChanged += CurrentAnimeModel_ValueChanged;
PlayCommand.AsyncExecuteEvent += PlayCommand_AsyncExecuteEvent; PlayCommand.AsyncExecuteCommand += PlayCommand_AsyncExecuteEvent;
StopCommand.ExecuteEvent += StopCommand_ExecuteEvent; StopCommand.ExecuteCommand += StopCommand_ExecuteEvent;
AddAnimeCommand.ExecuteEvent += AddAnimeCommand_ExecuteEvent; AddAnimeCommand.ExecuteCommand += AddAnimeCommand_ExecuteEvent;
RemoveAnimeCommand.ExecuteEvent += RemoveAnimeCommand_ExecuteEvent; RemoveAnimeCommand.ExecuteCommand += RemoveAnimeCommand_ExecuteEvent;
AddImageCommand.ExecuteEvent += AddImageCommand_ExecuteEvent; AddImageCommand.ExecuteCommand += AddImageCommand_ExecuteEvent;
RemoveImageCommand.ExecuteEvent += RemoveImageCommand_ExecuteEvent; RemoveImageCommand.ExecuteCommand += RemoveImageCommand_ExecuteEvent;
ChangeImageCommand.ExecuteEvent += ChangeImageCommand_ExecuteEvent; ChangeImageCommand.ExecuteCommand += ChangeImageCommand_ExecuteEvent;
ClearImageCommand.ExecuteEvent += ClearImageCommand_ExecuteEvent; ClearImageCommand.ExecuteCommand += ClearImageCommand_ExecuteEvent;
Anime.ValueChanged += Anime_ValueChanged; Anime.ValueChanged += Anime_ValueChanged;
} }

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using Panuon.WPF.UI; using Panuon.WPF.UI;
using System; using System;
@ -75,9 +76,9 @@ public class AnimePageVM
CurrentPet.ValueChanged += CurrentPet_ValueChanged; CurrentPet.ValueChanged += CurrentPet_ValueChanged;
Search.ValueChanged += Search_ValueChanged; Search.ValueChanged += Search_ValueChanged;
AddCommand.ExecuteEvent += Add; AddCommand.ExecuteCommand += Add;
EditCommand.ExecuteEvent += Edit; EditCommand.ExecuteCommand += Edit;
RemoveCommand.ExecuteEvent += Remove; RemoveCommand.ExecuteCommand += Remove;
} }
private void InitializeAllAnimes() private void InitializeAllAnimes()

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
@ -210,27 +211,27 @@ public class FoodAnimeEditWindowVM
CurrentAnimeModel.ValueChanged += CurrentAnimeModel_ValueChanged; CurrentAnimeModel.ValueChanged += CurrentAnimeModel_ValueChanged;
PlayCommand.AsyncExecuteEvent += PlayCommand_AsyncExecuteEvent; PlayCommand.AsyncExecuteCommand += PlayCommand_AsyncExecuteEvent;
StopCommand.ExecuteEvent += StopCommand_ExecuteEvent; StopCommand.ExecuteCommand += StopCommand_ExecuteEvent;
ReplaceFoodImageCommand.ExecuteEvent += ChangeFoodImageCommand_ExecuteEvent; ReplaceFoodImageCommand.ExecuteCommand += ChangeFoodImageCommand_ExecuteEvent;
ResetFoodImageCommand.ExecuteEvent += ResetFoodImageCommand_ExecuteEvent; ResetFoodImageCommand.ExecuteCommand += ResetFoodImageCommand_ExecuteEvent;
AddAnimeCommand.ExecuteEvent += AddAnimeCommand_ExecuteEvent; AddAnimeCommand.ExecuteCommand += AddAnimeCommand_ExecuteEvent;
RemoveAnimeCommand.ExecuteEvent += RemoveAnimeCommand_ExecuteEvent; RemoveAnimeCommand.ExecuteCommand += RemoveAnimeCommand_ExecuteEvent;
AddFrontImageCommand.ExecuteEvent += AddFrontImageCommand_ExecuteEvent; AddFrontImageCommand.ExecuteCommand += AddFrontImageCommand_ExecuteEvent;
RemoveFrontImageCommand.ExecuteEvent += RemoveFrontImageCommand_ExecuteEvent; RemoveFrontImageCommand.ExecuteCommand += RemoveFrontImageCommand_ExecuteEvent;
ClearFrontImageCommand.ExecuteEvent += ClearFrontImageCommand_ExecuteEvent; ClearFrontImageCommand.ExecuteCommand += ClearFrontImageCommand_ExecuteEvent;
ChangeFrontImageCommand.ExecuteEvent += ChangeFrontImageCommand_ExecuteEvent; ChangeFrontImageCommand.ExecuteCommand += ChangeFrontImageCommand_ExecuteEvent;
AddBackImageCommand.ExecuteEvent += AddBackImageCommand_ExecuteEvent; AddBackImageCommand.ExecuteCommand += AddBackImageCommand_ExecuteEvent;
RemoveBackImageCommand.ExecuteEvent += RemoveBackImageCommand_ExecuteEvent; RemoveBackImageCommand.ExecuteCommand += RemoveBackImageCommand_ExecuteEvent;
ClearBackImageCommand.ExecuteEvent += ClearBackImageCommand_ExecuteEvent; ClearBackImageCommand.ExecuteCommand += ClearBackImageCommand_ExecuteEvent;
ChangeBackImageCommand.ExecuteEvent += ChangeBackImageCommand_ExecuteEvent; ChangeBackImageCommand.ExecuteCommand += ChangeBackImageCommand_ExecuteEvent;
AddFoodLocationCommand.ExecuteEvent += AddeFoodLocationCommand_ExecuteEvent; AddFoodLocationCommand.ExecuteCommand += AddeFoodLocationCommand_ExecuteEvent;
RemoveFoodLocationCommand.ExecuteEvent += RemoveFoodLocationCommand_ExecuteEvent; RemoveFoodLocationCommand.ExecuteCommand += RemoveFoodLocationCommand_ExecuteEvent;
ClearFoodLocationCommand.ExecuteEvent += ClearFoodLocationCommand_ExecuteEvent; ClearFoodLocationCommand.ExecuteCommand += ClearFoodLocationCommand_ExecuteEvent;
} }
private void ResetFoodImageCommand_ExecuteEvent() private void ResetFoodImageCommand_ExecuteEvent()

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -51,9 +52,9 @@ public class ClickTextPageVM
{ {
ShowClickTexts.Value = ClickTexts; ShowClickTexts.Value = ClickTexts;
Search.ValueChanged += Search_ValueChanged; Search.ValueChanged += Search_ValueChanged;
AddCommand.ExecuteEvent += Add; AddCommand.ExecuteCommand += Add;
EditCommand.ExecuteEvent += Edit; EditCommand.ExecuteCommand += Edit;
RemoveCommand.ExecuteEvent += Remove; RemoveCommand.ExecuteCommand += Remove;
} }
private void Search_ValueChanged( private void Search_ValueChanged(

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
@ -32,10 +33,10 @@ public class FoodEditWindowVM
public FoodEditWindowVM() public FoodEditWindowVM()
{ {
AddImageCommand.ExecuteEvent += AddImage; AddImageCommand.ExecuteCommand += AddImage;
ChangeImageCommand.ExecuteEvent += ChangeImage; ChangeImageCommand.ExecuteCommand += ChangeImage;
AutoSetReferencePrice.ValueChanged += AutoSetReferencePrice_ValueChanged; AutoSetReferencePrice.ValueChanged += AutoSetReferencePrice_ValueChanged;
SetReferencePriceCommand.ExecuteEvent += SetReferencePriceToPrice; SetReferencePriceCommand.ExecuteCommand += SetReferencePriceToPrice;
Food.Value.ReferencePrice.ValueChanged += ReferencePrice_ValueChanged; Food.Value.ReferencePrice.ValueChanged += ReferencePrice_ValueChanged;
} }

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -31,9 +32,9 @@ public class FoodPageVM
ShowFoods.Value = Foods; ShowFoods.Value = Foods;
Search.ValueChanged += Search_ValueChanged; Search.ValueChanged += Search_ValueChanged;
AddCommand.ExecuteEvent += Add; AddCommand.ExecuteCommand += Add;
EditCommand.ExecuteEvent += Edit; EditCommand.ExecuteCommand += Edit;
RemoveCommand.ExecuteEvent += Remove; RemoveCommand.ExecuteCommand += Remove;
} }
private void Search_ValueChanged( private void Search_ValueChanged(

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -351,7 +352,7 @@ public class I18nEditWindowVM
{ {
if (AllI18nDatas.TryGetValue(id.Value, out var outData)) if (AllI18nDatas.TryGetValue(id.Value, out var outData))
{ {
foreach (var culture in I18nHelper.Current.CultureNames.Enumerate()) foreach (var culture in I18nHelper.Current.CultureNames.EnumerateIndex())
{ {
if (outData.Datas[culture.Index].Group is null) if (outData.Datas[culture.Index].Group is null)
{ {
@ -385,7 +386,7 @@ public class I18nEditWindowVM
sourceData.Id.Group?.Remove(sourceData.Id); sourceData.Id.Group?.Remove(sourceData.Id);
if (AllI18nDatas.TryGetValue(e.OldValue, out var outData)) if (AllI18nDatas.TryGetValue(e.OldValue, out var outData))
{ {
foreach (var culture in I18nHelper.Current.CultureNames.Enumerate()) foreach (var culture in I18nHelper.Current.CultureNames.EnumerateIndex())
{ {
if (outData.Datas[culture.Index].Group is null) if (outData.Datas[culture.Index].Group is null)
{ {
@ -417,7 +418,7 @@ public class I18nEditWindowVM
where T : class, new() where T : class, new()
{ {
var data = AllI18nDatas[id.Value]; var data = AllI18nDatas[id.Value];
foreach (var culture in I18nHelper.Current.CultureNames.Enumerate()) foreach (var culture in I18nHelper.Current.CultureNames.EnumerateIndex())
{ {
if (data.Datas[culture.Index].Group is ObservableValueGroup<string> group) if (data.Datas[culture.Index].Group is ObservableValueGroup<string> group)
{ {
@ -452,7 +453,7 @@ public class I18nEditWindowVM
where T : class, new() where T : class, new()
{ {
var data = AllI18nDatas[id.Value]; var data = AllI18nDatas[id.Value];
foreach (var culture in I18nHelper.Current.CultureNames.Enumerate()) foreach (var culture in I18nHelper.Current.CultureNames.EnumerateIndex())
{ {
var oldValue = data.Datas[culture.Index]; var oldValue = data.Datas[culture.Index];
var newValue = i18nValue(i18nModel.I18nDatas[culture.Value]); var newValue = i18nValue(i18nModel.I18nDatas[culture.Value]);

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -32,9 +33,9 @@ public class LowTextPageVM
{ {
ShowLowTexts.Value = LowTexts; ShowLowTexts.Value = LowTexts;
Search.ValueChanged += Search_ValueChanged; Search.ValueChanged += Search_ValueChanged;
AddCommand.ExecuteEvent += Add; AddCommand.ExecuteCommand += Add;
EditCommand.ExecuteEvent += Edit; EditCommand.ExecuteCommand += Edit;
RemoveCommand.ExecuteEvent += Remove; RemoveCommand.ExecuteCommand += Remove;
} }
private void Search_ValueChanged( private void Search_ValueChanged(

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -18,6 +18,7 @@ using Panuon.WPF.UI;
using VPet.ModMaker.Views.ModEdit.I18nEdit; using VPet.ModMaker.Views.ModEdit.I18nEdit;
using System.Globalization; using System.Globalization;
using Ookii.Dialogs.Wpf; using Ookii.Dialogs.Wpf;
using HKW.Models;
namespace VPet.ModMaker.ViewModels.ModEdit; namespace VPet.ModMaker.ViewModels.ModEdit;
@ -89,16 +90,16 @@ public class ModEditWindowVM
{ {
new I18nEditWindow(); new I18nEditWindow();
ModEditWindow = window; ModEditWindow = window;
ChangeImageCommand.ExecuteEvent += ChangeImage; ChangeImageCommand.ExecuteCommand += ChangeImage;
AddCultureCommand.ExecuteEvent += AddCulture; AddCultureCommand.ExecuteCommand += AddCulture;
EditCultureCommand.ExecuteEvent += EditCulture; EditCultureCommand.ExecuteCommand += EditCulture;
RemoveCultureCommand.ExecuteEvent += RemoveCulture; RemoveCultureCommand.ExecuteCommand += RemoveCulture;
EditI18nCommand.ExecuteEvent += EditI18n; EditI18nCommand.ExecuteCommand += EditI18n;
SetMainCultureCommand.ExecuteEvent += SetMainCulture; SetMainCultureCommand.ExecuteCommand += SetMainCulture;
SaveCommand.ExecuteEvent += Save; SaveCommand.ExecuteCommand += Save;
SaveToCommand.ExecuteEvent += SaveTo; SaveToCommand.ExecuteCommand += SaveTo;
SaveAsTranslationModCommand.ExecuteEvent += SaveAsTranslationMod; SaveAsTranslationModCommand.ExecuteCommand += SaveAsTranslationMod;
} }
private void SaveAsTranslationMod() private void SaveAsTranslationMod()

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
@ -27,8 +28,8 @@ public class MoveEditWindowVM
#endregion #endregion
public MoveEditWindowVM() public MoveEditWindowVM()
{ {
AddImageCommand.ExecuteEvent += AddImage; AddImageCommand.ExecuteCommand += AddImage;
ChangeImageCommand.ExecuteEvent += ChangeImage; ChangeImageCommand.ExecuteCommand += ChangeImage;
Image.ValueChanged += Image_ValueChanged; Image.ValueChanged += Image_ValueChanged;
} }

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -33,9 +34,9 @@ public class MovePageVM
CurrentPet.ValueChanged += CurrentPet_ValueChanged; CurrentPet.ValueChanged += CurrentPet_ValueChanged;
Search.ValueChanged += Search_ValueChanged; Search.ValueChanged += Search_ValueChanged;
AddCommand.ExecuteEvent += Add; AddCommand.ExecuteCommand += Add;
EditCommand.ExecuteEvent += Edit; EditCommand.ExecuteCommand += Edit;
RemoveCommand.ExecuteEvent += Remove; RemoveCommand.ExecuteCommand += Remove;
} }
private void CurrentPet_ValueChanged( private void CurrentPet_ValueChanged(

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
@ -27,8 +28,8 @@ public class PetEditWindowVM
#endregion #endregion
public PetEditWindowVM() public PetEditWindowVM()
{ {
AddImageCommand.ExecuteEvent += AddImage; AddImageCommand.ExecuteCommand += AddImage;
ChangeImageCommand.ExecuteEvent += ChangeImage; ChangeImageCommand.ExecuteCommand += ChangeImage;
Image.ValueChanged += Image_ValueChanged; Image.ValueChanged += Image_ValueChanged;
} }

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -29,9 +30,9 @@ public class PetPageVM
ShowPets.Value = Pets; ShowPets.Value = Pets;
Search.ValueChanged += Search_ValueChanged; Search.ValueChanged += Search_ValueChanged;
AddCommand.ExecuteEvent += Add; AddCommand.ExecuteCommand += Add;
EditCommand.ExecuteEvent += Edit; EditCommand.ExecuteCommand += Edit;
RemoveCommand.ExecuteEvent += Remove; RemoveCommand.ExecuteCommand += Remove;
} }
private void Search_ValueChanged( private void Search_ValueChanged(

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
@ -37,7 +37,7 @@ public class SaveTranslationModWindowVM
} }
CheckAll.ValueChanged += CheckAll_ValueChanged; CheckAll.ValueChanged += CheckAll_ValueChanged;
CheckAll.SenderPropertyChanged += CheckAll_SenderPropertyChanged; CheckAll.SenderPropertyChanged += CheckAll_SenderPropertyChanged;
SaveCommand.ExecuteEvent += Save; SaveCommand.ExecuteCommand += Save;
} }
private void CheckAll_ValueChanged(ObservableValue<bool?> sender, ValueChangedEventArgs<bool?> e) private void CheckAll_ValueChanged(ObservableValue<bool?> sender, ValueChangedEventArgs<bool?> e)

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -29,9 +30,9 @@ public class SelectTextPageVM
{ {
ShowSelectTexts.Value = SelectTexts; ShowSelectTexts.Value = SelectTexts;
Search.ValueChanged += Search_ValueChanged; Search.ValueChanged += Search_ValueChanged;
AddCommand.ExecuteEvent += Add; AddCommand.ExecuteCommand += Add;
EditCommand.ExecuteEvent += Edit; EditCommand.ExecuteCommand += Edit;
RemoveCommand.ExecuteEvent += Remove; RemoveCommand.ExecuteCommand += Remove;
} }
private void Search_ValueChanged( private void Search_ValueChanged(

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
@ -28,8 +29,8 @@ public class WorkEditWindowVM
#endregion #endregion
public WorkEditWindowVM() public WorkEditWindowVM()
{ {
AddImageCommand.ExecuteEvent += AddImage; AddImageCommand.ExecuteCommand += AddImage;
ChangeImageCommand.ExecuteEvent += ChangeImage; ChangeImageCommand.ExecuteCommand += ChangeImage;
Image.ValueChanged += Image_ValueChanged; Image.ValueChanged += Image_ValueChanged;
} }

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -33,9 +34,9 @@ public class WorkPageVM
CurrentPet.ValueChanged += CurrentPet_ValueChanged; CurrentPet.ValueChanged += CurrentPet_ValueChanged;
Search.ValueChanged += Search_ValueChanged; Search.ValueChanged += Search_ValueChanged;
AddCommand.ExecuteEvent += Add; AddCommand.ExecuteCommand += Add;
EditCommand.ExecuteEvent += Edit; EditCommand.ExecuteCommand += Edit;
RemoveCommand.ExecuteEvent += Remove; RemoveCommand.ExecuteCommand += Remove;
} }
private void CurrentPet_ValueChanged( private void CurrentPet_ValueChanged(

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using LinePutScript; using LinePutScript;
using LinePutScript.Converter; using LinePutScript.Converter;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
@ -12,6 +12,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input;
using VPet.ModMaker.Models; using VPet.ModMaker.Models;
using VPet.ModMaker.Views; using VPet.ModMaker.Views;
using VPet.ModMaker.Views.ModEdit; using VPet.ModMaker.Views.ModEdit;
@ -68,10 +69,10 @@ public class ModMakerWindowVM
LoadHistories(); LoadHistories();
ModMakerWindow = window; ModMakerWindow = window;
ShowHistories.Value = Histories; ShowHistories.Value = Histories;
CreateNewModCommand.ExecuteEvent += CreateNewMod; CreateNewModCommand.ExecuteCommand += CreateNewMod;
LoadModFromFileCommand.ExecuteEvent += LoadModFromFile; LoadModFromFileCommand.ExecuteCommand += LoadModFromFile;
ClearHistoriesCommand.ExecuteEvent += ClearHistories; ClearHistoriesCommand.ExecuteCommand += ClearHistories;
RemoveHistoryCommand.ExecuteEvent += RemoveHistory; RemoveHistoryCommand.ExecuteCommand += RemoveHistory;
HistoriesSearchText.ValueChanged += HistoriesSearchText_ValueChanged; HistoriesSearchText.ValueChanged += HistoriesSearchText_ValueChanged;
} }

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using LinePutScript.Localization.WPF; using LinePutScript.Localization.WPF;
using Panuon.WPF.UI; using Panuon.WPF.UI;
using System; using System;

View File

@ -1,4 +1,5 @@
using LinePutScript.Localization.WPF; using HKW.Models;
using LinePutScript.Localization.WPF;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
using LinePutScript.Localization.WPF; using HKW.Models;
using LinePutScript.Localization.WPF;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using HKW.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

View File

@ -1,4 +1,4 @@
using HKW.HKWViewModels.SimpleObservable; using HKW.HKWUtils.Observable;
using Panuon.WPF.UI; using Panuon.WPF.UI;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -93,7 +93,7 @@ public partial class I18nEditWindow : WindowX
MaxWidth = 500, MaxWidth = 500,
Header = culture, Header = culture,
Binding = new Binding(dataPath) { Mode = BindingMode.TwoWay }, Binding = new Binding(dataPath) { Mode = BindingMode.TwoWay },
ElementStyle = (Style)Utils.ModMakerStyles["TextBlock_Wrap"], ElementStyle = (Style)ModMakerInfo.NativeStyles["TextBlock_Wrap"],
SortMemberPath = dataPath SortMemberPath = dataPath
}; };
DataGrid_Datas.Columns.Add(column); DataGrid_Datas.Columns.Add(column);