public SettingsReader(PowerToysRunSettings settings, ThemeManager themeManager) { _settingsUtils = new SettingsUtils(); _settings = settings; _themeManager = themeManager; // Apply theme at startup _themeManager.ChangeTheme(_settings.Theme, true); }
public MainViewModel(PowerToysRunSettings settings) { _saved = false; _queryTextBeforeLeaveResults = string.Empty; _currentQuery = _emptyQuery; _disposed = false; _settings = settings ?? throw new ArgumentNullException(nameof(settings)); _historyItemsStorage = new WoxJsonStorage <QueryHistory>(); _userSelectedRecordStorage = new WoxJsonStorage <UserSelectedRecord>(); _topMostRecordStorage = new WoxJsonStorage <TopMostRecord>(); _history = _historyItemsStorage.Load(); _userSelectedRecord = _userSelectedRecordStorage.Load(); _topMostRecord = _topMostRecordStorage.Load(); ContextMenu = new ResultsViewModel(_settings); Results = new ResultsViewModel(_settings); History = new ResultsViewModel(_settings); _selectedResults = Results; InitializeKeyCommands(); RegisterResultsUpdatedEvent(); if (settings != null && settings.UsePowerToysRunnerKeyboardHook) { NativeEventWaiter.WaitForEventLoop(Constants.PowerLauncherSharedEvent(), OnHotkey); _hotkeyHandle = 0; } else { HotkeyManager = new HotkeyManager(); _settings.PropertyChanged += (s, e) => { if (e.PropertyName == nameof(PowerToysRunSettings.Hotkey)) { Application.Current.Dispatcher.Invoke(() => { if (!string.IsNullOrEmpty(_settings.PreviousHotkey)) { HotkeyManager.UnregisterHotkey(_hotkeyHandle); } if (!string.IsNullOrEmpty(_settings.Hotkey)) { SetHotkey(_settings.Hotkey, OnHotkey); } }); } }; SetHotkey(_settings.Hotkey, OnHotkey); SetCustomPluginHotkey(); } }
public SettingsWatcher(PowerToysRunSettings settings, ThemeManager themeManager) { _settingsUtils = new SettingsUtils(new SystemIOProvider()); _settings = settings; _themeManager = themeManager; // Set up watcher _watcher = Microsoft.PowerToys.Settings.UI.Library.Utilities.Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", OverloadSettings); // Load initial settings file OverloadSettings(); }
public MainWindow(PowerToysRunSettings settings, MainViewModel mainVM) : this() { DataContext = mainVM; _viewModel = mainVM; _settings = settings; InitializeComponent(); _firstDeleteTimer.Elapsed += CheckForFirstDelete; _firstDeleteTimer.Interval = 1000; }
public MainWindow(PowerToysRunSettings settings, MainViewModel mainVM) : this() { DataContext = mainVM; _viewModel = mainVM; _settings = settings; InitializeComponent(); _firstDeleteTimer.Elapsed += CheckForFirstDelete; _firstDeleteTimer.Interval = 1000; NativeEventWaiter.WaitForEventLoop(Constants.RunSendSettingsTelemetryEvent(), SendSettingsTelemetry); }
public SettingsReader(PowerToysRunSettings settings, ThemeManager themeManager) { _settingsUtils = new SettingsUtils(); _settings = settings; _themeManager = themeManager; var overloadSettings = _settingsUtils.GetSettingsOrDefault <PowerLauncherSettings>(PowerLauncherSettings.ModuleName); UpdateSettings(overloadSettings); _settingsUtils.SaveSettings(overloadSettings.ToJsonString(), PowerLauncherSettings.ModuleName); // Apply theme at startup _themeManager.ChangeTheme(_settings.Theme, true); }
public SettingsWatcher(PowerToysRunSettings settings, ThemeManager themeManager) { _settingsUtils = new SettingsUtils(); _settings = settings; _themeManager = themeManager; // Set up watcher _watcher = Microsoft.PowerToys.Settings.UI.Library.Utilities.Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", OverloadSettings); // Load initial settings file OverloadSettings(); // Apply theme at startup _themeManager.ChangeTheme(_settings.Theme, true); }
public ResultsViewModel(PowerToysRunSettings settings) : this() { _settings = settings ?? throw new ArgumentNullException(nameof(settings)); _settings.PropertyChanged += (s, e) => { if (e.PropertyName == nameof(_settings.MaxResultsToShow)) { Application.Current.Dispatcher.Invoke(() => { OnPropertyChanged(nameof(MaxHeight)); }); } }; }
public MainViewModel(PowerToysRunSettings settings) { _saved = false; _queryTextBeforeLeaveResults = string.Empty; _currentQuery = _emptyQuery; _disposed = false; _settings = settings ?? throw new ArgumentNullException(nameof(settings)); _historyItemsStorage = new WoxJsonStorage <QueryHistory>(); _userSelectedRecordStorage = new WoxJsonStorage <UserSelectedRecord>(); _history = _historyItemsStorage.Load(); _userSelectedRecord = _userSelectedRecordStorage.Load(); ContextMenu = new ResultsViewModel(_settings); Results = new ResultsViewModel(_settings); History = new ResultsViewModel(_settings); _selectedResults = Results; InitializeKeyCommands(); RegisterResultsUpdatedEvent(); }
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) { 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 }); }