diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs index 6d8e293960e8..0282a3417737 100644 --- a/installer/PowerToysSetup/Product.wxs +++ b/installer/PowerToysSetup/Product.wxs @@ -787,7 +787,7 @@ - + diff --git a/src/modules/launcher/PowerLauncher/App.xaml.cs b/src/modules/launcher/PowerLauncher/App.xaml.cs index 17974072e776..3028af9cf369 100644 --- a/src/modules/launcher/PowerLauncher/App.xaml.cs +++ b/src/modules/launcher/PowerLauncher/App.xaml.cs @@ -68,6 +68,7 @@ private void OnStartup(object sender, StartupEventArgs e) StringMatcher.Instance = _stringMatcher; _stringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision; + ThemeManager themeManager = new ThemeManager(this); PluginManager.LoadPlugins(_settings.PluginSettings); _mainVM = new MainViewModel(_settings); var window = new MainWindow(_settings, _mainVM); @@ -83,8 +84,6 @@ private void OnStartup(object sender, StartupEventArgs e) InternationalizationManager.Instance.ChangeLanguage(_settings.Language); // main windows needs initialized before theme change because of blur settings - ThemeManager.Instance.Settings = _settings; - ThemeManager.Instance.ChangeTheme(_settings.Theme); Http.Proxy = _settings.Proxy; diff --git a/src/modules/launcher/PowerLauncher/LauncherControl.xaml b/src/modules/launcher/PowerLauncher/LauncherControl.xaml index b08c34722e52..814257c24b50 100644 --- a/src/modules/launcher/PowerLauncher/LauncherControl.xaml +++ b/src/modules/launcher/PowerLauncher/LauncherControl.xaml @@ -9,25 +9,11 @@ d:DesignHeight="300" d:DesignWidth="720"> - #66000000 - - - - - - - diff --git a/src/modules/launcher/PowerLauncher/MainWindow.xaml b/src/modules/launcher/PowerLauncher/MainWindow.xaml index 46c87742eba7..3973e9b5547c 100644 --- a/src/modules/launcher/PowerLauncher/MainWindow.xaml +++ b/src/modules/launcher/PowerLauncher/MainWindow.xaml @@ -24,12 +24,6 @@ Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" d:DataContext="{d:DesignInstance vm:MainViewModel}"> - - - diff --git a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj index 12586fccb0c1..20d909704208 100644 --- a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj +++ b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj @@ -48,10 +48,6 @@ - - - - @@ -189,4 +185,25 @@ + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/ResultList.xaml b/src/modules/launcher/PowerLauncher/ResultList.xaml index e2480cd1d2f4..ff0515d84940 100644 --- a/src/modules/launcher/PowerLauncher/ResultList.xaml +++ b/src/modules/launcher/PowerLauncher/ResultList.xaml @@ -15,36 +15,12 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/modules/launcher/PowerLauncher/Themes/BlackAndWhite.xaml b/src/modules/launcher/PowerLauncher/Themes/BlackAndWhite.xaml deleted file mode 100644 index 8c3f0cbd45e9..000000000000 --- a/src/modules/launcher/PowerLauncher/Themes/BlackAndWhite.xaml +++ /dev/null @@ -1 +0,0 @@ - #4F6180 \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/Themes/BlurBlack.xaml b/src/modules/launcher/PowerLauncher/Themes/BlurBlack.xaml deleted file mode 100644 index 488048cf44dd..000000000000 --- a/src/modules/launcher/PowerLauncher/Themes/BlurBlack.xaml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - True - - - - - - - - - - - - - - - #356ef3 - - - - - - diff --git a/src/modules/launcher/PowerLauncher/Themes/BlurWhite.xaml b/src/modules/launcher/PowerLauncher/Themes/BlurWhite.xaml deleted file mode 100644 index 2fe9e3185f13..000000000000 --- a/src/modules/launcher/PowerLauncher/Themes/BlurWhite.xaml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - True - - - - - - - - - - - - - - - #356ef3 - - - - - - diff --git a/src/modules/launcher/PowerLauncher/Themes/Dark.xaml b/src/modules/launcher/PowerLauncher/Themes/Dark.xaml index 5bd54b0edaa6..3d382dea82ab 100644 --- a/src/modules/launcher/PowerLauncher/Themes/Dark.xaml +++ b/src/modules/launcher/PowerLauncher/Themes/Dark.xaml @@ -1,40 +1,31 @@  - - - - - - - - - + xmlns:markup="clr-namespace:MahApps.Metro.Markup;assembly=MahApps.Metro" + xmlns:markupWithAssembly="clr-namespace:MahApps.Metro.Markup;assembly=MahApps.Metro" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" xmlns:system="clr-namespace:System;assembly=System.Runtime" + mc:Ignorable="options"> - + + Dark.Accent1 + PowerToysRun + Accent1 (Dark) + Dark + Accent1 + Black - + #66FFFFFF + + + + + + + + + + + + - - - - - - #4F6180 - - - - - - + \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/Themes/Gray.xaml b/src/modules/launcher/PowerLauncher/Themes/Gray.xaml deleted file mode 100644 index e52d4201beb5..000000000000 --- a/src/modules/launcher/PowerLauncher/Themes/Gray.xaml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - #00AAF6 - - - - diff --git a/src/modules/launcher/PowerLauncher/Themes/HighContrast1.xaml b/src/modules/launcher/PowerLauncher/Themes/HighContrast1.xaml new file mode 100644 index 000000000000..1bb26e15fbd2 --- /dev/null +++ b/src/modules/launcher/PowerLauncher/Themes/HighContrast1.xaml @@ -0,0 +1,30 @@ + + + + HighContrast.Accent2 + PowerToysRun + Accent2 (HighContrast) + HighContrast + Accent2 + White + + #FF000000 + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/Themes/HighContrast2.xaml b/src/modules/launcher/PowerLauncher/Themes/HighContrast2.xaml new file mode 100644 index 000000000000..046ed1334047 --- /dev/null +++ b/src/modules/launcher/PowerLauncher/Themes/HighContrast2.xaml @@ -0,0 +1,30 @@ + + + + HighContrast.Accent3 + PowerToysRun + Accent3 (HighContrast) + HighContrast + Accent3 + White + + #FF000000 + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/Themes/HighContrastBlack.xaml b/src/modules/launcher/PowerLauncher/Themes/HighContrastBlack.xaml new file mode 100644 index 000000000000..1f5b996057ff --- /dev/null +++ b/src/modules/launcher/PowerLauncher/Themes/HighContrastBlack.xaml @@ -0,0 +1,30 @@ + + + + HighContrast.Accent4 + PowerToysRun + Accent4 (HighContrast) + HighContrast + Accent4 + White + + #FF000000 + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/Themes/HighContrastWhite.xaml b/src/modules/launcher/PowerLauncher/Themes/HighContrastWhite.xaml new file mode 100644 index 000000000000..dcf20eee4822 --- /dev/null +++ b/src/modules/launcher/PowerLauncher/Themes/HighContrastWhite.xaml @@ -0,0 +1,30 @@ + + + + HighContrast.Accent5 + PowerToysRun + Accent5 (HighContrast) + HighContrast + Accent5 + White + + #FF000000 + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/Themes/Light.xaml b/src/modules/launcher/PowerLauncher/Themes/Light.xaml index 6c373ef6024c..09e9da014e44 100644 --- a/src/modules/launcher/PowerLauncher/Themes/Light.xaml +++ b/src/modules/launcher/PowerLauncher/Themes/Light.xaml @@ -1,50 +1,31 @@ - + - - - + + Light.Accent1 + PowerToysRun + Accent1 (Light) + Light + Accent1 + White - - - - + #66000000 + + + + + + + + + + + + - - - - - - #3875D7 - - - - - \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/Themes/Metro Server.xaml b/src/modules/launcher/PowerLauncher/Themes/Metro Server.xaml deleted file mode 100644 index 9648203946b2..000000000000 --- a/src/modules/launcher/PowerLauncher/Themes/Metro Server.xaml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - #006ac1 - - - \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/Themes/Pink.xaml b/src/modules/launcher/PowerLauncher/Themes/Pink.xaml deleted file mode 100644 index 93f2dee6e3a5..000000000000 --- a/src/modules/launcher/PowerLauncher/Themes/Pink.xaml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - #cc1081 - - - \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/Themes/ThemeBuilder/Template.xaml b/src/modules/launcher/PowerLauncher/Themes/ThemeBuilder/Template.xaml deleted file mode 100644 index 8d1c4845a4e9..000000000000 --- a/src/modules/launcher/PowerLauncher/Themes/ThemeBuilder/Template.xaml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - {%selectedResultBackgroundColor%} - - - - - - diff --git a/src/modules/launcher/PowerLauncher/Themes/ThemeBuilder/ThemeConvertor.py b/src/modules/launcher/PowerLauncher/Themes/ThemeBuilder/ThemeConvertor.py deleted file mode 100644 index 674728ec3d80..000000000000 --- a/src/modules/launcher/PowerLauncher/Themes/ThemeBuilder/ThemeConvertor.py +++ /dev/null @@ -1,26 +0,0 @@ -import os,plistlib - -def convert(path,templatePath): - pl = plistlib.readPlist(path) - with open(templatePath, 'r') as content_file: - template = content_file.read() - for key in pl: - if "rgba" in pl[key]: - template = template.replace("{%"+key+"%}",tohex(pl[key].replace("rgba","rgb"))) - f = open(path.replace(".alfredtheme",".xaml"),'w') - f.write(template) - f.close() - - -def tohex(string): - string = string[4:] - split = string.split(",") - split[2] = ''.join(split[2].split(")")[0]) - r = int(split[0]) - g = int(split[1]) - b = int(split[2]) - tu = (r, g, b) - return '#%02x%02x%02x' % tu - -#print tohex("rgb(255,255,255,0.50)") -print convert("Night.alfredtheme","Light.xaml") diff --git a/src/modules/launcher/Wox.Core/Resource/Theme.cs b/src/modules/launcher/Wox.Core/Resource/Theme.cs deleted file mode 100644 index 05d176089222..000000000000 --- a/src/modules/launcher/Wox.Core/Resource/Theme.cs +++ /dev/null @@ -1,263 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Interop; -using System.Windows.Markup; -using System.Windows.Media; -using Wox.Infrastructure; -using Wox.Infrastructure.Logger; -using Wox.Infrastructure.UserSettings; - -namespace Wox.Core.Resource -{ - public class Theme - { - private readonly List _themeDirectories = new List(); - private ResourceDictionary _oldResource; - private string _oldTheme; - public Settings Settings { get; set; } - private const string Folder = "Themes"; - private const string Extension = ".xaml"; - private string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder); - private string UserDirectoryPath => Path.Combine(Constant.DataDirectory, Folder); - - public Theme() - { - _themeDirectories.Add(DirectoryPath); - _themeDirectories.Add(UserDirectoryPath); - MakeSureThemeDirectoriesExist(); - - var dicts = Application.Current.Resources.MergedDictionaries; - _oldResource = dicts.First(d => - { - var p = d.Source.AbsolutePath; - var dir = Path.GetDirectoryName(p).NonNull(); - var info = new DirectoryInfo(dir); - var f = info.Name; - var e = Path.GetExtension(p); - var found = f == Folder && e == Extension; - return found; - }); - _oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath); - } - - private void MakeSureThemeDirectoriesExist() - { - foreach (string dir in _themeDirectories) - { - if (!Directory.Exists(dir)) - { - try - { - Directory.CreateDirectory(dir); - } - catch (Exception e) - { - Log.Exception($"|Theme.MakeSureThemeDirectoriesExist|Exception when create directory <{dir}>", e); - } - } - } - } - - public bool ChangeTheme(string theme) - { - const string defaultTheme = "Dark"; - - string path = GetThemePath(theme); - try - { - if (string.IsNullOrEmpty(path)) - throw new DirectoryNotFoundException("Theme path can't be found <{path}>"); - - Settings.Theme = theme; - - var dicts = Application.Current.Resources.MergedDictionaries; - //always allow re-loading default theme, in case of failure of switching to a new theme from default theme - if (_oldTheme != theme || theme == defaultTheme) - { - dicts.Remove(_oldResource); - var newResource = GetResourceDictionary(); - dicts.Add(newResource); - _oldResource = newResource; - _oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath); - } - } - catch (DirectoryNotFoundException e) - { - Log.Error($"|Theme.ChangeTheme|Theme <{theme}> path can't be found"); - if (theme != defaultTheme) - { - MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme)); - ChangeTheme(defaultTheme); - } - return false; - } - catch (XamlParseException e) - { - Log.Error($"|Theme.ChangeTheme|Theme <{theme}> fail to parse"); - if (theme != defaultTheme) - { - MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme)); - ChangeTheme(defaultTheme); - } - return false; - } - return true; - } - - public ResourceDictionary GetResourceDictionary() - { - var uri = GetThemePath(Settings.Theme); - var dict = new ResourceDictionary - { - Source = new Uri(uri, UriKind.Absolute) - }; - - Style queryBoxStyle = dict["QueryBoxStyle"] as Style; - if (queryBoxStyle != null) - { - queryBoxStyle.Setters.Add(new Setter(TextBox.FontFamilyProperty, new FontFamily(Settings.QueryBoxFont))); - queryBoxStyle.Setters.Add(new Setter(TextBox.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.QueryBoxFontStyle))); - queryBoxStyle.Setters.Add(new Setter(TextBox.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(Settings.QueryBoxFontWeight))); - queryBoxStyle.Setters.Add(new Setter(TextBox.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(Settings.QueryBoxFontStretch))); - } - - Style resultItemStyle = dict["ItemTitleStyle"] as Style; - Style resultSubItemStyle = dict["ItemSubTitleStyle"] as Style; - Style resultItemSelectedStyle = dict["ItemTitleSelectedStyle"] as Style; - Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style; - if (resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null) - { - Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(Settings.ResultFont)); - Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.ResultFontStyle)); - Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(Settings.ResultFontWeight)); - Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(Settings.ResultFontStretch)); - - Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch }; - Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p))); - } - return dict; - } - - public List LoadAvailableThemes() - { - List themes = new List(); - foreach (var themeDirectory in _themeDirectories) - { - themes.AddRange( - Directory.GetFiles(themeDirectory) - .Where(filePath => filePath.EndsWith(Extension) && !filePath.EndsWith("Base.xaml")) - .ToList()); - } - return themes.OrderBy(o => o).ToList(); - } - - private string GetThemePath(string themeName) - { - foreach (string themeDirectory in _themeDirectories) - { - string path = Path.Combine(themeDirectory, themeName + Extension); - if (File.Exists(path)) - { - return path; - } - } - - return string.Empty; - } - - #region Blur Handling - /* - Found on https://github.com/riverar/sample-win10-aeroglass - */ - private enum AccentState - { - ACCENT_DISABLED = 0, - ACCENT_ENABLE_GRADIENT = 1, - ACCENT_ENABLE_TRANSPARENTGRADIENT = 2, - ACCENT_ENABLE_BLURBEHIND = 3, - ACCENT_INVALID_STATE = 4 - } - - [StructLayout(LayoutKind.Sequential)] - private struct AccentPolicy - { - public AccentState AccentState; - public int AccentFlags; - public int GradientColor; - public int AnimationId; - } - - [StructLayout(LayoutKind.Sequential)] - private struct WindowCompositionAttributeData - { - public WindowCompositionAttribute Attribute; - public IntPtr Data; - public int SizeOfData; - } - - private enum WindowCompositionAttribute - { - WCA_ACCENT_POLICY = 19 - } - [DllImport("user32.dll")] - private static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data); - - /// - /// Sets the blur for a window via SetWindowCompositionAttribute - /// - public void SetBlurForWindow() - { - - // Exception of FindResource can't be caught if global exception handle is set - if (Environment.OSVersion.Version >= new Version(6, 2)) - { - var resource = Application.Current.TryFindResource("ThemeBlurEnabled"); - bool blur; - if (resource is bool) - { - blur = (bool)resource; - } - else - { - blur = false; - } - - if (blur) - { - SetWindowAccent(Application.Current.MainWindow, AccentState.ACCENT_ENABLE_BLURBEHIND); - } - else - { - SetWindowAccent(Application.Current.MainWindow, AccentState.ACCENT_DISABLED); - } - } - } - - private void SetWindowAccent(Window w, AccentState state) - { - var windowHelper = new WindowInteropHelper(w); - var accent = new AccentPolicy { AccentState = state }; - var accentStructSize = Marshal.SizeOf(accent); - - var accentPtr = Marshal.AllocHGlobal(accentStructSize); - Marshal.StructureToPtr(accent, accentPtr, false); - - var data = new WindowCompositionAttributeData - { - Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY, - SizeOfData = accentStructSize, - Data = accentPtr - }; - - SetWindowCompositionAttribute(windowHelper.Handle, ref data); - - Marshal.FreeHGlobal(accentPtr); - } - #endregion - } -} diff --git a/src/modules/launcher/Wox.Core/Resource/ThemeManager.cs b/src/modules/launcher/Wox.Core/Resource/ThemeManager.cs deleted file mode 100644 index 193b0bd534b0..000000000000 --- a/src/modules/launcher/Wox.Core/Resource/ThemeManager.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Wox.Core.Resource -{ - public class ThemeManager - { - private static Theme instance; - private static object syncObject = new object(); - - public static Theme Instance - { - get - { - if (instance == null) - { - lock (syncObject) - { - if (instance == null) - { - instance = new Theme(); - } - } - } - return instance; - } - } - } -} diff --git a/src/modules/launcher/Wox.Core/Wox.Core.csproj b/src/modules/launcher/Wox.Core/Wox.Core.csproj index a4f2eb9c2b5b..3edfdf995fa3 100644 --- a/src/modules/launcher/Wox.Core/Wox.Core.csproj +++ b/src/modules/launcher/Wox.Core/Wox.Core.csproj @@ -57,6 +57,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/modules/launcher/Wox/App.xaml b/src/modules/launcher/Wox/App.xaml deleted file mode 100644 index 53341c629c00..000000000000 --- a/src/modules/launcher/Wox/App.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/modules/launcher/Wox/App.xaml.cs b/src/modules/launcher/Wox/App.xaml.cs deleted file mode 100644 index 4ee71d675993..000000000000 --- a/src/modules/launcher/Wox/App.xaml.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Diagnostics; -using System.Threading.Tasks; -using System.Timers; -using System.Windows; -using Wox.Core; -using Wox.Core.Plugin; -using Wox.Core.Resource; -using Wox.Helper; -using Wox.Infrastructure; -using Wox.Infrastructure.Http; -using Wox.Infrastructure.Image; -using Wox.Infrastructure.Logger; -using Wox.Infrastructure.UserSettings; -using Wox.ViewModel; -using Stopwatch = Wox.Infrastructure.Stopwatch; - -namespace Wox -{ - public partial class App : IDisposable, ISingleInstanceApp - { - public static PublicAPIInstance API { get; private set; } - private const string Unique = "Wox_Unique_Application_Mutex"; - private static bool _disposed; - private Settings _settings; - private MainViewModel _mainVM; - private SettingWindowViewModel _settingsVM; - private readonly Alphabet _alphabet = new Alphabet(); - private StringMatcher _stringMatcher; - - [STAThread] - public static void Main() - { - if (SingleInstance.InitializeAsFirstInstance(Unique)) - { - using (var application = new App()) - { - application.InitializeComponent(); - application.Run(); - } - } - } - - private void OnStartup(object sender, StartupEventArgs e) - { - Stopwatch.Normal("|App.OnStartup|Startup cost", () => - { - Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------"); - Log.Info($"|App.OnStartup|Runtime info:{ErrorReporting.RuntimeInfo()}"); - RegisterAppDomainExceptions(); - RegisterDispatcherUnhandledException(); - - ImageLoader.Initialize(); - - _settingsVM = new SettingWindowViewModel(); - _settings = _settingsVM.Settings; - - _alphabet.Initialize(_settings); - _stringMatcher = new StringMatcher(_alphabet); - StringMatcher.Instance = _stringMatcher; - _stringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision; - - PluginManager.LoadPlugins(_settings.PluginSettings); - _mainVM = new MainViewModel(_settings); - var window = new MainWindow(_settings, _mainVM); - API = new PublicAPIInstance(_settingsVM, _mainVM, _alphabet); - PluginManager.InitializePlugins(API); - - Current.MainWindow = window; - Current.MainWindow.Title = Constant.ExeFileName; - - // happlebao todo temp fix for instance code logic - // load plugin before change language, because plugin language also needs be changed - InternationalizationManager.Instance.Settings = _settings; - InternationalizationManager.Instance.ChangeLanguage(_settings.Language); - // main windows needs initialized before theme change because of blur settings - ThemeManager.Instance.Settings = _settings; - ThemeManager.Instance.ChangeTheme(_settings.Theme); - - Http.Proxy = _settings.Proxy; - - RegisterExitEvents(); - - _mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible; - Log.Info("|App.OnStartup|End Wox startup ---------------------------------------------------- "); - }); - } - - private void RegisterExitEvents() - { - AppDomain.CurrentDomain.ProcessExit += (s, e) => Dispose(); - Current.Exit += (s, e) => Dispose(); - Current.SessionEnding += (s, e) => Dispose(); - } - - /// - /// let exception throw as normal is better for Debug - /// - [Conditional("RELEASE")] - private void RegisterDispatcherUnhandledException() - { - DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException; - } - - - /// - /// let exception throw as normal is better for Debug - /// - [Conditional("RELEASE")] - private static void RegisterAppDomainExceptions() - { - AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle; - } - - public void Dispose() - { - // if sessionending is called, exit proverbially be called when log off / shutdown - // but if sessionending is not called, exit won't be called when log off / shutdown - if (!_disposed) - { - API.SaveAppAllSettings(); - _disposed = true; - } - } - - public void OnSecondAppStarted() - { - Current.MainWindow.Visibility = Visibility.Visible; - } - } -} \ No newline at end of file diff --git a/src/modules/launcher/Wox/MainWindow.xaml.cs b/src/modules/launcher/Wox/MainWindow.xaml.cs index b56904f8a433..bc2b098da5c0 100644 --- a/src/modules/launcher/Wox/MainWindow.xaml.cs +++ b/src/modules/launcher/Wox/MainWindow.xaml.cs @@ -54,7 +54,6 @@ private void OnInitialized(object sender, EventArgs e) private void OnLoaded(object sender, RoutedEventArgs _) { // todo is there a way to set blur only once? - ThemeManager.Instance.SetBlurForWindow(); WindowsInteropHelper.DisableControlBox(this); InitProgressbarAnimation(); InitializePosition(); diff --git a/src/modules/launcher/Wox/ViewModel/SettingWindowViewModel.cs b/src/modules/launcher/Wox/ViewModel/SettingWindowViewModel.cs index f3b9e14b8e10..80523756367d 100644 --- a/src/modules/launcher/Wox/ViewModel/SettingWindowViewModel.cs +++ b/src/modules/launcher/Wox/ViewModel/SettingWindowViewModel.cs @@ -168,13 +168,9 @@ public string SelectedTheme set { Settings.Theme = value; - ThemeManager.Instance.ChangeTheme(value); } } - public List Themes - => ThemeManager.Instance.LoadAvailableThemes().Select(Path.GetFileNameWithoutExtension).ToList(); - public Brush PreviewBackground { get @@ -257,7 +253,6 @@ public FontFamily SelectedQueryBoxFont set { Settings.QueryBoxFont = value.ToString(); - ThemeManager.Instance.ChangeTheme(Settings.Theme); } } @@ -278,7 +273,6 @@ public FamilyTypeface SelectedQueryBoxFontFaces Settings.QueryBoxFontStretch = value.Stretch.ToString(); Settings.QueryBoxFontWeight = value.Weight.ToString(); Settings.QueryBoxFontStyle = value.Style.ToString(); - ThemeManager.Instance.ChangeTheme(Settings.Theme); } } @@ -302,7 +296,6 @@ public FontFamily SelectedResultFont set { Settings.ResultFont = value.ToString(); - ThemeManager.Instance.ChangeTheme(Settings.Theme); } } @@ -323,7 +316,6 @@ public FamilyTypeface SelectedResultFontFaces Settings.ResultFontStretch = value.Stretch.ToString(); Settings.ResultFontWeight = value.Weight.ToString(); Settings.ResultFontStyle = value.Style.ToString(); - ThemeManager.Instance.ChangeTheme(Settings.Theme); } } diff --git a/src/modules/launcher/Wox/Wox.csproj b/src/modules/launcher/Wox/Wox.csproj index e988e96684d7..c5db45087a3e 100644 --- a/src/modules/launcher/Wox/Wox.csproj +++ b/src/modules/launcher/Wox/Wox.csproj @@ -37,14 +37,6 @@ MinimumRecommendedRules.ruleset 4 - - - - - - - -