[fxcop] Settings UI library (part 1) (#7187)

* Mark methods static and replace Count() with Length

* Use IsNullOrEmpty for null string checks

* Remove redundant initializations to default values

* Use nameof(property name) in place of string literals

* Add NativeMethods class

* Rename property getters in KeysDataModel & AppSpecificKeysDataModel

* Remove underscores from method names

* Mark Helper class static

* Address comments & typo fixes

* Add EncoderGuid property and fix failing build

* Update binding in GeneralPages.xaml
This commit is contained in:
Luthfi Mawarid
2020-10-09 17:58:52 -07:00
committed by GitHub
parent 8643bfc977
commit 889f20c4a7
17 changed files with 115 additions and 88 deletions

View File

@@ -12,14 +12,14 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("targetApp")] [JsonPropertyName("targetApp")]
public string TargetApp { get; set; } public string TargetApp { get; set; }
public new List<string> GetOriginalKeys() public new List<string> GetMappedOriginalKeys()
{ {
return base.GetOriginalKeys(); return base.GetMappedOriginalKeys();
} }
public new List<string> GetNewRemapKeys() public new List<string> GetMappedNewRemapKeys()
{ {
return base.GetNewRemapKeys(); return base.GetMappedNewRemapKeys();
} }
public bool Compare(AppSpecificKeysDataModel arg) public bool Compare(AppSpecificKeysDataModel arg)

View File

@@ -148,7 +148,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
return JsonSerializer.Serialize(this); return JsonSerializer.Serialize(this);
} }
private void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null) private static void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null)
{ {
var dataEvent = new SettingsEnabledEvent() var dataEvent = new SettingsEnabledEvent()
{ {

View File

@@ -81,7 +81,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
return JsonSerializer.Serialize(this); return JsonSerializer.Serialize(this);
} }
private string DefaultPowertoysVersion() private static string DefaultPowertoysVersion()
{ {
return interop.CommonManaged.GetProductVersion(); return interop.CommonManaged.GetProductVersion();
} }

View File

@@ -203,8 +203,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
_unit = value; _unit = value;
OnPropertyChanged(); OnPropertyChanged();
OnPropertyChanged("ExtraBoxOpacity"); OnPropertyChanged(nameof(ExtraBoxOpacity));
OnPropertyChanged("EnableEtraBoxes"); OnPropertyChanged(nameof(EnableEtraBoxes));
} }
} }
} }

View File

@@ -18,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("newRemapKeys")] [JsonPropertyName("newRemapKeys")]
public string NewRemapKeys { get; set; } public string NewRemapKeys { get; set; }
private List<string> MapKeys(string stringOfKeys) private static List<string> MapKeys(string stringOfKeys)
{ {
return stringOfKeys return stringOfKeys
.Split(';') .Split(';')
@@ -27,12 +27,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
.ToList(); .ToList();
} }
public List<string> GetOriginalKeys() public List<string> GetMappedOriginalKeys()
{ {
return MapKeys(OriginalKeys); return MapKeys(OriginalKeys);
} }
public List<string> GetNewRemapKeys() public List<string> GetMappedNewRemapKeys()
{ {
return MapKeys(NewRemapKeys); return MapKeys(NewRemapKeys);
} }

View File

@@ -72,7 +72,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
return JsonSerializer.Serialize(this); return JsonSerializer.Serialize(this);
} }
private void LogTelemetryEvent(bool value, [CallerMemberName] string propertyName = null) private static void LogTelemetryEvent(bool value, [CallerMemberName] string propertyName = null)
{ {
var dataEvent = new SettingsEnabledEvent() var dataEvent = new SettingsEnabledEvent()
{ {

View File

@@ -11,7 +11,7 @@ using Microsoft.PowerToys.Settings.UI.Lib.CustomAction;
namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
{ {
public class Helper public static class Helper
{ {
public static bool AllowRunnerToForeground() public static bool AllowRunnerToForeground()
{ {
@@ -20,7 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
if (processes.Length > 0) if (processes.Length > 0)
{ {
var pid = processes[0].Id; var pid = processes[0].Id;
result = AllowSetForegroundWindow(pid); result = NativeMethods.AllowSetForegroundWindow(pid);
} }
return result; return result;
@@ -74,9 +74,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
} }
[DllImport("user32.dll")]
private static extern bool AllowSetForegroundWindow(int dwProcessId);
private static readonly interop.LayoutMapManaged LayoutMap = new interop.LayoutMapManaged(); private static readonly interop.LayoutMapManaged LayoutMap = new interop.LayoutMapManaged();
public static string GetKeyName(uint key) public static string GetKeyName(uint key)
@@ -98,7 +95,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
var v1 = version1.Substring(1).Split('.').Select(int.Parse).ToArray(); var v1 = version1.Substring(1).Split('.').Select(int.Parse).ToArray();
var v2 = version2.Substring(1).Split('.').Select(int.Parse).ToArray(); var v2 = version2.Substring(1).Split('.').Select(int.Parse).ToArray();
if (v1.Count() != 3 || v2.Count() != 3) if (v1.Length != 3 || v2.Length != 3)
{ {
throw new FormatException(); throw new FormatException();
} }

View File

@@ -0,0 +1,17 @@
// 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;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
{
internal static class NativeMethods
{
[DllImport("user32.dll")]
public static extern bool AllowSetForegroundWindow(int dwProcessId);
}
}

View File

@@ -58,13 +58,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
SendConfigMSG = ipcMSGCallBackFunc; SendConfigMSG = ipcMSGCallBackFunc;
string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value; string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value;
_zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor : "#F5FCFF"; _zoneInActiveColor = !string.IsNullOrEmpty(inactiveColor) ? inactiveColor : "#F5FCFF";
string borderColor = Settings.Properties.FancyzonesBorderColor.Value; string borderColor = Settings.Properties.FancyzonesBorderColor.Value;
_zoneBorderColor = borderColor != string.Empty ? borderColor : "#FFFFFF"; _zoneBorderColor = !string.IsNullOrEmpty(borderColor) ? borderColor : "#FFFFFF";
string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value; string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value;
_zoneHighlightColor = highlightColor != string.Empty ? highlightColor : "#0078D7"; _zoneHighlightColor = !string.IsNullOrEmpty(highlightColor) ? highlightColor : "#0078D7";
_isEnabled = GeneralSettingsConfig.Enabled.FancyZones; _isEnabled = GeneralSettingsConfig.Enabled.FancyZones;
} }
@@ -110,8 +110,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig); OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig);
SendConfigMSG(snd.ToString()); SendConfigMSG(snd.ToString());
OnPropertyChanged("IsEnabled"); OnPropertyChanged(nameof(IsEnabled));
OnPropertyChanged("SnapHotkeysCategoryEnabled"); OnPropertyChanged(nameof(SnapHotkeysCategoryEnabled));
} }
} }
} }
@@ -179,7 +179,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_overrideSnapHotkeys = value; _overrideSnapHotkeys = value;
Settings.Properties.FancyzonesOverrideSnapHotkeys.Value = value; Settings.Properties.FancyzonesOverrideSnapHotkeys.Value = value;
RaisePropertyChanged(); RaisePropertyChanged();
OnPropertyChanged("SnapHotkeysCategoryEnabled"); OnPropertyChanged(nameof(SnapHotkeysCategoryEnabled));
} }
} }
} }
@@ -518,7 +518,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
} }
} }
private string ToRGBHex(string color) private static string ToRGBHex(string color)
{ {
try try
{ {

View File

@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
{ {
private GeneralSettings GeneralSettingsConfig { get; set; } private GeneralSettings GeneralSettingsConfig { get; set; }
public ButtonClickCommand CheckFoUpdatesEventHandler { get; set; } public ButtonClickCommand CheckForUpdatesEventHandler { get; set; }
public ButtonClickCommand RestartElevatedButtonEventHandler { get; set; } public ButtonClickCommand RestartElevatedButtonEventHandler { get; set; }
@@ -35,8 +35,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
public GeneralViewModel(ISettingsRepository<GeneralSettings> settingsRepository, string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func<string, int> updateTheme, Func<string, int> ipcMSGCallBackFunc, Func<string, int> ipcMSGRestartAsAdminMSGCallBackFunc, Func<string, int> ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "") public GeneralViewModel(ISettingsRepository<GeneralSettings> settingsRepository, string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func<string, int> updateTheme, Func<string, int> ipcMSGCallBackFunc, Func<string, int> ipcMSGRestartAsAdminMSGCallBackFunc, Func<string, int> ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "")
{ {
CheckFoUpdatesEventHandler = new ButtonClickCommand(CheckForUpdates_Click); CheckForUpdatesEventHandler = new ButtonClickCommand(CheckForUpdatesClick);
RestartElevatedButtonEventHandler = new ButtonClickCommand(Restart_Elevated); RestartElevatedButtonEventHandler = new ButtonClickCommand(RestartElevated);
// To obtain the general settings configuration of PowerToys if it exists, else to create a new file and return the default configurations. // To obtain the general settings configuration of PowerToys if it exists, else to create a new file and return the default configurations.
GeneralSettingsConfig = settingsRepository.SettingsConfig; GeneralSettingsConfig = settingsRepository.SettingsConfig;
@@ -77,15 +77,15 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_isAdmin = isAdmin; _isAdmin = isAdmin;
} }
private bool _packaged = false; private bool _packaged;
private bool _startup = false; private bool _startup;
private bool _isElevated = false; private bool _isElevated;
private bool _runElevated = false; private bool _runElevated;
private bool _isAdmin = false; private bool _isAdmin;
private bool _isDarkThemeRadioButtonChecked = false; private bool _isDarkThemeRadioButtonChecked;
private bool _isLightThemeRadioButtonChecked = false; private bool _isLightThemeRadioButtonChecked;
private bool _isSystemThemeRadioButtonChecked = false; private bool _isSystemThemeRadioButtonChecked;
private bool _autoDownloadUpdates = false; private bool _autoDownloadUpdates;
private string _latestAvailableVersion = string.Empty; private string _latestAvailableVersion = string.Empty;
@@ -159,8 +159,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
if (_isElevated != value) if (_isElevated != value)
{ {
_isElevated = value; _isElevated = value;
OnPropertyChanged("IsElevated"); OnPropertyChanged(nameof(IsElevated));
OnPropertyChanged("IsAdminButtonEnabled"); OnPropertyChanged(nameof(IsAdminButtonEnabled));
OnPropertyChanged("RunningAsAdminText"); OnPropertyChanged("RunningAsAdminText");
} }
} }
@@ -175,7 +175,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
set set
{ {
OnPropertyChanged("IsAdminButtonEnabled"); OnPropertyChanged(nameof(IsAdminButtonEnabled));
} }
} }
@@ -303,7 +303,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
} }
} }
// FxCop suggests marking this member static, but it is accessed through
// an instance in autogenerated files (GeneralPage.g.cs) and will break
// the file if modified
#pragma warning disable CA1822 // Mark members as static
public string PowerToysVersion public string PowerToysVersion
#pragma warning restore CA1822 // Mark members as static
{ {
get get
{ {
@@ -339,7 +344,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
} }
// callback function to launch the URL to check for updates. // callback function to launch the URL to check for updates.
private void CheckForUpdates_Click() private void CheckForUpdatesClick()
{ {
GeneralSettingsConfig.CustomActionName = "check_for_updates"; GeneralSettingsConfig.CustomActionName = "check_for_updates";
@@ -349,7 +354,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
SendCheckForUpdatesConfigMSG(customaction.ToString()); SendCheckForUpdatesConfigMSG(customaction.ToString());
} }
public void Restart_Elevated() public void RestartElevated()
{ {
GeneralSettingsConfig.CustomActionName = "restart_elevation"; GeneralSettingsConfig.CustomActionName = "restart_elevation";

View File

@@ -57,18 +57,18 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
{ {
size.Id = i; size.Id = i;
i++; i++;
size.PropertyChanged += Size_PropertyChanged; size.PropertyChanged += SizePropertyChanged;
} }
} }
private bool _isEnabled = false; private bool _isEnabled;
private ObservableCollection<ImageSize> _advancedSizes = new ObservableCollection<ImageSize>(); private ObservableCollection<ImageSize> _advancedSizes = new ObservableCollection<ImageSize>();
private int _jpegQualityLevel = 0; private int _jpegQualityLevel;
private int _pngInterlaceOption; private int _pngInterlaceOption;
private int _tiffCompressOption; private int _tiffCompressOption;
private string _fileName; private string _fileName;
private bool _keepDateModified; private bool _keepDateModified;
private int _encoderGuidId = 0; private int _encoderGuidId;
public bool IsEnabled public bool IsEnabled
{ {
@@ -87,7 +87,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig); OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig);
SendConfigMSG(snd.ToString()); SendConfigMSG(snd.ToString());
OnPropertyChanged("IsEnabled"); OnPropertyChanged(nameof(IsEnabled));
} }
} }
} }
@@ -103,7 +103,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
{ {
SavesImageSizes(value); SavesImageSizes(value);
_advancedSizes = value; _advancedSizes = value;
OnPropertyChanged("Sizes"); OnPropertyChanged(nameof(Sizes));
} }
} }
@@ -121,7 +121,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_jpegQualityLevel = value; _jpegQualityLevel = value;
Settings.Properties.ImageresizerJpegQualityLevel.Value = value; Settings.Properties.ImageresizerJpegQualityLevel.Value = value;
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); _settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
OnPropertyChanged("JPEGQualityLevel"); OnPropertyChanged(nameof(JPEGQualityLevel));
} }
} }
} }
@@ -140,7 +140,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_pngInterlaceOption = value; _pngInterlaceOption = value;
Settings.Properties.ImageresizerPngInterlaceOption.Value = value; Settings.Properties.ImageresizerPngInterlaceOption.Value = value;
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); _settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
OnPropertyChanged("PngInterlaceOption"); OnPropertyChanged(nameof(PngInterlaceOption));
} }
} }
} }
@@ -159,7 +159,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_tiffCompressOption = value; _tiffCompressOption = value;
Settings.Properties.ImageresizerTiffCompressOption.Value = value; Settings.Properties.ImageresizerTiffCompressOption.Value = value;
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); _settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
OnPropertyChanged("TiffCompressOption"); OnPropertyChanged(nameof(TiffCompressOption));
} }
} }
} }
@@ -178,7 +178,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_fileName = value; _fileName = value;
Settings.Properties.ImageresizerFileName.Value = value; Settings.Properties.ImageresizerFileName.Value = value;
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); _settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
OnPropertyChanged("FileName"); OnPropertyChanged(nameof(FileName));
} }
} }
} }
@@ -195,7 +195,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_keepDateModified = value; _keepDateModified = value;
Settings.Properties.ImageresizerKeepDateModified.Value = value; Settings.Properties.ImageresizerKeepDateModified.Value = value;
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); _settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
OnPropertyChanged("KeepDateModified"); OnPropertyChanged(nameof(KeepDateModified));
} }
} }
@@ -214,17 +214,25 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_settingsUtils.SaveSettings(Settings.Properties.ImageresizerSizes.ToJsonString(), ModuleName, "sizes.json"); _settingsUtils.SaveSettings(Settings.Properties.ImageresizerSizes.ToJsonString(), ModuleName, "sizes.json");
Settings.Properties.ImageresizerFallbackEncoder.Value = GetEncoderGuid(value); Settings.Properties.ImageresizerFallbackEncoder.Value = GetEncoderGuid(value);
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); _settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
OnPropertyChanged("Encoder"); OnPropertyChanged(nameof(Encoder));
} }
} }
} }
public string EncoderGuid
{
get
{
return ImageResizerViewModel.GetEncoderGuid(_encoderGuidId);
}
}
public void AddRow() public void AddRow()
{ {
ObservableCollection<ImageSize> imageSizes = Sizes; ObservableCollection<ImageSize> imageSizes = Sizes;
int maxId = imageSizes.Count > 0 ? imageSizes.OrderBy(x => x.Id).Last().Id : -1; int maxId = imageSizes.Count > 0 ? imageSizes.OrderBy(x => x.Id).Last().Id : -1;
ImageSize newSize = new ImageSize(maxId + 1); ImageSize newSize = new ImageSize(maxId + 1);
newSize.PropertyChanged += Size_PropertyChanged; newSize.PropertyChanged += SizePropertyChanged;
imageSizes.Add(newSize); imageSizes.Add(newSize);
_advancedSizes = imageSizes; _advancedSizes = imageSizes;
SavesImageSizes(imageSizes); SavesImageSizes(imageSizes);
@@ -247,7 +255,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); _settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
} }
public string GetEncoderGuid(int value) public static string GetEncoderGuid(int value)
{ {
// PNG Encoder guid // PNG Encoder guid
if (value == 0) if (value == 0)
@@ -288,40 +296,40 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
return null; return null;
} }
public int GetEncoderIndex(string guid) public static int GetEncoderIndex(string value)
{ {
// PNG Encoder guid // PNG Encoder guid
if (guid == "1b7cfaf4-713f-473c-bbcd-6137425faeaf") if (value == "1b7cfaf4-713f-473c-bbcd-6137425faeaf")
{ {
return 0; return 0;
} }
// Bitmap Encoder guid // Bitmap Encoder guid
else if (guid == "0af1d87e-fcfe-4188-bdeb-a7906471cbe3") else if (value == "0af1d87e-fcfe-4188-bdeb-a7906471cbe3")
{ {
return 1; return 1;
} }
// JPEG Encoder guid // JPEG Encoder guid
else if (guid == "19e4a5aa-5662-4fc5-a0c0-1758028e1057") else if (value == "19e4a5aa-5662-4fc5-a0c0-1758028e1057")
{ {
return 2; return 2;
} }
// Tiff encoder guid. // Tiff encoder guid.
else if (guid == "163bcc30-e2e9-4f0b-961d-a3e9fdb788a3") else if (value == "163bcc30-e2e9-4f0b-961d-a3e9fdb788a3")
{ {
return 3; return 3;
} }
// Tiff encoder guid. // Tiff encoder guid.
else if (guid == "57a37caa-367a-4540-916b-f183c5093a4b") else if (value == "57a37caa-367a-4540-916b-f183c5093a4b")
{ {
return 4; return 4;
} }
// Gif encoder guid. // Gif encoder guid.
else if (guid == "1f8a5601-7d4d-4cbd-9c82-1bc8d4eeb9a5") else if (value == "1f8a5601-7d4d-4cbd-9c82-1bc8d4eeb9a5")
{ {
return 5; return 5;
} }
@@ -329,7 +337,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
return -1; return -1;
} }
public void Size_PropertyChanged(object sender, PropertyChangedEventArgs e) public void SizePropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
ImageSize modifiedSize = (ImageSize)sender; ImageSize modifiedSize = (ImageSize)sender;
ObservableCollection<ImageSize> imageSizes = Sizes; ObservableCollection<ImageSize> imageSizes = Sizes;

View File

@@ -41,9 +41,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_mdRenderIsEnabled = Settings.Properties.EnableMdPreview; _mdRenderIsEnabled = Settings.Properties.EnableMdPreview;
} }
private bool _svgRenderIsEnabled = false; private bool _svgRenderIsEnabled;
private bool _mdRenderIsEnabled = false; private bool _mdRenderIsEnabled;
private bool _svgThumbnailIsEnabled = false; private bool _svgThumbnailIsEnabled;
public bool SVGRenderIsEnabled public bool SVGRenderIsEnabled
{ {

View File

@@ -54,12 +54,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_powerRenameEnabled = GeneralSettingsConfig.Enabled.PowerRename; _powerRenameEnabled = GeneralSettingsConfig.Enabled.PowerRename;
} }
private bool _powerRenameEnabled = false; private bool _powerRenameEnabled;
private bool _powerRenameEnabledOnContextMenu = false; private bool _powerRenameEnabledOnContextMenu;
private bool _powerRenameEnabledOnContextExtendedMenu = false; private bool _powerRenameEnabledOnContextExtendedMenu;
private bool _powerRenameRestoreFlagsOnLaunch = false; private bool _powerRenameRestoreFlagsOnLaunch;
private int _powerRenameMaxDispListNumValue = 0; private int _powerRenameMaxDispListNumValue;
private bool _autoComplete = false; private bool _autoComplete;
public bool IsEnabled public bool IsEnabled
{ {
@@ -78,8 +78,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
SendConfigMSG(snd.ToString()); SendConfigMSG(snd.ToString());
_powerRenameEnabled = value; _powerRenameEnabled = value;
OnPropertyChanged("IsEnabled"); OnPropertyChanged(nameof(IsEnabled));
RaisePropertyChanged("GlobalAndMruEnabled"); RaisePropertyChanged(nameof(GlobalAndMruEnabled));
} }
} }
} }
@@ -98,7 +98,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
_autoComplete = value; _autoComplete = value;
Settings.Properties.MRUEnabled.Value = value; Settings.Properties.MRUEnabled.Value = value;
RaisePropertyChanged(); RaisePropertyChanged();
RaisePropertyChanged("GlobalAndMruEnabled"); RaisePropertyChanged(nameof(GlobalAndMruEnabled));
} }
} }
} }

View File

@@ -58,10 +58,10 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
} }
} }
private bool _isEnabled = false; private bool _isEnabled;
private int _themeIndex = 0; private int _themeIndex;
private int _pressTime = 0; private int _pressTime;
private int _opacity = 0; private int _opacity;
public bool IsEnabled public bool IsEnabled
{ {
@@ -81,7 +81,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig); OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig);
SendConfigMSG(snd.ToString()); SendConfigMSG(snd.ToString());
OnPropertyChanged("IsEnabled"); OnPropertyChanged(nameof(IsEnabled));
} }
} }
} }

View File

@@ -59,7 +59,7 @@ namespace ViewModelTests
// Verifiy that the old settings persisted // Verifiy that the old settings persisted
Assert.AreEqual(originalGeneralSettings.Enabled.ImageResizer, viewModel.IsEnabled); Assert.AreEqual(originalGeneralSettings.Enabled.ImageResizer, viewModel.IsEnabled);
Assert.AreEqual(viewModel.GetEncoderIndex(originalSettings.Properties.ImageresizerFallbackEncoder.Value), viewModel.Encoder); Assert.AreEqual(ImageResizerViewModel.GetEncoderIndex(originalSettings.Properties.ImageresizerFallbackEncoder.Value), viewModel.Encoder);
Assert.AreEqual(originalSettings.Properties.ImageresizerFileName.Value, viewModel.FileName); Assert.AreEqual(originalSettings.Properties.ImageresizerFileName.Value, viewModel.FileName);
Assert.AreEqual(originalSettings.Properties.ImageresizerJpegQualityLevel.Value, viewModel.JPEGQualityLevel); Assert.AreEqual(originalSettings.Properties.ImageresizerJpegQualityLevel.Value, viewModel.JPEGQualityLevel);
Assert.AreEqual(originalSettings.Properties.ImageresizerKeepDateModified.Value, viewModel.KeepDateModified); Assert.AreEqual(originalSettings.Properties.ImageresizerKeepDateModified.Value, viewModel.KeepDateModified);
@@ -197,7 +197,7 @@ namespace ViewModelTests
// Assert // Assert
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG); viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);
Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.GetEncoderGuid(viewModel.Encoder)); Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.EncoderGuid);
Assert.AreEqual(3, viewModel.Encoder); Assert.AreEqual(3, viewModel.Encoder);
} }

View File

@@ -125,7 +125,7 @@
<Button x:Uid="GeneralPage_CheckForUpdates" <Button x:Uid="GeneralPage_CheckForUpdates"
Style="{StaticResource AccentButtonStyle}" Style="{StaticResource AccentButtonStyle}"
Foreground="White" Foreground="White"
Command="{Binding CheckFoUpdatesEventHandler}" Command="{Binding CheckForUpdatesEventHandler}"
/> />
<ToggleSwitch x:Uid="GeneralPage_ToggleSwitch_AutoDownloadUpdates" <ToggleSwitch x:Uid="GeneralPage_ToggleSwitch_AutoDownloadUpdates"

View File

@@ -24,7 +24,7 @@
Orientation="Horizontal" Orientation="Horizontal"
Height="56"> Height="56">
<ItemsControl <ItemsControl
ItemsSource="{x:Bind GetOriginalKeys()}" ItemsSource="{x:Bind GetMappedOriginalKeys()}"
IsTabStop="False"> IsTabStop="False">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
@@ -59,7 +59,7 @@
<ItemsControl <ItemsControl
Name="KeyboardManager_RemappedTo" Name="KeyboardManager_RemappedTo"
x:Uid="KeyboardManager_RemappedTo" x:Uid="KeyboardManager_RemappedTo"
ItemsSource="{x:Bind GetNewRemapKeys()}" ItemsSource="{x:Bind GetMappedNewRemapKeys()}"
Grid.Column="2" Grid.Column="2"
IsTabStop="False"> IsTabStop="False">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
@@ -97,7 +97,7 @@
Orientation="Horizontal" Orientation="Horizontal"
Height="56"> Height="56">
<ItemsControl <ItemsControl
ItemsSource="{x:Bind GetOriginalKeys()}" ItemsSource="{x:Bind GetMappedOriginalKeys()}"
IsTabStop="False"> IsTabStop="False">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
@@ -131,7 +131,7 @@
Margin="5,0,5,0"/> Margin="5,0,5,0"/>
<ItemsControl Name="KeyboardManager_ShortcutRemappedTo" <ItemsControl Name="KeyboardManager_ShortcutRemappedTo"
x:Uid="KeyboardManager_ShortcutRemappedTo" x:Uid="KeyboardManager_ShortcutRemappedTo"
ItemsSource="{x:Bind GetNewRemapKeys()}" ItemsSource="{x:Bind GetMappedNewRemapKeys()}"
Grid.Column="2" Grid.Column="2"
IsTabStop="False"> IsTabStop="False">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>