protected virtual void Dispose(bool disposing) { if (!_disposed) { Stopwatch.Normal("App.OnExit - Exit cost", () => { Log.Info("Start PowerToys Run Exit---------------------------------------------------- ", GetType()); if (disposing) { if (_themeManager != null) { _themeManager.ThemeChanged -= OnThemeChanged; } API?.SaveAppAllSettings(); PluginManager.Dispose(); _mainWindow?.Dispose(); API?.Dispose(); _mainVM?.Dispose(); _themeManager?.Dispose(); _disposed = true; } // TODO: free unmanaged resources (unmanaged objects) and override finalizer // TODO: set large fields to null _disposed = true; Log.Info("End PowerToys Run Exit ---------------------------------------------------- ", GetType()); }); } }
private void OnStartup(object sender, StartupEventArgs e) { Stopwatch.Normal("|App.OnStartup|Startup cost", () => { Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------"); RegisterDispatcherUnhandledException(); ImageLoader.Initialize(); Alphabet.Initialize(); var settingVM = new SettingWindowViewModel(); _settings = settingVM.Settings; PluginManager.LoadPlugins(_settings.PluginSettings); var mainVM = new MainViewModel(_settings); var window = new MainWindow(_settings, mainVM); API = new PublicAPIInstance(settingVM, mainVM); PluginManager.InitializePlugins(API); Current.MainWindow = window; Current.MainWindow.Title = Constant.Wox; RegisterExitEvents(); AutoStartup(); AutoUpdates(); mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible; Log.Info("|App.OnStartup|End Wox startup ---------------------------------------------------- "); }); }
private void UpdateResultViewInternal(List <Result> list, PluginMetadata metadata) { Dispatcher.Invoke(new Action(() => { Stopwatch.Normal($"UI update cost for {metadata.Name}", () => { pnlResult.AddResults(list, metadata.ID); }); })); }
public static void Initialize() { Format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); Stopwatch.Normal("|Wox.Infrastructure.Alphabet.Initialize|Preload pinyin cache", () => { _pinyinStorage = new BinaryStorage <ConcurrentDictionary <string, string> >("Pinyin"); PinyinCache = _pinyinStorage.TryLoad(new ConcurrentDictionary <string, string>()); // force pinyin library static constructor initialize PinyinHelper.toHanyuPinyinStringArray('T', Format); }); Log.Info( $"|Wox.Infrastructure.Alphabet.Init ialize|Number of preload pinyin combination<{PinyinCache.Count}>"); }
private void OnStartup(object sender, StartupEventArgs e) { Stopwatch.Normal("|App.OnStartup|Startup cost", () => { _portable.PreStartCleanUpAfterPortabilityUpdate(); Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------"); Log.Info($"|App.OnStartup|Runtime info:{ErrorReporting.RuntimeInfo()}"); RegisterAppDomainExceptions(); RegisterDispatcherUnhandledException(); ImageLoader.Initialize(); _settingsVM = new SettingWindowViewModel(_updater, _portable); _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); Log.Info($"|App.OnStartup|Dependencies Info:{ErrorReporting.DependenciesInfo()}"); Current.MainWindow = window; Current.MainWindow.Title = Constant.Wox; // 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 settigns ThemeManager.Instance.Settings = _settings; ThemeManager.Instance.ChangeTheme(_settings.Theme); Http.Proxy = _settings.Proxy; RegisterExitEvents(); AutoStartup(); AutoUpdates(); ParseCommandLineArgs(SingleInstance <App> .CommandLineArgs); _mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible; Log.Info("|App.OnStartup|End Wox startup ---------------------------------------------------- "); }); }
private void InitializePinyinHelpers() { _pinyinFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); Stopwatch.Normal("|Wox.Infrastructure.Alphabet.Initialize|Preload pinyin cache", () => { _pinyinStorage = new BinaryStorage <Dictionary <string, string[][]> >("Pinyin"); SetPinyinCacheAsDictionary(_pinyinStorage.TryLoad(new Dictionary <string, string[][]>())); // force pinyin library static constructor initialize PinyinHelper.toHanyuPinyinStringArray('T', _pinyinFormat); }); Log.Info($"Number of preload pinyin combination<{_pinyinCache.Count}>", GetType()); }
public Main() { _settingsStorage = new PluginJsonStorage <Settings>(); _settings = _settingsStorage.Load(); Stopwatch.Normal("Preload programs", () => { _cacheStorage = new BinaryStorage <ProgramIndexCache>(); _cache = _cacheStorage.Load(); _win32s = _cache.Programs; }); Log.Info($"Preload {_win32s.Length} programs from cache"); Stopwatch.Normal("Program Index", IndexPrograms); }
public Main() { _settingsStorage = new PluginJsonStorage <Settings>(); _settings = _settingsStorage.Load(); Stopwatch.Normal("|Wox.Plugin.Program.Main|Preload programs cost", () => { _win32Storage = new BinaryStorage <Win32[]>("Win32"); _win32s = _win32Storage.TryLoad(new Win32[] { }); }); Log.Info($"|Wox.Plugin.Program.Main|Number of preload win32 programs <{_win32s.Length}>"); Task.Run(() => { Stopwatch.Normal("|Wox.Plugin.Program.Main|Program index cost", IndexPrograms); }); }
private void OnStartup(object sender, StartupEventArgs e) { Stopwatch.Normal("|App.OnStartup|Startup cost", () => { Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------"); RegisterDispatcherUnhandledException(); ImageLoader.Initialize(); Alphabet.Initialize(); var settingVM = new SettingWindowViewModel(); _settings = settingVM.Settings; PluginManager.LoadPlugins(_settings.PluginSettings); var mainVM = new MainViewModel(_settings); var window = new MainWindow(_settings, mainVM); API = new PublicAPIInstance(settingVM, mainVM); PluginManager.InitializePlugins(API); Current.MainWindow = window; Current.MainWindow.Title = Constant.Wox; // happlebao todo temp fix for instance code logic // remove all dictionaries defined in xaml e.g.g App.xaml Current.Resources.MergedDictionaries.Clear(); // 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 settigns ThemeManager.Instance.Settings = _settings; ThemeManager.Instance.ChangeTheme(_settings.Theme); Http.Proxy = _settings.Proxy; RegisterExitEvents(); AutoStartup(); AutoUpdates(); mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible; Log.Info("|App.OnStartup|End Wox startup ---------------------------------------------------- "); }); }
protected virtual void Dispose(bool disposing) { // Prevent two disposes at the same time. lock (_disposingLock) { if (!disposing) { return; } if (_disposed) { return; } _disposed = true; } Stopwatch.Normal("App.OnExit - Exit cost", () => { Log.Info("Start PowerToys Run Exit---------------------------------------------------- ", GetType()); if (disposing) { if (_themeManager != null) { _themeManager.ThemeChanged -= OnThemeChanged; } API?.SaveAppAllSettings(); PluginManager.Dispose(); // Dispose needs to be called on the main Windows thread, since some resources owned by the thread need to be disposed. _mainWindow?.Dispatcher.Invoke(Dispose); API?.Dispose(); _mainVM?.Dispose(); _themeManager?.Dispose(); } // TODO: free unmanaged resources (unmanaged objects) and override finalizer // TODO: set large fields to null Log.Info("End PowerToys Run Exit ---------------------------------------------------- ", GetType()); }); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { Stopwatch.Normal("|App.OnExit|Exit cost", () => { Log.Info("|App.OnExit| Start PowerToys Run Exit---------------------------------------------------- "); if (disposing) { _mainWindow.Dispose(); API.SaveAppAllSettings(); _mainVM.Dispose(); _disposed = true; } // TODO: free unmanaged resources (unmanaged objects) and override finalizer // TODO: set large fields to null _disposed = true; Log.Info("|App.OnExit| End PowerToys Run Exit ---------------------------------------------------- "); }); } }
public Main() { _settingsStorage = new PluginJsonStorage <Settings>(); _settings = _settingsStorage.Load(); Stopwatch.Normal("|Wox.Plugin.Program.Main|Preload programs cost", () => { _win32Storage = new BinaryStorage <Win32[]>("Win32"); _win32s = _win32Storage.TryLoad(new Win32[] { }); #if WINVER_10 _uwpStorage = new BinaryStorage <UWP.Application[]>("UWP"); _uwps = _uwpStorage.TryLoad(new UWP.Application[] { }); #endif }); Log.Info($"|Wox.Plugin.Program.Main|Number of preload win32 programs <{_win32s.Length}>"); #if WINVER_10 Log.Info($"|Wox.Plugin.Program.Main|Number of preload uwps <{_uwps.Length}>"); #endif Task.Run(() => { Stopwatch.Normal("|Wox.Plugin.Program.Main|Program index cost", IndexPrograms); }); }
private void OnStartup(object sender, StartupEventArgs e) { Log.Info("On Startup.", GetType()); var bootTime = new System.Diagnostics.Stopwatch(); bootTime.Start(); Stopwatch.Normal("App.OnStartup - Startup cost", () => { var textToLog = new StringBuilder(); textToLog.AppendLine("Begin PowerToys Run startup ----------------------------------------------------"); textToLog.AppendLine($"Runtime info:{ErrorReporting.RuntimeInfo()}"); RegisterAppDomainExceptions(); RegisterDispatcherUnhandledException(); _themeManager = new ThemeManager(this); ImageLoader.Initialize(_themeManager.GetCurrentTheme()); _settingsVM = new SettingWindowViewModel(); _settings = _settingsVM.Settings; _settings.UsePowerToysRunnerKeyboardHook = e.Args.Contains("--centralized-kb-hook"); _stringMatcher = new StringMatcher(); StringMatcher.Instance = _stringMatcher; _stringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision; _mainVM = new MainViewModel(_settings); _mainWindow = new MainWindow(_settings, _mainVM); API = new PublicAPIInstance(_settingsVM, _mainVM, _themeManager); _settingsReader = new SettingsReader(_settings, _themeManager); _settingsReader.ReadSettings(); PluginManager.InitializePlugins(API); Current.MainWindow = _mainWindow; Current.MainWindow.Title = Constant.ExeFileName; // main windows needs initialized before theme change because of blur settings HttpClient.Proxy = _settings.Proxy; RegisterExitEvents(); _settingsReader.ReadSettingsOnChange(); _mainVM.MainWindowVisibility = Visibility.Visible; _mainVM.ColdStartFix(); _themeManager.ThemeChanged += OnThemeChanged; textToLog.AppendLine("End PowerToys Run startup ---------------------------------------------------- "); bootTime.Stop(); Log.Info(textToLog.ToString(), GetType()); _mainVM.RegisterHotkey(); PowerToysTelemetry.Log.WriteEvent(new LauncherBootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds }); // [Conditional("RELEASE")] // check update every 5 hours // check updates on startup }); }
private void UpdateResultViewInternal(List <Result> list, PluginMetadata metadata) { Stopwatch.Normal($"UI update cost for {metadata.Name}", () => { Results.AddResults(list, metadata.ID); }); }
private void OnStartup(object sender, StartupEventArgs e) { var bootTime = new System.Diagnostics.Stopwatch(); bootTime.Start(); 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(); _settingsWatcher = new SettingsWatcher(_settings); _mainVM.MainWindowVisibility = Visibility.Visible; _mainVM.ColdStartFix(); Log.Info("|App.OnStartup|End Wox startup ---------------------------------------------------- "); bootTime.Stop(); PowerToysTelemetry.Log.WriteEvent(new LauncherBootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds }); //[Conditional("RELEASE")] // check update every 5 hours // check updates on startup }); }
private void OnStartup(object sender, StartupEventArgs e) { Log.Info("On Startup.", GetType()); // Fix for .net 3.1.19 making PowerToys Run not adapt to DPI changes. PowerLauncher.Helper.NativeMethods.SetProcessDPIAware(); var bootTime = new System.Diagnostics.Stopwatch(); bootTime.Start(); Stopwatch.Normal("App.OnStartup - Startup cost", () => { var textToLog = new StringBuilder(); textToLog.AppendLine("Begin PowerToys Run startup ----------------------------------------------------"); textToLog.AppendLine($"Runtime info:{ErrorReporting.RuntimeInfo()}"); RegisterAppDomainExceptions(); RegisterDispatcherUnhandledException(); _themeManager = new ThemeManager(this); ImageLoader.Initialize(_themeManager.GetCurrentTheme()); _settingsVM = new SettingWindowViewModel(); _settings = _settingsVM.Settings; _settings.StartedFromPowerToysRunner = e.Args.Contains("--started-from-runner"); _stringMatcher = new StringMatcher(); StringMatcher.Instance = _stringMatcher; _stringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision; _mainVM = new MainViewModel(_settings); _mainWindow = new MainWindow(_settings, _mainVM); API = new PublicAPIInstance(_settingsVM, _mainVM, _themeManager); _settingsReader = new SettingsReader(_settings, _themeManager); _settingsReader.ReadSettings(); PluginManager.InitializePlugins(API); Current.MainWindow = _mainWindow; Current.MainWindow.Title = Constant.ExeFileName; RegisterExitEvents(); _settingsReader.ReadSettingsOnChange(); _mainVM.MainWindowVisibility = Visibility.Visible; _mainVM.ColdStartFix(); _themeManager.ThemeChanged += OnThemeChanged; textToLog.AppendLine("End PowerToys Run startup ---------------------------------------------------- "); bootTime.Stop(); Log.Info(textToLog.ToString(), GetType()); PowerToysTelemetry.Log.WriteEvent(new LauncherBootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds }); // [Conditional("RELEASE")] // check update every 5 hours // check updates on startup }); }
private void OnStartup(object sender, StartupEventArgs e) { for (int i = 0; i + 1 < e.Args.Length; i++) { if (e.Args[i] == "-powerToysPid") { int powerToysPid; if (int.TryParse(e.Args[i + 1], out powerToysPid)) { RunnerHelper.WaitForPowerToysRunner(powerToysPid, () => { try { Dispose(); } finally { Environment.Exit(0); } }); } break; } } var bootTime = new System.Diagnostics.Stopwatch(); bootTime.Start(); Stopwatch.Normal("|App.OnStartup|Startup cost", () => { Log.Info("Begin PowerToys Run startup ----------------------------------------------------", GetType()); Log.Info($"Runtime info:{ErrorReporting.RuntimeInfo()}", GetType()); RegisterAppDomainExceptions(); RegisterDispatcherUnhandledException(); _themeManager = new ThemeManager(this); ImageLoader.Initialize(_themeManager.GetCurrentTheme()); _settingsVM = new SettingWindowViewModel(); _settings = _settingsVM.Settings; _settings.UsePowerToysRunnerKeyboardHook = e.Args.Contains("--centralized-kb-hook"); _stringMatcher = new StringMatcher(); StringMatcher.Instance = _stringMatcher; _stringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision; PluginManager.LoadPlugins(_settings.PluginSettings); _mainVM = new MainViewModel(_settings); _mainWindow = new MainWindow(_settings, _mainVM); API = new PublicAPIInstance(_settingsVM, _mainVM, _themeManager); PluginManager.InitializePlugins(API); Current.MainWindow = _mainWindow; Current.MainWindow.Title = Constant.ExeFileName; // main windows needs initialized before theme change because of blur settings HttpClient.Proxy = _settings.Proxy; RegisterExitEvents(); _settingsWatcher = new SettingsWatcher(_settings, _themeManager); _mainVM.MainWindowVisibility = Visibility.Visible; _mainVM.ColdStartFix(); _themeManager.ThemeChanged += OnThemeChanged; Log.Info("End PowerToys Run startup ---------------------------------------------------- ", GetType()); bootTime.Stop(); PowerToysTelemetry.Log.WriteEvent(new LauncherBootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds }); // [Conditional("RELEASE")] // check update every 5 hours // check updates on startup }); }