mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
更新 AddCultureWindow
This commit is contained in:
parent
e0eac08928
commit
d4a82cb568
@ -59,11 +59,11 @@
|
||||
<Reference Include="LinePutScript.Localization.WPF, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\LinePutScript.Localization.WPF.1.0.6\lib\net462\LinePutScript.Localization.WPF.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Panuon.WPF, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.1.0.2\lib\net462\Panuon.WPF.dll</HintPath>
|
||||
<Reference Include="Panuon.WPF, Version=1.0.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.1.0.3\lib\net462\Panuon.WPF.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Panuon.WPF.UI, Version=1.1.15.8, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.UI.1.1.15.8\lib\net462\Panuon.WPF.UI.dll</HintPath>
|
||||
<Reference Include="Panuon.WPF.UI, Version=1.1.16.1, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Panuon.WPF.UI.1.1.16.2\lib\net462\Panuon.WPF.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
@ -77,10 +77,10 @@
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="VPet-Simulator.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\VPet-Simulator.Core.1.0.5.1\lib\net462\VPet-Simulator.Core.dll</HintPath>
|
||||
<HintPath>..\packages\VPet-Simulator.Core.1.0.7\lib\net462\VPet-Simulator.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="VPet-Simulator.Windows.Interface, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\VPet-Simulator.Windows.Interface.1.0.5.2\lib\net462\VPet-Simulator.Windows.Interface.dll</HintPath>
|
||||
<HintPath>..\packages\VPet-Simulator.Windows.Interface.1.0.7\lib\net462\VPet-Simulator.Windows.Interface.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
@ -117,6 +117,7 @@
|
||||
<Compile Include="Models\ModModel\WorkModel.cs" />
|
||||
<Compile Include="SimpleObservable\ObservableCommandT.cs" />
|
||||
<Compile Include="Styles.cs" />
|
||||
<Compile Include="ViewModels\ModEdit\AddCultureWindowVM.cs" />
|
||||
<Compile Include="ViewModels\ModEdit\AnimeEdit\AnimeEditWindowVM.cs" />
|
||||
<Compile Include="ViewModels\ModEdit\AnimeEdit\AnimePageVM.cs" />
|
||||
<Compile Include="ViewModels\ModEdit\ClickTextEdit\ClickTextEditWindowVM.cs" />
|
||||
@ -158,8 +159,8 @@
|
||||
<Compile Include="Views\ModEdit\LowTextEdit\LowTextEditWindow.xaml.cs">
|
||||
<DependentUpon>LowTextEditWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ModEdit\AddLangWindow.xaml.cs">
|
||||
<DependentUpon>AddLangWindow.xaml</DependentUpon>
|
||||
<Compile Include="Views\ModEdit\AddCultureWindow.xaml.cs">
|
||||
<DependentUpon>AddCultureWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\ModModel\ModInfoModel.cs" />
|
||||
<Compile Include="Models\ModMaker.cs" />
|
||||
@ -277,7 +278,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\ModEdit\AddLangWindow.xaml">
|
||||
<Page Include="Views\ModEdit\AddCultureWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
43
VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs
Normal file
43
VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs
Normal file
@ -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<ObservableCollection<string>> ShowCultures { get; } = new();
|
||||
public static ObservableCollection<string> AllCultures { get; set; } =
|
||||
new(LinePutScript.Localization.WPF.LocalizeCore.AvailableCultures);
|
||||
public ObservableValue<string> Culture { get; } = new();
|
||||
|
||||
public ObservableValue<string> 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))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<string> EditLangCommand { get; } = new();
|
||||
public ObservableCommand<string> RemoveLangCommand { get; } = new();
|
||||
public ObservableCommand<string> EditCultureCommand { get; } = new();
|
||||
public ObservableCommand<string> 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)
|
||||
|
73
VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml
Normal file
73
VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml
Normal file
@ -0,0 +1,73 @@
|
||||
<Window
|
||||
x:Class="VPet.ModMaker.Views.ModEdit.AddCultureWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
||||
xmlns:local="clr-namespace:VPet.ModMaker.Views.ModEdit"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||
xmlns:vm="clr-namespace:VPet.ModMaker.ViewModels.ModEdit"
|
||||
Title="Window_AddLang"
|
||||
Width="500"
|
||||
Height="400"
|
||||
d:DataContext="{d:DesignInstance Type=vm:AddCultureWindowVM}"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" MinWidth="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox
|
||||
x:Name="TextBox_Lang"
|
||||
pu:TextBoxHelper.Watermark="{ll:Str 语言区域标记}"
|
||||
Text="{Binding Lang.Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock Grid.Row="1">
|
||||
<Hyperlink Click="Hyperlink_Click">
|
||||
<TextBlock Text="{ll:Str 详情请参阅 Windows 支持的语言/区域名称列表中的“语言标记”列}" />
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox pu:TextBoxHelper.Watermark="{ll:Str 搜索}" Text="{Binding Search.Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<ListBox
|
||||
Grid.Row="1"
|
||||
ItemsSource="{Binding ShowLangs.Value}"
|
||||
SelectedItem="{Binding Lang.Value}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
@ -15,6 +15,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using VPet.ModMaker.Models;
|
||||
using VPet.ModMaker.ViewModels;
|
||||
using VPet.ModMaker.ViewModels.ModEdit;
|
||||
|
||||
namespace VPet.ModMaker.Views.ModEdit;
|
||||
@ -22,16 +23,16 @@ namespace VPet.ModMaker.Views.ModEdit;
|
||||
/// <summary>
|
||||
/// Window_AddLang.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Window_AddLang : Window
|
||||
public partial class AddCultureWindow : Window
|
||||
{
|
||||
public bool IsCancel { get; internal set; } = true;
|
||||
public bool IsCancel { get; private set; } = true;
|
||||
|
||||
public ObservableValue<string> Lang { get; } = new();
|
||||
public AddCultureWindowVM ViewModel => (AddCultureWindowVM)DataContext;
|
||||
|
||||
public Window_AddLang()
|
||||
public AddCultureWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = this;
|
||||
DataContext = new AddCultureWindowVM();
|
||||
TextBox_Lang.Focus();
|
||||
}
|
||||
|
||||
@ -42,14 +43,14 @@ public partial class Window_AddLang : Window
|
||||
|
||||
private void Button_Yes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Lang.Value))
|
||||
if (string.IsNullOrEmpty(ViewModel.Culture.Value))
|
||||
{
|
||||
MessageBox.Show("Lang不可为空", "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
MessageBox.Show("文化不可为空", "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
if (I18nHelper.Current.CultureNames.Contains(Lang.Value))
|
||||
if (I18nHelper.Current.CultureNames.Contains(ViewModel.Culture.Value))
|
||||
{
|
||||
MessageBox.Show("此语言已存在", "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
MessageBox.Show("此文化已存在", "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
IsCancel = false;
|
@ -1,57 +0,0 @@
|
||||
<Window
|
||||
x:Class="VPet.ModMaker.Views.ModEdit.Window_AddLang"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
||||
xmlns:local="clr-namespace:VPet.ModMaker.Views.ModEdit"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||
xmlns:vm="clr-namespace:VPet.ModMaker.ViewModels.ModEdit"
|
||||
Title="Window_AddLang"
|
||||
Width="400"
|
||||
Height="300"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d">
|
||||
<d:Window.DataContext>
|
||||
<local:Window_AddLang />
|
||||
</d:Window.DataContext>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox
|
||||
x:Name="TextBox_Lang"
|
||||
pu:TextBoxHelper.Watermark="{ll:Str 语言区域标记}"
|
||||
Text="{Binding Lang.Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock Grid.Row="1">
|
||||
<Hyperlink Click="Hyperlink_Click">
|
||||
<TextBlock Text="{ll:Str 详情请参阅 Windows 支持的语言/区域名称列表中的“语言标记”列}" />
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="Button_Cancel"
|
||||
Margin="10"
|
||||
Click="Button_Cancel_Click"
|
||||
Content="{ll:Str 取消}" />
|
||||
<Button
|
||||
x:Name="Button_Yes"
|
||||
Grid.Column="1"
|
||||
Margin="10"
|
||||
Click="Button_Yes_Click"
|
||||
Content="{ll:Str 确定}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
@ -18,13 +18,13 @@
|
||||
</d:Window.DataContext>
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ContextMenu x:Key="ContextMenu_Lang" x:Shared="false">
|
||||
<ContextMenu x:Key="ContextMenu_Culture" x:Shared="false">
|
||||
<MenuItem
|
||||
Command="{Binding DataContext.ChangeLangCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
||||
Command="{Binding DataContext.ChangeCultureCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
||||
CommandParameter="{Binding Content, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}}"
|
||||
Header="{ll:Str 修改语言}" />
|
||||
<MenuItem
|
||||
Command="{Binding DataContext.RemoveLangCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
||||
Command="{Binding DataContext.RemoveCultureCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
||||
CommandParameter="{Binding Content, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}}"
|
||||
Header="{ll:Str 删除语言}" />
|
||||
</ContextMenu>
|
||||
@ -44,7 +44,7 @@
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="IsEnabled" Value="True" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding SelectedItem, ElementName=ListBox_Langs}" Value="{x:Null}">
|
||||
<DataTrigger Binding="{Binding SelectedItem, ElementName=ListBox_Cultures}" Value="{x:Null}">
|
||||
<Setter Property="IsEnabled" Value="False" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
@ -284,12 +284,9 @@
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Button
|
||||
x:Name="Button_AddLang"
|
||||
Command="{Binding AddLangCommand}"
|
||||
Content="{ll:Str 添加语言}" />
|
||||
<Button Command="{Binding AddCultureCommand}" Content="{ll:Str 添加语言}" />
|
||||
<ListBox
|
||||
x:Name="ListBox_Langs"
|
||||
x:Name="ListBox_Cultures"
|
||||
Grid.Row="1"
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
ItemsSource="{Binding I18nData.CultureNames}"
|
||||
@ -298,7 +295,7 @@
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="ListBoxItem">
|
||||
<Setter Property="Content" Value="{Binding}" />
|
||||
<Setter Property="ContextMenu" Value="{StaticResource ContextMenu_Lang}" />
|
||||
<Setter Property="ContextMenu" Value="{StaticResource ContextMenu_Culture}" />
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
|
@ -2,8 +2,8 @@
|
||||
<packages>
|
||||
<package id="LinePutScript" version="1.9.2" targetFramework="net462" />
|
||||
<package id="LinePutScript.Localization.WPF" version="1.0.6" targetFramework="net462" />
|
||||
<package id="Panuon.WPF" version="1.0.2" targetFramework="net462" />
|
||||
<package id="Panuon.WPF.UI" version="1.1.15.8" targetFramework="net462" />
|
||||
<package id="VPet-Simulator.Core" version="1.0.5.1" targetFramework="net462" />
|
||||
<package id="VPet-Simulator.Windows.Interface" version="1.0.5.2" targetFramework="net462" />
|
||||
<package id="Panuon.WPF" version="1.0.3" targetFramework="net462" />
|
||||
<package id="Panuon.WPF.UI" version="1.1.16.2" targetFramework="net462" />
|
||||
<package id="VPet-Simulator.Core" version="1.0.7" targetFramework="net462" />
|
||||
<package id="VPet-Simulator.Windows.Interface" version="1.0.7" targetFramework="net462" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user