feat: 管理器支持深浅主题切换,发布 exe
- 新增 LightTheme.xaml 浅色主题资源 - 标题栏添加主题切换按钮(☀️/🌙) - Manager 支持深浅主题互换 - 发布 Manager.exe (292KB) 和 Installer.exe (171KB) - 插件安装包 Better-Seewo.2.0.0.exe (11.6MB)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
@@ -5,18 +6,42 @@ namespace BetterSeewoManager;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private bool _isDarkTheme = true;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
ContentFrame.Navigate(new System.Uri("Pages/InstallPage.xaml", System.UriKind.Relative));
|
||||
ApplyTheme();
|
||||
ContentFrame.Navigate(new Uri("Pages/InstallPage.xaml", UriKind.Relative));
|
||||
}
|
||||
|
||||
private void Tab_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is RadioButton rb && rb.Tag is string pageName)
|
||||
{
|
||||
var pageUri = new System.Uri($"Pages/{pageName}.xaml", System.UriKind.Relative);
|
||||
var pageUri = new Uri($"Pages/{pageName}.xaml", UriKind.Relative);
|
||||
ContentFrame.Navigate(pageUri);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnThemeToggle_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_isDarkTheme = !_isDarkTheme;
|
||||
ApplyTheme();
|
||||
}
|
||||
|
||||
private void ApplyTheme()
|
||||
{
|
||||
var app = (App)Application.Current;
|
||||
app.Resources.MergedDictionaries.Clear();
|
||||
app.Resources.MergedDictionaries.Add(new ResourceDictionary
|
||||
{
|
||||
Source = new Uri(_isDarkTheme
|
||||
? "Themes/DarkTheme.xaml"
|
||||
: "Themes/LightTheme.xaml", UriKind.Relative)
|
||||
});
|
||||
|
||||
BtnThemeToggle.Content = _isDarkTheme ? "☀️" : "🌙";
|
||||
StatusText.Text = _isDarkTheme ? "已切换到深色主题" : "已切换到浅色主题";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user