From d4a82cb568cb24e2e74479276b2d0171388eea44 Mon Sep 17 00:00:00 2001 From: Hakoyu Date: Sat, 23 Sep 2023 16:08:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20AddCultureWindow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet.ModMaker/VPet.ModMaker.csproj | 19 ++--- .../ViewModels/ModEdit/AddCultureWindowVM.cs | 43 +++++++++++ .../ViewModels/ModEdit/ModEditWindowVM.cs | 31 ++++---- .../Views/ModEdit/AddCultureWindow.xaml | 73 +++++++++++++++++++ ...indow.xaml.cs => AddCultureWindow.xaml.cs} | 19 ++--- .../Views/ModEdit/AddLangWindow.xaml | 57 --------------- .../Views/ModEdit/ModEditWindow.xaml | 17 ++--- VPet.ModMaker/packages.config | 8 +- 8 files changed, 163 insertions(+), 104 deletions(-) create mode 100644 VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs create mode 100644 VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml rename VPet.ModMaker/Views/ModEdit/{AddLangWindow.xaml.cs => AddCultureWindow.xaml.cs} (69%) delete mode 100644 VPet.ModMaker/Views/ModEdit/AddLangWindow.xaml diff --git a/VPet.ModMaker/VPet.ModMaker.csproj b/VPet.ModMaker/VPet.ModMaker.csproj index dcdec11..348deec 100644 --- a/VPet.ModMaker/VPet.ModMaker.csproj +++ b/VPet.ModMaker/VPet.ModMaker.csproj @@ -59,11 +59,11 @@ ..\packages\LinePutScript.Localization.WPF.1.0.6\lib\net462\LinePutScript.Localization.WPF.dll - - ..\packages\Panuon.WPF.1.0.2\lib\net462\Panuon.WPF.dll + + ..\packages\Panuon.WPF.1.0.3\lib\net462\Panuon.WPF.dll - - ..\packages\Panuon.WPF.UI.1.1.15.8\lib\net462\Panuon.WPF.UI.dll + + ..\packages\Panuon.WPF.UI.1.1.16.2\lib\net462\Panuon.WPF.UI.dll @@ -77,10 +77,10 @@ 4.0 - ..\packages\VPet-Simulator.Core.1.0.5.1\lib\net462\VPet-Simulator.Core.dll + ..\packages\VPet-Simulator.Core.1.0.7\lib\net462\VPet-Simulator.Core.dll - ..\packages\VPet-Simulator.Windows.Interface.1.0.5.2\lib\net462\VPet-Simulator.Windows.Interface.dll + ..\packages\VPet-Simulator.Windows.Interface.1.0.7\lib\net462\VPet-Simulator.Windows.Interface.dll @@ -117,6 +117,7 @@ + @@ -158,8 +159,8 @@ LowTextEditWindow.xaml - - AddLangWindow.xaml + + AddCultureWindow.xaml @@ -277,7 +278,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs new file mode 100644 index 0000000..57f503c --- /dev/null +++ b/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs @@ -0,0 +1,43 @@ +using HKW.HKWViewModels.SimpleObservable; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VPet.ModMaker.Models; + +namespace VPet.ModMaker.ViewModels.ModEdit; + +public class AddCultureWindowVM +{ + public ObservableValue> ShowCultures { get; } = new(); + public static ObservableCollection AllCultures { get; set; } = + new(LinePutScript.Localization.WPF.LocalizeCore.AvailableCultures); + public ObservableValue Culture { get; } = new(); + + public ObservableValue Search { get; } = new(); + + public AddCultureWindowVM() + { + ShowCultures.Value = AllCultures; + AllCultures.Add("zh-Hans"); + AllCultures.Add("zh-Hant"); + AllCultures.Add("en-US"); + Search.ValueChanged += Search_ValueChanged; + } + + private void Search_ValueChanged(string oldValue, string newValue) + { + if (string.IsNullOrWhiteSpace(newValue)) + { + ShowCultures.Value = AllCultures; + } + else + { + ShowCultures.Value = new( + AllCultures.Where(s => s.Contains(newValue, StringComparison.OrdinalIgnoreCase)) + ); + } + } +} diff --git a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs index 65a5e2a..faa2afb 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs @@ -30,10 +30,10 @@ public class ModEditWindowVM #region Command public ObservableCommand AddImageCommand { get; } = new(); public ObservableCommand ChangeImageCommand { get; } = new(); - public ObservableCommand AddLangCommand { get; } = new(); + public ObservableCommand AddCultureCommand { get; } = new(); - public ObservableCommand EditLangCommand { get; } = new(); - public ObservableCommand RemoveLangCommand { get; } = new(); + public ObservableCommand EditCultureCommand { get; } = new(); + public ObservableCommand RemoveCultureCommand { get; } = new(); public ObservableCommand SaveCommand { get; } = new(); public ObservableCommand SaveToCommand { get; } = new(); @@ -48,9 +48,9 @@ public class ModEditWindowVM AddImageCommand.ExecuteEvent += AddImage; ChangeImageCommand.ExecuteEvent += ChangeImage; - AddLangCommand.ExecuteEvent += AddLang; - EditLangCommand.ExecuteEvent += EditLang; - RemoveLangCommand.ExecuteEvent += RemoveLang; + AddCultureCommand.ExecuteEvent += AddCulture; + EditCultureCommand.ExecuteEvent += EditCulture; + RemoveCultureCommand.ExecuteEvent += RemoveLang; SaveCommand.ExecuteEvent += Save; SaveToCommand.ExecuteEvent += SaveTo; } @@ -96,28 +96,29 @@ public class ModEditWindowVM } } - private void AddLang() + private void AddCulture() { - var window = new Window_AddLang(); + var window = new AddCultureWindow(); window.ShowDialog(); if (window.IsCancel) return; - I18nHelper.Current.CultureNames.Add(window.Lang.Value); + I18nHelper.Current.CultureNames.Add(window.ViewModel.Culture.Value); if (I18nHelper.Current.CultureNames.Count == 1) - I18nHelper.Current.CultureName.Value = window.Lang.Value; + I18nHelper.Current.CultureName.Value = window.ViewModel.Culture.Value; } - private void EditLang(string oldLang) + private void EditCulture(string oldLang) { - var window = new Window_AddLang(); - window.Lang.Value = oldLang.Translate(); + var window = new AddCultureWindow(); + window.ViewModel.Culture.Value = oldLang.Translate(); window.ShowDialog(); if (window.IsCancel) return; I18nHelper.Current.CultureNames[I18nHelper.Current.CultureNames.IndexOf(oldLang)] = window - .Lang + .ViewModel + .Culture .Value; - CurrentLang.Value = window.Lang.Value; + CurrentLang.Value = window.ViewModel.Culture.Value; } private void RemoveLang(string oldLang) diff --git a/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml b/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml new file mode 100644 index 0000000..8331bcd --- /dev/null +++ b/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +