From dc744f236e52c4fd1800eaba4ef7ab899088cb84 Mon Sep 17 00:00:00 2001 From: Clint Rutkas Date: Wed, 19 Aug 2020 15:59:10 -0700 Subject: [PATCH] [warningsAsErrors] Getting settings online (#6053) * getting everything to compile * fixing json --- .../AppSpecificKeysDataModel.cs | 2 - .../BasePTModuleSettings.cs | 2 +- .../BoolProperty.cs | 5 +- .../BoolPropertyJsonConverter.cs | 2 - .../ConfigDefaults.cs | 4 -- .../DoubleProperty.cs | 2 +- .../EnabledModules.cs | 48 ++++++++--------- .../FancyZonesSettingsIPCMessage.cs | 5 +- .../GeneralSettings.cs | 22 ++++---- .../GenericProperty`1.cs | 1 - .../ImageResizerProperties.cs | 1 - .../ImageSize.cs | 3 -- .../IntProperty.cs | 2 +- .../KeyboardManagerProfile.cs | 1 - ...Microsoft.PowerToys.Settings.UI.Lib.csproj | 1 + .../PowerPreviewProperties.cs | 18 +++---- .../PowerRenameLocalProperties.cs | 1 - .../PowerRenameSettingsIPCMessage.cs | 5 +- .../ShortcutGuideProperties.cs | 3 -- .../ShortcutGuideSettingsIPCMessage.cs | 5 +- .../SndFancyZonesSettings.cs | 6 +-- .../SndImageResizerSettings.cs | 5 +- .../SndModuleSettings`1.cs | 6 ++- .../SndPowerPreviewSettings.cs | 3 -- .../SndShortcutGuideSettings.cs | 5 +- .../StringProperty.cs | 5 +- .../Utilities/Helper.cs | 3 -- .../ViewModels/Commands/ButtonClickCommand.cs | 4 +- .../ViewModels/FancyZonesViewModel.cs | 40 +++++++-------- .../ViewModels/GeneralViewModel.cs | 20 ++++---- .../ViewModels/ImageResizerViewModel.cs | 20 +++----- .../ViewModels/KeyboardManagerViewModel.cs | 51 +++++++++---------- .../ViewModels/PowerLauncherViewModel.cs | 1 - .../ViewModels/PowerPreviewViewModel.cs | 13 +++-- .../ViewModels/PowerRenameViewModel.cs | 7 ++- .../ViewModels/ShortcutGuideViewModel.cs | 12 ++--- ...rosoft.PowerToys.Settings.UI.Runner.csproj | 1 + ...oft.PowerToys.Settings.UI.UnitTests.csproj | 3 +- .../ViewModelTests/PowerPreview.cs | 6 +-- .../Microsoft.PowerToys.Settings.UI.csproj | 7 +++ .../Views/FancyZonesPage.xaml.cs | 2 +- .../Views/GeneralPage.xaml.cs | 4 +- .../Views/ImageResizerPage.xaml.cs | 6 +-- .../Views/KeyboardManagerPage.xaml.cs | 2 +- .../Views/PowerPreviewPage.xaml.cs | 8 +-- .../Views/PowerRenamePage.xaml.cs | 2 +- 46 files changed, 162 insertions(+), 213 deletions(-) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/AppSpecificKeysDataModel.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/AppSpecificKeysDataModel.cs index 1aa1230e58..6d8d851165 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/AppSpecificKeysDataModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/AppSpecificKeysDataModel.cs @@ -3,9 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Linq; using System.Text.Json.Serialization; -using Microsoft.PowerToys.Settings.UI.Lib.Utilities; namespace Microsoft.PowerToys.Settings.UI.Lib { diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/BasePTModuleSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/BasePTModuleSettings.cs index a638ade38c..5a223c3b15 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/BasePTModuleSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/BasePTModuleSettings.cs @@ -21,7 +21,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public virtual string ToJsonString() { // By default JsonSerializer will only serialize the properties in the base class. This can be avoided by passing the object type (more details at https://stackoverflow.com/a/62498888) - return JsonSerializer.Serialize(this, this.GetType()); + return JsonSerializer.Serialize(this, GetType()); } } } diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/BoolProperty.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/BoolProperty.cs index c3b2611f8c..fad18ef88f 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/BoolProperty.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/BoolProperty.cs @@ -2,9 +2,6 @@ // 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; -using System.Collections.Generic; -using System.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -14,7 +11,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib { public BoolProperty() { - this.Value = false; + Value = false; } public BoolProperty(bool value) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/BoolPropertyJsonConverter.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/BoolPropertyJsonConverter.cs index 6ef310e6a5..bdfbd6e00e 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/BoolPropertyJsonConverter.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/BoolPropertyJsonConverter.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.Text; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ConfigDefaults.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ConfigDefaults.cs index 504d076bda..5d25a15d00 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ConfigDefaults.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ConfigDefaults.cs @@ -2,10 +2,6 @@ // 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; -using System.Collections.Generic; -using System.Text; - namespace Microsoft.PowerToys.Settings.UI.Lib { public static class ConfigDefaults diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/DoubleProperty.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/DoubleProperty.cs index 1d714d93e3..4b6ee0f1f6 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/DoubleProperty.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/DoubleProperty.cs @@ -12,7 +12,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib { public DoubleProperty() { - this.Value = 0.0; + Value = 0.0; } public DoubleProperty(double value) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs index 8d5ea1dde0..835b9a7262 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/EnabledModules.cs @@ -21,13 +21,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonPropertyName("FancyZones")] public bool FancyZones { - get => this.fancyZones; + get => fancyZones; set { - if (this.fancyZones != value) + if (fancyZones != value) { LogTelemetryEvent(value); - this.fancyZones = value; + fancyZones = value; } } } @@ -37,13 +37,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonPropertyName("Image Resizer")] public bool ImageResizer { - get => this.imageResizer; + get => imageResizer; set { - if (this.imageResizer != value) + if (imageResizer != value) { LogTelemetryEvent(value); - this.imageResizer = value; + imageResizer = value; } } } @@ -53,13 +53,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonPropertyName("File Explorer Preview")] public bool FileExplorerPreview { - get => this.fileExplorerPreview; + get => fileExplorerPreview; set { - if (this.fileExplorerPreview != value) + if (fileExplorerPreview != value) { LogTelemetryEvent(value); - this.fileExplorerPreview = value; + fileExplorerPreview = value; } } } @@ -69,13 +69,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonPropertyName("Shortcut Guide")] public bool ShortcutGuide { - get => this.shortcutGuide; + get => shortcutGuide; set { - if (this.shortcutGuide != value) + if (shortcutGuide != value) { LogTelemetryEvent(value); - this.shortcutGuide = value; + shortcutGuide = value; } } } @@ -84,13 +84,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public bool PowerRename { - get => this.powerRename; + get => powerRename; set { - if (this.powerRename != value) + if (powerRename != value) { LogTelemetryEvent(value); - this.powerRename = value; + powerRename = value; } } } @@ -100,13 +100,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonPropertyName("Keyboard Manager")] public bool KeyboardManager { - get => this.keyboardManager; + get => keyboardManager; set { - if (this.keyboardManager != value) + if (keyboardManager != value) { LogTelemetryEvent(value); - this.keyboardManager = value; + keyboardManager = value; } } } @@ -116,13 +116,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonPropertyName("PowerToys Run")] public bool PowerLauncher { - get => this.powerLauncher; + get => powerLauncher; set { - if (this.powerLauncher != value) + if (powerLauncher != value) { LogTelemetryEvent(value); - this.powerLauncher = value; + powerLauncher = value; } } } @@ -132,13 +132,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonPropertyName("ColorPicker")] public bool ColorPicker { - get => this.colorPicker; + get => colorPicker; set { - if (this.colorPicker != value) + if (colorPicker != value) { LogTelemetryEvent(value); - this.colorPicker = value; + colorPicker = value; } } } diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/FancyZonesSettingsIPCMessage.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/FancyZonesSettingsIPCMessage.cs index e53552087d..e56d53f534 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/FancyZonesSettingsIPCMessage.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/FancyZonesSettingsIPCMessage.cs @@ -2,9 +2,6 @@ // 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; -using System.Collections.Generic; -using System.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -21,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public FancyZonesSettingsIPCMessage(SndFancyZonesSettings settings) { - this.Powertoys = settings; + Powertoys = settings; } public string ToJsonString() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/GeneralSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/GeneralSettings.cs index 6b4712ff96..6b8a4932b0 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/GeneralSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/GeneralSettings.cs @@ -52,24 +52,24 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public GeneralSettings() { - this.Packaged = false; - this.Startup = false; - this.IsAdmin = false; - this.IsElevated = false; - this.AutoDownloadUpdates = false; - this.Theme = "system"; - this.SystemTheme = "light"; + Packaged = false; + Startup = false; + IsAdmin = false; + IsElevated = false; + AutoDownloadUpdates = false; + Theme = "system"; + SystemTheme = "light"; try { - this.PowertoysVersion = DefaultPowertoysVersion(); + PowertoysVersion = DefaultPowertoysVersion(); } catch { - this.PowertoysVersion = "v0.0.0"; + PowertoysVersion = "v0.0.0"; } - this.Enabled = new EnabledModules(); - this.CustomActionName = string.Empty; + Enabled = new EnabledModules(); + CustomActionName = string.Empty; } // converts the current to a json string. diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/GenericProperty`1.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/GenericProperty`1.cs index bbdeed1cdd..8a75f16e46 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/GenericProperty`1.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/GenericProperty`1.cs @@ -2,7 +2,6 @@ // 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.Text.Json; using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ImageResizerProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ImageResizerProperties.cs index fd4e69b595..ef217cb47b 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ImageResizerProperties.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ImageResizerProperties.cs @@ -2,7 +2,6 @@ // 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.Collections.Generic; using System.Collections.ObjectModel; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ImageSize.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ImageSize.cs index 0f12980fd5..a1519e1a5d 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ImageSize.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ImageSize.cs @@ -2,11 +2,8 @@ // 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; -using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; -using System.Text; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/IntProperty.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/IntProperty.cs index 8706806da2..59da1fa985 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/IntProperty.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/IntProperty.cs @@ -12,7 +12,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib { public IntProperty() { - this.Value = 0; + Value = 0; } public IntProperty(int value) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/KeyboardManagerProfile.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/KeyboardManagerProfile.cs index 35eaf6558a..52a0c2d764 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/KeyboardManagerProfile.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/KeyboardManagerProfile.cs @@ -2,7 +2,6 @@ // 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.Collections.Generic; using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/Microsoft.PowerToys.Settings.UI.Lib.csproj b/src/core/Microsoft.PowerToys.Settings.UI.Lib/Microsoft.PowerToys.Settings.UI.Lib.csproj index e6c62395d3..525be8b769 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/Microsoft.PowerToys.Settings.UI.Lib.csproj +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/Microsoft.PowerToys.Settings.UI.Lib.csproj @@ -14,6 +14,7 @@ Github PowerToys en-US + true diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerPreviewProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerPreviewProperties.cs index ae18c935a2..1b69a4c75b 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerPreviewProperties.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerPreviewProperties.cs @@ -18,13 +18,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonConverter(typeof(BoolPropertyJsonConverter))] public bool EnableSvgPreview { - get => this.enableSvgPreview; + get => enableSvgPreview; set { - if (value != this.enableSvgPreview) + if (value != enableSvgPreview) { LogTelemetryEvent(value); - this.enableSvgPreview = value; + enableSvgPreview = value; } } } @@ -35,13 +35,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonConverter(typeof(BoolPropertyJsonConverter))] public bool EnableSvgThumbnail { - get => this.enableSvgThumbnail; + get => enableSvgThumbnail; set { - if (value != this.enableSvgThumbnail) + if (value != enableSvgThumbnail) { LogTelemetryEvent(value); - this.enableSvgThumbnail = value; + enableSvgThumbnail = value; } } } @@ -52,13 +52,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonConverter(typeof(BoolPropertyJsonConverter))] public bool EnableMdPreview { - get => this.enableMdPreview; + get => enableMdPreview; set { - if (value != this.enableMdPreview) + if (value != enableMdPreview) { LogTelemetryEvent(value); - this.enableMdPreview = value; + enableMdPreview = value; } } } diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs index c48563fcc9..a0ba1966fe 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Text.Json; -using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib { diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettingsIPCMessage.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettingsIPCMessage.cs index 047397678f..b410a9600e 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettingsIPCMessage.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettingsIPCMessage.cs @@ -2,9 +2,6 @@ // 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; -using System.Collections.Generic; -using System.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -21,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public PowerRenameSettingsIPCMessage(SndPowerRenameSettings settings) { - this.Powertoys = settings; + Powertoys = settings; } public string ToJsonString() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideProperties.cs index 0a4f525dc3..4d3bbaf3bc 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideProperties.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideProperties.cs @@ -2,9 +2,6 @@ // 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; -using System.Collections.Generic; -using System.Text; using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideSettingsIPCMessage.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideSettingsIPCMessage.cs index c0c835b180..348e932f73 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideSettingsIPCMessage.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ShortcutGuideSettingsIPCMessage.cs @@ -2,9 +2,6 @@ // 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; -using System.Collections.Generic; -using System.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -21,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public ShortcutGuideSettingsIPCMessage(SndShortcutGuideSettings settings) { - this.Powertoys = settings; + Powertoys = settings; } public string ToJsonString() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndFancyZonesSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndFancyZonesSettings.cs index 68e307fc5f..e644c985a5 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndFancyZonesSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndFancyZonesSettings.cs @@ -2,11 +2,7 @@ // 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; -using System.Collections.Generic; -using System.Text; using System.Text.Json; -using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib { @@ -20,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public SndFancyZonesSettings(FancyZonesSettings settings) { - this.FancyZones = settings; + FancyZones = settings; } public string ToJsonString() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndImageResizerSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndImageResizerSettings.cs index c4fb20ac2a..8092f3dd69 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndImageResizerSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndImageResizerSettings.cs @@ -2,9 +2,6 @@ // 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; -using System.Collections.Generic; -using System.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -17,7 +14,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public SndImageResizerSettings(ImageResizerSettings settings) { - this.ImageResizer = settings; + ImageResizer = settings; } public string ToJsonString() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndModuleSettings`1.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndModuleSettings`1.cs index 24e8665a04..8f51d25246 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndModuleSettings`1.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndModuleSettings`1.cs @@ -3,13 +3,15 @@ // See the LICENSE file in the project root for more information. using System.Text.Json; +using System.Text.Json.Serialization; namespace Microsoft.PowerToys.Settings.UI.Lib { // Represents a powertoys module settings setnt to the runner. public class SndModuleSettings { - public T powertoys { get; set; } + [JsonPropertyName("powertoys")] + public T PowertoysSetting { get; set; } public SndModuleSettings() { @@ -17,7 +19,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public SndModuleSettings(T settings) { - this.powertoys = settings; + PowertoysSetting = settings; } public string ToJsonString() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndPowerPreviewSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndPowerPreviewSettings.cs index c0decebfe2..66101c1e02 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndPowerPreviewSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndPowerPreviewSettings.cs @@ -2,9 +2,6 @@ // 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; -using System.Collections.Generic; -using System.Text; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndShortcutGuideSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndShortcutGuideSettings.cs index 80f49f4e99..19e1ca513f 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndShortcutGuideSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SndShortcutGuideSettings.cs @@ -2,9 +2,6 @@ // 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; -using System.Collections.Generic; -using System.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -21,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib public SndShortcutGuideSettings(ShortcutGuideSettings settings) { - this.ShortcutGuide = settings; + ShortcutGuide = settings; } public string ToJsonString() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/StringProperty.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/StringProperty.cs index 372e450aa9..6165d75448 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/StringProperty.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/StringProperty.cs @@ -2,9 +2,6 @@ // 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; -using System.Collections.Generic; -using System.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -15,7 +12,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib { public StringProperty() { - this.Value = string.Empty; + Value = string.Empty; } public StringProperty(string value) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/Utilities/Helper.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/Utilities/Helper.cs index 0af7cae035..b39266484d 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/Utilities/Helper.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/Utilities/Helper.cs @@ -7,9 +7,6 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Text.Json; -using System.Text.RegularExpressions; using Microsoft.PowerToys.Settings.UI.Lib.CustomAction; namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/Commands/ButtonClickCommand.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/Commands/ButtonClickCommand.cs index c31b17494e..9ddf80cfe4 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/Commands/ButtonClickCommand.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/Commands/ButtonClickCommand.cs @@ -13,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands public ButtonClickCommand(Action execute) { - this._execute = execute; + _execute = execute; } // Occurs when changes occur that affect whether or not the command should execute. @@ -30,5 +30,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands { _execute(); } + + public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty); } } diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/FancyZonesViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/FancyZonesViewModel.cs index 9b06937353..5cf3da09ba 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/FancyZonesViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/FancyZonesViewModel.cs @@ -35,35 +35,35 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels SettingsUtils.SaveSettings(Settings.ToJsonString(), GetSettingsSubPath()); } - this.LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor); + LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor); - this._shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value; - this._mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value; - this._overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value; - this._moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value; - this._displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value; - this._zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value; - this._appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value; - this._openWindowOnActiveMonitor = Settings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value; - this._restoreSize = Settings.Properties.FancyzonesRestoreSize.Value; - this._useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value; - this._showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value; - this._makeDraggedWindowTransparent = Settings.Properties.FancyzonesMakeDraggedWindowTransparent.Value; - this._highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value; - this._excludedApps = Settings.Properties.FancyzonesExcludedApps.Value; - this.EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value; + _shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value; + _mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value; + _overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value; + _moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value; + _displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value; + _zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value; + _appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value; + _openWindowOnActiveMonitor = Settings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value; + _restoreSize = Settings.Properties.FancyzonesRestoreSize.Value; + _useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value; + _showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value; + _makeDraggedWindowTransparent = Settings.Properties.FancyzonesMakeDraggedWindowTransparent.Value; + _highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value; + _excludedApps = Settings.Properties.FancyzonesExcludedApps.Value; + EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value; // set the callback functions value to hangle outgoing IPC message. SendConfigMSG = ipcMSGCallBackFunc; string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value; - this._zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor : "#F5FCFF"; + _zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor : "#F5FCFF"; string borderColor = Settings.Properties.FancyzonesBorderColor.Value; - this._zoneBorderColor = borderColor != string.Empty ? borderColor : "#FFFFFF"; + _zoneBorderColor = borderColor != string.Empty ? borderColor : "#FFFFFF"; string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value; - this._zoneHighlightColor = highlightColor != string.Empty ? highlightColor : "#0078D7"; + _zoneHighlightColor = highlightColor != string.Empty ? highlightColor : "#0078D7"; GeneralSettings generalSettings; try @@ -76,7 +76,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty); } - this._isEnabled = generalSettings.Enabled.FancyZones; + _isEnabled = generalSettings.Enabled.FancyZones; } private bool _isEnabled; diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/GeneralViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/GeneralViewModel.cs index f2975d50dc..51eccccc19 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/GeneralViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/GeneralViewModel.cs @@ -5,7 +5,6 @@ using System; using System.Diagnostics; using System.Runtime.CompilerServices; -using System.Text.Json; using Microsoft.PowerToys.Settings.UI.Lib.Helpers; using Microsoft.PowerToys.Settings.UI.Lib.Utilities; using Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands; @@ -20,7 +19,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels public ButtonClickCommand RestartElevatedButtonEventHandler { get; set; } - public Func UpdateUIThemeCallBack { get; } public Func SendConfigMSG { get; } @@ -29,16 +27,16 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels public Func SendCheckForUpdatesConfigMSG { get; } - public readonly string RunningAsUserDefaultText; + public string RunningAsUserDefaultText { get; set; } - public readonly string RunningAsAdminDefaultText; + public string RunningAsAdminDefaultText { get; set; } - public string SettingsConfigFileFolder = string.Empty; + private string _settingsConfigFileFolder = string.Empty; public GeneralViewModel(string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func updateTheme, Func ipcMSGCallBackFunc, Func ipcMSGRestartAsAdminMSGCallBackFunc, Func ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "") { - this.CheckFoUpdatesEventHandler = new ButtonClickCommand(CheckForUpdates_Click); - this.RestartElevatedButtonEventHandler = new ButtonClickCommand(Restart_Elevated); + CheckFoUpdatesEventHandler = new ButtonClickCommand(CheckForUpdates_Click); + RestartElevatedButtonEventHandler = new ButtonClickCommand(Restart_Elevated); try { @@ -72,7 +70,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels UpdateUIThemeCallBack(GeneralSettingsConfigs.Theme.ToLower()); // Update Settings file folder: - SettingsConfigFileFolder = configFileSubfolder; + _settingsConfigFileFolder = configFileSubfolder; switch (GeneralSettingsConfigs.Theme.ToLower()) { @@ -341,9 +339,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels } // callback function to launch the URL to check for updates. - private async void CheckForUpdates_Click() + private void CheckForUpdates_Click() { - GeneralSettings settings = SettingsUtils.GetSettings(SettingsConfigFileFolder); + GeneralSettings settings = SettingsUtils.GetSettings(_settingsConfigFileFolder); settings.CustomActionName = "check_for_updates"; OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings); @@ -354,7 +352,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels public void Restart_Elevated() { - GeneralSettings settings = SettingsUtils.GetSettings(SettingsConfigFileFolder); + GeneralSettings settings = SettingsUtils.GetSettings(_settingsConfigFileFolder); settings.CustomActionName = "restart_elevation"; OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings); diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/ImageResizerViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/ImageResizerViewModel.cs index 6cbb187452..373f7d0f55 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/ImageResizerViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/ImageResizerViewModel.cs @@ -3,14 +3,10 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; -using System.Windows.Input; -using Microsoft.PowerToys.Settings.UI.Lib; using Microsoft.PowerToys.Settings.UI.Lib.Helpers; -using Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands; namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels { @@ -49,14 +45,14 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels // set the callback functions value to hangle outgoing IPC message. SendConfigMSG = ipcMSGCallBackFunc; - this._isEnabled = generalSettings.Enabled.ImageResizer; - this._advancedSizes = Settings.Properties.ImageresizerSizes.Value; - this._jpegQualityLevel = Settings.Properties.ImageresizerJpegQualityLevel.Value; - this._pngInterlaceOption = Settings.Properties.ImageresizerPngInterlaceOption.Value; - this._tiffCompressOption = Settings.Properties.ImageresizerTiffCompressOption.Value; - this._fileName = Settings.Properties.ImageresizerFileName.Value; - this._keepDateModified = Settings.Properties.ImageresizerKeepDateModified.Value; - this._encoderGuidId = GetEncoderIndex(Settings.Properties.ImageresizerFallbackEncoder.Value); + _isEnabled = generalSettings.Enabled.ImageResizer; + _advancedSizes = Settings.Properties.ImageresizerSizes.Value; + _jpegQualityLevel = Settings.Properties.ImageresizerJpegQualityLevel.Value; + _pngInterlaceOption = Settings.Properties.ImageresizerPngInterlaceOption.Value; + _tiffCompressOption = Settings.Properties.ImageresizerTiffCompressOption.Value; + _fileName = Settings.Properties.ImageresizerFileName.Value; + _keepDateModified = Settings.Properties.ImageresizerKeepDateModified.Value; + _encoderGuidId = GetEncoderIndex(Settings.Properties.ImageresizerFallbackEncoder.Value); int i = 0; foreach (ImageSize size in _advancedSizes) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/KeyboardManagerViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/KeyboardManagerViewModel.cs index c0a795534d..712696733d 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/KeyboardManagerViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/KeyboardManagerViewModel.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -26,13 +25,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels private const string ProfileFileMutexName = "PowerToys.KeyboardManager.ConfigMutex"; private const int ProfileFileMutexWaitTimeoutMilliseconds = 1000; - private readonly FileSystemWatcher watcher; + public KeyboardManagerSettings Settings { get; set; } - private ICommand remapKeyboardCommand; - private ICommand editShortcutCommand; - public KeyboardManagerSettings settings; - private KeyboardManagerProfile profile; - private GeneralSettings generalSettings; + private ICommand _remapKeyboardCommand; + private ICommand _editShortcutCommand; + private KeyboardManagerProfile _profile; + private GeneralSettings _generalSettings; private Func SendConfigMSG { get; } @@ -47,28 +45,28 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels if (SettingsUtils.SettingsExists(PowerToyName)) { // Todo: Be more resilient while reading and saving settings. - settings = SettingsUtils.GetSettings(PowerToyName); + Settings = SettingsUtils.GetSettings(PowerToyName); // Load profile. if (!LoadProfile()) { - profile = new KeyboardManagerProfile(); + _profile = new KeyboardManagerProfile(); } } else { - settings = new KeyboardManagerSettings(PowerToyName); - SettingsUtils.SaveSettings(settings.ToJsonString(), PowerToyName); + Settings = new KeyboardManagerSettings(PowerToyName); + SettingsUtils.SaveSettings(Settings.ToJsonString(), PowerToyName); } if (SettingsUtils.SettingsExists()) { - generalSettings = SettingsUtils.GetSettings(string.Empty); + _generalSettings = SettingsUtils.GetSettings(string.Empty); } else { - generalSettings = new GeneralSettings(); - SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty); + _generalSettings = new GeneralSettings(); + SettingsUtils.SaveSettings(_generalSettings.ToJsonString(), string.Empty); } } @@ -76,16 +74,16 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels { get { - return generalSettings.Enabled.KeyboardManager; + return _generalSettings.Enabled.KeyboardManager; } set { - if (generalSettings.Enabled.KeyboardManager != value) + if (_generalSettings.Enabled.KeyboardManager != value) { - generalSettings.Enabled.KeyboardManager = value; + _generalSettings.Enabled.KeyboardManager = value; OnPropertyChanged(nameof(Enabled)); - OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(generalSettings); + OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(_generalSettings); SendConfigMSG(outgoing.ToString()); } @@ -97,9 +95,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels { get { - if (profile != null) + if (_profile != null) { - return profile.RemapKeys.InProcessRemapKeys; + return _profile.RemapKeys.InProcessRemapKeys; } else { @@ -117,9 +115,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels { get { - if (profile != null) + if (_profile != null) { - return CombineShortcutLists(profile.RemapShortcuts.GlobalRemapShortcuts, profile.RemapShortcuts.AppSpecificRemapShortcuts); + return CombineShortcutLists(_profile.RemapShortcuts.GlobalRemapShortcuts, _profile.RemapShortcuts.AppSpecificRemapShortcuts); } else { @@ -128,9 +126,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels } } - public ICommand RemapKeyboardCommand => remapKeyboardCommand ?? (remapKeyboardCommand = new RelayCommand(OnRemapKeyboard)); + public ICommand RemapKeyboardCommand => _remapKeyboardCommand ?? (_remapKeyboardCommand = new RelayCommand(OnRemapKeyboard)); - public ICommand EditShortcutCommand => editShortcutCommand ?? (editShortcutCommand = new RelayCommand(OnEditShortcut)); + public ICommand EditShortcutCommand => _editShortcutCommand ?? (_editShortcutCommand = new RelayCommand(OnEditShortcut)); private async void OnRemapKeyboard() { @@ -175,8 +173,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels // update the UI element here. try { - profile = SettingsUtils.GetSettings(PowerToyName, settings.Properties.ActiveConfiguration.Value + JsonFileType); - FilterRemapKeysList(profile.RemapKeys.InProcessRemapKeys); + _profile = SettingsUtils.GetSettings(PowerToyName, Settings.Properties.ActiveConfiguration.Value + JsonFileType); + FilterRemapKeysList(_profile.RemapKeys.InProcessRemapKeys); } finally { @@ -198,6 +196,5 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels return success; } - } } diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerLauncherViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerLauncherViewModel.cs index c82bfaafc6..68689f4067 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerLauncherViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerLauncherViewModel.cs @@ -57,7 +57,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels } catch { - } } diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerPreviewViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerPreviewViewModel.cs index 7933a86f3a..e79746f2fe 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerPreviewViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerPreviewViewModel.cs @@ -4,7 +4,6 @@ using System; using System.Runtime.CompilerServices; -using Microsoft.PowerToys.Settings.UI.Lib; using Microsoft.PowerToys.Settings.UI.Lib.Helpers; namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels @@ -17,12 +16,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels private Func SendConfigMSG { get; } - public string SettingsConfigFileFolder = string.Empty; + private string _settingsConfigFileFolder = string.Empty; public PowerPreviewViewModel(Func ipcMSGCallBackFunc, string configFileSubfolder = "") { // Update Settings file folder: - SettingsConfigFileFolder = configFileSubfolder; + _settingsConfigFileFolder = configFileSubfolder; try { @@ -37,9 +36,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels // set the callback functions value to hangle outgoing IPC message. SendConfigMSG = ipcMSGCallBackFunc; - this._svgRenderIsEnabled = Settings.Properties.EnableSvgPreview; - this._svgThumbnailIsEnabled = Settings.Properties.EnableSvgThumbnail; - this._mdRenderIsEnabled = Settings.Properties.EnableMdPreview; + _svgRenderIsEnabled = Settings.Properties.EnableSvgPreview; + _svgThumbnailIsEnabled = Settings.Properties.EnableSvgThumbnail; + _mdRenderIsEnabled = Settings.Properties.EnableMdPreview; } private bool _svgRenderIsEnabled = false; @@ -102,7 +101,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels public string GetSettingsSubPath() { - return SettingsConfigFileFolder + "\\" + ModuleName; + return _settingsConfigFileFolder + "\\" + ModuleName; } private void RaisePropertyChanged([CallerMemberName] string propertyName = null) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerRenameViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerRenameViewModel.cs index 4064b3dac8..43755e6914 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerRenameViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/PowerRenameViewModel.cs @@ -12,7 +12,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels { private const string ModuleName = "PowerRename"; - public string SettingsConfigFileFolder = string.Empty; + private string _settingsConfigFileFolder = string.Empty; private PowerRenameSettings Settings { get; set; } @@ -21,7 +21,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels public PowerRenameViewModel(Func ipcMSGCallBackFunc, string configFileSubfolder = "") { // Update Settings file folder: - SettingsConfigFileFolder = configFileSubfolder; + _settingsConfigFileFolder = configFileSubfolder; try { @@ -76,7 +76,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels { if (value != _powerRenameEnabled) { - GeneralSettings generalSettings = SettingsUtils.GetSettings(string.Empty); generalSettings.Enabled.PowerRename = value; OutGoingGeneralSettings snd = new OutGoingGeneralSettings(generalSettings); @@ -190,7 +189,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels public string GetSettingsSubPath() { - return SettingsConfigFileFolder + "\\" + ModuleName; + return _settingsConfigFileFolder + "\\" + ModuleName; } private void RaisePropertyChanged([CallerMemberName] string propertyName = null) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/ShortcutGuideViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/ShortcutGuideViewModel.cs index f196155572..32ed136f5b 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/ShortcutGuideViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/ShortcutGuideViewModel.cs @@ -16,12 +16,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels private Func SendConfigMSG { get; } - public string SettingsConfigFileFolder = string.Empty; + private string _settingsConfigFileFolder = string.Empty; public ShortcutGuideViewModel(Func ipcMSGCallBackFunc, string configFileSubfolder = "") { // Update Settings file folder: - SettingsConfigFileFolder = configFileSubfolder; + _settingsConfigFileFolder = configFileSubfolder; try { @@ -48,9 +48,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels // set the callback functions value to hangle outgoing IPC message. SendConfigMSG = ipcMSGCallBackFunc; - this._isEnabled = generalSettings.Enabled.ShortcutGuide; - this._pressTime = Settings.Properties.PressTime.Value; - this._opacity = Settings.Properties.OverlayOpacity.Value; + _isEnabled = generalSettings.Enabled.ShortcutGuide; + _pressTime = Settings.Properties.PressTime.Value; + _opacity = Settings.Properties.OverlayOpacity.Value; string theme = Settings.Properties.Theme.Value; @@ -172,7 +172,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels public string GetSettingsSubPath() { - return SettingsConfigFileFolder + "\\" + ModuleName; + return _settingsConfigFileFolder + "\\" + ModuleName; } public void RaisePropertyChanged([CallerMemberName] string propertyName = null) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj b/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj index e5a3921d41..2b5608d931 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj +++ b/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj @@ -25,6 +25,7 @@ win-x64 false false + true uap10.0.18362 diff --git a/src/core/Microsoft.PowerToys.Settings.UI.UnitTests/Microsoft.PowerToys.Settings.UI.UnitTests.csproj b/src/core/Microsoft.PowerToys.Settings.UI.UnitTests/Microsoft.PowerToys.Settings.UI.UnitTests.csproj index 46adf47662..ec0c974fc6 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.UnitTests/Microsoft.PowerToys.Settings.UI.UnitTests.csproj +++ b/src/core/Microsoft.PowerToys.Settings.UI.UnitTests/Microsoft.PowerToys.Settings.UI.UnitTests.csproj @@ -2,10 +2,9 @@ netcoreapp3.1 - false - x64 + true diff --git a/src/core/Microsoft.PowerToys.Settings.UI.UnitTests/ViewModelTests/PowerPreview.cs b/src/core/Microsoft.PowerToys.Settings.UI.UnitTests/ViewModelTests/PowerPreview.cs index 44b81baa4b..d319e1cbb9 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.UnitTests/ViewModelTests/PowerPreview.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.UnitTests/ViewModelTests/PowerPreview.cs @@ -55,7 +55,7 @@ namespace ViewModelTests Func SendMockIPCConfigMSG = msg => { SndModuleSettings snd = JsonSerializer.Deserialize>(msg); - Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.Properties.EnableSvgPreview); + Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableSvgPreview); return 0; }; @@ -73,7 +73,7 @@ namespace ViewModelTests Func SendMockIPCConfigMSG = msg => { SndModuleSettings snd = JsonSerializer.Deserialize>(msg); - Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.Properties.EnableSvgThumbnail); + Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableSvgThumbnail); return 0; }; @@ -91,7 +91,7 @@ namespace ViewModelTests Func SendMockIPCConfigMSG = msg => { SndModuleSettings snd = JsonSerializer.Deserialize>(msg); - Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.Properties.EnableMdPreview); + Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableMdPreview); return 0; }; diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj b/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj index 7ec560c2b4..051bec93f9 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj +++ b/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj @@ -9,6 +9,7 @@ Microsoft Corp. Copyright (C) 2020 Microsoft Corp. PowerToys + true @@ -297,6 +298,12 @@ false false + + 8.0 + + + 8.0 +