From 739bf2036eea976d5f17e0b1b305d356bd48ed75 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Wed, 15 Dec 2021 20:36:04 -0600 Subject: [PATCH] Delay Hotkey register & use safe way calling mainwindow animation --- Flow.Launcher/App.xaml.cs | 3 ++- Flow.Launcher/ViewModel/MainViewModel.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 9ee486b3b..1091f2f2f 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -69,7 +69,6 @@ namespace Flow.Launcher PluginManager.LoadPlugins(_settings.PluginSettings); _mainVM = new MainViewModel(_settings); - HotKeyMapper.Initialize(_mainVM); API = new PublicAPIInstance(_settingsVM, _mainVM, _alphabet); @@ -79,6 +78,8 @@ namespace Flow.Launcher await PluginManager.InitializePlugins(API); var window = new MainWindow(_settings, _mainVM); + HotKeyMapper.Initialize(_mainVM); + Log.Info($"|App.OnStartup|Dependencies Info:{ErrorReporting.DependenciesInfo()}"); Current.MainWindow = window; diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index abf3a1d14..a86eb77e7 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -736,7 +736,7 @@ namespace Flow.Launcher.ViewModel { if (_settings.UseSound) { - MediaPlayer media = new MediaPlayer(); + var media = new MediaPlayer(); media.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav")); media.Play(); } @@ -746,7 +746,7 @@ namespace Flow.Launcher.ViewModel MainWindowVisibilityStatus = true; if(_settings.UseAnimation) - ((MainWindow)Application.Current.MainWindow).WindowAnimator(); + ((MainWindow)Application.Current.MainWindow)?.WindowAnimator(); MainWindowOpacity = 1; }