VPet/VPet.Solution/Views/MainWindow.xaml.cs

69 lines
1.9 KiB
C#
Raw Normal View History

2023-12-23 14:44:10 +00:00
using HKW.HKWUtils;
2024-01-18 13:39:23 +00:00
using LinePutScript.Localization.WPF;
2023-12-23 14:44:10 +00:00
using Panuon.WPF.UI;
2023-12-30 14:54:49 +00:00
using System.ComponentModel;
2024-01-18 13:39:23 +00:00
using System.Text;
2023-12-30 14:54:49 +00:00
using System.Windows;
2023-12-23 14:44:10 +00:00
using System.Windows.Controls;
using VPet.Solution.ViewModels;
2024-01-13 13:56:21 +00:00
using VPet.Solution.Views.SaveViewer;
2024-01-07 14:57:27 +00:00
using VPet.Solution.Views.SettingEditor;
2023-12-18 14:53:56 +00:00
2023-12-23 14:44:10 +00:00
namespace VPet.Solution.Views;
2023-12-18 14:53:56 +00:00
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : WindowX
{
2023-12-30 14:54:49 +00:00
public MainWindowVM ViewModel => (MainWindowVM)DataContext;
2023-12-23 14:44:10 +00:00
2024-01-13 13:56:21 +00:00
public SettingWindow SettingWindow { get; } = new();
public SaveWindow SaveWindow { get; } = new();
2024-01-07 14:57:27 +00:00
2023-12-18 14:53:56 +00:00
public MainWindow()
{
if (App.IsDone)
{
Close();
return;
}
InitializeComponent();
2023-12-30 14:54:49 +00:00
this.SetViewModel<MainWindowVM>();
2024-01-18 13:39:23 +00:00
LocalizeCore.StoreTranslation = true;
LocalizeCore.LoadDefaultCulture();
ComboBox_Langs.ItemsSource = LocalizeCore.AvailableCultures;
ComboBox_Langs.SelectedItem = LocalizeCore.CurrentCulture;
2024-01-07 14:57:27 +00:00
Closed += MainWindow_Closed;
2023-12-23 14:44:10 +00:00
}
2024-01-07 14:57:27 +00:00
private void MainWindow_Closed(object sender, EventArgs e)
2023-12-23 14:44:10 +00:00
{
2024-01-07 14:57:27 +00:00
SettingWindow.CloseX();
2024-01-13 13:56:21 +00:00
SaveWindow.CloseX();
2024-01-07 14:57:27 +00:00
}
private void Button_OpenSettingEditor_Click(object sender, RoutedEventArgs e)
{
2024-01-09 15:22:25 +00:00
SettingWindow.ShowOrActivate();
2023-12-18 14:53:56 +00:00
}
2024-01-13 13:56:21 +00:00
2024-01-18 13:39:23 +00:00
private void Button_OpenSaveViewer_Click(object sender, RoutedEventArgs e)
2024-01-13 13:56:21 +00:00
{
SaveWindow.ShowOrActivate();
}
2024-01-18 13:39:23 +00:00
private void Button_OpenLocalText_Click(object sender, RoutedEventArgs e)
{
var sb = new StringBuilder();
foreach (var a in LocalizeCore.StoreTranslationList)
sb.AppendLine(a.Replace("\r\n", "\\r\\n"));
MessageBoxX.Show(sb.ToString());
}
private void ComboBox_Langs_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
LocalizeCore.LoadCulture((string)ComboBox_Langs.SelectedItem);
}
2023-12-18 14:53:56 +00:00
}