From 14247fa75a278b3e35158181144539660b0a7e06 Mon Sep 17 00:00:00 2001 From: Clint Rutkas Date: Wed, 22 Jul 2020 13:27:17 -0700 Subject: [PATCH] Dev/crutkas/fixing warnings (#5161) * new lines & braces * Tabs /space auto fix Co-authored-by: Clint Rutkas --- .../Telemetry/PowerToysTelemetry.cs | 2 +- .../DoubleProperty.cs | 1 - .../EnabledModules.cs | 2 +- .../OutGoingGeneralSettings.cs | 2 +- .../PowerPreviewProperties.cs | 1 - .../PowerRenameLocalProperties.cs | 1 - .../PowerRenameSettingsIPCMessage.cs | 1 - .../ShortcutGuideProperties.cs | 1 - .../ShortcutGuideSettingsIPCMessage.cs | 3 +- .../SndImageResizerSettings.cs | 1 - .../SndModuleSettings.cs | 2 +- .../SndShortcutGuideSettings.cs | 4 +- .../Program.cs | 3 +- .../Helpers/Observable.cs | 2 +- .../ViewModels/PowerLauncherViewModel.cs | 516 +++++++++--------- .../ViewModels/PowerRenameViewModel.cs | 2 +- .../ModelsTests/SettingsUtilsTests.cs | 4 +- .../UnitTestApp.xaml.cs | 2 +- .../ViewModelTests/FancyZones.cs | 8 +- .../ViewModelTests/General.cs | 4 +- .../colorPicker/ColorPickerUI/App.xaml.cs | 5 +- .../ColorPickerUI/Behaviors/ResizeBehavior.cs | 3 +- .../ColorPickerUI/Mouse/CursorManager.cs | 2 +- .../ColorPickerUI/Settings/UserSettings.cs | 4 +- .../editor/FancyZonesEditor/App.xaml.cs | 3 +- .../editor/FancyZonesEditor/Native.cs | 2 +- .../Microsoft.Plugin.Calculator/Main.cs | 4 +- .../NumberTranslator.cs | 2 +- .../ContextMenuLoader.cs | 4 +- .../Plugins/Microsoft.Plugin.Folder/Main.cs | 4 +- .../ContextMenuLoader.cs | 14 +- .../DriveDetection/RegistryWrapper.cs | 4 +- .../SearchHelper/OleDBSearch.cs | 2 +- .../SearchHelper/WindowsSearchAPI.cs | 7 +- .../Programs/UWPTests.cs | 2 +- .../Programs/Win32Tests.cs | 2 +- .../Storage/ListRepositoryTests.cs | 20 +- .../Storage/Win32ProgramRepositoryTest.cs | 14 +- .../Plugins/Microsoft.Plugin.Program/Main.cs | 2 +- .../Programs/AppxPackageHelper.cs | 2 +- .../Programs/PackageWrapper.cs | 6 +- .../Programs/ShellLinkHelper.cs | 2 +- .../Microsoft.Plugin.Program/Programs/UWP.cs | 62 +-- .../Programs/Win32.cs | 66 +-- .../Microsoft.Plugin.Program/Settings.cs | 2 +- .../Storage/PackageRepository.cs | 2 +- .../Storage/Win32ProgramFileSystemWatchers.cs | 2 +- .../Storage/Win32ProgramRepository.cs | 12 +- .../Views/ProgramSetting.xaml.cs | 12 +- .../Plugins/Microsoft.Plugin.Shell/Main.cs | 8 +- .../Microsoft.Plugin.Shell/Settings.cs | 2 +- .../ShellSetting.xaml.cs | 4 +- .../Components/InteropAndHelpers.cs | 4 +- .../Components/OpenWindows.cs | 2 +- .../Components/SearchController.cs | 2 +- .../Components/WindowResult.cs | 6 +- .../launcher/PowerLauncher/App.xaml.cs | 5 +- .../PowerLauncher/Helper/ErrorReporting.cs | 4 +- .../PowerLauncher/Helper/ResultCollection.cs | 4 +- .../PowerLauncher/Helper/SingleInstance.cs | 26 +- .../launcher/PowerLauncher/MainWindow.xaml.cs | 26 +- .../PowerLauncher/PublicAPIInstance.cs | 8 +- .../launcher/PowerLauncher/Settings.cs | 25 +- .../launcher/PowerLauncher/SettingsWatcher.cs | 4 +- .../ViewModel/ContextMenuItemViewModel.cs | 3 +- .../PowerLauncher/ViewModel/MainViewModel.cs | 44 +- .../ViewModel/ResultViewModel.cs | 4 +- .../ViewModel/ResultsViewModel.cs | 4 +- .../ViewModel/SettingWindowViewModel.cs | 2 +- .../Wox.Core/Plugin/ExecutablePlugin.cs | 6 +- .../launcher/Wox.Core/Plugin/JsonPRCModel.cs | 3 +- .../launcher/Wox.Core/Plugin/PluginManager.cs | 10 +- .../launcher/Wox.Core/Resource/FontHelper.cs | 5 +- .../launcher/Wox.Infrastructure/Alphabet.cs | 10 +- .../Exception/ExceptionFormatter.cs | 6 +- .../FileVersionInfoWrapper.cs | 2 +- .../launcher/Wox.Infrastructure/Helper.cs | 2 +- .../Wox.Infrastructure/Hotkey/HotkeyModel.cs | 2 +- .../Wox.Infrastructure/Image/ImageCache.cs | 2 +- .../Wox.Infrastructure/Image/ImageLoader.cs | 2 +- .../Image/ThumbnailReader.cs | 4 +- .../launcher/Wox.Infrastructure/Logger/Log.cs | 2 +- .../Storage/BinaryStorage.cs | 2 +- .../Storage/FileSystemWatcherWrapper.cs | 12 +- .../Wox.Infrastructure/Storage/JsonStorage.cs | 2 +- .../Storage/ListRepository.cs | 6 +- .../Storage/PluginJsonStorage.cs | 2 +- .../Storage/StoragePowerToysVersionInfo.cs | 16 +- .../Wox.Infrastructure/StringMatcher.cs | 26 +- .../UserSettings/PluginSettings.cs | 2 +- .../UserSettings/Settings.cs | 7 +- .../launcher/Wox.Plugin/PluginMetadata.cs | 4 +- src/modules/launcher/Wox.Plugin/PluginPair.cs | 2 +- src/modules/launcher/Wox.Plugin/Result.cs | 5 +- .../launcher/Wox.Plugin/ThemeManager.cs | 12 +- .../launcher/Wox.Plugin/ToolTipData.cs | 4 +- .../launcher/Wox.Test/FuzzyMatcherTest.cs | 4 +- .../launcher/Wox.Test/MainViewModelTest.cs | 2 +- .../Wox.Test/Plugins/WindowsIndexerTest.cs | 2 +- .../HTMLParsingExtensionTest.cs | 2 +- .../MarkdownPreviewHandlerTest.cs | 8 +- .../FormHandlerControlTests.cs | 4 +- .../StreamWrapperTests.cs | 24 +- .../SvgPreviewControlTests.cs | 14 +- .../EditorCanvasZoneResizeTests.cs | 8 +- .../EditorCustomLayoutsTests.cs | 6 +- .../EditorGridZoneResizeTests.cs | 10 +- .../FancyZonesTests/EditorOpeningTests.cs | 4 +- .../FancyZonesTests/EditorSettingsTests.cs | 6 +- .../EditorTemplatesEditTests.cs | 2 +- .../FancyZonesSettingsTests.cs | 58 +- src/tests/win-app-driver/PowerToysSession.cs | 6 +- .../win-app-driver/PowerToysTrayTests.cs | 28 +- .../win-app-driver/TestShortcutHelper.cs | 12 +- 114 files changed, 694 insertions(+), 681 deletions(-) diff --git a/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs b/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs index 30982a252..5a25d7a9c 100644 --- a/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs +++ b/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs @@ -13,7 +13,7 @@ namespace Microsoft.PowerToys.Telemetry /// public class PowerToysTelemetry : TelemetryBase { - + /// /// Name for ETW event. /// diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/DoubleProperty.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/DoubleProperty.cs index c953ffae6..1d714d93e 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/DoubleProperty.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/DoubleProperty.cs @@ -7,7 +7,6 @@ using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib { - // Represents the configuration property of the settings that store Double type. public class DoubleProperty { diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs index c95f51a09..bbec91a44 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs @@ -148,7 +148,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib return JsonSerializer.Serialize(this); } - private void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null ) + private void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null) { var dataEvent = new SettingsEnabledEvent() { diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/OutGoingGeneralSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/OutGoingGeneralSettings.cs index c99d24dbe..2fade3fa2 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/OutGoingGeneralSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/OutGoingGeneralSettings.cs @@ -26,4 +26,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib return JsonSerializer.Serialize(this); } } -} \ No newline at end of file +} diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerPreviewProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerPreviewProperties.cs index 935f99689..48ccf048f 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerPreviewProperties.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerPreviewProperties.cs @@ -65,7 +65,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public PowerPreviewProperties() { - } public override string ToString() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs index 820c3898c..c48563fcc 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs @@ -7,7 +7,6 @@ using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib { - public class PowerRenameLocalProperties { public PowerRenameLocalProperties() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettingsIPCMessage.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettingsIPCMessage.cs index 9a56de6bc..f895249b0 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettingsIPCMessage.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettingsIPCMessage.cs @@ -13,7 +13,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public PowerRenameSettingsIPCMessage() { - } public PowerRenameSettingsIPCMessage(SndPowerRenameSettings settings) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideProperties.cs index 11b0193f1..0a4f525dc 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideProperties.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideProperties.cs @@ -9,7 +9,6 @@ using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib { - public class ShortcutGuideProperties { public ShortcutGuideProperties() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideSettingsIPCMessage.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideSettingsIPCMessage.cs index 714e04277..c0c835b18 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideSettingsIPCMessage.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideSettingsIPCMessage.cs @@ -17,7 +17,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public ShortcutGuideSettingsIPCMessage() { - } public ShortcutGuideSettingsIPCMessage(SndShortcutGuideSettings settings) @@ -30,4 +29,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib return JsonSerializer.Serialize(this); } } -} \ No newline at end of file +} diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndImageResizerSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndImageResizerSettings.cs index c49011d8e..c4fb20ac2 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndImageResizerSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndImageResizerSettings.cs @@ -10,7 +10,6 @@ using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib { - public class SndImageResizerSettings { [JsonPropertyName("Image Resizer")] diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndModuleSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndModuleSettings.cs index aed13e7d0..db849614b 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndModuleSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndModuleSettings.cs @@ -27,4 +27,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib return JsonSerializer.Serialize(this); } } -} \ No newline at end of file +} diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndShortcutGuideSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndShortcutGuideSettings.cs index 45685b74d..01a80f95c 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndShortcutGuideSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndShortcutGuideSettings.cs @@ -6,7 +6,6 @@ using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib { - public class SndShortcutGuideSettings { [JsonPropertyName("Shortcut Guide")] @@ -14,7 +13,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public SndShortcutGuideSettings() { - } public SndShortcutGuideSettings(ShortcutGuideSettings settings) @@ -27,4 +25,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib return JsonSerializer.Serialize(this); } } -} \ No newline at end of file +} diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Runner/Program.cs b/src/core/Microsoft.PowerToys.Settings.UI.Runner/Program.cs index adb6b745b..d92afeeb7 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Runner/Program.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Runner/Program.cs @@ -58,7 +58,8 @@ namespace Microsoft.PowerToys.Settings.UI.Runner IsUserAnAdmin = false; } - RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () => { + RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () => + { Environment.Exit(0); }); diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Helpers/Observable.cs b/src/core/Microsoft.PowerToys.Settings.UI/Helpers/Observable.cs index d70825aeb..19c925537 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/Helpers/Observable.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI/Helpers/Observable.cs @@ -11,7 +11,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers { public event PropertyChangedEventHandler PropertyChanged; - protected void Set(ref T storage, T value, [CallerMemberName]string propertyName = null) + protected void Set(ref T storage, T value, [CallerMemberName] string propertyName = null) { if (Equals(storage, value)) { diff --git a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerLauncherViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerLauncherViewModel.cs index 5e4bc01f1..b1e2128e2 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerLauncherViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerLauncherViewModel.cs @@ -1,258 +1,258 @@ -// Copyright (c) Microsoft Corporation -// The Microsoft Corporation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -using System.Runtime.CompilerServices; -using System.Text.Json; - -using Microsoft.PowerToys.Settings.UI.Helpers; -using Microsoft.PowerToys.Settings.UI.Lib; -using Microsoft.PowerToys.Settings.UI.Views; - -namespace Microsoft.PowerToys.Settings.UI.ViewModels -{ - public class PowerLauncherViewModel : Observable - { - private PowerLauncherSettings settings; - private GeneralSettings generalSettings; - - public delegate void SendCallback(PowerLauncherSettings settings); - - private readonly SendCallback callback; - - public PowerLauncherViewModel() - { - callback = (PowerLauncherSettings settings) => - { - // Propagate changes to Power Launcher through IPC - ShellPage.DefaultSndMSGCallback( - string.Format("{{ \"powertoys\": {{ \"{0}\": {1} }} }}", PowerLauncherSettings.ModuleName, JsonSerializer.Serialize(settings))); - }; - if (SettingsUtils.SettingsExists(PowerLauncherSettings.ModuleName)) - { - settings = SettingsUtils.GetSettings(PowerLauncherSettings.ModuleName); - } - else - { - settings = new PowerLauncherSettings(); - settings.Properties.open_powerlauncher.Alt = true; - settings.Properties.open_powerlauncher.Code = (int)Windows.System.VirtualKey.Space; - settings.Properties.maximum_number_of_results = 4; - callback(settings); - } - - if (SettingsUtils.SettingsExists()) - { - generalSettings = SettingsUtils.GetSettings(); - } - else - { - generalSettings = new GeneralSettings(); - } - } - - public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback) - { - this.settings = settings; - this.callback = callback; - } - - private void UpdateSettings([CallerMemberName] string propertyName = null) - { - // Notify UI of property change - OnPropertyChanged(propertyName); - - callback(settings); - } - - public bool EnablePowerLauncher - { - get - { - return generalSettings.Enabled.PowerLauncher; - } - - set - { - if (generalSettings.Enabled.PowerLauncher != value) - { - generalSettings.Enabled.PowerLauncher = value; - OnPropertyChanged(nameof(EnablePowerLauncher)); - OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(generalSettings); - ShellPage.DefaultSndMSGCallback(outgoing.ToString()); - } - } - } - - public string SearchResultPreference - { - get - { - return settings.Properties.search_result_preference; - } - - set - { - if (settings.Properties.search_result_preference != value) - { - settings.Properties.search_result_preference = value; - UpdateSettings(); - } - } - } - - public string SearchTypePreference - { - get - { - return settings.Properties.search_type_preference; - } - - set - { - if (settings.Properties.search_type_preference != value) - { - settings.Properties.search_type_preference = value; - UpdateSettings(); - } - } - } - - public int MaximumNumberOfResults - { - get - { - return settings.Properties.maximum_number_of_results; - } - - set - { - if (settings.Properties.maximum_number_of_results != value) - { - settings.Properties.maximum_number_of_results = value; - UpdateSettings(); - } - } - } - - public HotkeySettings OpenPowerLauncher - { - get - { - return settings.Properties.open_powerlauncher; - } - - set - { - if (settings.Properties.open_powerlauncher != value) - { - settings.Properties.open_powerlauncher = value; - UpdateSettings(); - } - } - } - - public HotkeySettings OpenFileLocation - { - get - { - return settings.Properties.open_file_location; - } - - set - { - if (settings.Properties.open_file_location != value) - { - settings.Properties.open_file_location = value; - UpdateSettings(); - } - } - } - - public HotkeySettings CopyPathLocation - { - get - { - return settings.Properties.copy_path_location; - } - - set - { - if (settings.Properties.copy_path_location != value) - { - settings.Properties.copy_path_location = value; - UpdateSettings(); - } - } - } - - public bool OverrideWinRKey - { - get - { - return settings.Properties.override_win_r_key; - } - - set - { - if (settings.Properties.override_win_r_key != value) - { - settings.Properties.override_win_r_key = value; - UpdateSettings(); - } - } - } - - public bool OverrideWinSKey - { - get - { - return settings.Properties.override_win_s_key; - } - - set - { - if (settings.Properties.override_win_s_key != value) - { - settings.Properties.override_win_s_key = value; - UpdateSettings(); - } - } - } - - public bool IgnoreHotkeysInFullScreen - { - get - { - return settings.Properties.ignore_hotkeys_in_fullscreen; - } - - set - { - if (settings.Properties.ignore_hotkeys_in_fullscreen != value) - { - settings.Properties.ignore_hotkeys_in_fullscreen = value; - UpdateSettings(); - } - } - } - - public bool ClearInputOnLaunch - { - get - { - return settings.Properties.clear_input_on_launch; - } - - set - { - if (settings.Properties.clear_input_on_launch != value) - { - settings.Properties.clear_input_on_launch = value; - UpdateSettings(); - } - } - } - +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System.Runtime.CompilerServices; +using System.Text.Json; + +using Microsoft.PowerToys.Settings.UI.Helpers; +using Microsoft.PowerToys.Settings.UI.Lib; +using Microsoft.PowerToys.Settings.UI.Views; + +namespace Microsoft.PowerToys.Settings.UI.ViewModels +{ + public class PowerLauncherViewModel : Observable + { + private PowerLauncherSettings settings; + private GeneralSettings generalSettings; + + public delegate void SendCallback(PowerLauncherSettings settings); + + private readonly SendCallback callback; + + public PowerLauncherViewModel() + { + callback = (PowerLauncherSettings settings) => + { + // Propagate changes to Power Launcher through IPC + ShellPage.DefaultSndMSGCallback( + string.Format("{{ \"powertoys\": {{ \"{0}\": {1} }} }}", PowerLauncherSettings.ModuleName, JsonSerializer.Serialize(settings))); + }; + if (SettingsUtils.SettingsExists(PowerLauncherSettings.ModuleName)) + { + settings = SettingsUtils.GetSettings(PowerLauncherSettings.ModuleName); + } + else + { + settings = new PowerLauncherSettings(); + settings.Properties.open_powerlauncher.Alt = true; + settings.Properties.open_powerlauncher.Code = (int)Windows.System.VirtualKey.Space; + settings.Properties.maximum_number_of_results = 4; + callback(settings); + } + + if (SettingsUtils.SettingsExists()) + { + generalSettings = SettingsUtils.GetSettings(); + } + else + { + generalSettings = new GeneralSettings(); + } + } + + public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback) + { + this.settings = settings; + this.callback = callback; + } + + private void UpdateSettings([CallerMemberName] string propertyName = null) + { + // Notify UI of property change + OnPropertyChanged(propertyName); + + callback(settings); + } + + public bool EnablePowerLauncher + { + get + { + return generalSettings.Enabled.PowerLauncher; + } + + set + { + if (generalSettings.Enabled.PowerLauncher != value) + { + generalSettings.Enabled.PowerLauncher = value; + OnPropertyChanged(nameof(EnablePowerLauncher)); + OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(generalSettings); + ShellPage.DefaultSndMSGCallback(outgoing.ToString()); + } + } + } + + public string SearchResultPreference + { + get + { + return settings.Properties.search_result_preference; + } + + set + { + if (settings.Properties.search_result_preference != value) + { + settings.Properties.search_result_preference = value; + UpdateSettings(); + } + } + } + + public string SearchTypePreference + { + get + { + return settings.Properties.search_type_preference; + } + + set + { + if (settings.Properties.search_type_preference != value) + { + settings.Properties.search_type_preference = value; + UpdateSettings(); + } + } + } + + public int MaximumNumberOfResults + { + get + { + return settings.Properties.maximum_number_of_results; + } + + set + { + if (settings.Properties.maximum_number_of_results != value) + { + settings.Properties.maximum_number_of_results = value; + UpdateSettings(); + } + } + } + + public HotkeySettings OpenPowerLauncher + { + get + { + return settings.Properties.open_powerlauncher; + } + + set + { + if (settings.Properties.open_powerlauncher != value) + { + settings.Properties.open_powerlauncher = value; + UpdateSettings(); + } + } + } + + public HotkeySettings OpenFileLocation + { + get + { + return settings.Properties.open_file_location; + } + + set + { + if (settings.Properties.open_file_location != value) + { + settings.Properties.open_file_location = value; + UpdateSettings(); + } + } + } + + public HotkeySettings CopyPathLocation + { + get + { + return settings.Properties.copy_path_location; + } + + set + { + if (settings.Properties.copy_path_location != value) + { + settings.Properties.copy_path_location = value; + UpdateSettings(); + } + } + } + + public bool OverrideWinRKey + { + get + { + return settings.Properties.override_win_r_key; + } + + set + { + if (settings.Properties.override_win_r_key != value) + { + settings.Properties.override_win_r_key = value; + UpdateSettings(); + } + } + } + + public bool OverrideWinSKey + { + get + { + return settings.Properties.override_win_s_key; + } + + set + { + if (settings.Properties.override_win_s_key != value) + { + settings.Properties.override_win_s_key = value; + UpdateSettings(); + } + } + } + + public bool IgnoreHotkeysInFullScreen + { + get + { + return settings.Properties.ignore_hotkeys_in_fullscreen; + } + + set + { + if (settings.Properties.ignore_hotkeys_in_fullscreen != value) + { + settings.Properties.ignore_hotkeys_in_fullscreen = value; + UpdateSettings(); + } + } + } + + public bool ClearInputOnLaunch + { + get + { + return settings.Properties.clear_input_on_launch; + } + + set + { + if (settings.Properties.clear_input_on_launch != value) + { + settings.Properties.clear_input_on_launch = value; + UpdateSettings(); + } + } + } + public bool DisableDriveDetectionWarning { get @@ -268,6 +268,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels UpdateSettings(); } } - } - } -} + } + } +} diff --git a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerRenameViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerRenameViewModel.cs index 3e47cedd0..e0aca1cf7 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerRenameViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerRenameViewModel.cs @@ -195,4 +195,4 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels } } } -} \ No newline at end of file +} diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/SettingsUtilsTests.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/SettingsUtilsTests.cs index 1445ebf3b..b8ac78dd9 100644 --- a/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/SettingsUtilsTests.cs +++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/SettingsUtilsTests.cs @@ -59,7 +59,7 @@ namespace CommonLibTest BasePTSettingsTest expected_json = JsonSerializer.Deserialize(file_contents_correct_json_content); // Act - if(SettingsUtils.SettingsFolderExists(file_name)) + if (SettingsUtils.SettingsFolderExists(file_name)) { DeleteFolder(file_name); } @@ -75,7 +75,7 @@ namespace CommonLibTest public void SettingsFolderExists_ShouldReturnFalse_WhenFilePathIsNotFound() { // Arrange - string file_name_random = "test\\"+ RandomString(); + string file_name_random = "test\\" + RandomString(); string file_name_exists = "test\\exists"; string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}"; diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/UnitTestApp.xaml.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/UnitTestApp.xaml.cs index 8acaacca7..9e66dc703 100644 --- a/src/core/Microsoft.PowerToys.Settings.UnitTest/UnitTestApp.xaml.cs +++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/UnitTestApp.xaml.cs @@ -66,7 +66,7 @@ namespace Microsoft.PowerToys.Settings.UnitTest // Place the frame in the current Window Window.Current.Content = rootFrame; } - + Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI(); // Ensure the current window is active diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/FancyZones.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/FancyZones.cs index 45e8f2b09..908b53807 100644 --- a/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/FancyZones.cs +++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/FancyZones.cs @@ -272,7 +272,7 @@ namespace ViewModelTests { // arrange FancyZonesViewModel viewModel = new FancyZonesViewModel(); - Assert.AreEqual(ConfigDefaults.DefaultFancyZonesZoneHighlightColor, ToRGBHex(viewModel.ZoneHighlightColor)); + Assert.AreEqual(ConfigDefaults.DefaultFancyZonesZoneHighlightColor, ToRGBHex(viewModel.ZoneHighlightColor)); // Assert ShellPage.DefaultSndMSGCallback = msg => @@ -282,7 +282,7 @@ namespace ViewModelTests }; // act - viewModel.ZoneHighlightColor = Color.FromArgb(0, 225,225,225); + viewModel.ZoneHighlightColor = Color.FromArgb(0, 225, 225, 225); } [TestMethod] @@ -290,7 +290,7 @@ namespace ViewModelTests { // arrange FancyZonesViewModel viewModel = new FancyZonesViewModel(); - Assert.AreEqual(ConfigDefaults.DefaultFancyzonesBorderColor, ToRGBHex(viewModel.ZoneBorderColor)); + Assert.AreEqual(ConfigDefaults.DefaultFancyzonesBorderColor, ToRGBHex(viewModel.ZoneBorderColor)); // Assert ShellPage.DefaultSndMSGCallback = msg => @@ -308,7 +308,7 @@ namespace ViewModelTests { // arrange FancyZonesViewModel viewModel = new FancyZonesViewModel(); - Assert.AreEqual(ConfigDefaults.DefaultFancyZonesInActiveColor, ToRGBHex(viewModel.ZoneInActiveColor)); + Assert.AreEqual(ConfigDefaults.DefaultFancyZonesInActiveColor, ToRGBHex(viewModel.ZoneInActiveColor)); // Assert ShellPage.DefaultSndMSGCallback = msg => diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/General.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/General.cs index 4e027828c..84d2d0351 100644 --- a/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/General.cs +++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/General.cs @@ -49,10 +49,10 @@ namespace ViewModelTests { // Arrange GeneralViewModel viewModel = new GeneralViewModel(); - + Assert.AreEqual(viewModel.RunningAsUserDefaultText, viewModel.RunningAsText); Assert.IsFalse(viewModel.IsElevated); - + // Act viewModel.IsElevated = true; diff --git a/src/modules/colorPicker/ColorPickerUI/App.xaml.cs b/src/modules/colorPicker/ColorPickerUI/App.xaml.cs index 3c3563ca2..775961da0 100644 --- a/src/modules/colorPicker/ColorPickerUI/App.xaml.cs +++ b/src/modules/colorPicker/ColorPickerUI/App.xaml.cs @@ -46,12 +46,13 @@ namespace ColorPickerUI return; } - if(_args.Length > 0) + if (_args.Length > 0) { _ = int.TryParse(_args[0], out _powerToysPid); } - RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () => { + RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () => + { Environment.Exit(0); }); diff --git a/src/modules/colorPicker/ColorPickerUI/Behaviors/ResizeBehavior.cs b/src/modules/colorPicker/ColorPickerUI/Behaviors/ResizeBehavior.cs index c710945dc..e1818e7b9 100644 --- a/src/modules/colorPicker/ColorPickerUI/Behaviors/ResizeBehavior.cs +++ b/src/modules/colorPicker/ColorPickerUI/Behaviors/ResizeBehavior.cs @@ -14,7 +14,8 @@ namespace ColorPicker.Behaviors { var sender = ((ResizeBehavior)d).AssociatedObject; var move = new DoubleAnimation(sender.Width, (double)e.NewValue, new Duration(TimeSpan.FromMilliseconds(150)), FillBehavior.Stop); - move.Completed += (s, e1) => { + move.Completed += (s, e1) => + { sender.BeginAnimation(FrameworkElement.WidthProperty, null); sender.Width = (double)e.NewValue; }; move.EasingFunction = new QuadraticEase() { EasingMode = EasingMode.EaseOut }; diff --git a/src/modules/colorPicker/ColorPickerUI/Mouse/CursorManager.cs b/src/modules/colorPicker/ColorPickerUI/Mouse/CursorManager.cs index 61ed0e89a..a18c2643d 100644 --- a/src/modules/colorPicker/ColorPickerUI/Mouse/CursorManager.cs +++ b/src/modules/colorPicker/ColorPickerUI/Mouse/CursorManager.cs @@ -38,7 +38,7 @@ namespace ColorPicker.Mouse { try { - if(curFile != null) + if (curFile != null) { Registry.SetValue(CursorsRegistryPath, cursorRegistryName, curFile); Win32Apis.SystemParametersInfo(SPI_SETCURSORS, 0, new IntPtr(0), SPIF_SENDCHANGE); diff --git a/src/modules/colorPicker/ColorPickerUI/Settings/UserSettings.cs b/src/modules/colorPicker/ColorPickerUI/Settings/UserSettings.cs index 0f7bb853c..13124522a 100644 --- a/src/modules/colorPicker/ColorPickerUI/Settings/UserSettings.cs +++ b/src/modules/colorPicker/ColorPickerUI/Settings/UserSettings.cs @@ -25,7 +25,7 @@ namespace ColorPicker.Settings ChangeCursor = new SettingItem(true); ActivationShortcut = new SettingItem(DefaultActivationShortcut); CopiedColorRepresentation = new SettingItem(ColorRepresentationType.HEX); - + LoadSettingsFromJson(); _watcher = Helper.GetFileWatcher(ColorPickerModuleName, "settings.json", LoadSettingsFromJson); } @@ -76,7 +76,7 @@ namespace ColorPicker.Settings Logger.LogError("Failed to read changed settings", ex); Thread.Sleep(500); } - catch(Exception ex) + catch (Exception ex) { Logger.LogError("Failed to read changed settings", ex); } diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs index f415366de..5fecf1d57 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs @@ -25,7 +25,8 @@ namespace FancyZonesEditor private void OnStartup(object sender, StartupEventArgs e) { - RunnerHelper.WaitForPowerToysRunner(Settings.PowerToysPID, () => { + RunnerHelper.WaitForPowerToysRunner(Settings.PowerToysPID, () => + { Environment.Exit(0); }); diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Native.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Native.cs index 1eb1a5419..64da24667 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Native.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Native.cs @@ -11,7 +11,7 @@ namespace FancyZonesEditor internal static class Native { [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Ansi)] - public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)]string lpFileName); + public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpFileName); [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] public static extern IntPtr GetProcAddress(IntPtr hModule, string procName); diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/Main.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/Main.cs index 29cda2497..6b997c52d 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/Main.cs @@ -44,7 +44,7 @@ namespace Microsoft.Plugin.Calculator var result = MagesEngine.Interpret(query.Search); // This could happen for some incorrect queries, like pi(2) - if(result == null) + if (result == null) { return new List(); } @@ -86,7 +86,7 @@ namespace Microsoft.Plugin.Calculator thread.Join(); return ret; } - } + } }; } } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/NumberTranslator.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/NumberTranslator.cs index 32b7cac5b..57e9aefce 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/NumberTranslator.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/NumberTranslator.cs @@ -63,7 +63,7 @@ namespace Microsoft.Plugin.Calculator { return Translate(input, this.sourceCulture, this.targetCulture, this.splitRegexForSource); } - + /// /// Translate from target to source culture. /// diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/ContextMenuLoader.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/ContextMenuLoader.cs index 7a2a3dd1c..87c15f17f 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/ContextMenuLoader.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/ContextMenuLoader.cs @@ -111,7 +111,7 @@ namespace Microsoft.Plugin.Folder { Process.Start("explorer.exe", $" /select,\"{record.FullPath}\""); } - catch(Exception e) + catch (Exception e) { var message = $"Fail to open file at {record.FullPath}"; LogException(message, e); @@ -159,7 +159,7 @@ namespace Microsoft.Plugin.Folder private bool CanRunAsDifferentUser(string path) { - switch(Path.GetExtension(path)) + switch (Path.GetExtension(path)) { case ".exe": case ".bat": diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Main.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Main.cs index ab963cb2d..8adc5105c 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Main.cs @@ -197,7 +197,7 @@ namespace Microsoft.Plugin.Folder { if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue; - if(fileSystemInfo is DirectoryInfo) + if (fileSystemInfo is DirectoryInfo) { var folderSubtitleString = fileSystemInfo.FullName; @@ -246,7 +246,7 @@ namespace Microsoft.Plugin.Folder return true; }, - ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath} + ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath } }; return result; } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/ContextMenuLoader.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/ContextMenuLoader.cs index cf1a3d63b..b9c330870 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/ContextMenuLoader.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/ContextMenuLoader.cs @@ -24,7 +24,7 @@ namespace Microsoft.Plugin.Indexer } // Extensions for adding run as admin context menu item for applications - private readonly string[] appExtensions = { ".exe", ".bat", ".appref-ms", ".lnk" }; + private readonly string[] appExtensions = { ".exe", ".bat", ".appref-ms", ".lnk" }; public ContextMenuLoader(PluginInitContext context) { @@ -44,7 +44,7 @@ namespace Microsoft.Plugin.Indexer } // Test to check if File can be Run as admin, if yes, we add a 'run as admin' context menu item - if(CanFileBeRunAsAdmin(record.Path)) + if (CanFileBeRunAsAdmin(record.Path)) { contextMenus.Add(CreateRunAsAdminContextMenu(record)); } @@ -55,7 +55,7 @@ namespace Microsoft.Plugin.Indexer Title = _context.API.GetTranslation("Microsoft_plugin_indexer_copy_path"), Glyph = "\xE8C8", FontFamily = "Segoe MDL2 Assets", - AcceleratorKey = Key.C, + AcceleratorKey = Key.C, AcceleratorModifiers = ModifierKeys.Control, Action = (context) => @@ -128,7 +128,7 @@ namespace Microsoft.Plugin.Indexer Task.Run(() => Helper.RunAsAdmin(record.Path)); return true; } - catch(Exception e) + catch (Exception e) { Log.Exception($"|Microsoft.Plugin.Indexer.ContextMenu| Failed to run {record.Path} as admin, {e.Message}", e); return false; @@ -142,9 +142,9 @@ namespace Microsoft.Plugin.Indexer private bool CanFileBeRunAsAdmin(string path) { string fileExtension = Path.GetExtension(path); - foreach(string extension in appExtensions) + foreach (string extension in appExtensions) { - if(extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase)) + if (extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase)) { return true; } @@ -169,7 +169,7 @@ namespace Microsoft.Plugin.Indexer { Process.Start("explorer.exe", $" /select,\"{record.Path}\""); } - catch(Exception e) + catch (Exception e) { var message = $"Fail to open file at {record.Path}"; LogException(message, e); diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/DriveDetection/RegistryWrapper.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/DriveDetection/RegistryWrapper.cs index 804918b2f..91cc8dd0e 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/DriveDetection/RegistryWrapper.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/DriveDetection/RegistryWrapper.cs @@ -14,10 +14,10 @@ namespace Microsoft.Plugin.Indexer.DriveDetection { using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(registryLocation)) { - if(regKey != null) + if (regKey != null) { Object value = regKey.GetValue(valueName); - if(value != null) + if (value != null) { return (int)value; } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/OleDBSearch.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/OleDBSearch.cs index 7903f4b4a..c17913b4c 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/OleDBSearch.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/OleDBSearch.cs @@ -69,7 +69,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper resultDisposed = true; } - if(conn.State == System.Data.ConnectionState.Closed) + if (conn.State == System.Data.ConnectionState.Closed) { connDisposed = true; } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs index c0520c9df..1d3d3a569 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs @@ -30,7 +30,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper List oleDBResults = WindowsIndexerSearch.Query(queryHelper.ConnectionString, sqlQuery); // Loop over all records from the database - foreach(OleDBResult oleDBResult in oleDBResults) + foreach (OleDBResult oleDBResult in oleDBResults) { if (oleDBResult.fieldData[0] == DBNull.Value || oleDBResult.fieldData[1] == DBNull.Value || oleDBResult.fieldData[2] == DBNull.Value) { @@ -49,7 +49,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper Title = (string)oleDBResult.fieldData[1] }; _Result.Add(result); - } + } } return _Result; @@ -105,7 +105,8 @@ namespace Microsoft.Plugin.Indexer.SearchHelper public IEnumerable Search(string keyword, string pattern = "*", int maxCount = 30) { - lock(_lock){ + lock (_lock) + { ISearchQueryHelper queryHelper; InitQueryHelper(out queryHelper, maxCount); ModifyQueryHelper(ref queryHelper, pattern); diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/UWPTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/UWPTests.cs index 534b9b768..d01275a74 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/UWPTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/UWPTests.cs @@ -79,7 +79,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs // Arrange PackageWrapper invalidPackagedApp = new PackageWrapper(); Main._settings = new Settings(); - List packages = new List() {invalidPackagedApp }; + List packages = new List() { invalidPackagedApp }; var mock = new Mock(); mock.Setup(x => x.FindPackagesForCurrentUser()).Returns(packages); UWP.PackageManagerWrapper = mock.Object; diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/Win32Tests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/Win32Tests.cs index b12db73ae..df6146594 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/Win32Tests.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Programs/Win32Tests.cs @@ -56,7 +56,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs Name = "Command Prompt", ExecutableName = "cmd.exe", FullPath = "c:\\windows\\system32\\cmd.exe", - LnkResolvedPath ="c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\command prompt.lnk", + LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\command prompt.lnk", AppType = 2 }; diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ListRepositoryTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ListRepositoryTests.cs index fd1953419..2f7adc4a5 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ListRepositoryTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/ListRepositoryTests.cs @@ -64,8 +64,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage { //Arrange ListRepository repository = new ListRepository(); - var numItems = 1000; - for(var i=0; i - { - for (var i = 0; i < numItems; ++i) - { - repository.Add($"NewItem_{i}"); - } - }); + var addTask = Task.Run(() => + { + for (var i = 0; i < numItems; ++i) + { + repository.Add($"NewItem_{i}"); + } + }); //Assert that this does not throw. Collections that aren't syncronized will throw an invalidoperatioexception if the list is modified while enumerating - Assert.DoesNotThrowAsync(async () => + Assert.DoesNotThrowAsync(async () => { await Task.WhenAll(new Task[] { iterationTask, addTask }); }); diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/Win32ProgramRepositoryTest.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/Win32ProgramRepositoryTest.cs index 252310fec..ef527e75f 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/Win32ProgramRepositoryTest.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program.UnitTests/Storage/Win32ProgramRepositoryTest.cs @@ -42,9 +42,9 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage // Arrange Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage>("Win32"), _settings, _pathsToWatch); - Win32 item1 = new Win32 - { - Name = name, + Win32 item1 = new Win32 + { + Name = name, ExecutableName = exename, FullPath = fullPath, Description = description1 @@ -108,7 +108,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage { // Arrange Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage>("Win32"), _settings, _pathsToWatch); - RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory , newpath, oldpath); + RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, newpath, oldpath); string oldFullPath = directory + "\\" + oldpath; string newFullPath = directory + "\\" + newpath; @@ -132,12 +132,12 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage // Arrange Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage>("Win32"), _settings, _pathsToWatch); FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path); - + // FileVersionInfo must be mocked for exe applications var mockFileVersionInfo = new Mock(); mockFileVersionInfo.Setup(m => m.GetVersionInfo(It.IsAny())).Returns((FileVersionInfo)null); Win32._fileVersionInfoWrapper = mockFileVersionInfo.Object; - + // Act _fileSystemMocks[0].Raise(m => m.Created += null, e); @@ -377,7 +377,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage string oldFullPath = directory + "\\" + oldpath; string FullPath = directory + "\\" + path; - + // ShellLinkHelper must be mocked for lnk applications var mockShellLink = new Mock(); mockShellLink.Setup(m => m.RetrieveTargetPath(It.IsAny())).Returns(String.Empty); diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Main.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Main.cs index e852310dd..c3115cf48 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Main.cs @@ -66,7 +66,7 @@ namespace Microsoft.Plugin.Program Task.WaitAll(a, b); _settings.LastIndexTime = DateTime.Today; - + } public void Save() diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/AppxPackageHelper.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/AppxPackageHelper.cs index f9605a574..cf68de5ba 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/AppxPackageHelper.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/AppxPackageHelper.cs @@ -74,7 +74,7 @@ namespace Microsoft.Plugin.Program.Programs public interface IAppxManifestProperties { [PreserveSig] - int GetBoolValue([MarshalAs(UnmanagedType.LPWStr)]string name, out bool value); + int GetBoolValue([MarshalAs(UnmanagedType.LPWStr)] string name, out bool value); [PreserveSig] int GetStringValue([MarshalAs(UnmanagedType.LPWStr)] string name, [MarshalAs(UnmanagedType.LPWStr)] out string value); } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/PackageWrapper.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/PackageWrapper.cs index fa153d819..2bd667be2 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/PackageWrapper.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/PackageWrapper.cs @@ -36,7 +36,7 @@ namespace Microsoft.Plugin.Program.Programs string path; try { - path = package.InstalledLocation.Path; + path = package.InstalledLocation.Path; } catch (Exception e) when (e is ArgumentException || e is FileNotFoundException) { @@ -48,11 +48,11 @@ namespace Microsoft.Plugin.Program.Programs package.Id.Name, package.Id.FullName, package.Id.FamilyName, - package.IsFramework, + package.IsFramework, package.IsDevelopmentMode, path ); - + } } } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/ShellLinkHelper.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/ShellLinkHelper.cs index c5a74f737..a0588d70e 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/ShellLinkHelper.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/ShellLinkHelper.cs @@ -117,7 +117,7 @@ namespace Microsoft.Plugin.Program.Programs { ((IPersistFile)link).Load(path, STGM_READ); } - catch(System.IO.FileNotFoundException ex) + catch (System.IO.FileNotFoundException ex) { ProgramLogger.LogException($"|Win32| ShellLinkHelper.retrieveTargetPath | {path} | Path could not be retrieved", ex); return String.Empty; diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs index 47fac6c6d..d8ad80c1f 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs @@ -41,7 +41,7 @@ namespace Microsoft.Plugin.Program.Programs public static IPackageManager PackageManagerWrapper { get; set; } = new PackageManagerWrapper(); public UWP(IPackage package) - { + { Name = package.Name; FullName = package.FullName; FamilyName = package.FamilyName; @@ -63,10 +63,10 @@ namespace Microsoft.Plugin.Program.Programs if (hResult == Hresult.Ok) { - var apps = new List(); - + var apps = new List(); + List _apps = _helper.getAppsFromManifest(stream); - foreach(var _app in _apps) + foreach (var _app in _apps) { var app = new Application(_app, this); apps.Add(app); @@ -194,12 +194,12 @@ namespace Microsoft.Plugin.Program.Programs } catch (Exception e) { - ProgramLogger.LogException("UWP" ,"CurrentUserPackages", $"id","An unexpected error occurred and " + ProgramLogger.LogException("UWP", "CurrentUserPackages", $"id", "An unexpected error occurred and " + $"unable to verify if package is valid", e); return false; - } - - + } + + return valid; }); @@ -242,7 +242,7 @@ namespace Microsoft.Plugin.Program.Programs public string Name => DisplayName; public string Location => Package.Location; public bool Enabled { get; set; } - public bool CanRunElevated {get;set;} + public bool CanRunElevated { get; set; } public string LogoUri { get; set; } public string LogoPath { get; set; } @@ -253,7 +253,7 @@ namespace Microsoft.Plugin.Program.Programs { var displayNameMatch = StringMatcher.FuzzySearch(query, DisplayName); var descriptionMatch = StringMatcher.FuzzySearch(query, Description); - var score = new[] { displayNameMatch.Score, descriptionMatch.Score/2 }.Max(); + var score = new[] { displayNameMatch.Score, descriptionMatch.Score / 2 }.Max(); return score; } @@ -325,23 +325,23 @@ namespace Microsoft.Plugin.Program.Programs } } ); - } - contextMenus.Add( - new ContextMenuResult - { - PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = api.GetTranslation("wox_plugin_program_open_containing_folder"), - Glyph = "\xE838", - FontFamily = "Segoe MDL2 Assets", - AcceleratorKey = Key.E, - AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift), - Action = _ => - { - Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location)); - - return true; - } - }); + } + contextMenus.Add( + new ContextMenuResult + { + PluginName = Assembly.GetExecutingAssembly().GetName().Name, + Title = api.GetTranslation("wox_plugin_program_open_containing_folder"), + Glyph = "\xE838", + FontFamily = "Segoe MDL2 Assets", + AcceleratorKey = Key.E, + AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift), + Action = _ => + { + Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location)); + + return true; + } + }); contextMenus.Add(new ContextMenuResult { @@ -436,7 +436,7 @@ namespace Microsoft.Plugin.Program.Programs if (File.Exists(manifest)) { var file = File.ReadAllText(manifest); - if(file.Contains("TrustLevel=\"mediumIL\"", StringComparison.InvariantCultureIgnoreCase)) + if (file.Contains("TrustLevel=\"mediumIL\"", StringComparison.InvariantCultureIgnoreCase)) { return true; } @@ -565,8 +565,8 @@ namespace Microsoft.Plugin.Program.Programs { var end = path.Length - extension.Length; var prefix = path.Substring(0, end); - var paths = new List { path }; - + var paths = new List { path }; + var scaleFactors = new Dictionary> { // scale factors on win10: https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-app-assets#asset-size-tables, @@ -594,7 +594,7 @@ namespace Microsoft.Plugin.Program.Programs else { int appIconSize = 36; - var targetSizes = new List{16, 24, 30, 36, 44, 60, 72, 96, 128, 180, 256}.AsParallel(); + var targetSizes = new List { 16, 24, 30, 36, 44, 60, 72, 96, 128, 180, 256 }.AsParallel(); Dictionary pathFactorPairs = new Dictionary(); foreach (var factor in targetSizes) diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32.cs index 472361e88..54799bbb9 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32.cs @@ -64,7 +64,7 @@ namespace Microsoft.Plugin.Program.Programs var nameMatch = StringMatcher.FuzzySearch(query, Name); var descriptionMatch = StringMatcher.FuzzySearch(query, Description); var executableNameMatch = StringMatcher.FuzzySearch(query, ExecutableName); - var score = new[] { nameMatch.Score, descriptionMatch.Score/2, executableNameMatch.Score }.Max(); + var score = new[] { nameMatch.Score, descriptionMatch.Score / 2, executableNameMatch.Score }.Max(); return score; } @@ -81,7 +81,7 @@ namespace Microsoft.Plugin.Program.Programs public bool FilterWebApplication(string query) { // If the app is not a web application, then do not filter it - if(!IsWebApplication()) + if (!IsWebApplication()) { return false; } @@ -101,7 +101,7 @@ namespace Microsoft.Plugin.Program.Programs pathContainsQuery = true; } - if(Name.Contains(subquery, StringComparison.OrdinalIgnoreCase)) + if (Name.Contains(subquery, StringComparison.OrdinalIgnoreCase)) { nameContainsQuery = true; } @@ -112,19 +112,19 @@ namespace Microsoft.Plugin.Program.Programs // Function to set the subtitle based on the Type of application private string SetSubtitle(IPublicAPI api) { - if(AppType == (uint)ApplicationTypes.WIN32_APPLICATION) + if (AppType == (uint)ApplicationTypes.WIN32_APPLICATION) { return api.GetTranslation("powertoys_run_plugin_program_win32_application"); } - else if(AppType == (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION) + else if (AppType == (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION) { return api.GetTranslation("powertoys_run_plugin_program_internet_shortcut_application"); } - else if(AppType == (uint)ApplicationTypes.WEB_APPLICATION) + else if (AppType == (uint)ApplicationTypes.WEB_APPLICATION) { return api.GetTranslation("powertoys_run_plugin_program_web_application"); } - else if(AppType == (uint)ApplicationTypes.RUN_COMMAND) + else if (AppType == (uint)ApplicationTypes.RUN_COMMAND) { return api.GetTranslation("powertoys_run_plugin_program_run_command"); } @@ -153,7 +153,7 @@ namespace Microsoft.Plugin.Program.Programs return null; } - if(!hasArguments) + if (!hasArguments) { var noArgumentScoreModifier = 5; score += noArgumentScoreModifier; @@ -168,7 +168,7 @@ namespace Microsoft.Plugin.Program.Programs } // NOTE: This is to display run commands only when there is an exact match, like in start menu - if(!QueryEqualsNameForRunCommands(query)) + if (!QueryEqualsNameForRunCommands(query)) { return null; } @@ -330,27 +330,27 @@ namespace Microsoft.Plugin.Program.Programs const string urlPrefix = "URL="; const string iconFilePrefix = "IconFile="; - foreach(string line in lines) + foreach (string line in lines) { - if(line.StartsWith(urlPrefix)) + if (line.StartsWith(urlPrefix)) { urlPath = line.Substring(urlPrefix.Length); Uri uri = new Uri(urlPath); // To filter out only those steam shortcuts which have 'run' or 'rungameid' as the hostname - if(InternetShortcutURLPrefixes.Match(urlPath).Success) + if (InternetShortcutURLPrefixes.Match(urlPath).Success) { validApp = true; } } - if(line.StartsWith(iconFilePrefix)) + if (line.StartsWith(iconFilePrefix)) { iconPath = line.Substring(iconFilePrefix.Length); } } - if(!validApp) + if (!validApp) { return new Win32() { Valid = false, Enabled = false }; } @@ -386,8 +386,8 @@ namespace Microsoft.Plugin.Program.Programs try { const int MAX_PATH = 260; - StringBuilder buffer = new StringBuilder(MAX_PATH); - + StringBuilder buffer = new StringBuilder(MAX_PATH); + string target = _helper.RetrieveTargetPath(path); if (!string.IsNullOrEmpty(target)) @@ -473,25 +473,25 @@ namespace Microsoft.Plugin.Program.Programs string extension = Path.GetExtension(path); - if(extension.Equals(exeExtension, StringComparison.OrdinalIgnoreCase)) + if (extension.Equals(exeExtension, StringComparison.OrdinalIgnoreCase)) { app = ExeProgram(path); } - else if(extension.Equals(lnkExtension, StringComparison.OrdinalIgnoreCase)) + else if (extension.Equals(lnkExtension, StringComparison.OrdinalIgnoreCase)) { app = LnkProgram(path); } - else if(extension.Equals(apprefExtension, StringComparison.OrdinalIgnoreCase)) + else if (extension.Equals(apprefExtension, StringComparison.OrdinalIgnoreCase)) { app = Win32Program(path); } - else if(extension.Equals(urlExtenion, StringComparison.OrdinalIgnoreCase)) + else if (extension.Equals(urlExtenion, StringComparison.OrdinalIgnoreCase)) { app = InternetShortcutProgram(path); } - + // if the app is valid, only then return the application, else return null - if(app?.Valid ?? false) + if (app?.Valid ?? false) { return app; } @@ -511,8 +511,8 @@ namespace Microsoft.Plugin.Program.Programs var files = new List(); var folderQueue = new Queue(); - folderQueue.Enqueue(directory); - + folderQueue.Enqueue(directory); + do { var currentDirectory = folderQueue.Dequeue(); @@ -540,7 +540,7 @@ namespace Microsoft.Plugin.Program.Programs try { // If the search is set to be non-recursive, then do not enqueue the child directories. - if(!recursiveSearch) + if (!recursiveSearch) { continue; } @@ -606,9 +606,9 @@ namespace Microsoft.Plugin.Program.Programs IEnumerable toFilterAllPaths = new List(); bool isRecursiveSearch = true; - foreach(string path in searchPaths) + foreach (string path in searchPaths) { - if(path.Length > 0) + if (path.Length > 0) { // to expand any environment variables present in the path string directory = Environment.ExpandEnvironmentVariables(path); @@ -629,7 +629,7 @@ namespace Microsoft.Plugin.Program.Programs var allPrograms = programs1.Concat(programs2).Where(p => p.Valid) .Concat(programs3).Where(p => p.Valid) .Concat(programs4).Where(p => p.Valid) - .Select( p => { p.AppType = (uint)ApplicationTypes.RUN_COMMAND; return p; }); + .Select(p => { p.AppType = (uint)ApplicationTypes.RUN_COMMAND; return p; }); return allPrograms; } @@ -643,8 +643,8 @@ namespace Microsoft.Plugin.Program.Programs { var _paths = ProgramPaths(location, suffixes); toFilter = toFilter.Concat(_paths); - } - + } + var paths = toFilter .Where(t1 => !disabledProgramsList.Any(x => x.UniqueIdentifier == t1)) .Select(t1 => t1) @@ -665,7 +665,7 @@ namespace Microsoft.Plugin.Program.Programs { var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Programs); var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms); - List IndexLocation = new List() { directory1, directory2}; + List IndexLocation = new List() { directory1, directory2 }; return IndexPath(suffixes, IndexLocation); } @@ -777,8 +777,8 @@ namespace Microsoft.Plugin.Program.Programs { public bool Equals(Win32 app1, Win32 app2) { - - if(!string.IsNullOrEmpty(app1.Name) && !string.IsNullOrEmpty(app2.Name) + + if (!string.IsNullOrEmpty(app1.Name) && !string.IsNullOrEmpty(app2.Name) && !string.IsNullOrEmpty(app1.ExecutableName) && !string.IsNullOrEmpty(app2.ExecutableName) && !string.IsNullOrEmpty(app1.FullPath) && !string.IsNullOrEmpty(app2.FullPath)) { diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Settings.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Settings.cs index cbb3156d4..7c447af09 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Settings.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Settings.cs @@ -9,7 +9,7 @@ namespace Microsoft.Plugin.Program public DateTime LastIndexTime { get; set; } public List ProgramSources { get; set; } = new List(); public List DisabledProgramSources { get; set; } = new List(); - public string[] ProgramSuffixes { get; set; } = {"bat", "appref-ms", "exe", "lnk", "url"}; + public string[] ProgramSuffixes { get; set; } = { "bat", "appref-ms", "exe", "lnk", "url" }; public bool EnableStartMenuSource { get; set; } = true; diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/PackageRepository.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/PackageRepository.cs index 502f0c69f..9bee7c362 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/PackageRepository.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/PackageRepository.cs @@ -35,7 +35,7 @@ namespace Microsoft.Plugin.Program.Storage try { var packageWrapper = PackageWrapper.GetWrapperFromPackage(args.Package); - if(!string.IsNullOrEmpty(packageWrapper.InstalledLocation)) + if (!string.IsNullOrEmpty(packageWrapper.InstalledLocation)) { var uwp = new UWP(packageWrapper); uwp.InitializeAppInfo(packageWrapper.InstalledLocation); diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramFileSystemWatchers.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramFileSystemWatchers.cs index 96efa82bd..8db3124ce 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramFileSystemWatchers.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramFileSystemWatchers.cs @@ -52,7 +52,7 @@ namespace Microsoft.Plugin.Program.Storage { if (disposing) { - for(int index = 0; index < _pathsToWatch.Length; index++) + for (int index = 0; index < _pathsToWatch.Length; index++) { _fileSystemWatchers[index].Dispose(); } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs index 735db5d11..15f69abe8 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs @@ -17,7 +17,7 @@ namespace Microsoft.Plugin.Program.Storage private IList _fileSystemWatcherHelpers; private string[] _pathsToWatch; private int _numberOfPathsToWatch; - private Collection extensionsToWatch = new Collection{ "*.exe", "*.lnk", "*.appref-ms", "*.url" }; + private Collection extensionsToWatch = new Collection { "*.exe", "*.lnk", "*.appref-ms", "*.url" }; private readonly string lnkExtension = ".lnk"; private readonly string urlExtension = ".url"; @@ -33,7 +33,7 @@ namespace Microsoft.Plugin.Program.Storage private void InitializeFileSystemWatchers() { - for(int index = 0; index < _numberOfPathsToWatch; index++) + for (int index = 0; index < _numberOfPathsToWatch; index++) { // To set the paths to monitor _fileSystemWatcherHelpers[index].Path = _pathsToWatch[index]; @@ -77,7 +77,7 @@ namespace Microsoft.Plugin.Program.Storage { oldApp = new Win32() { Name = Path.GetFileNameWithoutExtension(e.OldName), ExecutableName = newApp.ExecutableName, FullPath = newApp.FullPath }; } - else if(extension.Equals(urlExtension, StringComparison.OrdinalIgnoreCase)) + else if (extension.Equals(urlExtension, StringComparison.OrdinalIgnoreCase)) { oldApp = new Win32() { Name = Path.GetFileNameWithoutExtension(e.OldName), ExecutableName = Path.GetFileName(e.OldName), FullPath = newApp.FullPath }; } @@ -126,7 +126,7 @@ namespace Microsoft.Plugin.Program.Storage app = Programs.Win32.GetAppFromPath(path); } } - catch(Exception ex) + catch (Exception ex) { Log.Info($"|Win32ProgramRepository|OnAppDeleted-{extension}Program|{path}|Unable to create program from {path}| {ex.Message}"); } @@ -154,7 +154,7 @@ namespace Microsoft.Plugin.Program.Storage // Unlike the rename event args, since we do not have a newPath, we iterate through all the programs and find the one with the same LnkResolved path. private Programs.Win32 GetAppWithSameLnkResolvedPath(string lnkResolvedPath) { - foreach(Programs.Win32 app in Items) + foreach (Programs.Win32 app in Items) { if (lnkResolvedPath.ToLower().Equals(app.LnkResolvedPath)) { @@ -167,7 +167,7 @@ namespace Microsoft.Plugin.Program.Storage private void OnAppCreated(object sender, FileSystemEventArgs e) { string path = e.FullPath; - if(!Path.GetExtension(path).Equals(urlExtension)) + if (!Path.GetExtension(path).Equals(urlExtension)) { Programs.Win32 app = Programs.Win32.GetAppFromPath(path); if (app != null) diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Views/ProgramSetting.xaml.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Views/ProgramSetting.xaml.cs index 7802eeb59..70f774095 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Views/ProgramSetting.xaml.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Views/ProgramSetting.xaml.cs @@ -58,7 +58,7 @@ namespace Microsoft.Plugin.Program.Views private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e) { var add = new AddProgramSource(context, _settings); - if(add.ShowDialog() ?? false) + if (add.ShowDialog() ?? false) { ReIndexing(); } @@ -139,14 +139,14 @@ namespace Microsoft.Plugin.Program.Views UniqueIdentifier = directory }; - directoriesToAdd.Add(source); + directoriesToAdd.Add(source); } } if (directoriesToAdd.Count() > 0) { directoriesToAdd.ForEach(x => _settings.ProgramSources.Add(x)); - directoriesToAdd.ForEach(x => ProgramSettingDisplayList.Add(x)); + directoriesToAdd.ForEach(x => ProgramSettingDisplayList.Add(x)); programSourceView.Items.Refresh(); ReIndexing(); @@ -212,8 +212,8 @@ namespace Microsoft.Plugin.Program.Views ProgramSettingDisplayList.SetProgramSourcesStatus(selectedItems, true); ProgramSettingDisplayList.RemoveDisabledFromSettings(); - } - + } + if (selectedItems.IsReindexRequired()) ReIndexing(); @@ -256,7 +256,7 @@ namespace Microsoft.Plugin.Program.Views var sortBy = columnBinding?.Path.Path ?? headerClicked.Column.Header as string; Sort(sortBy, direction); - + _lastHeaderClicked = headerClicked; _lastDirection = direction; } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Main.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Main.cs index 9311408bb..ad51f0246 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Main.cs @@ -198,7 +198,7 @@ namespace Microsoft.Plugin.Shell else if (_settings.Shell == Shell.RunCommand) { //Open explorer if the path is a file or directory - if(Directory.Exists(command) || File.Exists(command)) + if (Directory.Exists(command) || File.Exists(command)) { info = ShellCommand.SetProcessStartInfo("explorer.exe", arguments: command, verb: runAsAdministratorArg); } @@ -236,11 +236,11 @@ namespace Microsoft.Plugin.Shell return info; } - private void Execute(Func startProcess,ProcessStartInfo info) + private void Execute(Func startProcess, ProcessStartInfo info) { try { - startProcess(info); + startProcess(info); } catch (FileNotFoundException e) { @@ -248,7 +248,7 @@ namespace Microsoft.Plugin.Shell var message = $"Command not found: {e.Message}"; _context.API.ShowMsg(name, message); } - catch(Win32Exception e) + catch (Win32Exception e) { var name = "Plugin: Shell"; var message = $"Error running the command: {e.Message}"; diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Settings.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Settings.cs index 61c9af1b0..2c248a1e1 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Settings.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Settings.cs @@ -5,7 +5,7 @@ namespace Microsoft.Plugin.Shell public class Settings { public Shell Shell { get; set; } = Shell.RunCommand; - + // not overriding Win+R // crutkas we need to earn the right for Win+R override public bool ReplaceWinR { get; set; } = false; diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/ShellSetting.xaml.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/ShellSetting.xaml.cs index 62d103bbb..149931925 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/ShellSetting.xaml.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/ShellSetting.xaml.cs @@ -49,10 +49,10 @@ namespace Microsoft.Plugin.Shell _settings.ReplaceWinR = false; }; - ShellComboBox.SelectedIndex = (int) _settings.Shell; + ShellComboBox.SelectedIndex = (int)_settings.Shell; ShellComboBox.SelectionChanged += (o, e) => { - _settings.Shell = (Shell) ShellComboBox.SelectedIndex; + _settings.Shell = (Shell)ShellComboBox.SelectedIndex; LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand; }; } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/InteropAndHelpers.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/InteropAndHelpers.cs index f20aa0331..7d92d9d26 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/InteropAndHelpers.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/InteropAndHelpers.cs @@ -815,7 +815,7 @@ namespace Microsoft.Plugin.WindowWalker.Components public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); [DllImport("psapi.dll")] - public static extern uint GetProcessImageFileName(IntPtr hProcess, [Out] StringBuilder lpImageFileName, [In] [MarshalAs(UnmanagedType.U4)] int nSize); + public static extern uint GetProcessImageFileName(IntPtr hProcess, [Out] StringBuilder lpImageFileName, [In][MarshalAs(UnmanagedType.U4)] int nSize); [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr GetProp(IntPtr hWnd, string lpString); @@ -824,7 +824,7 @@ namespace Microsoft.Plugin.WindowWalker.Components public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId); [DllImport("dwmapi.dll", EntryPoint = "#113", CallingConvention = CallingConvention.StdCall)] - public static extern int DwmpActivateLivePreview([MarshalAs(UnmanagedType.Bool)]bool fActivate, IntPtr hWndExclude, IntPtr hWndInsertBefore, LivePreviewTrigger lpt, IntPtr prcFinalRect); + public static extern int DwmpActivateLivePreview([MarshalAs(UnmanagedType.Bool)] bool fActivate, IntPtr hWndExclude, IntPtr hWndInsertBefore, LivePreviewTrigger lpt, IntPtr prcFinalRect); [DllImport("dwmapi.dll", PreserveSig = false)] public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize); diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/OpenWindows.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/OpenWindows.cs index 46e6f5fa6..5044010c5 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/OpenWindows.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/OpenWindows.cs @@ -91,7 +91,7 @@ namespace Microsoft.Plugin.WindowWalker.Components Window newWindow = new Window(hwnd); if (newWindow.IsWindow && newWindow.Visible && newWindow.IsOwner && - (!newWindow.IsToolWindow || newWindow.IsAppWindow ) && !newWindow.TaskListDeleted && + (!newWindow.IsToolWindow || newWindow.IsAppWindow) && !newWindow.TaskListDeleted && newWindow.ClassName != "Windows.UI.Core.CoreWindow") { windows.Add(newWindow); diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/SearchController.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/SearchController.cs index 35cf3bbe4..8e7f8866a 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/SearchController.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/SearchController.cs @@ -94,7 +94,7 @@ namespace Microsoft.Plugin.WindowWalker.Components /// Event handler for when the search text has been updated /// public async Task UpdateSearchText(string searchText) - { + { this.SearchText = searchText; await SyncOpenWindowsWithModelAsync(); } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/WindowResult.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/WindowResult.cs index 0a766b325..e984b1511 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/WindowResult.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/WindowResult.cs @@ -6,13 +6,13 @@ using System.Threading.Tasks; namespace Microsoft.Plugin.WindowWalker.Components { - class WindowResult:Window + class WindowResult : Window { /// /// Number of letters in between constant for when /// the result hasn't been set yet /// - public const int NoResult = -1; + public const int NoResult = -1; /// /// Properties that signify how many characters (including spaces) @@ -27,7 +27,7 @@ namespace Microsoft.Plugin.WindowWalker.Components /// /// Constructor for WindowResult /// - public WindowResult(Window window):base(window.Hwnd) + public WindowResult(Window window) : base(window.Hwnd) { LettersInBetweenScore = WindowResult.NoResult; } diff --git a/src/modules/launcher/PowerLauncher/App.xaml.cs b/src/modules/launcher/PowerLauncher/App.xaml.cs index 0766f6786..99b253d29 100644 --- a/src/modules/launcher/PowerLauncher/App.xaml.cs +++ b/src/modules/launcher/PowerLauncher/App.xaml.cs @@ -58,7 +58,8 @@ namespace PowerLauncher private void OnStartup(object sender, StartupEventArgs e) { - RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () => { + RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () => + { Dispose(); Environment.Exit(0); }); @@ -104,7 +105,7 @@ namespace PowerLauncher RegisterExitEvents(); _settingsWatcher = new SettingsWatcher(_settings); - + _mainVM.MainWindowVisibility = Visibility.Visible; _mainVM.ColdStartFix(); _themeManager.ThemeChanged += OnThemeChanged; diff --git a/src/modules/launcher/PowerLauncher/Helper/ErrorReporting.cs b/src/modules/launcher/PowerLauncher/Helper/ErrorReporting.cs index 6e5fd6693..b688039dd 100644 --- a/src/modules/launcher/PowerLauncher/Helper/ErrorReporting.cs +++ b/src/modules/launcher/PowerLauncher/Helper/ErrorReporting.cs @@ -10,14 +10,14 @@ namespace PowerLauncher.Helper { private static void Report(Exception e) { - if( e != null) + if (e != null) { var logger = LogManager.GetLogger("UnHandledException"); logger.Fatal(ExceptionFormatter.FormatException(e)); var reportWindow = new ReportWindow(e); reportWindow.Show(); - } + } } public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e) diff --git a/src/modules/launcher/PowerLauncher/Helper/ResultCollection.cs b/src/modules/launcher/PowerLauncher/Helper/ResultCollection.cs index 1283e5303..735c19e8c 100644 --- a/src/modules/launcher/PowerLauncher/Helper/ResultCollection.cs +++ b/src/modules/launcher/PowerLauncher/Helper/ResultCollection.cs @@ -27,11 +27,11 @@ namespace PowerLauncher.Helper /// public void Update(List newItems) { - if(newItems == null) + if (newItems == null) { throw new ArgumentNullException(nameof(newItems)); } - + int newCount = newItems.Count; int oldCount = Items.Count; int location = newCount > oldCount ? oldCount : newCount; diff --git a/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs b/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs index 312afb7c6..a37c2ffed 100644 --- a/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs +++ b/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs @@ -16,7 +16,7 @@ using static PowerLauncher.Helper.WindowsInteropHelper; // http://blogs.microsoft.co.il/arik/2010/05/28/wpf-single-instance-application/ // modified to allow single instance restart -namespace PowerLauncher.Helper +namespace PowerLauncher.Helper { internal enum WM { @@ -208,12 +208,12 @@ namespace PowerLauncher.Helper } } - } + } - public interface ISingleInstanceApp - { - void OnSecondAppStarted(); - } + public interface ISingleInstanceApp + { + void OnSecondAppStarted(); + } /// /// This class checks to make sure that only one instance of @@ -226,9 +226,9 @@ namespace PowerLauncher.Helper /// running as Administrator, can activate it with command line arguments. /// For most apps, this will not be much of an issue. /// - public static class SingleInstance - where TApplication: Application , ISingleInstanceApp - + public static class SingleInstance + where TApplication : Application, ISingleInstanceApp + { #region Private Fields @@ -260,7 +260,7 @@ namespace PowerLauncher.Helper /// If not, activates the first instance. /// /// True if this is the first instance of the application. - internal static bool InitializeAsFirstInstance( string uniqueName ) + internal static bool InitializeAsFirstInstance(string uniqueName) { // Build unique application Id and the IPC channel name. string applicationIdentifier = uniqueName + Environment.UserName; @@ -298,7 +298,7 @@ namespace PowerLauncher.Helper /// Gets command line args - for ClickOnce deployed applications, command line args may not be passed directly, they have to be retrieved. /// /// List of command line arg strings. - private static IList GetCommandLineArgs( string uniqueApplicationName ) + private static IList GetCommandLineArgs(string uniqueApplicationName) { string[] args = null; @@ -309,7 +309,7 @@ namespace PowerLauncher.Helper } catch (NotSupportedException) { - + // The application was clickonce deployed // Clickonce deployed apps cannot receive traditional commandline arguments // As a workaround commandline arguments can be written to a shared location before @@ -353,7 +353,7 @@ namespace PowerLauncher.Helper { using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(channelName, PipeDirection.In)) { - while(true) + while (true) { // Wait for connection to the pipe await pipeServer.WaitForConnectionAsync().ConfigureAwait(false); diff --git a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs index e7409ba17..f33e7c7fa 100644 --- a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs +++ b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs @@ -110,7 +110,7 @@ namespace PowerLauncher private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) { - if(e.PropertyName == nameof(MainViewModel.MainWindowVisibility)) + if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility)) { if (Visibility == System.Windows.Visibility.Visible) { @@ -124,7 +124,7 @@ namespace PowerLauncher _viewModel.LastQuerySelected = true; } } - } + } else if (e.PropertyName == nameof(MainViewModel.SystemQueryText)) { this._isTextSetProgrammatically = true; @@ -153,19 +153,19 @@ namespace PowerLauncher private void OnActivated(object sender, EventArgs e) { - if (_settings.ClearInputOnLaunch) - { - _viewModel.ClearQueryCommand.Execute(null); - } + if (_settings.ClearInputOnLaunch) + { + _viewModel.ClearQueryCommand.Execute(null); + } } private void OnDeactivated(object sender, EventArgs e) { - if (_settings.HideWhenDeactivated) + if (_settings.HideWhenDeactivated) { //(this.FindResource("OutroStoryboard") as Storyboard).Begin(); Hide(); - } + } } private void UpdatePosition() @@ -176,7 +176,7 @@ namespace PowerLauncher Top = _settings.WindowTop; } else - { + { Top = WindowTop(); Left = WindowLeft(); } @@ -290,7 +290,7 @@ namespace PowerLauncher private void SuggestionsList_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListView listview = (ListView)sender; - _viewModel.Results.SelectedItem = (ResultViewModel) listview.SelectedItem; + _viewModel.Results.SelectedItem = (ResultViewModel)listview.SelectedItem; if (e.AddedItems.Count > 0 && e.AddedItems[0] != null) { listview.ScrollIntoView(e.AddedItems[0]); @@ -304,7 +304,7 @@ namespace PowerLauncher _viewModel.Results.SelectedIndex, _viewModel.Results.SelectedItem?.ToString(), _viewModel.QueryText); - } + } } private const int millisecondsToWait = 100; @@ -312,7 +312,7 @@ namespace PowerLauncher private bool disposedValue = false; private void QueryTextBox_TextChanged(object sender, TextChangedEventArgs e) - { + { if (_isTextSetProgrammatically) { var textBox = ((TextBox)sender); @@ -345,7 +345,7 @@ namespace PowerLauncher })); } } - + private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Right) diff --git a/src/modules/launcher/PowerLauncher/PublicAPIInstance.cs b/src/modules/launcher/PowerLauncher/PublicAPIInstance.cs index 43893fb3c..5e021d2fe 100644 --- a/src/modules/launcher/PowerLauncher/PublicAPIInstance.cs +++ b/src/modules/launcher/PowerLauncher/PublicAPIInstance.cs @@ -78,7 +78,7 @@ namespace Wox } public void ShowMsg(string title, string subTitle = "", string iconPath = "", bool useMainWindowAsOwner = true) - { + { } public void InstallPlugin(string path) @@ -115,16 +115,16 @@ namespace Wox { ThemeChanged?.Invoke(oldTheme, newTheme); } - + protected virtual void Dispose(bool disposing) { if (!_disposed) - { + { if (disposing) { _themeManager.ThemeChanged -= OnThemeChanged; _disposed = true; - } + } } } #endregion diff --git a/src/modules/launcher/PowerLauncher/Settings.cs b/src/modules/launcher/PowerLauncher/Settings.cs index 9a92f14eb..4c41b1291 100644 --- a/src/modules/launcher/PowerLauncher/Settings.cs +++ b/src/modules/launcher/PowerLauncher/Settings.cs @@ -1,14 +1,17 @@ -namespace PowerLauncher.Properties { - - +namespace PowerLauncher.Properties +{ + + // This class allows you to handle specific events on the settings class: // The SettingChanging event is raised before a setting's value is changed. // The PropertyChanged event is raised after a setting's value is changed. // The SettingsLoaded event is raised after the setting values are loaded. // The SettingsSaving event is raised before the setting values are saved. - internal sealed partial class Settings { - - public Settings() { + internal sealed partial class Settings + { + + public Settings() + { // // To add event handlers for saving and changing settings, uncomment the lines below: // // this.SettingChanging += this.SettingChangingEventHandler; @@ -16,12 +19,14 @@ // this.SettingsSaving += this.SettingsSavingEventHandler; // } - - private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { + + private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) + { // Add code to handle the SettingChangingEvent event here. } - - private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { + + private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) + { // Add code to handle the SettingsSaving event here. } } diff --git a/src/modules/launcher/PowerLauncher/SettingsWatcher.cs b/src/modules/launcher/PowerLauncher/SettingsWatcher.cs index 5270c4a8b..dc8f837dc 100644 --- a/src/modules/launcher/PowerLauncher/SettingsWatcher.cs +++ b/src/modules/launcher/PowerLauncher/SettingsWatcher.cs @@ -26,7 +26,7 @@ namespace PowerLauncher { _settings = settings; // Set up watcher - _watcher = Microsoft.PowerToys.Settings.UI.Lib.Utilities.Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", OverloadSettings); + _watcher = Microsoft.PowerToys.Settings.UI.Lib.Utilities.Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", OverloadSettings); // Load initial settings file OverloadSettings(); @@ -75,7 +75,7 @@ namespace PowerLauncher if (_settings.ClearInputOnLaunch != overloadSettings.Properties.clear_input_on_launch) { - _settings.ClearInputOnLaunch = overloadSettings.Properties.clear_input_on_launch; + _settings.ClearInputOnLaunch = overloadSettings.Properties.clear_input_on_launch; } } // the settings application can hold a lock on the settings.json file which will result in a IOException. diff --git a/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs index d5277fde5..cb1aa9bc6 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs @@ -15,7 +15,8 @@ namespace PowerLauncher.ViewModel public string Title { get; set; } public string Glyph { get; set; } public string FontFamily { get; set; } - public ICommand Command { + public ICommand Command + { get { return this._command; diff --git a/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs index d58ed2204..2d6bd6606 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs @@ -117,7 +117,7 @@ namespace PowerLauncher.ViewModel private void InitializeKeyCommands() { - IgnoreCommand = new RelayCommand(_ => {}); + IgnoreCommand = new RelayCommand(_ => { }); EscCommand = new RelayCommand(_ => { @@ -187,7 +187,7 @@ namespace PowerLauncher.ViewModel results.SelectedIndex = int.Parse(index.ToString(), CultureInfo.InvariantCulture); } - if(results.SelectedItem != null) + if (results.SelectedItem != null) { //If there is a context button selected fire the action for that button before the main command. bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton(); @@ -218,7 +218,7 @@ namespace PowerLauncher.ViewModel } } } - } + } }); LoadContextMenuCommand = new RelayCommand(_ => @@ -248,12 +248,12 @@ namespace PowerLauncher.ViewModel ClearQueryCommand = new RelayCommand(_ => { - if(!string.IsNullOrEmpty(QueryText)) + if (!string.IsNullOrEmpty(QueryText)) { - ChangeQueryText(string.Empty,true); - //Push Event to UI SystemQuery has changed - OnPropertyChanged(nameof(SystemQueryText)); - } + ChangeQueryText(string.Empty, true); + //Push Event to UI SystemQuery has changed + OnPropertyChanged(nameof(SystemQueryText)); + } }); } @@ -271,7 +271,7 @@ namespace PowerLauncher.ViewModel public string SystemQueryText { get; set; } = String.Empty; public string QueryText { get; set; } = String.Empty; - + /// /// we need move cursor to end when we manually changed query @@ -280,11 +280,11 @@ namespace PowerLauncher.ViewModel /// /// /// Optional Parameter that if true, will automatically execute a query against the updated text - public void ChangeQueryText(string queryText, bool requery=false) + public void ChangeQueryText(string queryText, bool requery = false) { SystemQueryText = queryText; - - if(requery) + + if (requery) { QueryText = queryText; Query(); @@ -332,11 +332,13 @@ namespace PowerLauncher.ViewModel private Visibility _visibility; - public Visibility MainWindowVisibility { + public Visibility MainWindowVisibility + { get { return _visibility; } - set { + set + { _visibility = value; - if(value == Visibility.Visible) + if (value == Visibility.Visible) { PowerToysTelemetry.Log.WriteEvent(new LauncherShowEvent()); } @@ -344,7 +346,7 @@ namespace PowerLauncher.ViewModel { PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent()); } - + } } @@ -503,7 +505,7 @@ namespace PowerLauncher.ViewModel _updateSource?.Cancel(); _lastQuery = _emptyQuery; Results.SelectedItem = null; - Results.Clear(); + Results.Clear(); Results.Visibility = Visibility.Collapsed; } } @@ -569,7 +571,7 @@ namespace PowerLauncher.ViewModel hotkey.Shift = hotkeyModel.Shift; hotkey.Ctrl = hotkeyModel.Ctrl; hotkey.Win = hotkeyModel.Win; - hotkey.Key = (byte) KeyInterop.VirtualKeyFromKey(hotkeyModel.CharKey); + hotkey.Key = (byte)KeyInterop.VirtualKeyFromKey(hotkeyModel.CharKey); _hotkeyHandle = _hotkeyManager.RegisterHotkey(hotkey, action); } @@ -672,7 +674,7 @@ namespace PowerLauncher.ViewModel /// public void UpdateResultView(List list, PluginMetadata metadata, Query originQuery) { - if(list == null) + if (list == null) { throw new ArgumentNullException(nameof(list)); } @@ -799,8 +801,8 @@ namespace PowerLauncher.ViewModel _hotkeyManager.Dispose(); _updateSource.Dispose(); _disposed = true; - } - } + } + } } public void Dispose() diff --git a/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs index b16ceae9b..c2c2c4464 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs @@ -42,10 +42,10 @@ namespace PowerLauncher.ViewModel { Result = result; } - + ContextMenuSelectedIndex = NoSelectionIndex; LoadContextMenu(); - + ActivateContextButtonsHoverCommand = new RelayCommand(ActivateContextButtonsHoverAction); ActivateContextButtonsSelectionCommand = new RelayCommand(ActivateContextButtonsSelectionAction); DeactivateContextButtonsHoverCommand = new RelayCommand(DeactivateContextButtonsHoverAction); diff --git a/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs index 74228a15e..58364bb51 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs @@ -165,7 +165,7 @@ namespace PowerLauncher.ViewModel public void SelectNextTabItem() { //Do nothing if there is no selected item or we've selected the next context button - if(!SelectedItem?.SelectNextContextButton() ?? true) + if (!SelectedItem?.SelectNextContextButton() ?? true) { SelectNextResult(); } @@ -320,6 +320,6 @@ namespace PowerLauncher.ViewModel } #endregion - + } } \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher/ViewModel/SettingWindowViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/SettingWindowViewModel.cs index b5e5996ff..2eb35024c 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/SettingWindowViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/SettingWindowViewModel.cs @@ -39,7 +39,7 @@ namespace PowerLauncher.ViewModel #region about public string ActivatedTimes => string.Format(CultureInfo.InvariantCulture, _translater.GetTranslation("about_activate_times"), Settings.ActivateTimes); - + #endregion } } diff --git a/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs b/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs index 2753b00b3..c485c638f 100644 --- a/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs +++ b/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs @@ -40,8 +40,10 @@ namespace Wox.Core.Plugin return Execute(_startInfo); } - protected override string ExecuteContextMenu(Result selectedResult) { - JsonRPCServerRequestModel request = new JsonRPCServerRequestModel { + protected override string ExecuteContextMenu(Result selectedResult) + { + JsonRPCServerRequestModel request = new JsonRPCServerRequestModel + { Method = "contextmenu", Parameters = new object[] { selectedResult.ContextData }, }; diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonPRCModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonPRCModel.cs index 2b7db2149..5a02975b5 100644 --- a/src/modules/launcher/Wox.Core/Plugin/JsonPRCModel.cs +++ b/src/modules/launcher/Wox.Core/Plugin/JsonPRCModel.cs @@ -71,7 +71,8 @@ namespace Wox.Core.Plugin private string GetParameterByType(object parameter) { - if (parameter == null) { + if (parameter == null) + { return "null"; } if (parameter is string) diff --git a/src/modules/launcher/Wox.Core/Plugin/PluginManager.cs b/src/modules/launcher/Wox.Core/Plugin/PluginManager.cs index 549039485..735a344e6 100644 --- a/src/modules/launcher/Wox.Core/Plugin/PluginManager.cs +++ b/src/modules/launcher/Wox.Core/Plugin/PluginManager.cs @@ -53,7 +53,7 @@ namespace Wox.Core.Plugin public static void ReloadData() { - foreach(var plugin in AllPlugins) + foreach (var plugin in AllPlugins) { var reloadablePlugin = plugin.Plugin as IReloadable; reloadablePlugin?.ReloadData(); @@ -104,7 +104,7 @@ namespace Wox.Core.Plugin catch (Exception e) { Log.Exception(nameof(PluginManager), $"Fail to Init plugin: {pair.Metadata.Name}", e); - pair.Metadata.Disabled = true; + pair.Metadata.Disabled = true; failedPlugins.Enqueue(pair); } }); @@ -271,10 +271,10 @@ namespace Wox.Core.Plugin { GlobalPlugins.Remove(plugin); } - - if(oldActionkeyword != Query.GlobalPluginWildcardSign) + + if (oldActionkeyword != Query.GlobalPluginWildcardSign) NonGlobalPlugins.Remove(oldActionkeyword); - + plugin.Metadata.ActionKeywords.Remove(oldActionkeyword); } diff --git a/src/modules/launcher/Wox.Core/Resource/FontHelper.cs b/src/modules/launcher/Wox.Core/Resource/FontHelper.cs index c7cc54bf6..16b0247e1 100644 --- a/src/modules/launcher/Wox.Core/Resource/FontHelper.cs +++ b/src/modules/launcher/Wox.Core/Resource/FontHelper.cs @@ -14,9 +14,10 @@ namespace Wox.Core.Resource try { - return (FontWeight) fontWeightConverter.ConvertFromInvariantString(value); + return (FontWeight)fontWeightConverter.ConvertFromInvariantString(value); } - catch { + catch + { return FontWeights.Normal; } } diff --git a/src/modules/launcher/Wox.Infrastructure/Alphabet.cs b/src/modules/launcher/Wox.Infrastructure/Alphabet.cs index 778b2cb41..05a7f9337 100644 --- a/src/modules/launcher/Wox.Infrastructure/Alphabet.cs +++ b/src/modules/launcher/Wox.Infrastructure/Alphabet.cs @@ -23,7 +23,7 @@ namespace Wox.Infrastructure private ConcurrentDictionary PinyinCache; private BinaryStorage> _pinyinStorage; private Settings _settings; - + public void Initialize([NotNull] Settings settings) { _settings = settings ?? throw new ArgumentNullException(nameof(settings)); @@ -60,10 +60,10 @@ namespace Wox.Infrastructure if (!ContainsChinese(source)) return source; - + var combination = PinyinCombination(source); - - var pinyinArray=combination.Select(x => string.Join("", x)); + + var pinyinArray = combination.Select(x => string.Join("", x)); var acronymArray = combination.Select(Acronym).Distinct(); var joinedSingleStringCombination = new StringBuilder(); @@ -77,7 +77,7 @@ namespace Wox.Infrastructure { if (!_settings.ShouldUsePinyin) { - return; + return; } _pinyinStorage.Save(GetPinyinCacheAsDictionary()); } diff --git a/src/modules/launcher/Wox.Infrastructure/Exception/ExceptionFormatter.cs b/src/modules/launcher/Wox.Infrastructure/Exception/ExceptionFormatter.cs index 7fdccd7db..68aea8939 100644 --- a/src/modules/launcher/Wox.Infrastructure/Exception/ExceptionFormatter.cs +++ b/src/modules/launcher/Wox.Infrastructure/Exception/ExceptionFormatter.cs @@ -90,12 +90,12 @@ namespace Wox.Infrastructure.Exception else if (string.IsNullOrEmpty(ass.Location)) { sb.Append("location is null or empty"); - + } else { - sb.Append(ass.Location); - + sb.Append(ass.Location); + } sb.AppendLine(")"); } diff --git a/src/modules/launcher/Wox.Infrastructure/FileSystemHelper/FileVersionInfoWrapper.cs b/src/modules/launcher/Wox.Infrastructure/FileSystemHelper/FileVersionInfoWrapper.cs index 7a1f02543..fdba9d2be 100644 --- a/src/modules/launcher/Wox.Infrastructure/FileSystemHelper/FileVersionInfoWrapper.cs +++ b/src/modules/launcher/Wox.Infrastructure/FileSystemHelper/FileVersionInfoWrapper.cs @@ -8,7 +8,7 @@ namespace Wox.Infrastructure.FileSystemHelper public FileVersionInfoWrapper() { } public FileVersionInfo GetVersionInfo(string path) { - if(File.Exists(path)) + if (File.Exists(path)) { return FileVersionInfo.GetVersionInfo(path); } diff --git a/src/modules/launcher/Wox.Infrastructure/Helper.cs b/src/modules/launcher/Wox.Infrastructure/Helper.cs index 16feaeb5b..92516b49d 100644 --- a/src/modules/launcher/Wox.Infrastructure/Helper.cs +++ b/src/modules/launcher/Wox.Infrastructure/Helper.cs @@ -92,7 +92,7 @@ namespace Wox.Infrastructure { Process.Start(info); } - catch(System.Exception ex) + catch (System.Exception ex) { Log.Exception($"Wox.Infrastructure.Helper| Unable to Run {path} as admin : {ex.Message}", ex); } diff --git a/src/modules/launcher/Wox.Infrastructure/Hotkey/HotkeyModel.cs b/src/modules/launcher/Wox.Infrastructure/Hotkey/HotkeyModel.cs index 820a960ff..af14e71d3 100644 --- a/src/modules/launcher/Wox.Infrastructure/Hotkey/HotkeyModel.cs +++ b/src/modules/launcher/Wox.Infrastructure/Hotkey/HotkeyModel.cs @@ -103,7 +103,7 @@ namespace Wox.Infrastructure.Hotkey { try { - CharKey = (Key) Enum.Parse(typeof (Key), charKey); + CharKey = (Key)Enum.Parse(typeof(Key), charKey); } catch (ArgumentException) { diff --git a/src/modules/launcher/Wox.Infrastructure/Image/ImageCache.cs b/src/modules/launcher/Wox.Infrastructure/Image/ImageCache.cs index f3be34d50..4c4b9b478 100644 --- a/src/modules/launcher/Wox.Infrastructure/Image/ImageCache.cs +++ b/src/modules/launcher/Wox.Infrastructure/Image/ImageCache.cs @@ -23,7 +23,7 @@ namespace Wox.Infrastructure.Image var i = _data[path]; return i; } - set + set { _data[path] = value; diff --git a/src/modules/launcher/Wox.Infrastructure/Image/ImageLoader.cs b/src/modules/launcher/Wox.Infrastructure/Image/ImageLoader.cs index 079b43c22..f03bbaf48 100644 --- a/src/modules/launcher/Wox.Infrastructure/Image/ImageLoader.cs +++ b/src/modules/launcher/Wox.Infrastructure/Image/ImageLoader.cs @@ -207,7 +207,7 @@ namespace Wox.Infrastructure.Image int ImageCacheValue; if (GuidToKey.TryGetValue(hash, out string key)) { // image already exists - if(ImageCache.Usage.TryGetValue(path, out ImageCacheValue)) + if (ImageCache.Usage.TryGetValue(path, out ImageCacheValue)) { img = ImageCache[key]; } diff --git a/src/modules/launcher/Wox.Infrastructure/Image/ThumbnailReader.cs b/src/modules/launcher/Wox.Infrastructure/Image/ThumbnailReader.cs index 31f4ea4a0..553aa6348 100644 --- a/src/modules/launcher/Wox.Infrastructure/Image/ThumbnailReader.cs +++ b/src/modules/launcher/Wox.Infrastructure/Image/ThumbnailReader.cs @@ -41,8 +41,8 @@ namespace Wox.Infrastructure.Image internal interface IShellItem { void BindToHandler(IntPtr pbc, - [MarshalAs(UnmanagedType.LPStruct)]Guid bhid, - [MarshalAs(UnmanagedType.LPStruct)]Guid riid, + [MarshalAs(UnmanagedType.LPStruct)] Guid bhid, + [MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IntPtr ppv); void GetParent(out IShellItem ppsi); diff --git a/src/modules/launcher/Wox.Infrastructure/Logger/Log.cs b/src/modules/launcher/Wox.Infrastructure/Logger/Log.cs index 611265baa..d73a6b048 100644 --- a/src/modules/launcher/Wox.Infrastructure/Logger/Log.cs +++ b/src/modules/launcher/Wox.Infrastructure/Logger/Log.cs @@ -49,7 +49,7 @@ namespace Wox.Infrastructure.Logger return valid; } - + [MethodImpl(MethodImplOptions.Synchronized)] public static void Exception(string className, string message, System.Exception exception, [CallerMemberName] string methodName = "") diff --git a/src/modules/launcher/Wox.Infrastructure/Storage/BinaryStorage.cs b/src/modules/launcher/Wox.Infrastructure/Storage/BinaryStorage.cs index 26c62a3a0..8db856498 100644 --- a/src/modules/launcher/Wox.Infrastructure/Storage/BinaryStorage.cs +++ b/src/modules/launcher/Wox.Infrastructure/Storage/BinaryStorage.cs @@ -36,7 +36,7 @@ namespace Wox.Infrastructure.Storage // Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible if (_storageHelper.clearCache) { - if(File.Exists(FilePath)) + if (File.Exists(FilePath)) { File.Delete(FilePath); Log.Info($"|BinaryStorage.TryLoad|Deleting cached data| <{FilePath}>"); diff --git a/src/modules/launcher/Wox.Infrastructure/Storage/FileSystemWatcherWrapper.cs b/src/modules/launcher/Wox.Infrastructure/Storage/FileSystemWatcherWrapper.cs index f64772651..bf5f8c2ed 100644 --- a/src/modules/launcher/Wox.Infrastructure/Storage/FileSystemWatcherWrapper.cs +++ b/src/modules/launcher/Wox.Infrastructure/Storage/FileSystemWatcherWrapper.cs @@ -8,14 +8,14 @@ namespace Wox.Infrastructure.Storage { public FileSystemWatcherWrapper() { } - Collection IFileSystemWatcherWrapper.Filters - { + Collection IFileSystemWatcherWrapper.Filters + { get => this.Filters; - set - { - if(value != null) + set + { + if (value != null) { - foreach(string filter in value) + foreach (string filter in value) { this.Filters.Add(filter); } diff --git a/src/modules/launcher/Wox.Infrastructure/Storage/JsonStorage.cs b/src/modules/launcher/Wox.Infrastructure/Storage/JsonStorage.cs index af973171f..0ffb4a33a 100644 --- a/src/modules/launcher/Wox.Infrastructure/Storage/JsonStorage.cs +++ b/src/modules/launcher/Wox.Infrastructure/Storage/JsonStorage.cs @@ -40,7 +40,7 @@ namespace Wox.Infrastructure.Storage // Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible if (_storageHelper.clearCache) { - if(File.Exists(FilePath)) + if (File.Exists(FilePath)) { File.Delete(FilePath); Log.Info($"|JsonStorage.TryLoad|Deleting cached data|<{FilePath}>"); diff --git a/src/modules/launcher/Wox.Infrastructure/Storage/ListRepository.cs b/src/modules/launcher/Wox.Infrastructure/Storage/ListRepository.cs index 2f2d2ea75..8c39355d1 100644 --- a/src/modules/launcher/Wox.Infrastructure/Storage/ListRepository.cs +++ b/src/modules/launcher/Wox.Infrastructure/Storage/ListRepository.cs @@ -25,7 +25,7 @@ namespace Wox.Infrastructure.Storage public ListRepository() { - + } public void Set(IList items) @@ -35,7 +35,7 @@ namespace Wox.Infrastructure.Storage { _items = new ConcurrentDictionary(items.ToDictionary(i => i.GetHashCode())); } - catch(ArgumentException e) + catch (ArgumentException e) { Log.Info($"|LisRepository.Set| Trying to insert a duplicate item", e.Message); } @@ -52,7 +52,7 @@ namespace Wox.Infrastructure.Storage { Log.Error($"|ListRepository.Add| Item Already Exists <{insertedItem}>"); } - + } public void Remove(T removedItem) diff --git a/src/modules/launcher/Wox.Infrastructure/Storage/PluginJsonStorage.cs b/src/modules/launcher/Wox.Infrastructure/Storage/PluginJsonStorage.cs index eaf35ab4f..c24876276 100644 --- a/src/modules/launcher/Wox.Infrastructure/Storage/PluginJsonStorage.cs +++ b/src/modules/launcher/Wox.Infrastructure/Storage/PluginJsonStorage.cs @@ -2,7 +2,7 @@ namespace Wox.Infrastructure.Storage { - public class PluginJsonStorage :JsonStorage where T : new() + public class PluginJsonStorage : JsonStorage where T : new() { public PluginJsonStorage() { diff --git a/src/modules/launcher/Wox.Infrastructure/Storage/StoragePowerToysVersionInfo.cs b/src/modules/launcher/Wox.Infrastructure/Storage/StoragePowerToysVersionInfo.cs index 552c1d343..e78ee152a 100644 --- a/src/modules/launcher/Wox.Infrastructure/Storage/StoragePowerToysVersionInfo.cs +++ b/src/modules/launcher/Wox.Infrastructure/Storage/StoragePowerToysVersionInfo.cs @@ -11,7 +11,7 @@ namespace Wox.Infrastructure.Storage // This detail is accessed by the storage items and is used to decide if the cache must be deleted or not public bool clearCache = false; - + private String currentPowerToysVersion = String.Empty; private String FilePath { get; set; } = String.Empty; @@ -32,17 +32,17 @@ namespace Wox.Infrastructure.Storage // If there is some error in populating/retrieving the version numbers, then the cache must be deleted // This case will not be hit, but is present as a fail safe - if(String.IsNullOrEmpty(version1) || String.IsNullOrEmpty(version2)) + if (String.IsNullOrEmpty(version1) || String.IsNullOrEmpty(version2)) { return true; } - string[] split1 = version1.Split( new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries); - string[] split2 = version2.Split( new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries); + string[] split1 = version1.Split(new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries); + string[] split2 = version2.Split(new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries); - for(int i=0; i public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption opt) { - if (string.IsNullOrEmpty(stringToCompare) || string.IsNullOrEmpty(query)) return new MatchResult (false, UserSettingSearchPrecision); - + if (string.IsNullOrEmpty(stringToCompare) || string.IsNullOrEmpty(query)) return new MatchResult(false, UserSettingSearchPrecision); + query = query.Trim(); if (_alphabet != null) @@ -70,8 +70,8 @@ namespace Wox.Infrastructure var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare; - var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query; - + var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query; + var querySubstrings = queryWithoutCase.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int currentQuerySubstringIndex = 0; var currentQuerySubstring = querySubstrings[currentQuerySubstringIndex]; @@ -153,9 +153,9 @@ namespace Wox.Infrastructure currentQuerySubstring = querySubstrings[currentQuerySubstringIndex]; currentQuerySubstringCharacterIndex = 0; } - } - - // proceed to calculate score if every char or substring without whitespaces matched + } + + // proceed to calculate score if every char or substring without whitespaces matched if (allQuerySubstringsMatched) { var nearestSpaceIndex = CalculateClosestSpaceIndex(spaceIndices, firstMatchIndex); @@ -164,13 +164,13 @@ namespace Wox.Infrastructure return new MatchResult(true, UserSettingSearchPrecision, indexList, score); } - return new MatchResult (false, UserSettingSearchPrecision); + return new MatchResult(false, UserSettingSearchPrecision); } // To get the index of the closest space which preceeds the first matching index private int CalculateClosestSpaceIndex(List spaceIndices, int firstMatchIndex) { - if(spaceIndices.Count == 0) + if (spaceIndices.Count == 0) { return -1; } @@ -182,7 +182,7 @@ namespace Wox.Infrastructure } } - private static bool AllPreviousCharsMatched(int startIndexToVerify, int currentQuerySubstringCharacterIndex, + private static bool AllPreviousCharsMatched(int startIndexToVerify, int currentQuerySubstringCharacterIndex, string fullStringToCompareWithoutCase, string currentQuerySubstring) { var allMatch = true; @@ -196,8 +196,8 @@ namespace Wox.Infrastructure } return allMatch; - } - + } + private static List GetUpdatedIndexList(int startIndexToVerify, int currentQuerySubstringCharacterIndex, int firstMatchIndexInWord, List indexList) { var updatedList = new List(); @@ -240,7 +240,7 @@ namespace Wox.Infrastructure { int count = query.Count(c => !char.IsWhiteSpace(c)); int threshold = 4; - if(count <= threshold) + if (count <= threshold) { score += count * 10; } diff --git a/src/modules/launcher/Wox.Infrastructure/UserSettings/PluginSettings.cs b/src/modules/launcher/Wox.Infrastructure/UserSettings/PluginSettings.cs index 144fa88f3..5234185fd 100644 --- a/src/modules/launcher/Wox.Infrastructure/UserSettings/PluginSettings.cs +++ b/src/modules/launcher/Wox.Infrastructure/UserSettings/PluginSettings.cs @@ -27,7 +27,7 @@ namespace Wox.Infrastructure.UserSettings { ID = metadata.ID, Name = metadata.Name, - ActionKeywords = metadata.ActionKeywords, + ActionKeywords = metadata.ActionKeywords, Disabled = metadata.Disabled }; } diff --git a/src/modules/launcher/Wox.Infrastructure/UserSettings/Settings.cs b/src/modules/launcher/Wox.Infrastructure/UserSettings/Settings.cs index 0ede87453..f410be79c 100644 --- a/src/modules/launcher/Wox.Infrastructure/UserSettings/Settings.cs +++ b/src/modules/launcher/Wox.Infrastructure/UserSettings/Settings.cs @@ -11,13 +11,14 @@ namespace Wox.Infrastructure.UserSettings { private string _hotkey = "Alt + Space"; private string _previousHotkey = ""; - public string PreviousHotkey { + public string PreviousHotkey + { get { return _previousHotkey; } } - public string Hotkey + public string Hotkey { get { @@ -84,7 +85,7 @@ namespace Wox.Infrastructure.UserSettings public double WindowTop { get; set; } private int _maxResultsToShow = 4; - public int MaxResultsToShow + public int MaxResultsToShow { get { diff --git a/src/modules/launcher/Wox.Plugin/PluginMetadata.cs b/src/modules/launcher/Wox.Plugin/PluginMetadata.cs index 64b8b032c..9f6ffafc2 100644 --- a/src/modules/launcher/Wox.Plugin/PluginMetadata.cs +++ b/src/modules/launcher/Wox.Plugin/PluginMetadata.cs @@ -17,7 +17,7 @@ namespace Wox.Plugin public string Description { get; set; } public string Website { get; set; } public bool Disabled { get; set; } - public string ExecuteFilePath { get; private set;} + public string ExecuteFilePath { get; private set; } public string ExecuteFileName { get; set; } @@ -36,7 +36,7 @@ namespace Wox.Plugin public List ActionKeywords { get; set; } - public string IcoPath { get; set;} + public string IcoPath { get; set; } public override string ToString() { diff --git a/src/modules/launcher/Wox.Plugin/PluginPair.cs b/src/modules/launcher/Wox.Plugin/PluginPair.cs index f00888964..b1b9e5a31 100644 --- a/src/modules/launcher/Wox.Plugin/PluginPair.cs +++ b/src/modules/launcher/Wox.Plugin/PluginPair.cs @@ -5,7 +5,7 @@ public IPlugin Plugin { get; internal set; } public PluginMetadata Metadata { get; internal set; } - + public override string ToString() { diff --git a/src/modules/launcher/Wox.Plugin/Result.cs b/src/modules/launcher/Wox.Plugin/Result.cs index 196ee68ad..3c8aa5118 100644 --- a/src/modules/launcher/Wox.Plugin/Result.cs +++ b/src/modules/launcher/Wox.Plugin/Result.cs @@ -14,8 +14,9 @@ namespace Wox.Plugin private ToolTipData _toolTipData; private string _pluginDirectory; private string _icoPath; - public string Title { - get { return _title; } + public string Title + { + get { return _title; } set { _title = value.Replace("\n", " "); diff --git a/src/modules/launcher/Wox.Plugin/ThemeManager.cs b/src/modules/launcher/Wox.Plugin/ThemeManager.cs index 09d53548a..cc253aed6 100644 --- a/src/modules/launcher/Wox.Plugin/ThemeManager.cs +++ b/src/modules/launcher/Wox.Plugin/ThemeManager.cs @@ -70,11 +70,11 @@ namespace Wox.Plugin { return currentTheme; } - + private static Theme GetHighContrastBaseType() { string RegistryKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes"; - string theme = (string) Registry.GetValue(RegistryKey, "CurrentTheme", string.Empty); + string theme = (string)Registry.GetValue(RegistryKey, "CurrentTheme", string.Empty); theme = theme.Split('\\').Last().Split('.').First().ToString(); if (theme == "hc1") @@ -153,13 +153,13 @@ namespace Wox.Plugin protected virtual void Dispose(bool disposing) { if (!_disposed) - { + { if (disposing) { ControlzEx.Theming.ThemeManager.Current.ThemeChanged -= Current_ThemeChanged; SystemParameters.StaticPropertyChanged -= SystemParameters_StaticPropertyChanged; _disposed = true; - } + } } } @@ -175,8 +175,8 @@ namespace Wox.Plugin public enum Theme { None, - Light, - Dark, + Light, + Dark, HighContrastOne, HighContrastTwo, HighContrastBlack, diff --git a/src/modules/launcher/Wox.Plugin/ToolTipData.cs b/src/modules/launcher/Wox.Plugin/ToolTipData.cs index 2051a081b..08e624e83 100644 --- a/src/modules/launcher/Wox.Plugin/ToolTipData.cs +++ b/src/modules/launcher/Wox.Plugin/ToolTipData.cs @@ -9,8 +9,8 @@ namespace Wox.Plugin public string Text { get; private set; } public ToolTipData(string title, string text) - { - if(string.IsNullOrEmpty(title)) + { + if (string.IsNullOrEmpty(title)) { throw new ArgumentException("title cannot be null or empty", "title"); } diff --git a/src/modules/launcher/Wox.Test/FuzzyMatcherTest.cs b/src/modules/launcher/Wox.Test/FuzzyMatcherTest.cs index a4062ab7f..46e17c677 100644 --- a/src/modules/launcher/Wox.Test/FuzzyMatcherTest.cs +++ b/src/modules/launcher/Wox.Test/FuzzyMatcherTest.cs @@ -150,7 +150,7 @@ namespace Wox.Test [TestCase("chr", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Regular, false)] [TestCase("chr", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.None, true)] [TestCase("ccs", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Low, true)] - [TestCase("cand", "Candy Crush Saga from King",StringMatcher.SearchPrecisionScore.Regular, true)] + [TestCase("cand", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Regular, true)] [TestCase("cand", "Help cure hope raise on mind entity Chrome", StringMatcher.SearchPrecisionScore.Regular, false)] public void WhenGivenDesiredPrecisionThenShouldReturnAllResultsGreaterOrEqual( string queryString, @@ -159,7 +159,7 @@ namespace Wox.Test bool expectedPrecisionResult) { // When - var matcher = new StringMatcher {UserSettingSearchPrecision = expectedPrecisionScore}; + var matcher = new StringMatcher { UserSettingSearchPrecision = expectedPrecisionScore }; // Given var matchResult = matcher.FuzzyMatch(queryString, compareString); diff --git a/src/modules/launcher/Wox.Test/MainViewModelTest.cs b/src/modules/launcher/Wox.Test/MainViewModelTest.cs index 58e6b31d9..1153d8c26 100644 --- a/src/modules/launcher/Wox.Test/MainViewModelTest.cs +++ b/src/modules/launcher/Wox.Test/MainViewModelTest.cs @@ -20,7 +20,7 @@ namespace Wox.Test // Act string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query); - + // Assert Assert.AreEqual(autoCompleteText, string.Empty); } diff --git a/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs b/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs index f34f9cee9..d94368661 100644 --- a/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs +++ b/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs @@ -303,7 +303,7 @@ namespace Wox.Test.Plugins [TestCase(0, true, ExpectedResult = true)] [TestCase(1, false, ExpectedResult = true)] [TestCase(1, true, ExpectedResult = true)] - public bool DriveDetection_MustDisplayResults_WhenEnhancedModeIsOnOrWhenWarningIsDisabled(int enhancedModeStatus, bool disableWarningCheckBoxStatus) + public bool DriveDetection_MustDisplayResults_WhenEnhancedModeIsOnOrWhenWarningIsDisabled(int enhancedModeStatus, bool disableWarningCheckBoxStatus) { // Arrange var mockRegistry = new Mock(); diff --git a/src/modules/previewpane/PreviewPaneUnitTests/HTMLParsingExtensionTest.cs b/src/modules/previewpane/PreviewPaneUnitTests/HTMLParsingExtensionTest.cs index c45fdef55..ef4f8a735 100644 --- a/src/modules/previewpane/PreviewPaneUnitTests/HTMLParsingExtensionTest.cs +++ b/src/modules/previewpane/PreviewPaneUnitTests/HTMLParsingExtensionTest.cs @@ -36,7 +36,7 @@ namespace PreviewPaneUnitTests { // Arrange String mdString = "> Blockquotes."; - HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(()=> { }); + HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { }); MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension); // Act diff --git a/src/modules/previewpane/PreviewPaneUnitTests/MarkdownPreviewHandlerTest.cs b/src/modules/previewpane/PreviewPaneUnitTests/MarkdownPreviewHandlerTest.cs index e0ebaaf29..213c15491 100644 --- a/src/modules/previewpane/PreviewPaneUnitTests/MarkdownPreviewHandlerTest.cs +++ b/src/modules/previewpane/PreviewPaneUnitTests/MarkdownPreviewHandlerTest.cs @@ -18,7 +18,7 @@ namespace PreviewPaneUnitTests public void MarkdownPreviewHandlerControl__AddsBrowserToForm_WhenDoPreviewIsCalled() { // Arrange - using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl()) + using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl()) { // Act markdownPreviewHandlerControl.DoPreview("HelperFiles/MarkdownWithExternalImage.txt"); @@ -33,7 +33,7 @@ namespace PreviewPaneUnitTests public void MarkdownPreviewHandlerControl__AddsInfoBarToFormIfExternalImageLinkPresent_WhenDoPreviewIsCalled() { // Arrange - using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl()) + using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl()) { // Act markdownPreviewHandlerControl.DoPreview("HelperFiles/MarkdownWithExternalImage.txt"); @@ -63,7 +63,7 @@ namespace PreviewPaneUnitTests public void MarkdownPreviewHandlerControl__DoesNotAddInfoBarToFormIfExternalImageLinkNotPresent_WhenDoPreviewIsCalled() { // Arrange - using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl()) + using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl()) { // Act markdownPreviewHandlerControl.DoPreview("HelperFiles/MarkdownWithScript.txt"); @@ -91,7 +91,7 @@ namespace PreviewPaneUnitTests Assert.AreEqual(((WebBrowser)markdownPreviewHandlerControl.Controls[0]).ScriptErrorsSuppressed, true); Assert.AreEqual(((WebBrowser)markdownPreviewHandlerControl.Controls[0]).ScrollBarsEnabled, true); Assert.AreEqual(((WebBrowser)markdownPreviewHandlerControl.Controls[0]).AllowNavigation, false); - } + } } [TestMethod] diff --git a/src/modules/previewpane/UnitTests-PreviewHandlerCommon/FormHandlerControlTests.cs b/src/modules/previewpane/UnitTests-PreviewHandlerCommon/FormHandlerControlTests.cs index 9ba2aa0ca..74946e233 100644 --- a/src/modules/previewpane/UnitTests-PreviewHandlerCommon/FormHandlerControlTests.cs +++ b/src/modules/previewpane/UnitTests-PreviewHandlerCommon/FormHandlerControlTests.cs @@ -21,7 +21,7 @@ namespace UnitTests_PreviewHandlerCommon public void FormHandlerControl_ShouldCreateHandle_OnInitialization() { // Arrange and act - using (var testFormHandlerControl = new TestFormControl()) + using (var testFormHandlerControl = new TestFormControl()) { // Assert Assert.IsTrue(testFormHandlerControl.IsHandleCreated); @@ -111,7 +111,7 @@ namespace UnitTests_PreviewHandlerCommon Assert.AreEqual(bounds, testFormHandlerControl.Bounds); } } - + [TestMethod] public void FormHandlerControl_ShouldSetTextColor_WhenSetTextColorCalled() { diff --git a/src/modules/previewpane/UnitTests-PreviewHandlerCommon/StreamWrapperTests.cs b/src/modules/previewpane/UnitTests-PreviewHandlerCommon/StreamWrapperTests.cs index 51ebec302..4485589b4 100644 --- a/src/modules/previewpane/UnitTests-PreviewHandlerCommon/StreamWrapperTests.cs +++ b/src/modules/previewpane/UnitTests-PreviewHandlerCommon/StreamWrapperTests.cs @@ -19,7 +19,7 @@ namespace UnitTests_PreviewHandlerCommon public class StreamWrapperTests { [TestMethod] - public void StreamWrapper_ShouldThrow_IfInitializeWithNullStream() + public void StreamWrapper_ShouldThrow_IfInitializeWithNullStream() { // Arrange IStream stream = null; @@ -30,7 +30,7 @@ namespace UnitTests_PreviewHandlerCommon { var streamWrapper = new StreamWrapper(stream); } - catch (ArgumentNullException ex) + catch (ArgumentNullException ex) { exception = ex; } @@ -151,7 +151,7 @@ namespace UnitTests_PreviewHandlerCommon { // Arrange int expectedDwOrigin = 0; - switch (origin) + switch (origin) { case SeekOrigin.Begin: expectedDwOrigin = 0; @@ -218,7 +218,7 @@ namespace UnitTests_PreviewHandlerCommon { streamWrapper.Read(buffer, offSet, bytesToRead); } - catch (ArgumentOutOfRangeException ex) + catch (ArgumentOutOfRangeException ex) { exception = ex; } @@ -236,7 +236,7 @@ namespace UnitTests_PreviewHandlerCommon // Arrange var inputBuffer = new byte[1024]; var streamBytes = new byte[count]; - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { streamBytes[i] = (byte)i; } @@ -244,12 +244,12 @@ namespace UnitTests_PreviewHandlerCommon var stremMock = new Mock(); stremMock - .Setup(x => x.Read(It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((buffer, countToRead , bytesReadPtr) => - { - Array.Copy(streamBytes, 0, buffer, 0, streamBytes.Length); - Marshal.WriteInt32(bytesReadPtr, count); - }); + .Setup(x => x.Read(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback((buffer, countToRead, bytesReadPtr) => + { + Array.Copy(streamBytes, 0, buffer, 0, streamBytes.Length); + Marshal.WriteInt32(bytesReadPtr, count); + }); var streamWrapper = new StreamWrapper(stremMock.Object); @@ -274,7 +274,7 @@ namespace UnitTests_PreviewHandlerCommon { streamWrapper.Flush(); } - catch (NotImplementedException ex) + catch (NotImplementedException ex) { exception = ex; } diff --git a/src/modules/previewpane/UnitTests-SvgPreviewHandler/SvgPreviewControlTests.cs b/src/modules/previewpane/UnitTests-SvgPreviewHandler/SvgPreviewControlTests.cs index 9e2469fc4..0f0e95faf 100644 --- a/src/modules/previewpane/UnitTests-SvgPreviewHandler/SvgPreviewControlTests.cs +++ b/src/modules/previewpane/UnitTests-SvgPreviewHandler/SvgPreviewControlTests.cs @@ -23,7 +23,7 @@ namespace UnitTests_SvgPreviewHandler public void SvgPreviewControl_ShouldAddExtendedBrowserControl_WhenDoPreviewCalled() { // Arrange - using (var svgPreviewControl = new SvgPreviewControl()) + using (var svgPreviewControl = new SvgPreviewControl()) { // Act svgPreviewControl.DoPreview(GetMockStream("")); @@ -38,7 +38,7 @@ namespace UnitTests_SvgPreviewHandler public void SvgPreviewControl_ShouldSetDocumentStream_WhenDoPreviewCalled() { // Arrange - using (var svgPreviewControl = new SvgPreviewControl()) + using (var svgPreviewControl = new SvgPreviewControl()) { // Act svgPreviewControl.DoPreview(GetMockStream("")); @@ -66,7 +66,7 @@ namespace UnitTests_SvgPreviewHandler public void SvgPreviewControl_ShouldFillDockForWebBrowser_WhenDoPreviewCalled() { // Arrange - using (var svgPreviewControl = new SvgPreviewControl()) + using (var svgPreviewControl = new SvgPreviewControl()) { // Act svgPreviewControl.DoPreview(GetMockStream("")); @@ -80,7 +80,7 @@ namespace UnitTests_SvgPreviewHandler public void SvgPreviewControl_ShouldSetScriptErrorsSuppressedProperty_WhenDoPreviewCalled() { // Arrange - using (var svgPreviewControl = new SvgPreviewControl()) + using (var svgPreviewControl = new SvgPreviewControl()) { // Act svgPreviewControl.DoPreview(GetMockStream("")); @@ -94,7 +94,7 @@ namespace UnitTests_SvgPreviewHandler public void SvgPreviewControl_ShouldSetScrollBarsEnabledProperty_WhenDoPreviewCalled() { // Arrange - using (var svgPreviewControl = new SvgPreviewControl()) + using (var svgPreviewControl = new SvgPreviewControl()) { // Act svgPreviewControl.DoPreview(GetMockStream("")); @@ -175,7 +175,7 @@ namespace UnitTests_SvgPreviewHandler public void SvgPreviewControl_ShouldAddTextBox_IfBlockedElementsArePresent() { // Arrange - using (var svgPreviewControl = new SvgPreviewControl()) + using (var svgPreviewControl = new SvgPreviewControl()) { var svgBuilder = new StringBuilder(); svgBuilder.AppendLine(""); @@ -196,7 +196,7 @@ namespace UnitTests_SvgPreviewHandler public void SvgPreviewControl_ShouldNotAddTextBox_IfNoBlockedElementsArePresent() { // Arrange - using (var svgPreviewControl = new SvgPreviewControl()) + using (var svgPreviewControl = new SvgPreviewControl()) { var svgBuilder = new StringBuilder(); svgBuilder.AppendLine(""); diff --git a/src/tests/win-app-driver/FancyZonesTests/EditorCanvasZoneResizeTests.cs b/src/tests/win-app-driver/FancyZonesTests/EditorCanvasZoneResizeTests.cs index c8d6b1870..2ee1bd474 100644 --- a/src/tests/win-app-driver/FancyZonesTests/EditorCanvasZoneResizeTests.cs +++ b/src/tests/win-app-driver/FancyZonesTests/EditorCanvasZoneResizeTests.cs @@ -12,7 +12,7 @@ namespace PowerToysTests { int shiftX = shiftLeft ? -(corner.Rect.Width / 2) + 1 : (corner.Rect.Width / 2) - 1; int shiftY = shiftUp ? -(corner.Rect.Height / 2) + 1 : (corner.Rect.Height / 2) - 1; - + new Actions(session).MoveToElement(corner) .MoveByOffset(shiftX, shiftY) .ClickAndHold().MoveByOffset(xOffset, yOffset).Release().Perform(); @@ -83,7 +83,7 @@ namespace PowerToysTests Assert.IsTrue(leftBorder.Rect.X <= rightBorder.Rect.X); Assert.IsTrue(width > rightBorder.Rect.X - leftBorder.Rect.X); } - + [TestMethod] public void MoveRightBorder() { @@ -205,7 +205,7 @@ namespace PowerToysTests Assert.IsTrue(bottomLeftCorner.Rect.X <= rightBorder.Rect.X); Assert.IsTrue(actualHeight < expectedHeight); Assert.IsTrue(actualWidth < expectedWidth); - + expectedHeight = actualHeight; expectedWidth = actualWidth; @@ -271,7 +271,7 @@ namespace PowerToysTests LaunchPowerToys(); } OpenEditor(); - OpenCustomLayouts(); + OpenCustomLayouts(); } [ClassCleanup] diff --git a/src/tests/win-app-driver/FancyZonesTests/EditorCustomLayoutsTests.cs b/src/tests/win-app-driver/FancyZonesTests/EditorCustomLayoutsTests.cs index 67289b247..48901c9d0 100644 --- a/src/tests/win-app-driver/FancyZonesTests/EditorCustomLayoutsTests.cs +++ b/src/tests/win-app-driver/FancyZonesTests/EditorCustomLayoutsTests.cs @@ -9,7 +9,7 @@ namespace PowerToysTests { [TestClass] public class FancyZonesEditorCustomLayoutsTests : FancyZonesEditor - { + { private void SetLayoutName(string name) { WindowsElement textBox = session.FindElementByClassName("TextBox"); @@ -119,7 +119,7 @@ namespace PowerToysTests { OpenCreatorWindow("Create new custom", "Custom layout creator"); string name = "My custom zone layout name"; - SetLayoutName(name); + SetLayoutName(name); SaveTest("canvas", name, 0); } @@ -236,7 +236,7 @@ namespace PowerToysTests SetLayoutName(name); new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform(); - + //remove layout OpenEditor(); OpenCustomLayouts(); diff --git a/src/tests/win-app-driver/FancyZonesTests/EditorGridZoneResizeTests.cs b/src/tests/win-app-driver/FancyZonesTests/EditorGridZoneResizeTests.cs index 961b0113e..a790b80c3 100644 --- a/src/tests/win-app-driver/FancyZonesTests/EditorGridZoneResizeTests.cs +++ b/src/tests/win-app-driver/FancyZonesTests/EditorGridZoneResizeTests.cs @@ -7,7 +7,7 @@ using System.Collections.ObjectModel; using System.Windows.Forms; namespace PowerToysTests -{ +{ [TestClass] public class FancyZonesEditorGridZoneResizeTests : FancyZonesEditor { @@ -82,7 +82,7 @@ namespace PowerToysTests foreach (AppiumWebElement thumb in thumbs) { int expected = thumb.Rect.X; - + Move(thumb, 0, false, false); int actual = thumb.Rect.X; @@ -242,7 +242,7 @@ namespace PowerToysTests ReadOnlyCollection zones = session.FindElementsByClassName("GridZone"); Assert.AreEqual(4, zones.Count); - + //check that zone was splitted vertically Assert.AreEqual(zones[0].Rect.Height, zones[1].Rect.Height); Assert.AreEqual(zones[1].Rect.Height, zones[2].Rect.Height); @@ -311,7 +311,7 @@ namespace PowerToysTests [TestMethod] public void MoveVerticallyWithLimiter() { - OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton"); + OpenCreatorWindow("Rows", "Custom table layout creator", "EditTemplateButton"); WindowsElement gridEditor = session.FindElementByClassName("GridEditor"); Assert.IsNotNull(gridEditor); @@ -388,7 +388,7 @@ namespace PowerToysTests //move thumb AppiumWebElement thumb = thumbs[1]; //thumb from merged zone is still present - Move(thumb, 0, false, true); + Move(thumb, 0, false, true); Assert.IsTrue(thumb.Rect.Left <= moveStep); Assert.IsTrue(thumb.Rect.Right > 0); } diff --git a/src/tests/win-app-driver/FancyZonesTests/EditorOpeningTests.cs b/src/tests/win-app-driver/FancyZonesTests/EditorOpeningTests.cs index 02f587709..507bf65b1 100644 --- a/src/tests/win-app-driver/FancyZonesTests/EditorOpeningTests.cs +++ b/src/tests/win-app-driver/FancyZonesTests/EditorOpeningTests.cs @@ -248,8 +248,8 @@ namespace PowerToysTests [TestInitialize] public void TestInitialize() - { - + { + } [TestCleanup] diff --git a/src/tests/win-app-driver/FancyZonesTests/EditorSettingsTests.cs b/src/tests/win-app-driver/FancyZonesTests/EditorSettingsTests.cs index bca8542c1..c10687da2 100644 --- a/src/tests/win-app-driver/FancyZonesTests/EditorSettingsTests.cs +++ b/src/tests/win-app-driver/FancyZonesTests/EditorSettingsTests.cs @@ -40,7 +40,7 @@ namespace PowerToysTests WaitSeconds(1); Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting(editorZoneCount)); OpenEditor(); - + minusButton = session.FindElementByAccessibilityId("decrementZones"); zoneCount = session.FindElementByAccessibilityId("zoneCount"); } @@ -64,7 +64,7 @@ namespace PowerToysTests [TestMethod] public void ShowSpacingTest() { - for (int i = 0; i < 2; ++i) + for (int i = 0; i < 2; ++i) { OpenEditor(); @@ -139,7 +139,7 @@ namespace PowerToysTests Assert.AreEqual(editorSpacingValue, GetEditZonesSetting(editorSpacing)); } } - + [TestMethod] public void SpacingTestLargeValue() { diff --git a/src/tests/win-app-driver/FancyZonesTests/EditorTemplatesEditTests.cs b/src/tests/win-app-driver/FancyZonesTests/EditorTemplatesEditTests.cs index 24dbf0bb3..6e88583c0 100644 --- a/src/tests/win-app-driver/FancyZonesTests/EditorTemplatesEditTests.cs +++ b/src/tests/win-app-driver/FancyZonesTests/EditorTemplatesEditTests.cs @@ -196,7 +196,7 @@ namespace PowerToysTests editorWindow.SendKeys(OpenQA.Selenium.Keys.Alt + OpenQA.Selenium.Keys.F4); } } - catch(OpenQA.Selenium.WebDriverException) + catch (OpenQA.Selenium.WebDriverException) { //editor has already closed } diff --git a/src/tests/win-app-driver/FancyZonesTests/FancyZonesSettingsTests.cs b/src/tests/win-app-driver/FancyZonesTests/FancyZonesSettingsTests.cs index c9021bfd7..1c3711e4a 100644 --- a/src/tests/win-app-driver/FancyZonesTests/FancyZonesSettingsTests.cs +++ b/src/tests/win-app-driver/FancyZonesTests/FancyZonesSettingsTests.cs @@ -58,7 +58,7 @@ namespace PowerToysTests { return properties[propertyName].ToObject()["value"].Value(); } - + private void ScrollDown(int count) { Actions scroll = new Actions(session); @@ -115,7 +115,7 @@ namespace PowerToysTests colorInput.SendKeys("0"); colorInput.SendKeys(OpenQA.Selenium.Keys.Enter); Assert.AreEqual("0\r\n", colorInput.Text); - + string invalidSymbols = "qwertyuiopasdfghjklzxcvbnm,./';][{}:`~!@#$%^&*()_-+=\"\'\\"; foreach (char symbol in invalidSymbols) { @@ -148,7 +148,7 @@ namespace PowerToysTests //too big value colorInput.SendKeys(OpenQA.Selenium.Keys.Control + OpenQA.Selenium.Keys.Backspace); colorInput.SendKeys("555"); - + Actions action = new Actions(session); //reset focus from input action.MoveToElement(colorInput).MoveByOffset(0, colorInput.Rect.Height).Click().Perform(); @@ -290,7 +290,7 @@ namespace PowerToysTests foreach (WindowsElement toggle in toggles) { Assert.IsNotNull(toggle); - + bool isOn = toggle.GetAttribute("Toggle.ToggleState") == "1"; toggleValues.Add(isOn); @@ -331,14 +331,14 @@ namespace PowerToysTests foreach (WindowsElement toggle in toggles) { Assert.IsNotNull(toggle); - + bool isOn = toggle.GetAttribute("Toggle.ToggleState") == "1"; toggleValues.Add(isOn); toggle.Click(); toggle.Click(); } - + SaveChanges(); WaitSeconds(1); @@ -372,12 +372,12 @@ namespace PowerToysTests SaveAndCheckOpacitySettings(editor, 100); //for invalid input values previously saved value expected - SetOpacity(editor, "asdf"); - SaveAndCheckOpacitySettings(editor, 100); - + SetOpacity(editor, "asdf"); + SaveAndCheckOpacitySettings(editor, 100); + SetOpacity(editor, "*"); - SaveAndCheckOpacitySettings(editor, 100); - + SaveAndCheckOpacitySettings(editor, 100); + SetOpacity(editor, OpenQA.Selenium.Keys.Return); SaveAndCheckOpacitySettings(editor, 100); @@ -396,7 +396,7 @@ namespace PowerToysTests SaveAndCheckOpacitySettings(editor, 99); System.Drawing.Rectangle editorRect = editor.Rect; - + Actions action = new Actions(session); action.MoveToElement(editor).MoveByOffset(editorRect.Width / 2 + 10, -editorRect.Height / 4).Perform(); WaitSeconds(1); @@ -413,7 +413,7 @@ namespace PowerToysTests [TestMethod] public void HighlightOpacityDecreaseValue() { - + WindowsElement editor = session.FindElementByName("Zone opacity (%)"); Assert.IsNotNull(editor); @@ -445,7 +445,7 @@ namespace PowerToysTests editor.Click(); //activate AppiumWebElement clearButton = editor.FindElementByName("Clear value"); Assert.IsNotNull(clearButton); - + /*element is not pointer- or keyboard interactable.*/ Actions action = new Actions(session); action.MoveToElement(clearButton).Click().Perform(); @@ -475,7 +475,7 @@ namespace PowerToysTests .Click().SendKeys(OpenQA.Selenium.Keys.PageDown + OpenQA.Selenium.Keys.PageDown).SendKeys(OpenQA.Selenium.Keys.PageUp + OpenQA.Selenium.Keys.PageUp).Perform(); TestColorSliders(saturationAndBrightness[0], hue[0], hex[0], red[0], green[0], blue[0], "fancyzones_zoneHighlightColor"); } - + [TestMethod] public void HighlightColorTest() { @@ -508,7 +508,7 @@ namespace PowerToysTests TestRgbInput("Red"); TestRgbInput("Green"); - TestRgbInput("Blue"); + TestRgbInput("Blue"); } [TestMethod] @@ -518,9 +518,9 @@ namespace PowerToysTests WindowsElement hexInput = session.FindElementByXPath("//Edit[@Name=\"Hex\"]"); Assert.IsNotNull(hexInput); - + hexInput.SendKeys(OpenQA.Selenium.Keys.Control + OpenQA.Selenium.Keys.Backspace); - + string invalidSymbols = "qwrtyuiopsghjklzxvnm,./';][{}:`~!#@$%^&*()_-+=\"\'\\"; foreach (char symbol in invalidSymbols) { @@ -535,7 +535,7 @@ namespace PowerToysTests Assert.AreEqual(symbol.ToString(), hexInput.Text.Trim()); hexInput.SendKeys(OpenQA.Selenium.Keys.Backspace); } - + //too many symbols hexInput.SendKeys(OpenQA.Selenium.Keys.Control + OpenQA.Selenium.Keys.Backspace); hexInput.SendKeys("000000"); @@ -604,7 +604,7 @@ namespace PowerToysTests [TestMethod] public void ExitDialogSave() { - WindowsElement toggle = session.FindElementByXPath("//Pane[@Name=\"PowerToys Settings\"]/*[@LocalizedControlType=\"toggleswitch\"]"); + WindowsElement toggle = session.FindElementByXPath("//Pane[@Name=\"PowerToys Settings\"]/*[@LocalizedControlType=\"toggleswitch\"]"); Assert.IsNotNull(toggle); bool initialToggleValue = toggle.GetAttribute("Toggle.ToggleState") == "1"; @@ -618,15 +618,15 @@ namespace PowerToysTests //check if window still opened WindowsElement powerToysWindow = session.FindElementByXPath("//Window[@Name=\"PowerToys Settings\"]"); - Assert.IsNotNull(powerToysWindow); + Assert.IsNotNull(powerToysWindow); //check settings change JObject savedProps = GetProperties(); - + Assert.AreNotEqual(initialToggleValue, GetPropertyValue(savedProps, "fancyzones_shiftDrag")); - + //return initial app state - toggle.Click(); + toggle.Click(); } [TestMethod] @@ -636,7 +636,7 @@ namespace PowerToysTests Assert.IsNotNull(toggle); bool initialToggleValue = toggle.GetAttribute("Toggle.ToggleState") == "1"; - + toggle.Click(); CloseSettings(); @@ -646,12 +646,12 @@ namespace PowerToysTests exitDialog.FindElementByName("Exit").Click(); //check if window still opened - try + try { WindowsElement powerToysWindow = session.FindElementByXPath("//Window[@Name=\"PowerToys Settings\"]"); Assert.IsNull(powerToysWindow); } - catch(OpenQA.Selenium.WebDriverException) + catch (OpenQA.Selenium.WebDriverException) { //window is no longer available, which is expected } @@ -734,7 +734,7 @@ namespace PowerToysTests exitDialogButton.Click(); } } - catch(OpenQA.Selenium.WebDriverException) + catch (OpenQA.Selenium.WebDriverException) { //element couldn't be located } @@ -761,7 +761,7 @@ namespace PowerToysTests [TestCleanup] public void TestCleanup() { - ScrollUp(); + ScrollUp(); } } } diff --git a/src/tests/win-app-driver/PowerToysSession.cs b/src/tests/win-app-driver/PowerToysSession.cs index c6a5e067b..04029d093 100644 --- a/src/tests/win-app-driver/PowerToysSession.cs +++ b/src/tests/win-app-driver/PowerToysSession.cs @@ -158,7 +158,7 @@ namespace PowerToysTests { Console.WriteLine(ex.Message); } -} + } public static void CloseSettings() { @@ -186,7 +186,7 @@ namespace PowerToysTests isLaunched = (pt != null); trayButton.Click(); //close } - catch(OpenQA.Selenium.WebDriverException) + catch (OpenQA.Selenium.WebDriverException) { //PowerToys not found } @@ -228,7 +228,7 @@ namespace PowerToysTests trayButton.Click(); //close tray isPowerToysLaunched = false; } - catch(Exception ex) + catch (Exception ex) { Console.WriteLine(ex.Message); } diff --git a/src/tests/win-app-driver/PowerToysTrayTests.cs b/src/tests/win-app-driver/PowerToysTrayTests.cs index a8b21432f..d7bcdad46 100644 --- a/src/tests/win-app-driver/PowerToysTrayTests.cs +++ b/src/tests/win-app-driver/PowerToysTrayTests.cs @@ -34,12 +34,12 @@ namespace PowerToysTests WindowsElement pt = session.FindElementByName("PowerToys"); Assert.IsNotNull(pt); - new Actions(session).MoveToElement(pt).ContextClick().Perform(); - - //open settings - WaitElementByXPath("//MenuItem[@Name=\"Settings\"]").Click(); - - //check settings window opened + new Actions(session).MoveToElement(pt).ContextClick().Perform(); + + //open settings + WaitElementByXPath("//MenuItem[@Name=\"Settings\"]").Click(); + + //check settings window opened WindowsElement settingsWindow = WaitElementByName("PowerToys Settings"); Assert.IsNotNull(settingsWindow); @@ -58,12 +58,12 @@ namespace PowerToysTests AppiumWebElement powerToys = overflowArea.FindElementByName("PowerToys"); Assert.IsNotNull(powerToys); - new Actions(session).MoveToElement(powerToys).ContextClick().Perform(); - - //exit - WaitElementByXPath("//MenuItem[@Name=\"Exit\"]").Click(); - - //check PowerToys exited + new Actions(session).MoveToElement(powerToys).ContextClick().Perform(); + + //exit + WaitElementByXPath("//MenuItem[@Name=\"Exit\"]").Click(); + + //check PowerToys exited powerToys = null; try { @@ -108,8 +108,8 @@ namespace PowerToysTests if (isSettingsOpened) { CloseSettings(); - } - + } + if (isTrayOpened) { trayButton.Click(); diff --git a/src/tests/win-app-driver/TestShortcutHelper.cs b/src/tests/win-app-driver/TestShortcutHelper.cs index cb69738d2..e41b9f6a7 100644 --- a/src/tests/win-app-driver/TestShortcutHelper.cs +++ b/src/tests/win-app-driver/TestShortcutHelper.cs @@ -17,7 +17,7 @@ namespace PowerToysTests private void PressWinKey() { - if(!isWinKeyPressed) + if (!isWinKeyPressed) { new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).Perform(); isWinKeyPressed = true; @@ -26,7 +26,7 @@ namespace PowerToysTests private void ReleaseWinKey() { - if(isWinKeyPressed) + if (isWinKeyPressed) { new Actions(session).KeyUp(OpenQA.Selenium.Keys.Command).Perform(); isWinKeyPressed = false; @@ -89,7 +89,8 @@ namespace PowerToysTests // FindElementByClassName will be faster than using with XPath. WindowsElement shortcutHelperWindow = session.FindElementByClassName("PToyD2DPopup"); Assert.IsNotNull(shortcutHelperWindow); - } catch (InvalidOperationException) + } + catch (InvalidOperationException) { // Not the exception we wanted to catch here. Assert.Fail("Shortcut Guide not found"); @@ -121,11 +122,12 @@ namespace PowerToysTests try { startMenuWindow = session.FindElementByXPath("/Pane[@ClassName=\"#32769\"]/Window[@Name=\"Start\"]"); - } catch (Exception) + } + catch (Exception) { //Start menu not found, as expected. } - if (startMenuWindow!=null) + if (startMenuWindow != null) { string startMenuWindowHandle = (int.Parse(startMenuWindow.GetAttribute("NativeWindowHandle"))).ToString("x"); // Create session for controlling the Start Menu.