[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

@@ -11,7 +11,7 @@ using Microsoft.PowerToys.Settings.UI.Lib.CustomAction;
namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
{
public class Helper
public static class Helper
{
public static bool AllowRunnerToForeground()
{
@@ -20,7 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
if (processes.Length > 0)
{
var pid = processes[0].Id;
result = AllowSetForegroundWindow(pid);
result = NativeMethods.AllowSetForegroundWindow(pid);
}
return result;
@@ -74,9 +74,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
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();
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 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();
}