HandyControl/HandyControlDemo/App.xaml.cs
2018-12-27 00:01:03 +08:00

60 lines
1.8 KiB
C#

using System;
using System.Globalization;
using System.Threading;
using System.Windows;
using HandyControl.Controls;
using HandyControl.Data;
using HandyControl.Tools;
using HandyControlDemo.Data;
using HandyControlDemo.Tools;
namespace HandyControlDemo
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
GlobalData.Init();
Thread.CurrentThread.CurrentUICulture = new CultureInfo(GlobalData.Config.Lang);
if (GlobalData.Config.Skin != SkinType.Default)
{
UpdateSkin(GlobalData.Config.Skin);
}
BlurWindow.SystemVersionInfo = CommonHelper.GetSystemVersionInfo();
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
GlobalData.Save();
}
internal void UpdateSkin(SkinType skin)
{
var skins0 = Resources.MergedDictionaries[0];
skins0.MergedDictionaries.Clear();
skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(skin));
skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skin));
var skins1 = Resources.MergedDictionaries[1];
skins1.MergedDictionaries.Clear();
skins1.MergedDictionaries.Add(new ResourceDictionary
{
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
});
skins1.MergedDictionaries.Add(new ResourceDictionary
{
Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
});
Current.MainWindow?.OnApplyTemplate();
}
}
}