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[] { }); _uwpStorage = new BinaryStorage <UWP.Application[]>("UWP"); _uwps = _uwpStorage.TryLoad(new UWP.Application[] { }); }); Log.Info($"|Wox.Plugin.Program.Main|Number of preload win32 programs <{_win32s.Length}>"); Log.Info($"|Wox.Plugin.Program.Main|Number of preload uwps <{_uwps.Length}>"); Task.Run(() => { Stopwatch.Normal("|Wox.Plugin.Program.Main|Program index cost", IndexPrograms); }); }
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(); _mainWindow?.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()); }); }
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(); _settingsVM = new SettingWindowViewModel(); _settings = _settingsVM.Settings; PluginManager.LoadPlugins(_settings.PluginSettings); _mainVM = new MainViewModel(_settings); var window = new MainWindow(_settings, _mainVM); API = new PublicAPIInstance(_settingsVM, _mainVM); PluginManager.InitializePlugins(API); Current.MainWindow = window; Current.MainWindow.Title = Constant.Wox; // 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 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) { 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 ---------------------------------------------------- "); }); } }
protected override void OnStartup(StartupEventArgs e) { Stopwatch.Debug("Startup Time", () => { base.OnStartup(e); WoxDirectroy.Executable = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString(); RegisterUnhandledException(); ThreadPool.SetMaxThreads(30, 10); ThreadPool.SetMinThreads(10, 5); ThreadPool.QueueUserWorkItem(_ => { ImageLoader.ImageLoader.PreloadImages(); }); MainViewModel mainVM = new MainViewModel(); API = new PublicAPIInstance(mainVM); Window = new MainWindow { DataContext = mainVM }; NotifyIconManager notifyIconManager = new NotifyIconManager(API); PluginManager.Init(API); CommandArgsFactory.Execute(e.Args.ToList()); }); }
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 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) { 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 }); }
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 UpdateResultViewInternal(List <Result> list, PluginMetadata metadata) { Stopwatch.Normal($"UI update cost for {metadata.Name}", () => { Results.AddResults(list, metadata.ID); }); }