更新 VPet.Solution 结构

This commit is contained in:
Hakoyu 2024-01-07 22:57:27 +08:00
parent c85c381c07
commit 4d1cd4bc14
31 changed files with 428 additions and 278 deletions

View File

@ -1,9 +1,9 @@
using System.ComponentModel;
using System.Windows;
namespace VPet.Solution.Models;
namespace VPet.Solution.Models.SettingEditor;
public class GraphicsSettingModel : ObservableClass<SettingModel>
public class GraphicsSettingModel : ObservableClass<GraphicsSettingModel>
{
private double _zoomLevel = 1;

View File

@ -1,7 +1,7 @@
using HKW.HKWUtils.Observable;
using VPet_Simulator.Core;
namespace VPet.Solution.Models;
namespace VPet.Solution.Models.SettingEditor;
public class InteractiveSettingModel : ObservableClass<InteractiveSettingModel>
{

View File

@ -6,7 +6,7 @@ using System.Windows;
using VPet.Solution.Properties;
using VPet_Simulator.Windows.Interface;
namespace VPet.Solution.Models;
namespace VPet.Solution.Models.SettingEditor;
public class SettingModel : ObservableClass<SettingModel>
{

View File

@ -1,6 +1,6 @@
namespace VPet.Solution.Models;
namespace VPet.Solution.Models.SettingEditor;
public class SystemSettingModel : ObservableClass<SettingModel>
public class SystemSettingModel : ObservableClass<SystemSettingModel>
{
/// <summary>
/// 数据收集是否被禁止(当日)

View File

@ -23,6 +23,14 @@ public abstract class ObservableClass<TObject>
INotifyPropertyChangedX<TObject>
where TObject : ObservableClass<TObject>
{
public ObservableClass()
{
if (GetType() != typeof(TObject))
throw new InvalidCastException(
$"Inconsistency between target type [{GetType().FullName}] and generic type [{typeof(TObject).FullName}]"
);
}
#region OnPropertyChange
/// <summary>
/// 设置属性值

View File

@ -1,4 +1,5 @@
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
@ -321,6 +322,43 @@ public static class Extensions
{
return (T)(page.DataContext ??= new T());
}
private static Dictionary<Window, WindowCloseState> _windowCloseStates = new();
public static void SetCloseState(this Window window, WindowCloseState state)
{
window.Closing -= WindowCloseState_Closing;
window.Closing += WindowCloseState_Closing;
_windowCloseStates[window] = state;
}
public static void CloseX(this Window window)
{
_windowCloseStates.Remove(window);
window.Closing -= WindowCloseState_Closing;
window.Close();
}
private static void WindowCloseState_Closing(object sender, CancelEventArgs e)
{
if (sender is not Window window)
return;
if (_windowCloseStates.TryGetValue(window, out var state) is false)
return;
if (state is WindowCloseState.Close)
return;
e.Cancel = true;
window.Visibility =
state is WindowCloseState.Hidden ? Visibility.Hidden : Visibility.Collapsed;
return;
}
}
public enum WindowCloseState
{
Close,
Hidden,
Collapsed
}
/// <summary>

View File

@ -95,27 +95,31 @@
<Compile Include="Converters\MaxConverter.cs" />
<Compile Include="Converters\ValueToBoolConverter.cs" />
<Compile Include="Converters\BoolInverter.cs" />
<Compile Include="Models\GraphicsSettingModel.cs" />
<Compile Include="Models\InteractiveSettingModel.cs" />
<Compile Include="Models\SystemSettingModel.cs" />
<Compile Include="Models\SettingEditor\GraphicsSettingModel.cs" />
<Compile Include="Models\SettingEditor\InteractiveSettingModel.cs" />
<Compile Include="Models\SettingEditor\SystemSettingModel.cs" />
<Compile Include="Utils\ClearFocus.cs" />
<Compile Include="Utils\ElementHelper.cs" />
<Compile Include="Utils\FindTopParent.cs" />
<Compile Include="ViewModels\CustomizedSettingPageVM.cs" />
<Compile Include="ViewModels\DiagnosticSettingPageVM.cs" />
<Compile Include="ViewModels\ModSettingPageVM.cs" />
<Compile Include="Models\SettingModel.cs" />
<Compile Include="ViewModels\SystemSettingPageVM.cs" />
<Compile Include="Views\CustomizedSettingPage.xaml.cs">
<Compile Include="ViewModels\MainWindowVM.cs" />
<Compile Include="ViewModels\SettingEditor\CustomizedSettingPageVM.cs" />
<Compile Include="ViewModels\SettingEditor\DiagnosticSettingPageVM.cs" />
<Compile Include="ViewModels\SettingEditor\ModSettingPageVM.cs" />
<Compile Include="Models\SettingEditor\SettingModel.cs" />
<Compile Include="ViewModels\SettingEditor\SystemSettingPageVM.cs" />
<Compile Include="Views\SettingEditor\SettingWindow.xaml.cs">
<DependentUpon>SettingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingEditor\CustomizedSettingPage.xaml.cs">
<DependentUpon>CustomizedSettingPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\DiagnosticSettingPage.xaml.cs">
<Compile Include="Views\SettingEditor\DiagnosticSettingPage.xaml.cs">
<DependentUpon>DiagnosticSettingPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ModSettingPage.xaml.cs">
<Compile Include="Views\SettingEditor\ModSettingPage.xaml.cs">
<DependentUpon>ModSettingPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SystemSettingPage.xaml.cs">
<Compile Include="Views\SettingEditor\SystemSettingPage.xaml.cs">
<DependentUpon>SystemSettingPage.xaml</DependentUpon>
</Compile>
<Page Include="Converters.xaml">
@ -130,19 +134,23 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\CustomizedSettingPage.xaml">
<Page Include="Views\SettingEditor\SettingWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\SettingEditor\CustomizedSettingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\DiagnosticSettingPage.xaml">
<Page Include="Views\SettingEditor\DiagnosticSettingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\GraphicsSettingPage.xaml">
<Page Include="Views\SettingEditor\GraphicsSettingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\InteractiveSettingPage.xaml">
<Page Include="Views\SettingEditor\InteractiveSettingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@ -154,13 +162,13 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="ViewModels\GraphicsSettingPageVM.cs" />
<Compile Include="ViewModels\InteractiveSettingPageVM.cs" />
<Compile Include="ViewModels\MainWindowVM.cs" />
<Compile Include="Views\GraphicsSettingPage.xaml.cs">
<Compile Include="ViewModels\SettingEditor\GraphicsSettingPageVM.cs" />
<Compile Include="ViewModels\SettingEditor\InteractiveSettingPageVM.cs" />
<Compile Include="ViewModels\SettingEditor\SettingWindowVM.cs" />
<Compile Include="Views\SettingEditor\GraphicsSettingPage.xaml.cs">
<DependentUpon>GraphicsSettingPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\InteractiveSettingPage.xaml.cs">
<Compile Include="Views\SettingEditor\InteractiveSettingPage.xaml.cs">
<DependentUpon>InteractiveSettingPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\MainWindow.xaml.cs">
@ -195,11 +203,11 @@
<Compile Include="NativeStyles.xaml.cs">
<DependentUpon>NativeStyles.xaml</DependentUpon>
</Compile>
<Page Include="Views\ModSettingPage.xaml">
<Page Include="Views\SettingEditor\ModSettingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SystemSettingPage.xaml">
<Page Include="Views\SettingEditor\SystemSettingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@ -241,6 +249,10 @@
<Name>VPet-Simulator.Windows.Interface</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Models\SaveEditor\" />
<Folder Include="ViewModels\SaveEditor\" />
<Folder Include="Views\SaveEditor\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,89 +1,9 @@
using HKW.HKWUtils.Observable;
using LinePutScript;
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet.Solution.Models;
using VPet_Simulator.Windows.Interface;
namespace VPet.Solution.ViewModels;
public class MainWindowVM : ObservableClass<MainWindowVM>
{
public static MainWindowVM Current { get; private set; }
private SettingModel _currentSettings;
public SettingModel CurrentSetting
{
get => _currentSettings;
set => SetProperty(ref _currentSettings, value);
}
private readonly ObservableCollection<SettingModel> _settings = new();
private IEnumerable<SettingModel> _showSettings;
public IEnumerable<SettingModel> ShowSettings
{
get => _showSettings;
set => SetProperty(ref _showSettings, value);
}
private string _searchSetting;
public string SearchSetting
{
get => _searchSetting;
set => SetProperty(ref _searchSetting, value);
}
public MainWindowVM()
{
Current = this;
ShowSettings = _settings;
foreach (var s in LoadSettings())
_settings.Add(s);
PropertyChanged += MainWindowVM_PropertyChanged;
}
private void MainWindowVM_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SearchSetting))
{
if (string.IsNullOrWhiteSpace(SearchSetting))
ShowSettings = _settings;
else
ShowSettings = _settings.Where(
s => s.Name.Contains(SearchSetting, StringComparison.OrdinalIgnoreCase)
);
}
}
public static IEnumerable<SettingModel> LoadSettings()
{
foreach (
var file in Directory
.EnumerateFiles(Environment.CurrentDirectory)
.Where(
(s) =>
{
if (s.EndsWith(".lps") is false)
return false;
return Path.GetFileName(s).StartsWith("Setting");
}
)
)
{
var setting = new Setting(File.ReadAllText(file));
yield return new SettingModel(setting)
{
Name = Path.GetFileNameWithoutExtension(file),
FilePath = file
};
}
}
}
public class MainWindowVM : ObservableClass<MainWindowVM> { }

View File

@ -4,6 +4,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VPet.Solution.ViewModels;
namespace VPet.Solution.ViewModels.SettingEditor;
public class CustomizedSettingPageVM { }

View File

@ -4,6 +4,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VPet.Solution.ViewModels;
namespace VPet.Solution.ViewModels.SettingEditor;
public class DiagnosticSettingPageVM { }

View File

@ -5,8 +5,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet.Solution.Models;
using VPet.Solution.Models.SettingEditor;
namespace VPet.Solution.ViewModels;
namespace VPet.Solution.ViewModels.SettingEditor;
public class GraphicsSettingPageVM : ObservableClass<GraphicsSettingPageVM>
{
@ -19,12 +20,12 @@ public class GraphicsSettingPageVM : ObservableClass<GraphicsSettingPageVM>
public GraphicsSettingPageVM()
{
MainWindowVM.Current.PropertyChangedX += Current_PropertyChangedX;
SettingWindowVM.Current.PropertyChangedX += Current_PropertyChangedX;
}
private void Current_PropertyChangedX(MainWindowVM sender, PropertyChangedXEventArgs e)
private void Current_PropertyChangedX(SettingWindowVM sender, PropertyChangedXEventArgs e)
{
if (e.PropertyName == nameof(MainWindowVM.CurrentSetting))
if (e.PropertyName == nameof(SettingWindowVM.CurrentSetting))
{
GraphicsSetting = sender.CurrentSetting.GraphicsSetting;
}

View File

@ -4,8 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet.Solution.Models;
using VPet.Solution.Models.SettingEditor;
namespace VPet.Solution.ViewModels;
namespace VPet.Solution.ViewModels.SettingEditor;
public class InteractiveSettingPageVM : ObservableClass<InteractiveSettingPageVM>
{
@ -18,12 +19,12 @@ public class InteractiveSettingPageVM : ObservableClass<InteractiveSettingPageVM
public InteractiveSettingPageVM()
{
MainWindowVM.Current.PropertyChangedX += Current_PropertyChangedX;
SettingWindowVM.Current.PropertyChangedX += Current_PropertyChangedX;
}
private void Current_PropertyChangedX(MainWindowVM sender, PropertyChangedXEventArgs e)
private void Current_PropertyChangedX(SettingWindowVM sender, PropertyChangedXEventArgs e)
{
if (e.PropertyName == nameof(MainWindowVM.CurrentSetting))
if (e.PropertyName == nameof(SettingWindowVM.CurrentSetting))
{
InteractiveSetting = sender.CurrentSetting.InteractiveSetting;
}

View File

@ -4,6 +4,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VPet.Solution.ViewModels;
namespace VPet.Solution.ViewModels.SettingEditor;
public class ModSettingPageVM { }

View File

@ -0,0 +1,90 @@
using HKW.HKWUtils.Observable;
using LinePutScript;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet.Solution.Models;
using VPet.Solution.Models.SettingEditor;
using VPet_Simulator.Windows.Interface;
namespace VPet.Solution.ViewModels.SettingEditor;
public class SettingWindowVM : ObservableClass<SettingWindowVM>
{
public static SettingWindowVM Current { get; private set; }
private SettingModel _currentSettings;
public SettingModel CurrentSetting
{
get => _currentSettings;
set => SetProperty(ref _currentSettings, value);
}
private readonly ObservableCollection<SettingModel> _settings = new();
private IEnumerable<SettingModel> _showSettings;
public IEnumerable<SettingModel> ShowSettings
{
get => _showSettings;
set => SetProperty(ref _showSettings, value);
}
private string _searchSetting;
public string SearchSetting
{
get => _searchSetting;
set => SetProperty(ref _searchSetting, value);
}
public SettingWindowVM()
{
Current = this;
ShowSettings = _settings;
foreach (var s in LoadSettings())
_settings.Add(s);
PropertyChanged += MainWindowVM_PropertyChanged;
}
private void MainWindowVM_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SearchSetting))
{
if (string.IsNullOrWhiteSpace(SearchSetting))
ShowSettings = _settings;
else
ShowSettings = _settings.Where(
s => s.Name.Contains(SearchSetting, StringComparison.OrdinalIgnoreCase)
);
}
}
public static IEnumerable<SettingModel> LoadSettings()
{
foreach (
var file in Directory
.EnumerateFiles(Environment.CurrentDirectory)
.Where(
(s) =>
{
if (s.EndsWith(".lps") is false)
return false;
return Path.GetFileName(s).StartsWith("Setting");
}
)
)
{
var setting = new Setting(File.ReadAllText(file));
yield return new SettingModel(setting)
{
Name = Path.GetFileNameWithoutExtension(file),
FilePath = file
};
}
}
}

View File

@ -5,8 +5,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet.Solution.Models;
using VPet.Solution.Models.SettingEditor;
namespace VPet.Solution.ViewModels;
namespace VPet.Solution.ViewModels.SettingEditor;
public class SystemSettingPageVM : ObservableClass<SystemSettingPageVM>
{
@ -19,12 +20,12 @@ public class SystemSettingPageVM : ObservableClass<SystemSettingPageVM>
public SystemSettingPageVM()
{
MainWindowVM.Current.PropertyChangedX += Current_PropertyChangedX;
SettingWindowVM.Current.PropertyChangedX += Current_PropertyChangedX;
}
private void Current_PropertyChangedX(MainWindowVM sender, PropertyChangedXEventArgs e)
private void Current_PropertyChangedX(SettingWindowVM sender, PropertyChangedXEventArgs e)
{
if (e.PropertyName == nameof(MainWindowVM.CurrentSetting))
if (e.PropertyName == nameof(SettingWindowVM.CurrentSetting))
{
SystemSetting = sender.CurrentSetting.SystemSetting;
}

View File

@ -15,122 +15,24 @@
MinWidth="400"
MinHeight="200"
d:DataContext="{d:DesignInstance Type=vm:MainWindowVM}"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition MinWidth="300" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBox Style="{DynamicResource StandardTextBoxStyle}" Text="{Binding SearchSetting, UpdateSourceTrigger=PropertyChanged}" />
<ListBox
x:Name="ListBox_Saves"
Grid.Row="1"
d:ItemsSource="{d:SampleData ItemCount=5}"
ItemsSource="{Binding ShowSettings}"
SelectedItem="{Binding CurrentSetting}"
Style="{DynamicResource SideMenuListBoxStyle}">
<ListBox.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="ListBoxItem">
<Setter Property="Content" Value="{Binding Name}" />
<Setter Property="ToolTip" Value="{Binding Path}" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<ListBox x:Name="ListBox_Main" Style="{DynamicResource SideMenuListBoxStyle}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem x:Name="ListBoxItem_GraphicsSettings" Content="{ll:Str 图形}" />
<ListBoxItem x:Name="ListBoxItem_SystemSettings" Content="{ll:Str 系统}" />
<ListBoxItem x:Name="ListBoxItem_InteractiveSettings" Content="{ll:Str 互动}" />
<ListBoxItem x:Name="ListBoxItem_CustomizedSettings" Content="{ll:Str 自定}" />
<ListBoxItem x:Name="ListBoxItem_DiagnosticSettings" Content="{ll:Str 诊断}" />
<ListBoxItem x:Name="ListBoxItem_ModSettings" Content="{ll:Str Mod管理}" />
</ListBox>
<Frame
x:Name="Frame_Main"
Grid.Row="1"
Content="{Binding SelectedItem.Tag, ElementName=ListBox_Main}"
ContentRendered="Frame_Main_ContentRendered"
NavigationUIVisibility="Hidden" />
<!--<TabControl
x:Name="MainTab"
Grid.Column="1"
Margin="5"
d:SelectionChanged="MainTab_SelectionChanged"
pu:TabControlHelper.CanHeaderPanelScroll="True"
pu:TabControlHelper.ItemsCornerRadius="4"
pu:TabControlHelper.ItemsHeight="NaN"
pu:TabControlHelper.ItemsHoverBackground="{DynamicResource PrimaryLight}"
pu:TabControlHelper.ItemsPadding="10,7"
pu:TabControlHelper.ItemsSelectedBackground="{DynamicResource PrimaryDark}"
pu:TabControlHelper.ItemsSelectedForeground="{DynamicResource DARKPrimaryText}"
Background="Transparent"
BorderThickness="0"
Foreground="{DynamicResource PrimaryText}">
<TabControl.ContentTemplate>
<DataTemplate>
<Border
Margin="0,5,0,10"
Background="{DynamicResource DARKPrimaryText}"
CornerRadius="15">
<ContentControl Margin="10,5" Content="{Binding}" />
</Border>
</DataTemplate>
</TabControl.ContentTemplate>
<TabItem
BorderBrush="{DynamicResource PrimaryDarker}"
Foreground="{DynamicResource PrimaryText}"
Header="" />
<TabItem BorderBrush="{DynamicResource PrimaryDarker}" Header="{ll:Str 系统}" />
<TabItem BorderBrush="{DynamicResource PrimaryDarker}" Header="{ll:Str 互动}" />
<TabItem BorderBrush="{DynamicResource PrimaryDarker}" Header="{ll:Str 自定}" />
<TabItem BorderBrush="{DynamicResource PrimaryDarker}" Header="{ll:Str 诊断}" />
<TabItem BorderBrush="{DynamicResource PrimaryDarker}" Header="{ll:Str MOD管理}" />
</TabControl>
<Label
x:Name="GameVerison"
Grid.ColumnSpan="2"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Background="{x:Null}"
Content="版本v1.0 (655366666)"
FontSize="10"
Foreground="Green" />-->
</Grid>
<!--<Grid Grid.Column="1">
<TextBox
x:Name="tb_seach_menu"
Margin="3,6,6,0"
VerticalAlignment="Top"
d:TextChanged="tb_seach_menu_textchange"
pu:TextBoxHelper.Watermark="{ll:Str 搜索设置}"
FontSize="16"
Style="{DynamicResource StandardTextBoxStyle}" />
<ListBox
x:Name="ListMenu"
Margin="3,40,6,3"
pu:ListBoxHelper.CornerRadius="5"
pu:ListBoxHelper.ItemsHoverBackground="{DynamicResource Primary}"
pu:ListBoxHelper.ItemsSelectedBackground="{DynamicResource SecondaryLight}"
Background="{DynamicResource SecondaryLighter}"
BorderBrush="{DynamicResource Primary}"
BorderThickness="2"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto" />
</Grid>-->
<Button
x:Name="Button_OpenSettingEditor"
Click="Button_OpenSettingEditor_Click"
Content="{ll:Str 打开设置编辑器}"
FontSize="16"
Style="{DynamicResource Button_BaseStyle}" />
<Button
x:Name="Button_OpenSaveEditor"
Grid.Column="1"
Content="{ll:Str 打开存档编辑器}"
FontSize="16"
Style="{DynamicResource Button_BaseStyle}" />
</Grid>
</pu:WindowX>

View File

@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using VPet.Solution.ViewModels;
using VPet.Solution.Views.SettingEditor;
namespace VPet.Solution.Views;
@ -14,6 +15,8 @@ public partial class MainWindow : WindowX
{
public MainWindowVM ViewModel => (MainWindowVM)DataContext;
public SettingWindow SettingWindow { get; set; } = new();
public MainWindow()
{
if (App.IsDone)
@ -24,21 +27,18 @@ public partial class MainWindow : WindowX
InitializeComponent();
this.SetViewModel<MainWindowVM>();
ListBoxItem_GraphicsSettings.Tag = new GraphicsSettingPage();
ListBoxItem_SystemSettings.Tag = new SystemSettingPage();
ListBoxItem_InteractiveSettings.Tag = new InteractiveSettingPage();
ListBoxItem_CustomizedSettings.Tag = new CustomizedSettingPage();
ListBoxItem_DiagnosticSettings.Tag = new DiagnosticSettingPage();
ListBoxItem_ModSettings.Tag = new ModSettingPage();
Closed += MainWindow_Closed;
}
private void Frame_Main_ContentRendered(object sender, EventArgs e)
private void MainWindow_Closed(object sender, EventArgs e)
{
if (sender is not Frame frame)
return;
// 清理过时页面
while (frame.CanGoBack)
frame.RemoveBackEntry();
GC.Collect();
SettingWindow.CloseX();
}
private void Button_OpenSettingEditor_Click(object sender, RoutedEventArgs e)
{
if (SettingWindow.IsVisible is false)
SettingWindow.Show();
SettingWindow.Activate();
}
}

View File

@ -1,13 +1,13 @@
<Page
x:Class="VPet.Solution.Views.CustomizedSettingPage"
x:Class="VPet.Solution.Views.SettingEditor.CustomizedSettingPage"
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.Solution.Views"
xmlns:local="clr-namespace:VPet.Solution.Views.SettingEditor"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels.SettingEditor"
Title="CustomizedSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:CustomizedSettingPageVM}"
d:DesignHeight="450"

View File

@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace VPet.Solution.Views;
namespace VPet.Solution.Views.SettingEditor;
/// <summary>
/// CustomizedSettingsPage.xaml 的交互逻辑

View File

@ -1,13 +1,13 @@
<Page
x:Class="VPet.Solution.Views.DiagnosticSettingPage"
x:Class="VPet.Solution.Views.SettingEditor.DiagnosticSettingPage"
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.Solution.Views"
xmlns:local="clr-namespace:VPet.Solution.Views.SettingEditor"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels.SettingEditor"
Title="DiagnosticSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:DiagnosticSettingPageVM}"
d:DesignHeight="450"

View File

@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace VPet.Solution.Views;
namespace VPet.Solution.Views.SettingEditor;
/// <summary>
/// DiagnosticSettingsPage.xaml 的交互逻辑

View File

@ -1,14 +1,14 @@
<Page
x:Class="VPet.Solution.Views.GraphicsSettingPage"
x:Class="VPet.Solution.Views.SettingEditor.GraphicsSettingPage"
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:h="clr-namespace:HKW.WPF.Helpers"
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
xmlns:local="clr-namespace:VPet.Solution.Views"
xmlns:local="clr-namespace:VPet.Solution.Views.SettingEditor"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels.SettingEditor"
Title="GraphicsSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:GraphicsSettingPageVM}"
d:DesignHeight="450"

View File

@ -13,9 +13,9 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VPet.Solution.ViewModels;
using VPet.Solution.ViewModels.SettingEditor;
namespace VPet.Solution.Views;
namespace VPet.Solution.Views.SettingEditor;
/// <summary>
/// GraphicsSettingsPage.xaml 的交互逻辑

View File

@ -1,14 +1,14 @@
<Page
x:Class="VPet.Solution.Views.InteractiveSettingPage"
x:Class="VPet.Solution.Views.SettingEditor.InteractiveSettingPage"
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.Solution.Views"
xmlns:local="clr-namespace:VPet.Solution.Views.SettingEditor"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels.SettingEditor"
Title="InteractiveSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:InteractiveSettingPageVM}"
d:DesignHeight="450"

View File

@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace VPet.Solution.Views;
namespace VPet.Solution.Views.SettingEditor;
/// <summary>
/// InteractiveSettingsPage.xaml 的交互逻辑

View File

@ -1,13 +1,13 @@
<Page
x:Class="VPet.Solution.Views.ModSettingPage"
x:Class="VPet.Solution.Views.SettingEditor.ModSettingPage"
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.Solution.Views"
xmlns:local="clr-namespace:VPet.Solution.Views.SettingEditor"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels.SettingEditor"
Title="ModSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:GraphicsSettingPageVM}"
d:DesignHeight="450"

View File

@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace VPet.Solution.Views;
namespace VPet.Solution.Views.SettingEditor;
/// <summary>
/// ModSettingsPage.xaml 的交互逻辑

View File

@ -0,0 +1,137 @@
<pu:WindowX
x:Class="VPet.Solution.Views.SettingEditor.SettingWindow"
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.Solution"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels.SettingEditor"
Title="{ll:Str 'VPET 问题解决工具'}"
Width="800"
Height="450"
MinWidth="400"
MinHeight="200"
d:DataContext="{d:DesignInstance Type=vm:SettingWindowVM}"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition MinWidth="300" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBox Style="{DynamicResource StandardTextBoxStyle}" Text="{Binding SearchSetting, UpdateSourceTrigger=PropertyChanged}" />
<ListBox
x:Name="ListBox_Saves"
Grid.Row="1"
d:ItemsSource="{d:SampleData ItemCount=5}"
ItemsSource="{Binding ShowSettings}"
SelectedItem="{Binding CurrentSetting}"
Style="{DynamicResource SideMenuListBoxStyle}">
<ListBox.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="ListBoxItem">
<Setter Property="Content" Value="{Binding Name}" />
<Setter Property="ToolTip" Value="{Binding Path}" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<ListBox x:Name="ListBox_Main" Style="{DynamicResource SideMenuListBoxStyle}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem x:Name="ListBoxItem_GraphicsSettings" Content="{ll:Str 图形}" />
<ListBoxItem x:Name="ListBoxItem_SystemSettings" Content="{ll:Str 系统}" />
<ListBoxItem x:Name="ListBoxItem_InteractiveSettings" Content="{ll:Str 互动}" />
<ListBoxItem x:Name="ListBoxItem_CustomizedSettings" Content="{ll:Str 自定}" />
<ListBoxItem x:Name="ListBoxItem_DiagnosticSettings" Content="{ll:Str 诊断}" />
<ListBoxItem x:Name="ListBoxItem_ModSettings" Content="{ll:Str Mod管理}" />
</ListBox>
<Frame
x:Name="Frame_Main"
Grid.Row="1"
Content="{Binding SelectedItem.Tag, ElementName=ListBox_Main}"
ContentRendered="Frame_Main_ContentRendered"
NavigationUIVisibility="Hidden" />
<!--<TabControl
x:Name="MainTab"
Grid.Column="1"
Margin="5"
d:SelectionChanged="MainTab_SelectionChanged"
pu:TabControlHelper.CanHeaderPanelScroll="True"
pu:TabControlHelper.ItemsCornerRadius="4"
pu:TabControlHelper.ItemsHeight="NaN"
pu:TabControlHelper.ItemsHoverBackground="{DynamicResource PrimaryLight}"
pu:TabControlHelper.ItemsPadding="10,7"
pu:TabControlHelper.ItemsSelectedBackground="{DynamicResource PrimaryDark}"
pu:TabControlHelper.ItemsSelectedForeground="{DynamicResource DARKPrimaryText}"
Background="Transparent"
BorderThickness="0"
Foreground="{DynamicResource PrimaryText}">
<TabControl.ContentTemplate>
<DataTemplate>
<Border
Margin="0,5,0,10"
Background="{DynamicResource DARKPrimaryText}"
CornerRadius="15">
<ContentControl Margin="10,5" Content="{Binding}" />
</Border>
</DataTemplate>
</TabControl.ContentTemplate>
<TabItem
BorderBrush="{DynamicResource PrimaryDarker}"
Foreground="{DynamicResource PrimaryText}"
Header="" />
<TabItem BorderBrush="{DynamicResource PrimaryDarker}" Header="{ll:Str 系统}" />
<TabItem BorderBrush="{DynamicResource PrimaryDarker}" Header="{ll:Str 互动}" />
<TabItem BorderBrush="{DynamicResource PrimaryDarker}" Header="{ll:Str 自定}" />
<TabItem BorderBrush="{DynamicResource PrimaryDarker}" Header="{ll:Str 诊断}" />
<TabItem BorderBrush="{DynamicResource PrimaryDarker}" Header="{ll:Str MOD管理}" />
</TabControl>
<Label
x:Name="GameVerison"
Grid.ColumnSpan="2"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Background="{x:Null}"
Content="版本v1.0 (655366666)"
FontSize="10"
Foreground="Green" />-->
</Grid>
<!--<Grid Grid.Column="1">
<TextBox
x:Name="tb_seach_menu"
Margin="3,6,6,0"
VerticalAlignment="Top"
d:TextChanged="tb_seach_menu_textchange"
pu:TextBoxHelper.Watermark="{ll:Str 搜索设置}"
FontSize="16"
Style="{DynamicResource StandardTextBoxStyle}" />
<ListBox
x:Name="ListMenu"
Margin="3,40,6,3"
pu:ListBoxHelper.CornerRadius="5"
pu:ListBoxHelper.ItemsHoverBackground="{DynamicResource Primary}"
pu:ListBoxHelper.ItemsSelectedBackground="{DynamicResource SecondaryLight}"
Background="{DynamicResource SecondaryLighter}"
BorderBrush="{DynamicResource Primary}"
BorderThickness="2"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto" />
</Grid>-->
</Grid>
</pu:WindowX>

View File

@ -0,0 +1,40 @@
using HKW.HKWUtils;
using Panuon.WPF.UI;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using VPet.Solution.ViewModels.SettingEditor;
namespace VPet.Solution.Views.SettingEditor;
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class SettingWindow : WindowX
{
public SettingWindowVM ViewModel => (SettingWindowVM)DataContext;
public SettingWindow()
{
InitializeComponent();
this.SetViewModel<SettingWindowVM>();
this.SetCloseState(WindowCloseState.Hidden);
ListBoxItem_GraphicsSettings.Tag = new GraphicsSettingPage();
ListBoxItem_SystemSettings.Tag = new SystemSettingPage();
ListBoxItem_InteractiveSettings.Tag = new InteractiveSettingPage();
ListBoxItem_CustomizedSettings.Tag = new CustomizedSettingPage();
ListBoxItem_DiagnosticSettings.Tag = new DiagnosticSettingPage();
ListBoxItem_ModSettings.Tag = new ModSettingPage();
}
private void Frame_Main_ContentRendered(object sender, EventArgs e)
{
if (sender is not Frame frame)
return;
// 清理过时页面
while (frame.CanGoBack)
frame.RemoveBackEntry();
GC.Collect();
}
}

View File

@ -1,15 +1,15 @@
<Page
x:Class="VPet.Solution.Views.SystemSettingPage"
x:Class="VPet.Solution.Views.SettingEditor.SystemSettingPage"
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:h="clr-namespace:HKW.WPF.Helpers"
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
xmlns:local="clr-namespace:VPet.Solution.Views"
xmlns:local="clr-namespace:VPet.Solution.Views.SettingEditor"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels"
xmlns:vm="clr-namespace:VPet.Solution.ViewModels.SettingEditor"
Title="SystemSettingsPage"
d:DataContext="{d:DesignInstance Type=vm:SystemSettingPageVM}"
d:DesignHeight="450"

View File

@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace VPet.Solution.Views;
namespace VPet.Solution.Views.SettingEditor;
/// <summary>
/// SystemSettingsPage.xaml 的交互逻辑