mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
.NET 8 Upgrade Silenced Errors Fix (#30469)
* [Dev][Build] .NET 8 Upgrade Silenced errors first fix. * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1859 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1854. * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1860 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1861 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1862 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1863 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1864 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA1865 * [Dev][Build] .NET 8 Upgrade Silenced errors. CA2208 * [Dev][Build] .NET 8 Upgrade Silenced errors. CS9191 * [Dev][Build] .NET 8 Upgrade Silenced errors. Spell check * [Dev][Build] .NET 8 Upgrade Silenced errors. Spell check * [Dev][Build] .NET 8 Upgrade Silenced errors. - CompositeFormat variables used more than once in the same file were assigned to a single variable. - GetProcessesByName logic fix. - String comparion fix. - ArgumentOutOfRangeException message change. * [Dev][Build] .NET 8 Upgrade Silenced errors. - Null check added. - static readonly CompositeFormat added for all fields.
This commit is contained in:
@@ -96,49 +96,4 @@ end_of_line = crlf
|
|||||||
dotnet_diagnostic.IDE0065.severity = none
|
dotnet_diagnostic.IDE0065.severity = none
|
||||||
|
|
||||||
# IDE0009: Add this or Me qualification
|
# IDE0009: Add this or Me qualification
|
||||||
dotnet_diagnostic.IDE0009.severity = none
|
dotnet_diagnostic.IDE0009.severity = none
|
||||||
|
|
||||||
# CA1859: Change type for improved performance
|
|
||||||
dotnet_diagnostic.CA1859.severity = none
|
|
||||||
|
|
||||||
# CA1716: Identifiers should not match keywords
|
|
||||||
dotnet_diagnostic.CA1716.severity = none
|
|
||||||
|
|
||||||
# SYSLIB1096: Convert to 'GeneratedComInterface'
|
|
||||||
dotnet_diagnostic.SYSLIB1096.severity = silent
|
|
||||||
|
|
||||||
# CA1309: Use ordinal StringComparison
|
|
||||||
dotnet_diagnostic.CA1309.severity = suggestion
|
|
||||||
|
|
||||||
# CS1615: Argument may not be passed with the ref keyword
|
|
||||||
dotnet_diagnostic.CS1615.severity = none
|
|
||||||
|
|
||||||
# CA1854: Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup
|
|
||||||
dotnet_diagnostic.CA1854.severity = suggestion
|
|
||||||
|
|
||||||
# CA1860: Avoid using 'Enumerable.Any()' extension method
|
|
||||||
dotnet_diagnostic.CA1860.severity = suggestion
|
|
||||||
|
|
||||||
# CA1861: Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array
|
|
||||||
dotnet_diagnostic.CA1861.severity = suggestion
|
|
||||||
|
|
||||||
# CA1862: Prefer using 'StringComparer'/'StringComparison' to perform case-insensitive string comparisons
|
|
||||||
dotnet_diagnostic.CA1862.severity = suggestion
|
|
||||||
|
|
||||||
# CA1863: Cache a CompositeFormat for repeated use in this formatting operation
|
|
||||||
dotnet_diagnostic.CA1863.severity = none
|
|
||||||
|
|
||||||
# CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method
|
|
||||||
dotnet_diagnostic.CA1864.severity = suggestion
|
|
||||||
|
|
||||||
# CA1865: Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char
|
|
||||||
dotnet_diagnostic.CA1865.severity = suggestion
|
|
||||||
|
|
||||||
# CA1869: Cache and reuse 'JsonSerializerOptions' instances
|
|
||||||
dotnet_diagnostic.CA1869.severity = none
|
|
||||||
|
|
||||||
# CA2208: Instantiate argument exceptions correctly
|
|
||||||
dotnet_diagnostic.CA2208.severity = none
|
|
||||||
|
|
||||||
# CS9191: The 'ref' modifier for argument corresponding to 'in' is equivalent to 'in'. Consider using 'in' instead.
|
|
||||||
dotnet_diagnostic.CS9191.severity = none
|
|
||||||
@@ -145,7 +145,7 @@ namespace AllExperiments
|
|||||||
|
|
||||||
private string? AssignmentUnit { get; set; }
|
private string? AssignmentUnit { get; set; }
|
||||||
|
|
||||||
private IVariantAssignmentRequest GetVariantAssignmentRequest()
|
private VariantAssignmentRequest GetVariantAssignmentRequest()
|
||||||
{
|
{
|
||||||
var jsonFilePath = CreateFilePath();
|
var jsonFilePath = CreateFilePath();
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ namespace Microsoft.PowerToys.FilePreviewCommon.Monaco.Formatters
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string LangSet => "json";
|
public string LangSet => "json";
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||||
|
};
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Format(string value)
|
public string Format(string value)
|
||||||
{
|
{
|
||||||
@@ -22,11 +28,7 @@ namespace Microsoft.PowerToys.FilePreviewCommon.Monaco.Formatters
|
|||||||
|
|
||||||
using (var jDocument = JsonDocument.Parse(value, new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }))
|
using (var jDocument = JsonDocument.Parse(value, new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }))
|
||||||
{
|
{
|
||||||
return JsonSerializer.Serialize(jDocument, new JsonSerializerOptions
|
return JsonSerializer.Serialize(jDocument, _serializerOptions);
|
||||||
{
|
|
||||||
WriteIndented = true,
|
|
||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Hosts.Settings
|
|||||||
private const string HostsModuleName = "Hosts";
|
private const string HostsModuleName = "Hosts";
|
||||||
private const int MaxNumberOfRetry = 5;
|
private const int MaxNumberOfRetry = 5;
|
||||||
|
|
||||||
private readonly ISettingsUtils _settingsUtils;
|
private readonly SettingsUtils _settingsUtils;
|
||||||
private readonly IFileSystemWatcher _watcher;
|
private readonly IFileSystemWatcher _watcher;
|
||||||
private readonly object _loadingSettingsLock = new object();
|
private readonly object _loadingSettingsLock = new object();
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ namespace MouseWithoutBorders
|
|||||||
private static string lastDragDropFile;
|
private static string lastDragDropFile;
|
||||||
private static long clipboardCopiedTime;
|
private static long clipboardCopiedTime;
|
||||||
|
|
||||||
|
internal static readonly char[] Comma = new char[] { ',' };
|
||||||
|
internal static readonly char[] Star = new char[] { '*' };
|
||||||
|
internal static readonly char[] NullSeparator = new char[] { '\0' };
|
||||||
|
|
||||||
internal static ID LastIDWithClipboardData { get; set; }
|
internal static ID LastIDWithClipboardData { get; set; }
|
||||||
|
|
||||||
internal static string LastDragDropFile
|
internal static string LastDragDropFile
|
||||||
@@ -406,7 +410,7 @@ namespace MouseWithoutBorders
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
remoteMachine = postAct.Contains("mspaint,") ? postAct.Split(new char[] { ',' })[1] : Common.LastMachineWithClipboardData;
|
remoteMachine = postAct.Contains("mspaint,") ? postAct.Split(Comma)[1] : Common.LastMachineWithClipboardData;
|
||||||
|
|
||||||
remoteMachine = remoteMachine.Trim();
|
remoteMachine = remoteMachine.Trim();
|
||||||
|
|
||||||
@@ -518,7 +522,7 @@ namespace MouseWithoutBorders
|
|||||||
|
|
||||||
fileName = Common.GetStringU(header).Replace("\0", string.Empty);
|
fileName = Common.GetStringU(header).Replace("\0", string.Empty);
|
||||||
Common.LogDebug("Header: " + fileName);
|
Common.LogDebug("Header: " + fileName);
|
||||||
string[] headers = fileName.Split(new char[] { '*' });
|
string[] headers = fileName.Split(Star);
|
||||||
|
|
||||||
if (headers.Length < 2 || !long.TryParse(headers[0], out long dataSize))
|
if (headers.Length < 2 || !long.TryParse(headers[0], out long dataSize))
|
||||||
{
|
{
|
||||||
@@ -973,7 +977,7 @@ namespace MouseWithoutBorders
|
|||||||
|
|
||||||
foreach (string txt in texts)
|
foreach (string txt in texts)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(txt.Trim(new char[] { '\0' })))
|
if (string.IsNullOrEmpty(txt.Trim(NullSeparator)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ namespace MouseWithoutBorders
|
|||||||
{
|
{
|
||||||
internal partial class Common
|
internal partial class Common
|
||||||
{
|
{
|
||||||
private static SymmetricAlgorithm symAl;
|
#pragma warning disable SYSLIB0021
|
||||||
|
private static AesCryptoServiceProvider symAl;
|
||||||
|
#pragma warning restore SYSLIB0021
|
||||||
private static string myKey;
|
private static string myKey;
|
||||||
private static uint magicNumber;
|
private static uint magicNumber;
|
||||||
private static Random ran = new(); // Used for non encryption related functionality.
|
private static Random ran = new(); // Used for non encryption related functionality.
|
||||||
|
|||||||
@@ -313,7 +313,8 @@ namespace MouseWithoutBorders
|
|||||||
HasSwitchedMachineSinceLastCopy = true;
|
HasSwitchedMachineSinceLastCopy = true;
|
||||||
|
|
||||||
// Common.CreateLowIntegrityProcess("\"" + Path.GetDirectoryName(Application.ExecutablePath) + "\\MouseWithoutBordersHelper.exe\"", string.Empty, 0, false, 0);
|
// Common.CreateLowIntegrityProcess("\"" + Path.GetDirectoryName(Application.ExecutablePath) + "\\MouseWithoutBordersHelper.exe\"", string.Empty, 0, false, 0);
|
||||||
if (Process.GetProcessesByName(HelperProcessName)?.Any() != true)
|
var processes = Process.GetProcessesByName(HelperProcessName);
|
||||||
|
if (processes?.Length == 0)
|
||||||
{
|
{
|
||||||
Log("Unable to start helper process.");
|
Log("Unable to start helper process.");
|
||||||
Common.ShowToolTip("Error starting Mouse Without Borders Helper, clipboard sharing will not work!", 5000, ToolTipIcon.Error);
|
Common.ShowToolTip("Error starting Mouse Without Borders Helper, clipboard sharing will not work!", 5000, ToolTipIcon.Error);
|
||||||
@@ -325,7 +326,8 @@ namespace MouseWithoutBorders
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Process.GetProcessesByName(HelperProcessName)?.Any() == true)
|
var processes = Process.GetProcessesByName(HelperProcessName);
|
||||||
|
if (processes?.Length > 0)
|
||||||
{
|
{
|
||||||
Log("Helper process found running.");
|
Log("Helper process found running.");
|
||||||
}
|
}
|
||||||
@@ -432,7 +434,7 @@ namespace MouseWithoutBorders
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(Setting.Values.Username) && !Common.RunOnLogonDesktop)
|
if (string.IsNullOrEmpty(Setting.Values.Username) && !Common.RunOnLogonDesktop)
|
||||||
{
|
{
|
||||||
if (Program.User.ToLower(CultureInfo.CurrentCulture).Contains("system"))
|
if (Program.User.Contains("system", StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
_ = Common.ImpersonateLoggedOnUserAndDoSomething(() =>
|
_ = Common.ImpersonateLoggedOnUserAndDoSomething(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,12 +84,11 @@ namespace MouseWithoutBorders
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", MessageId = "System.String.ToLower", Justification = "Dotnet port with style preservation")]
|
|
||||||
internal static int CreateProcessInInputDesktopSession(string commandLine, string arg, string desktop, short wShowWindow, bool lowIntegrity = false)
|
internal static int CreateProcessInInputDesktopSession(string commandLine, string arg, string desktop, short wShowWindow, bool lowIntegrity = false)
|
||||||
|
|
||||||
// As user who runs explorer.exe
|
// As user who runs explorer.exe
|
||||||
{
|
{
|
||||||
if (!Program.User.ToLower(CultureInfo.InvariantCulture).Contains("system"))
|
if (!Program.User.Contains("system", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
ProcessStartInfo s = new(commandLine, arg);
|
ProcessStartInfo s = new(commandLine, arg);
|
||||||
s.WindowStyle = wShowWindow != 0 ? ProcessWindowStyle.Normal : ProcessWindowStyle.Hidden;
|
s.WindowStyle = wShowWindow != 0 ? ProcessWindowStyle.Normal : ProcessWindowStyle.Hidden;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace MouseWithoutBorders
|
|||||||
{
|
{
|
||||||
Process[] ps = Process.GetProcessesByName("MouseWithoutBordersSvc");
|
Process[] ps = Process.GetProcessesByName("MouseWithoutBordersSvc");
|
||||||
|
|
||||||
if (ps.Any())
|
if (ps.Length != 0)
|
||||||
{
|
{
|
||||||
if (DateTime.UtcNow - lastStartServiceTime < TimeSpan.FromSeconds(5))
|
if (DateTime.UtcNow - lastStartServiceTime < TimeSpan.FromSeconds(5))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -353,6 +353,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
private static bool ctrlDown;
|
private static bool ctrlDown;
|
||||||
private static bool altDown;
|
private static bool altDown;
|
||||||
private static bool shiftDown;
|
private static bool shiftDown;
|
||||||
|
internal static readonly string[] Args = new string[] { "CAD" };
|
||||||
|
|
||||||
private static void ResetModifiersState(HotkeySettings matchingHotkey)
|
private static void ResetModifiersState(HotkeySettings matchingHotkey)
|
||||||
{
|
{
|
||||||
@@ -456,7 +457,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
if (ctrlDown && altDown)
|
if (ctrlDown && altDown)
|
||||||
{
|
{
|
||||||
ctrlDown = altDown = false;
|
ctrlDown = altDown = false;
|
||||||
new ServiceController("MouseWithoutBordersSvc").Start(new string[] { "CAD" });
|
new ServiceController("MouseWithoutBordersSvc").Start(Args);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
}
|
}
|
||||||
else if (list.Count >= 4)
|
else if (list.Count >= 4)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("machineNames.Length > Common.MAX_MACHINE");
|
throw new ArgumentException($"The number of machines exceeded the maximum allowed limit of {Common.MAX_MACHINE}. Actual count: {list.Count}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = LearnMachine(name);
|
_ = LearnMachine(name);
|
||||||
@@ -178,7 +178,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
}
|
}
|
||||||
else if (list.Count >= 4)
|
else if (list.Count >= 4)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("infos.Length > Common.MAX_MACHINE");
|
throw new ArgumentException($"The number of machines exceeded the maximum allowed limit of {Common.MAX_MACHINE}. Actual count: {list.Count}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = LearnMachine(inf.Name);
|
_ = LearnMachine(inf.Name);
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ namespace MouseWithoutBorders.Class
|
|||||||
{
|
{
|
||||||
internal static class MachinePoolHelpers
|
internal static class MachinePoolHelpers
|
||||||
{
|
{
|
||||||
|
internal static readonly char[] Comma = new char[] { ',' };
|
||||||
|
internal static readonly char[] Colon = new char[] { ':' };
|
||||||
|
|
||||||
internal static MachineInf[] LoadMachineInfoFromMachinePoolStringSetting(string s)
|
internal static MachineInf[] LoadMachineInfoFromMachinePoolStringSetting(string s)
|
||||||
{
|
{
|
||||||
if (s == null)
|
if (s == null)
|
||||||
@@ -15,7 +18,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
throw new ArgumentNullException(s);
|
throw new ArgumentNullException(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] st = s.Split(new char[] { ',' });
|
string[] st = s.Split(Comma);
|
||||||
|
|
||||||
if (st.Length < Common.MAX_MACHINE)
|
if (st.Length < Common.MAX_MACHINE)
|
||||||
{
|
{
|
||||||
@@ -25,7 +28,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
MachineInf[] rv = new MachineInf[Common.MAX_MACHINE];
|
MachineInf[] rv = new MachineInf[Common.MAX_MACHINE];
|
||||||
for (int i = 0; i < Common.MAX_MACHINE; i++)
|
for (int i = 0; i < Common.MAX_MACHINE; i++)
|
||||||
{
|
{
|
||||||
string[] mc = st[i].Split(new char[] { ':' });
|
string[] mc = st[i].Split(Colon);
|
||||||
if (mc.Length == 2)
|
if (mc.Length == 2)
|
||||||
{
|
{
|
||||||
rv[i].Name = mc[0];
|
rv[i].Name = mc[0];
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
{
|
{
|
||||||
internal bool Changed;
|
internal bool Changed;
|
||||||
|
|
||||||
private readonly ISettingsUtils _settingsUtils;
|
private readonly SettingsUtils _settingsUtils;
|
||||||
private readonly object _loadingSettingsLock = new object();
|
private readonly object _loadingSettingsLock = new object();
|
||||||
private readonly IFileSystemWatcher _watcher;
|
private readonly IFileSystemWatcher _watcher;
|
||||||
|
|
||||||
|
|||||||
@@ -887,14 +887,14 @@ namespace MouseWithoutBorders.Class
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(Setting.Values.Name2IP))
|
if (!string.IsNullOrEmpty(Setting.Values.Name2IP))
|
||||||
{
|
{
|
||||||
string[] name2ip = Setting.Values.Name2IP.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
string[] name2ip = Setting.Values.Name2IP.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
string[] nameNip;
|
string[] nameNip;
|
||||||
|
|
||||||
if (name2ip != null)
|
if (name2ip != null)
|
||||||
{
|
{
|
||||||
foreach (string st in name2ip)
|
foreach (string st in name2ip)
|
||||||
{
|
{
|
||||||
nameNip = st.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
nameNip = st.Split(BlankSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
if (nameNip != null && nameNip.Length >= 2 && nameNip[0].Trim().Equals(machineName, StringComparison.OrdinalIgnoreCase)
|
if (nameNip != null && nameNip.Length >= 2 && nameNip[0].Trim().Equals(machineName, StringComparison.OrdinalIgnoreCase)
|
||||||
&& IPAddress.TryParse(nameNip[1].Trim(), out IPAddress ip) && !validAddressesSt.Contains("[" + ip.ToString() + "]")
|
&& IPAddress.TryParse(nameNip[1].Trim(), out IPAddress ip) && !validAddressesSt.Contains("[" + ip.ToString() + "]")
|
||||||
@@ -1063,7 +1063,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
|
|
||||||
List<IPAddress> localIPv4Addresses = GetMyIPv4Addresses().ToList();
|
List<IPAddress> localIPv4Addresses = GetMyIPv4Addresses().ToList();
|
||||||
|
|
||||||
if (!localIPv4Addresses.Any())
|
if (localIPv4Addresses.Count == 0)
|
||||||
{
|
{
|
||||||
Common.Log($"No IPv4 resolved from the local machine: {Common.MachineName}");
|
Common.Log($"No IPv4 resolved from the local machine: {Common.MachineName}");
|
||||||
return true;
|
return true;
|
||||||
@@ -1234,6 +1234,8 @@ namespace MouseWithoutBorders.Class
|
|||||||
}
|
}
|
||||||
|
|
||||||
private long lastRemoteMachineID;
|
private long lastRemoteMachineID;
|
||||||
|
internal static readonly string[] Separator = new string[] { "\r\n" };
|
||||||
|
internal static readonly char[] BlankSeparator = new char[] { ' ' };
|
||||||
|
|
||||||
private void MainTCPRoutine(TcpSk tcp, string machineName, bool isClient)
|
private void MainTCPRoutine(TcpSk tcp, string machineName, bool isClient)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static bool logged;
|
private static bool logged;
|
||||||
|
internal static readonly string[] Separator = new[] { " " };
|
||||||
|
|
||||||
private void LogError(string log)
|
private void LogError(string log)
|
||||||
{
|
{
|
||||||
@@ -146,7 +147,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Assuming the format of netstat's output is fixed.
|
// Assuming the format of netstat's output is fixed.
|
||||||
pid = int.Parse(portLogLine.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Last(), CultureInfo.CurrentCulture);
|
pid = int.Parse(portLogLine.Split(Separator, StringSplitOptions.RemoveEmptyEntries).Last(), CultureInfo.CurrentCulture);
|
||||||
process = Process.GetProcessById(pid);
|
process = Process.GetProcessById(pid);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|||||||
@@ -123,13 +123,14 @@ namespace MouseWithoutBorders
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string lastMessage = string.Empty;
|
private string lastMessage = string.Empty;
|
||||||
|
private static readonly string[] Separator = new string[] { "\r\n" };
|
||||||
|
|
||||||
internal void ShowTip(ToolTipIcon icon, string msg, int durationInMilliseconds)
|
internal void ShowTip(ToolTipIcon icon, string msg, int durationInMilliseconds)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
string text = msg + $"\r\n {(lastMessage.Equals(msg, StringComparison.OrdinalIgnoreCase) ? string.Empty : $"\r\nPrevious message/error: {lastMessage}")} ";
|
string text = msg + $"\r\n {(lastMessage.Equals(msg, StringComparison.OrdinalIgnoreCase) ? string.Empty : $"\r\nPrevious message/error: {lastMessage}")} ";
|
||||||
lastMessage = msg;
|
lastMessage = msg;
|
||||||
int y = (-text.Split(new string[] { "\r\n" }, StringSplitOptions.None).Length * 15) - 30;
|
int y = (-text.Split(Separator, StringSplitOptions.None).Length * 15) - 30;
|
||||||
|
|
||||||
toolTipManual.Hide(this);
|
toolTipManual.Hide(this);
|
||||||
|
|
||||||
|
|||||||
@@ -742,11 +742,13 @@ namespace MouseWithoutBorders
|
|||||||
LoadMachines();
|
LoadMachines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static readonly string[] Separator = new string[] { "\r\n" };
|
||||||
|
|
||||||
internal void ShowTip(ToolTipIcon icon, string text, int duration)
|
internal void ShowTip(ToolTipIcon icon, string text, int duration)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
text += "\r\n ";
|
text += "\r\n ";
|
||||||
int y = (-text.Split(new string[] { "\r\n" }, StringSplitOptions.None).Length * 15) - 30;
|
int y = (-text.Split(Separator, StringSplitOptions.None).Length * 15) - 30;
|
||||||
|
|
||||||
toolTipManual.Hide(this);
|
toolTipManual.Hide(this);
|
||||||
|
|
||||||
|
|||||||
@@ -148,6 +148,8 @@ internal sealed class ImageMethods
|
|||||||
return resultText.Trim();
|
return resultText.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static readonly char[] Separator = new char[] { '\n', '\r' };
|
||||||
|
|
||||||
public static async Task<string> ExtractText(Bitmap bmp, Language? preferredLanguage, System.Windows.Point? singlePoint = null)
|
public static async Task<string> ExtractText(Bitmap bmp, Language? preferredLanguage, System.Windows.Point? singlePoint = null)
|
||||||
{
|
{
|
||||||
Language? selectedLanguage = preferredLanguage ?? GetOCRLanguage();
|
Language? selectedLanguage = preferredLanguage ?? GetOCRLanguage();
|
||||||
@@ -211,7 +213,7 @@ internal sealed class ImageMethods
|
|||||||
|
|
||||||
if (culture.TextInfo.IsRightToLeft)
|
if (culture.TextInfo.IsRightToLeft)
|
||||||
{
|
{
|
||||||
string[] textListLines = text.ToString().Split(new char[] { '\n', '\r' });
|
string[] textListLines = text.ToString().Split(Separator);
|
||||||
|
|
||||||
_ = text.Clear();
|
_ = text.Clear();
|
||||||
foreach (string textLine in textListLines)
|
foreach (string textLine in textListLines)
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ public class ResultTable
|
|||||||
return rowAreas;
|
return rowAreas;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CheckIntersectionsWithWordBorders(int hitGridSpacing, ICollection<WordBorder> wordBorders, ICollection<int> rowAreas, int i, Rect horizontalLineRect)
|
private static void CheckIntersectionsWithWordBorders(int hitGridSpacing, ICollection<WordBorder> wordBorders, List<int> rowAreas, int i, Rect horizontalLineRect)
|
||||||
{
|
{
|
||||||
foreach (WordBorder wb in wordBorders)
|
foreach (WordBorder wb in wordBorders)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace PowerOCR.Settings
|
|||||||
[Export(typeof(IUserSettings))]
|
[Export(typeof(IUserSettings))]
|
||||||
public class UserSettings : IUserSettings
|
public class UserSettings : IUserSettings
|
||||||
{
|
{
|
||||||
private readonly ISettingsUtils _settingsUtils;
|
private readonly SettingsUtils _settingsUtils;
|
||||||
private const string PowerOcrModuleName = "TextExtractor";
|
private const string PowerOcrModuleName = "TextExtractor";
|
||||||
private const string DefaultActivationShortcut = "Win + Shift + O";
|
private const string DefaultActivationShortcut = "Win + Shift + O";
|
||||||
private const int MaxNumberOfRetry = 5;
|
private const int MaxNumberOfRetry = 5;
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ namespace Awake.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Manager
|
public class Manager
|
||||||
{
|
{
|
||||||
|
private static readonly CompositeFormat AwakeMinutes = System.Text.CompositeFormat.Parse(Properties.Resources.AWAKE_MINUTES);
|
||||||
|
private static readonly CompositeFormat AwakeHours = System.Text.CompositeFormat.Parse(Properties.Resources.AWAKE_HOURS);
|
||||||
|
|
||||||
private static BlockingCollection<ExecutionState> _stateQueue;
|
private static BlockingCollection<ExecutionState> _stateQueue;
|
||||||
|
|
||||||
private static CancellationTokenSource _tokenSource;
|
private static CancellationTokenSource _tokenSource;
|
||||||
@@ -276,9 +279,9 @@ namespace Awake.Core
|
|||||||
{
|
{
|
||||||
Dictionary<string, int> optionsList = new Dictionary<string, int>
|
Dictionary<string, int> optionsList = new Dictionary<string, int>
|
||||||
{
|
{
|
||||||
{ string.Format(CultureInfo.InvariantCulture, Resources.AWAKE_MINUTES, 30), 1800 },
|
{ string.Format(CultureInfo.InvariantCulture, AwakeMinutes, 30), 1800 },
|
||||||
{ Resources.AWAKE_1_HOUR, 3600 },
|
{ Resources.AWAKE_1_HOUR, 3600 },
|
||||||
{ string.Format(CultureInfo.InvariantCulture, Resources.AWAKE_HOURS, 2), 7200 },
|
{ string.Format(CultureInfo.InvariantCulture, AwakeHours, 2), 7200 },
|
||||||
};
|
};
|
||||||
return optionsList;
|
return optionsList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ namespace Awake
|
|||||||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||||
|
|
||||||
private static ManualResetEvent _exitSignal = new ManualResetEvent(false);
|
private static ManualResetEvent _exitSignal = new ManualResetEvent(false);
|
||||||
|
internal static readonly string[] AliasesConfigOption = new[] { "--use-pt-config", "-c" };
|
||||||
|
internal static readonly string[] AliasesDisplayOption = new[] { "--display-on", "-d" };
|
||||||
|
internal static readonly string[] AliasesTimeOption = new[] { "--time-limit", "-t" };
|
||||||
|
internal static readonly string[] AliasesPidOption = new[] { "--pid", "-p" };
|
||||||
|
internal static readonly string[] AliasesExpireAtOption = new[] { "--expire-at", "-e" };
|
||||||
|
|
||||||
private static int Main(string[] args)
|
private static int Main(string[] args)
|
||||||
{
|
{
|
||||||
@@ -86,7 +91,7 @@ namespace Awake
|
|||||||
Logger.LogInfo("Parsing parameters...");
|
Logger.LogInfo("Parsing parameters...");
|
||||||
|
|
||||||
Option<bool> configOption = new(
|
Option<bool> configOption = new(
|
||||||
aliases: new[] { "--use-pt-config", "-c" },
|
aliases: AliasesConfigOption,
|
||||||
getDefaultValue: () => false,
|
getDefaultValue: () => false,
|
||||||
description: $"Specifies whether {Core.Constants.AppName} will be using the PowerToys configuration file for managing the state.")
|
description: $"Specifies whether {Core.Constants.AppName} will be using the PowerToys configuration file for managing the state.")
|
||||||
{
|
{
|
||||||
@@ -95,7 +100,7 @@ namespace Awake
|
|||||||
};
|
};
|
||||||
|
|
||||||
Option<bool> displayOption = new(
|
Option<bool> displayOption = new(
|
||||||
aliases: new[] { "--display-on", "-d" },
|
aliases: AliasesDisplayOption,
|
||||||
getDefaultValue: () => true,
|
getDefaultValue: () => true,
|
||||||
description: "Determines whether the display should be kept awake.")
|
description: "Determines whether the display should be kept awake.")
|
||||||
{
|
{
|
||||||
@@ -104,7 +109,7 @@ namespace Awake
|
|||||||
};
|
};
|
||||||
|
|
||||||
Option<uint> timeOption = new(
|
Option<uint> timeOption = new(
|
||||||
aliases: new[] { "--time-limit", "-t" },
|
aliases: AliasesTimeOption,
|
||||||
getDefaultValue: () => 0,
|
getDefaultValue: () => 0,
|
||||||
description: "Determines the interval, in seconds, during which the computer is kept awake.")
|
description: "Determines the interval, in seconds, during which the computer is kept awake.")
|
||||||
{
|
{
|
||||||
@@ -113,7 +118,7 @@ namespace Awake
|
|||||||
};
|
};
|
||||||
|
|
||||||
Option<int> pidOption = new(
|
Option<int> pidOption = new(
|
||||||
aliases: new[] { "--pid", "-p" },
|
aliases: AliasesPidOption,
|
||||||
getDefaultValue: () => 0,
|
getDefaultValue: () => 0,
|
||||||
description: $"Bind the execution of {Core.Constants.AppName} to another process. When the process ends, the system will resume managing the current sleep and display state.")
|
description: $"Bind the execution of {Core.Constants.AppName} to another process. When the process ends, the system will resume managing the current sleep and display state.")
|
||||||
{
|
{
|
||||||
@@ -122,7 +127,7 @@ namespace Awake
|
|||||||
};
|
};
|
||||||
|
|
||||||
Option<string> expireAtOption = new(
|
Option<string> expireAtOption = new(
|
||||||
aliases: new[] { "--expire-at", "-e" },
|
aliases: AliasesExpireAtOption,
|
||||||
getDefaultValue: () => string.Empty,
|
getDefaultValue: () => string.Empty,
|
||||||
description: $"Determines the end date/time when {Core.Constants.AppName} will back off and let the system manage the current sleep and display state.")
|
description: $"Determines the end date/time when {Core.Constants.AppName} will back off and let the system manage the current sleep and display state.")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace ColorPicker.Behaviors
|
|||||||
private static readonly TimeSpan _animationTimeSmaller = _animationTime;
|
private static readonly TimeSpan _animationTimeSmaller = _animationTime;
|
||||||
private static readonly IEasingFunction _easeFunctionSmaller = new QuadraticEase() { EasingMode = EasingMode.EaseIn };
|
private static readonly IEasingFunction _easeFunctionSmaller = new QuadraticEase() { EasingMode = EasingMode.EaseIn };
|
||||||
|
|
||||||
private static void CustomAnimation(DependencyProperty prop, IAnimatable sender, double fromValue, double toValue)
|
private static void CustomAnimation(DependencyProperty prop, FrameworkElement sender, double fromValue, double toValue)
|
||||||
{
|
{
|
||||||
// if the animation is to/from a value of 0, it will cancel the current animation
|
// if the animation is to/from a value of 0, it will cancel the current animation
|
||||||
DoubleAnimation move = null;
|
DoubleAnimation move = null;
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ namespace ColorPicker.Controls
|
|||||||
newHexString = newHexString.ToLowerInvariant();
|
newHexString = newHexString.ToLowerInvariant();
|
||||||
|
|
||||||
// Return only with hashtag if user typed it before
|
// Return only with hashtag if user typed it before
|
||||||
bool addHashtag = oldValue.StartsWith("#", StringComparison.InvariantCulture);
|
bool addHashtag = oldValue.StartsWith('#');
|
||||||
return addHashtag ? "#" + newHexString : newHexString;
|
return addHashtag ? "#" + newHexString : newHexString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ namespace ColorPicker.Controls
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Hex with or without hashtag and six characters
|
// Hex with or without hashtag and six characters
|
||||||
return hexCodeText.StartsWith("#", StringComparison.InvariantCulture) ? hexCodeText : "#" + hexCodeText;
|
return hexCodeText.StartsWith('#') ? hexCodeText : "#" + hexCodeText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using ColorPicker.Models;
|
using ColorPicker.Models;
|
||||||
|
|
||||||
@@ -21,6 +22,9 @@ namespace ColorPicker.Helpers
|
|||||||
|
|
||||||
internal static class SerializationHelper
|
internal static class SerializationHelper
|
||||||
{
|
{
|
||||||
|
public static readonly JsonSerializerOptions DefaultOptions = new JsonSerializerOptions { WriteIndented = false };
|
||||||
|
public static readonly JsonSerializerOptions IndentedOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||||
|
|
||||||
public static Dictionary<string, Dictionary<string, string>> ConvertToDesiredColorFormats(
|
public static Dictionary<string, Dictionary<string, string>> ConvertToDesiredColorFormats(
|
||||||
IList colorsToExport,
|
IList colorsToExport,
|
||||||
IEnumerable<ColorFormatModel> colorRepresentations,
|
IEnumerable<ColorFormatModel> colorRepresentations,
|
||||||
@@ -116,10 +120,7 @@ namespace ColorPicker.Helpers
|
|||||||
|
|
||||||
public static string ToJson(this Dictionary<string, Dictionary<string, string>> source, bool indented = true)
|
public static string ToJson(this Dictionary<string, Dictionary<string, string>> source, bool indented = true)
|
||||||
{
|
{
|
||||||
var options = new JsonSerializerOptions
|
var options = indented ? IndentedOptions : DefaultOptions;
|
||||||
{
|
|
||||||
WriteIndented = indented,
|
|
||||||
};
|
|
||||||
|
|
||||||
return JsonSerializer.Serialize(source, options);
|
return JsonSerializer.Serialize(source, options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace ColorPicker.Helpers
|
|||||||
ShowZoomWindow(point);
|
ShowZoomWindow(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BitmapSource BitmapToImageSource(Bitmap bitmap)
|
private static BitmapImage BitmapToImageSource(Bitmap bitmap)
|
||||||
{
|
{
|
||||||
using (MemoryStream memory = new MemoryStream())
|
using (MemoryStream memory = new MemoryStream())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace ColorPicker.Settings
|
|||||||
[Export(typeof(IUserSettings))]
|
[Export(typeof(IUserSettings))]
|
||||||
public class UserSettings : IUserSettings
|
public class UserSettings : IUserSettings
|
||||||
{
|
{
|
||||||
private readonly ISettingsUtils _settingsUtils;
|
private readonly SettingsUtils _settingsUtils;
|
||||||
private const string ColorPickerModuleName = "ColorPicker";
|
private const string ColorPickerModuleName = "ColorPicker";
|
||||||
private const string ColorPickerHistoryFilename = "colorHistory.json";
|
private const string ColorPickerHistoryFilename = "colorHistory.json";
|
||||||
private const string DefaultActivationShortcut = "Ctrl + Break";
|
private const string DefaultActivationShortcut = "Ctrl + Break";
|
||||||
@@ -36,6 +36,11 @@ namespace ColorPicker.Settings
|
|||||||
|
|
||||||
private bool _loadingColorsHistory;
|
private bool _loadingColorsHistory;
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
};
|
||||||
|
|
||||||
[ImportingConstructor]
|
[ImportingConstructor]
|
||||||
public UserSettings(Helpers.IThrottledActionInvoker throttledActionInvoker)
|
public UserSettings(Helpers.IThrottledActionInvoker throttledActionInvoker)
|
||||||
{
|
{
|
||||||
@@ -58,7 +63,7 @@ namespace ColorPicker.Settings
|
|||||||
{
|
{
|
||||||
if (!_loadingColorsHistory)
|
if (!_loadingColorsHistory)
|
||||||
{
|
{
|
||||||
_settingsUtils.SaveSettings(JsonSerializer.Serialize(ColorHistory, new JsonSerializerOptions { WriteIndented = true }), ColorPickerModuleName, ColorPickerHistoryFilename);
|
_settingsUtils.SaveSettings(JsonSerializer.Serialize(ColorHistory, _serializerOptions), ColorPickerModuleName, ColorPickerHistoryFilename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ namespace FancyZonesEditor
|
|||||||
private SnappyHelperBase snappyX;
|
private SnappyHelperBase snappyX;
|
||||||
private SnappyHelperBase snappyY;
|
private SnappyHelperBase snappyY;
|
||||||
|
|
||||||
private SnappyHelperBase NewMagneticSnapper(bool isX, ResizeMode mode)
|
private SnappyHelperMagnetic NewMagneticSnapper(bool isX, ResizeMode mode)
|
||||||
{
|
{
|
||||||
Rect workingArea = App.Overlay.WorkArea;
|
Rect workingArea = App.Overlay.WorkArea;
|
||||||
int screenAxisOrigin = (int)(isX ? workingArea.Left : workingArea.Top);
|
int screenAxisOrigin = (int)(isX ? workingArea.Left : workingArea.Top);
|
||||||
@@ -245,7 +245,7 @@ namespace FancyZonesEditor
|
|||||||
return new SnappyHelperMagnetic(Model.Zones, ZoneIndex, isX, mode, screenAxisOrigin, screenAxisSize);
|
return new SnappyHelperMagnetic(Model.Zones, ZoneIndex, isX, mode, screenAxisOrigin, screenAxisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SnappyHelperBase NewNonMagneticSnapper(bool isX, ResizeMode mode)
|
private SnappyHelperNonMagnetic NewNonMagneticSnapper(bool isX, ResizeMode mode)
|
||||||
{
|
{
|
||||||
Rect workingArea = App.Overlay.WorkArea;
|
Rect workingArea = App.Overlay.WorkArea;
|
||||||
int screenAxisOrigin = (int)(isX ? workingArea.Left : workingArea.Top);
|
int screenAxisOrigin = (int)(isX ? workingArea.Left : workingArea.Top);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
using System.Windows.Automation.Peers;
|
using System.Windows.Automation.Peers;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
@@ -10,6 +11,8 @@ namespace FancyZonesEditor.Controls
|
|||||||
{
|
{
|
||||||
internal sealed class CustomSliderAutomationPeer : SliderAutomationPeer
|
internal sealed class CustomSliderAutomationPeer : SliderAutomationPeer
|
||||||
{
|
{
|
||||||
|
private static readonly CompositeFormat CustomSliderAnnounce = System.Text.CompositeFormat.Parse(Properties.Resources.Custom_slider_announce);
|
||||||
|
|
||||||
private string name = string.Empty;
|
private string name = string.Empty;
|
||||||
|
|
||||||
public CustomSliderAutomationPeer(Slider owner)
|
public CustomSliderAutomationPeer(Slider owner)
|
||||||
@@ -29,7 +32,7 @@ namespace FancyZonesEditor.Controls
|
|||||||
|
|
||||||
string announce = string.Format(
|
string announce = string.Format(
|
||||||
CultureInfo.CurrentCulture,
|
CultureInfo.CurrentCulture,
|
||||||
Properties.Resources.Custom_slider_announce,
|
CustomSliderAnnounce,
|
||||||
name,
|
name,
|
||||||
element.Minimum,
|
element.Minimum,
|
||||||
element.Maximum,
|
element.Maximum,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Automation;
|
using System.Windows.Automation;
|
||||||
using System.Windows.Automation.Peers;
|
using System.Windows.Automation.Peers;
|
||||||
@@ -36,6 +37,10 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
private bool haveTriedToGetFocusAlready;
|
private bool haveTriedToGetFocusAlready;
|
||||||
|
|
||||||
|
private static readonly CompositeFormat EditTemplate = System.Text.CompositeFormat.Parse(Properties.Resources.Edit_Template);
|
||||||
|
private static readonly CompositeFormat PixelValue = System.Text.CompositeFormat.Parse(Properties.Resources.Pixel_Value);
|
||||||
|
private static readonly CompositeFormat TemplateZoneCountValue = System.Text.CompositeFormat.Parse(Properties.Resources.Template_Zone_Count_Value);
|
||||||
|
|
||||||
public int WrapPanelItemSize { get; set; } = DefaultWrapPanelItemSize;
|
public int WrapPanelItemSize { get; set; } = DefaultWrapPanelItemSize;
|
||||||
|
|
||||||
public MainWindow(bool spanZonesAcrossMonitors, Rect workArea)
|
public MainWindow(bool spanZonesAcrossMonitors, Rect workArea)
|
||||||
@@ -335,7 +340,7 @@ namespace FancyZonesEditor
|
|||||||
App.Overlay.StartEditing(_settings.SelectedModel);
|
App.Overlay.StartEditing(_settings.SelectedModel);
|
||||||
|
|
||||||
Keyboard.ClearFocus();
|
Keyboard.ClearFocus();
|
||||||
EditLayoutDialogTitle.Text = string.Format(CultureInfo.CurrentCulture, Properties.Resources.Edit_Template, ((LayoutModel)dataContext).Name);
|
EditLayoutDialogTitle.Text = string.Format(CultureInfo.CurrentCulture, EditTemplate, ((LayoutModel)dataContext).Name);
|
||||||
await EditLayoutDialog.ShowAsync();
|
await EditLayoutDialog.ShowAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,7 +572,7 @@ namespace FancyZonesEditor
|
|||||||
FrameworkElementAutomationPeer.FromElement(SensitivityInput) as SliderAutomationPeer;
|
FrameworkElementAutomationPeer.FromElement(SensitivityInput) as SliderAutomationPeer;
|
||||||
string activityId = "sliderValueChanged";
|
string activityId = "sliderValueChanged";
|
||||||
|
|
||||||
string value = string.Format(CultureInfo.CurrentCulture, Properties.Resources.Pixel_Value, SensitivityInput.Value);
|
string value = string.Format(CultureInfo.CurrentCulture, PixelValue, SensitivityInput.Value);
|
||||||
|
|
||||||
if (peer != null && value != null)
|
if (peer != null && value != null)
|
||||||
{
|
{
|
||||||
@@ -588,7 +593,7 @@ namespace FancyZonesEditor
|
|||||||
FrameworkElementAutomationPeer.FromElement(TemplateZoneCount) as SliderAutomationPeer;
|
FrameworkElementAutomationPeer.FromElement(TemplateZoneCount) as SliderAutomationPeer;
|
||||||
string activityId = "templateZoneCountValueChanged";
|
string activityId = "templateZoneCountValueChanged";
|
||||||
|
|
||||||
string value = string.Format(CultureInfo.CurrentCulture, Properties.Resources.Template_Zone_Count_Value, TemplateZoneCount.Value);
|
string value = string.Format(CultureInfo.CurrentCulture, TemplateZoneCountValue, TemplateZoneCount.Value);
|
||||||
|
|
||||||
if (peer != null && value != null)
|
if (peer != null && value != null)
|
||||||
{
|
{
|
||||||
@@ -609,7 +614,7 @@ namespace FancyZonesEditor
|
|||||||
FrameworkElementAutomationPeer.FromElement(Spacing) as SliderAutomationPeer;
|
FrameworkElementAutomationPeer.FromElement(Spacing) as SliderAutomationPeer;
|
||||||
string activityId = "spacingValueChanged";
|
string activityId = "spacingValueChanged";
|
||||||
|
|
||||||
string value = string.Format(CultureInfo.CurrentCulture, Properties.Resources.Pixel_Value, Spacing.Value);
|
string value = string.Format(CultureInfo.CurrentCulture, PixelValue, Spacing.Value);
|
||||||
|
|
||||||
if (peer != null && value != null)
|
if (peer != null && value != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@@ -231,7 +232,7 @@ namespace FancyZonesEditor
|
|||||||
{
|
{
|
||||||
foreach (LayoutModel model in CustomModels)
|
foreach (LayoutModel model in CustomModels)
|
||||||
{
|
{
|
||||||
if (model.Uuid == currentApplied.ZonesetUuid.ToUpperInvariant())
|
if (string.Equals(model.Uuid, currentApplied.ZonesetUuid, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// found match
|
// found match
|
||||||
foundModel = model;
|
foundModel = model;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Collections.Specialized;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using ImageResizer.Models;
|
using ImageResizer.Models;
|
||||||
using ImageResizer.Test;
|
using ImageResizer.Test;
|
||||||
@@ -16,6 +17,13 @@ namespace ImageResizer.Properties
|
|||||||
[TestClass]
|
[TestClass]
|
||||||
public class SettingsTests
|
public class SettingsTests
|
||||||
{
|
{
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly CompositeFormat ValueMustBeBetween = System.Text.CompositeFormat.Parse(Properties.Resources.ValueMustBeBetween);
|
||||||
|
|
||||||
private static App _imageResizerApp;
|
private static App _imageResizerApp;
|
||||||
|
|
||||||
public SettingsTests()
|
public SettingsTests()
|
||||||
@@ -187,7 +195,7 @@ namespace ImageResizer.Properties
|
|||||||
|
|
||||||
// Using InvariantCulture since this is used internally
|
// Using InvariantCulture since this is used internally
|
||||||
Assert.AreEqual(
|
Assert.AreEqual(
|
||||||
string.Format(CultureInfo.InvariantCulture, Resources.ValueMustBeBetween, 1, 100),
|
string.Format(CultureInfo.InvariantCulture, ValueMustBeBetween, 1, 100),
|
||||||
result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,9 +363,9 @@ namespace ImageResizer.Properties
|
|||||||
|
|
||||||
// Execute readFile/writefile twice and see if serialized string is still correct
|
// Execute readFile/writefile twice and see if serialized string is still correct
|
||||||
var resultWrapper = JsonSerializer.Deserialize<SettingsWrapper>(defaultInput);
|
var resultWrapper = JsonSerializer.Deserialize<SettingsWrapper>(defaultInput);
|
||||||
var serializedInput = JsonSerializer.Serialize(resultWrapper, new JsonSerializerOptions() { WriteIndented = true });
|
var serializedInput = JsonSerializer.Serialize(resultWrapper, _serializerOptions);
|
||||||
var resultWrapper2 = JsonSerializer.Deserialize<SettingsWrapper>(serializedInput);
|
var resultWrapper2 = JsonSerializer.Deserialize<SettingsWrapper>(serializedInput);
|
||||||
var serializedInput2 = JsonSerializer.Serialize(resultWrapper2, new JsonSerializerOptions() { WriteIndented = true });
|
var serializedInput2 = JsonSerializer.Serialize(resultWrapper2, _serializerOptions);
|
||||||
|
|
||||||
Assert.AreEqual(serializedInput, serializedInput2);
|
Assert.AreEqual(serializedInput, serializedInput2);
|
||||||
Assert.AreEqual("Image Resizer", resultWrapper2.Name);
|
Assert.AreEqual("Image Resizer", resultWrapper2.Name);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace ImageResizer.Models
|
|||||||
{
|
{
|
||||||
public class ResizeSize : Observable
|
public class ResizeSize : Observable
|
||||||
{
|
{
|
||||||
private static readonly IDictionary<string, string> _tokens = new Dictionary<string, string>
|
private static readonly Dictionary<string, string> _tokens = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
["$small$"] = Resources.Small,
|
["$small$"] = Resources.Small,
|
||||||
["$medium$"] = Resources.Medium,
|
["$medium$"] = Resources.Medium,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using System.Collections.Specialized;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO.Abstractions;
|
using System.IO.Abstractions;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -27,6 +28,8 @@ namespace ImageResizer.Properties
|
|||||||
WriteIndented = true,
|
WriteIndented = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static readonly CompositeFormat ValueMustBeBetween = System.Text.CompositeFormat.Parse(Properties.Resources.ValueMustBeBetween);
|
||||||
|
|
||||||
// Used to synchronize access to the settings.json file
|
// Used to synchronize access to the settings.json file
|
||||||
private static Mutex _jsonMutex = new Mutex();
|
private static Mutex _jsonMutex = new Mutex();
|
||||||
private static string _settingsPath = _fileSystem.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "Image Resizer", "settings.json");
|
private static string _settingsPath = _fileSystem.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "Image Resizer", "settings.json");
|
||||||
@@ -122,7 +125,7 @@ namespace ImageResizer.Properties
|
|||||||
if (JpegQualityLevel < 1 || JpegQualityLevel > 100)
|
if (JpegQualityLevel < 1 || JpegQualityLevel > 100)
|
||||||
{
|
{
|
||||||
// Using CurrentCulture since this is user facing
|
// Using CurrentCulture since this is user facing
|
||||||
return string.Format(CultureInfo.CurrentCulture, Resources.ValueMustBeBetween, 1, 100);
|
return string.Format(CultureInfo.CurrentCulture, ValueMustBeBetween, 1, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
|||||||
[TestClass]
|
[TestClass]
|
||||||
public class InputInterpreterTests
|
public class InputInterpreterTests
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CA1861 // Avoid constant arrays as arguments
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow(new string[] { "1,5'" }, new string[] { "1,5", "'" })]
|
[DataRow(new string[] { "1,5'" }, new string[] { "1,5", "'" })]
|
||||||
[DataRow(new string[] { "1.5'" }, new string[] { "1.5", "'" })]
|
[DataRow(new string[] { "1.5'" }, new string[] { "1.5", "'" })]
|
||||||
@@ -58,6 +59,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
|||||||
[DataRow(new string[] { "5", "f", "in", "celsius" }, new string[] { "5", "°f", "in", "DegreeCelsius" })]
|
[DataRow(new string[] { "5", "f", "in", "celsius" }, new string[] { "5", "°f", "in", "DegreeCelsius" })]
|
||||||
[DataRow(new string[] { "5", "c", "in", "f" }, new string[] { "5", "°c", "in", "°f" })]
|
[DataRow(new string[] { "5", "c", "in", "f" }, new string[] { "5", "°c", "in", "°f" })]
|
||||||
[DataRow(new string[] { "5", "f", "in", "c" }, new string[] { "5", "°f", "in", "°c" })]
|
[DataRow(new string[] { "5", "f", "in", "c" }, new string[] { "5", "°f", "in", "°c" })]
|
||||||
|
#pragma warning restore CA1861 // Avoid constant arrays as arguments
|
||||||
public void PrefixesDegrees(string[] input, string[] expectedResult)
|
public void PrefixesDegrees(string[] input, string[] expectedResult)
|
||||||
{
|
{
|
||||||
InputInterpreter.DegreePrefixer(ref input);
|
InputInterpreter.DegreePrefixer(ref input);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -157,12 +158,12 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void FeetToFt(ref string[] split)
|
public static void FeetToFt(ref string[] split)
|
||||||
{
|
{
|
||||||
if (split[1].ToLowerInvariant() == "feet")
|
if (string.Equals(split[1], "feet", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
split[1] = "ft";
|
split[1] = "ft";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (split[3].ToLowerInvariant() == "feet")
|
if (string.Equals(split[3], "feet", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
split[3] = "ft";
|
split[3] = "ft";
|
||||||
}
|
}
|
||||||
@@ -183,7 +184,8 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
|
|||||||
public static void GallonHandler(ref string[] split, CultureInfo culture)
|
public static void GallonHandler(ref string[] split, CultureInfo culture)
|
||||||
{
|
{
|
||||||
HashSet<string> britishCultureNames = new HashSet<string>() { "en-AI", "en-VG", "en-GB", "en-KY", "en-MS", "en-AG", "en-DM", "en-GD", "en-KN", "en-LC", "en-VC", "en-IE", "en-GY", "en-AE" };
|
HashSet<string> britishCultureNames = new HashSet<string>() { "en-AI", "en-VG", "en-GB", "en-KY", "en-MS", "en-AG", "en-DM", "en-GD", "en-KN", "en-LC", "en-VC", "en-IE", "en-GY", "en-AE" };
|
||||||
if (split[1].ToLowerInvariant() == "gal" || split[1].ToLowerInvariant() == "gallon")
|
if (string.Equals(split[1], "gal", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(split[1], "gallon", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (britishCultureNames.Contains(culture.Name))
|
if (britishCultureNames.Contains(culture.Name))
|
||||||
{
|
{
|
||||||
@@ -195,7 +197,8 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (split[3].ToLowerInvariant() == "gal" || split[3].ToLowerInvariant() == "gallon")
|
if (string.Equals(split[3], "gal", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(split[3], "gallon", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (britishCultureNames.Contains(culture.Name))
|
if (britishCultureNames.Contains(culture.Name))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
@@ -27,6 +28,8 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
|
|||||||
private static string _icon_path;
|
private static string _icon_path;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
|
private static readonly CompositeFormat CopyToClipboard = System.Text.CompositeFormat.Parse(Properties.Resources.copy_to_clipboard);
|
||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(context);
|
ArgumentNullException.ThrowIfNull(context);
|
||||||
@@ -61,7 +64,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
|
|||||||
Title = result.ToString(null),
|
Title = result.ToString(null),
|
||||||
IcoPath = _icon_path,
|
IcoPath = _icon_path,
|
||||||
Score = 300,
|
Score = 300,
|
||||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.copy_to_clipboard, result.QuantityInfo.Name),
|
SubTitle = string.Format(CultureInfo.CurrentCulture, CopyToClipboard, result.QuantityInfo.Name),
|
||||||
Action = c =>
|
Action = c =>
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
|
|||||||
private static Enum GetUnitEnum(string unit, QuantityInfo unitInfo)
|
private static Enum GetUnitEnum(string unit, QuantityInfo unitInfo)
|
||||||
{
|
{
|
||||||
UnitInfo first = Array.Find(unitInfo.UnitInfos, info =>
|
UnitInfo first = Array.Find(unitInfo.UnitInfos, info =>
|
||||||
unit.ToLowerInvariant() == info.Name.ToLowerInvariant() || unit.ToLowerInvariant() == info.PluralName.ToLowerInvariant());
|
string.Equals(unit, info.Name, StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(unit, info.PluralName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
if (first != null)
|
if (first != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
results = results.Where(a => a.Title.ToLowerInvariant().Contains(query.Search.ToLowerInvariant())).ToList();
|
results = results.Where(a => a.Title.Contains(query.Search, StringComparison.InvariantCultureIgnoreCase)).ToList();
|
||||||
|
|
||||||
results.ForEach(x =>
|
results.ForEach(x =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.RemoteMachinesHelper
|
|||||||
{
|
{
|
||||||
public class VSCodeRemoteMachinesApi
|
public class VSCodeRemoteMachinesApi
|
||||||
{
|
{
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
AllowTrailingCommas = true,
|
||||||
|
ReadCommentHandling = JsonCommentHandling.Skip,
|
||||||
|
};
|
||||||
|
|
||||||
public VSCodeRemoteMachinesApi()
|
public VSCodeRemoteMachinesApi()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -35,7 +41,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.RemoteMachinesHelper
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
JsonElement vscodeSettingsFile = JsonSerializer.Deserialize<JsonElement>(fileContent, new JsonSerializerOptions() { AllowTrailingCommas = true, ReadCommentHandling = JsonCommentHandling.Skip });
|
JsonElement vscodeSettingsFile = JsonSerializer.Deserialize<JsonElement>(fileContent, _serializerOptions);
|
||||||
if (vscodeSettingsFile.TryGetProperty("remote.SSH.configFile", out var pathElement))
|
if (vscodeSettingsFile.TryGetProperty("remote.SSH.configFile", out var pathElement))
|
||||||
{
|
{
|
||||||
var path = pathElement.GetString();
|
var path = pathElement.GetString();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Community.PowerToys.Run.Plugin.ValueGenerator
|
|||||||
|
|
||||||
string command = query.Terms[0];
|
string command = query.Terms[0];
|
||||||
|
|
||||||
if (command.ToLower(null) == "md5")
|
if (command.Equals("md5", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
int commandIndex = query.RawUserQuery.IndexOf(command, StringComparison.InvariantCultureIgnoreCase);
|
int commandIndex = query.RawUserQuery.IndexOf(command, StringComparison.InvariantCultureIgnoreCase);
|
||||||
string content = query.RawUserQuery.Substring(commandIndex + command.Length).Trim();
|
string content = query.RawUserQuery.Substring(commandIndex + command.Length).Trim();
|
||||||
@@ -115,13 +115,13 @@ namespace Community.PowerToys.Run.Plugin.ValueGenerator
|
|||||||
request = new GUIDRequest(version);
|
request = new GUIDRequest(version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (command.ToLower(null) == "base64")
|
else if (command.Equals("base64", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
int commandIndex = query.RawUserQuery.IndexOf(command, StringComparison.InvariantCultureIgnoreCase);
|
int commandIndex = query.RawUserQuery.IndexOf(command, StringComparison.InvariantCultureIgnoreCase);
|
||||||
string content = query.RawUserQuery.Substring(commandIndex + command.Length).Trim();
|
string content = query.RawUserQuery.Substring(commandIndex + command.Length).Trim();
|
||||||
request = new Base64Request(Encoding.UTF8.GetBytes(content));
|
request = new Base64Request(Encoding.UTF8.GetBytes(content));
|
||||||
}
|
}
|
||||||
else if (command.ToLower(null) == "base64d")
|
else if (command.Equals("base64d", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
int commandIndex = query.RawUserQuery.IndexOf(command, StringComparison.InvariantCultureIgnoreCase);
|
int commandIndex = query.RawUserQuery.IndexOf(command, StringComparison.InvariantCultureIgnoreCase);
|
||||||
string content = query.RawUserQuery.Substring(commandIndex + command.Length).Trim();
|
string content = query.RawUserQuery.Substring(commandIndex + command.Length).Trim();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
using Microsoft.PowerToys.Settings.UI.Library;
|
using Microsoft.PowerToys.Settings.UI.Library;
|
||||||
@@ -38,6 +39,10 @@ namespace Community.PowerToys.Run.Plugin.WebSearch
|
|||||||
|
|
||||||
public static string PluginID => "9F1B49201C3F4BF781CAAD5CD88EA4DC";
|
public static string PluginID => "9F1B49201C3F4BF781CAAD5CD88EA4DC";
|
||||||
|
|
||||||
|
private static readonly CompositeFormat PluginInBrowserName = System.Text.CompositeFormat.Parse(Properties.Resources.plugin_in_browser_name);
|
||||||
|
private static readonly CompositeFormat PluginOpen = System.Text.CompositeFormat.Parse(Properties.Resources.plugin_open);
|
||||||
|
private static readonly CompositeFormat PluginSearchFailed = System.Text.CompositeFormat.Parse(Properties.Resources.plugin_search_failed);
|
||||||
|
|
||||||
public IEnumerable<PluginAdditionalOption> AdditionalOptions => new List<PluginAdditionalOption>()
|
public IEnumerable<PluginAdditionalOption> AdditionalOptions => new List<PluginAdditionalOption>()
|
||||||
{
|
{
|
||||||
new PluginAdditionalOption()
|
new PluginAdditionalOption()
|
||||||
@@ -66,7 +71,7 @@ namespace Community.PowerToys.Run.Plugin.WebSearch
|
|||||||
results.Add(new Result
|
results.Add(new Result
|
||||||
{
|
{
|
||||||
Title = Properties.Resources.plugin_description.Remove(Description.Length - 1, 1),
|
Title = Properties.Resources.plugin_description.Remove(Description.Length - 1, 1),
|
||||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.plugin_in_browser_name, BrowserInfo.Name ?? BrowserInfo.MSEdgeName),
|
SubTitle = string.Format(CultureInfo.CurrentCulture, PluginInBrowserName, BrowserInfo.Name ?? BrowserInfo.MSEdgeName),
|
||||||
QueryTextDisplay = string.Empty,
|
QueryTextDisplay = string.Empty,
|
||||||
IcoPath = _iconPath,
|
IcoPath = _iconPath,
|
||||||
ProgramArguments = arguments,
|
ProgramArguments = arguments,
|
||||||
@@ -98,7 +103,7 @@ namespace Community.PowerToys.Run.Plugin.WebSearch
|
|||||||
var result = new Result
|
var result = new Result
|
||||||
{
|
{
|
||||||
Title = searchTerm,
|
Title = searchTerm,
|
||||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.plugin_open, BrowserInfo.Name ?? BrowserInfo.MSEdgeName),
|
SubTitle = string.Format(CultureInfo.CurrentCulture, PluginOpen, BrowserInfo.Name ?? BrowserInfo.MSEdgeName),
|
||||||
QueryTextDisplay = searchTerm,
|
QueryTextDisplay = searchTerm,
|
||||||
IcoPath = _iconPath,
|
IcoPath = _iconPath,
|
||||||
};
|
};
|
||||||
@@ -170,7 +175,7 @@ namespace Community.PowerToys.Run.Plugin.WebSearch
|
|||||||
|
|
||||||
onPluginError = () =>
|
onPluginError = () =>
|
||||||
{
|
{
|
||||||
string errorMsgString = string.Format(CultureInfo.CurrentCulture, Properties.Resources.plugin_search_failed, BrowserInfo.Name ?? BrowserInfo.MSEdgeName);
|
string errorMsgString = string.Format(CultureInfo.CurrentCulture, PluginSearchFailed, BrowserInfo.Name ?? BrowserInfo.MSEdgeName);
|
||||||
|
|
||||||
Log.Error(errorMsgString, this.GetType());
|
Log.Error(errorMsgString, this.GetType());
|
||||||
_context.API.ShowMsg(
|
_context.API.ShowMsg(
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace Microsoft.Plugin.Folder.UnitTests
|
|||||||
[TestClass]
|
[TestClass]
|
||||||
public class DriveOrSharedFolderTests
|
public class DriveOrSharedFolderTests
|
||||||
{
|
{
|
||||||
|
private static readonly string[] DriverNames = new[] { "c:", "d:" };
|
||||||
|
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow(@"\\test-server\testdir", true)]
|
[DataRow(@"\\test-server\testdir", true)]
|
||||||
[DataRow(@"c:", true)]
|
[DataRow(@"c:", true)]
|
||||||
@@ -33,7 +35,7 @@ namespace Microsoft.Plugin.Folder.UnitTests
|
|||||||
var driveInformationMock = new Mock<IDriveInformation>();
|
var driveInformationMock = new Mock<IDriveInformation>();
|
||||||
|
|
||||||
driveInformationMock.Setup(r => r.GetDriveNames())
|
driveInformationMock.Setup(r => r.GetDriveNames())
|
||||||
.Returns(() => new[] { "c:", "d:" });
|
.Returns(() => DriverNames);
|
||||||
|
|
||||||
var folderLinksMock = new Mock<IFolderLinks>();
|
var folderLinksMock = new Mock<IFolderLinks>();
|
||||||
var folderHelper = new FolderHelper(driveInformationMock.Object, folderLinksMock.Object);
|
var folderHelper = new FolderHelper(driveInformationMock.Object, folderLinksMock.Object);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Microsoft.Plugin.Folder.UnitTests
|
|||||||
[TestClass]
|
[TestClass]
|
||||||
public class QueryEnvironmentVariableTests
|
public class QueryEnvironmentVariableTests
|
||||||
{
|
{
|
||||||
private static IQueryEnvironmentVariable _queryEnvironmentVariable;
|
private static QueryEnvironmentVariable _queryEnvironmentVariable;
|
||||||
private static MockFileSystem _fileSystem;
|
private static MockFileSystem _fileSystem;
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace Microsoft.Plugin.Folder
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static PluginInitContext _context;
|
private static PluginInitContext _context;
|
||||||
private IContextMenu _contextMenuLoader;
|
private ContextMenuLoader _contextMenuLoader;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public string Name => Properties.Resources.wox_plugin_folder_plugin_name;
|
public string Name => Properties.Resources.wox_plugin_folder_plugin_name;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace Microsoft.Plugin.Folder.Sources
|
|||||||
{
|
{
|
||||||
// folder exist, add \ at the end of doesn't exist
|
// folder exist, add \ at the end of doesn't exist
|
||||||
// Using Ordinal since this is internal and is used for a symbol
|
// Using Ordinal since this is internal and is used for a symbol
|
||||||
if (!search.EndsWith(@"\", StringComparison.Ordinal))
|
if (!search.EndsWith('\\'))
|
||||||
{
|
{
|
||||||
search += @"\";
|
search += @"\";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
namespace Microsoft.Plugin.Folder.Sources.Result
|
namespace Microsoft.Plugin.Folder.Sources.Result
|
||||||
@@ -12,6 +13,8 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
|||||||
{
|
{
|
||||||
private readonly IShellAction _shellAction;
|
private readonly IShellAction _shellAction;
|
||||||
|
|
||||||
|
private static readonly CompositeFormat WoxPluginFolderSelectFolderFirstResultTitle = System.Text.CompositeFormat.Parse(Properties.Resources.wox_plugin_folder_select_folder_first_result_title);
|
||||||
|
|
||||||
public string Search { get; set; }
|
public string Search { get; set; }
|
||||||
|
|
||||||
public CreateOpenCurrentFolderResult(string search)
|
public CreateOpenCurrentFolderResult(string search)
|
||||||
@@ -29,10 +32,10 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
|||||||
{
|
{
|
||||||
return new Wox.Plugin.Result
|
return new Wox.Plugin.Result
|
||||||
{
|
{
|
||||||
Title = string.Format(CultureInfo.InvariantCulture, Properties.Resources.wox_plugin_folder_select_folder_first_result_title, new DirectoryInfo(Search).Name),
|
Title = string.Format(CultureInfo.InvariantCulture, WoxPluginFolderSelectFolderFirstResultTitle, new DirectoryInfo(Search).Name),
|
||||||
QueryTextDisplay = Search,
|
QueryTextDisplay = Search,
|
||||||
SubTitle = Properties.Resources.wox_plugin_folder_select_folder_first_result_subtitle,
|
SubTitle = Properties.Resources.wox_plugin_folder_select_folder_first_result_subtitle,
|
||||||
ToolTipData = new ToolTipData(string.Format(CultureInfo.InvariantCulture, Properties.Resources.wox_plugin_folder_select_folder_first_result_title, new DirectoryInfo(Search).Name), Properties.Resources.wox_plugin_folder_select_folder_first_result_subtitle),
|
ToolTipData = new ToolTipData(string.Format(CultureInfo.InvariantCulture, WoxPluginFolderSelectFolderFirstResultTitle, new DirectoryInfo(Search).Name), Properties.Resources.wox_plugin_folder_select_folder_first_result_subtitle),
|
||||||
IcoPath = Search,
|
IcoPath = Search,
|
||||||
Score = 500,
|
Score = 500,
|
||||||
Action = c => _shellAction.ExecuteSanitized(Search, contextApi),
|
Action = c => _shellAction.ExecuteSanitized(Search, contextApi),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
@@ -10,7 +11,9 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
|||||||
{
|
{
|
||||||
public class EnvironmentVariableResult : IItemResult
|
public class EnvironmentVariableResult : IItemResult
|
||||||
{
|
{
|
||||||
private readonly IShellAction _shellAction = new ShellAction();
|
private readonly ShellAction _shellAction = new ShellAction();
|
||||||
|
|
||||||
|
private static readonly CompositeFormat WoxPluginFolderSelectFolderResultSubtitle = System.Text.CompositeFormat.Parse(Properties.Resources.wox_plugin_folder_select_folder_result_subtitle);
|
||||||
|
|
||||||
public string Search { get; set; }
|
public string Search { get; set; }
|
||||||
|
|
||||||
@@ -35,8 +38,8 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
|||||||
IcoPath = Path,
|
IcoPath = Path,
|
||||||
|
|
||||||
// Using CurrentCulture since this is user facing
|
// Using CurrentCulture since this is user facing
|
||||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Path),
|
SubTitle = string.Format(CultureInfo.CurrentCulture, WoxPluginFolderSelectFolderResultSubtitle, Path),
|
||||||
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Path)),
|
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, WoxPluginFolderSelectFolderResultSubtitle, Path)),
|
||||||
QueryTextDisplay = Path,
|
QueryTextDisplay = Path,
|
||||||
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
|
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
|
||||||
Action = c => _shellAction.Execute(Path, contextApi),
|
Action = c => _shellAction.Execute(Path, contextApi),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO.Abstractions;
|
using System.IO.Abstractions;
|
||||||
|
using System.Text;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
@@ -11,7 +12,9 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
|||||||
{
|
{
|
||||||
public class FileItemResult : IItemResult
|
public class FileItemResult : IItemResult
|
||||||
{
|
{
|
||||||
private static readonly IShellAction ShellAction = new ShellAction();
|
private static readonly ShellAction ShellAction = new ShellAction();
|
||||||
|
|
||||||
|
private static readonly CompositeFormat WoxPluginFolderSelectFileResultSubtitle = System.Text.CompositeFormat.Parse(Properties.Resources.wox_plugin_folder_select_file_result_subtitle);
|
||||||
|
|
||||||
private readonly IPath _path;
|
private readonly IPath _path;
|
||||||
|
|
||||||
@@ -38,8 +41,8 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
|||||||
Title = Title,
|
Title = Title,
|
||||||
|
|
||||||
// Using CurrentCulture since this is user facing
|
// Using CurrentCulture since this is user facing
|
||||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_file_result_subtitle, FilePath),
|
SubTitle = string.Format(CultureInfo.CurrentCulture, WoxPluginFolderSelectFileResultSubtitle, FilePath),
|
||||||
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_file_result_subtitle, FilePath)),
|
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, WoxPluginFolderSelectFileResultSubtitle, FilePath)),
|
||||||
IcoPath = FilePath,
|
IcoPath = FilePath,
|
||||||
Action = c => ShellAction.Execute(FilePath, contextApi),
|
Action = c => ShellAction.Execute(FilePath, contextApi),
|
||||||
ContextData = new SearchResult { Type = ResultType.File, Path = FilePath },
|
ContextData = new SearchResult { Type = ResultType.File, Path = FilePath },
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
@@ -10,7 +11,9 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
|||||||
{
|
{
|
||||||
public class FolderItemResult : IItemResult
|
public class FolderItemResult : IItemResult
|
||||||
{
|
{
|
||||||
private static readonly IShellAction ShellAction = new ShellAction();
|
private static readonly ShellAction ShellAction = new ShellAction();
|
||||||
|
|
||||||
|
private static readonly CompositeFormat WoxPluginFolderSelectFolderResultSubtitle = System.Text.CompositeFormat.Parse(Properties.Resources.wox_plugin_folder_select_folder_result_subtitle);
|
||||||
|
|
||||||
public FolderItemResult()
|
public FolderItemResult()
|
||||||
{
|
{
|
||||||
@@ -39,8 +42,8 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
|||||||
IcoPath = Path,
|
IcoPath = Path,
|
||||||
|
|
||||||
// Using CurrentCulture since this is user facing
|
// Using CurrentCulture since this is user facing
|
||||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Subtitle),
|
SubTitle = string.Format(CultureInfo.CurrentCulture, WoxPluginFolderSelectFolderResultSubtitle, Subtitle),
|
||||||
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Subtitle)),
|
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, WoxPluginFolderSelectFolderResultSubtitle, Subtitle)),
|
||||||
QueryTextDisplay = Path,
|
QueryTextDisplay = Path,
|
||||||
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
|
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
|
||||||
Action = c => ShellAction.Execute(Path, contextApi),
|
Action = c => ShellAction.Execute(Path, contextApi),
|
||||||
|
|||||||
@@ -3,12 +3,15 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
namespace Microsoft.Plugin.Folder.Sources.Result
|
namespace Microsoft.Plugin.Folder.Sources.Result
|
||||||
{
|
{
|
||||||
public class TruncatedItemResult : IItemResult
|
public class TruncatedItemResult : IItemResult
|
||||||
{
|
{
|
||||||
|
private static readonly CompositeFormat MicrosoftPluginFolderTruncationWarningSubtitle = System.Text.CompositeFormat.Parse(Properties.Resources.Microsoft_plugin_folder_truncation_warning_subtitle);
|
||||||
|
|
||||||
public int PreTruncationCount { get; set; }
|
public int PreTruncationCount { get; set; }
|
||||||
|
|
||||||
public int PostTruncationCount { get; set; }
|
public int PostTruncationCount { get; set; }
|
||||||
@@ -25,8 +28,8 @@ namespace Microsoft.Plugin.Folder.Sources.Result
|
|||||||
QueryTextDisplay = Search,
|
QueryTextDisplay = Search,
|
||||||
|
|
||||||
// Using CurrentCulture since this is user facing
|
// Using CurrentCulture since this is user facing
|
||||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.Microsoft_plugin_folder_truncation_warning_subtitle, PostTruncationCount, PreTruncationCount),
|
SubTitle = string.Format(CultureInfo.CurrentCulture, MicrosoftPluginFolderTruncationWarningSubtitle, PostTruncationCount, PreTruncationCount),
|
||||||
ToolTipData = new ToolTipData(Properties.Resources.Microsoft_plugin_folder_truncation_warning_title, string.Format(CultureInfo.CurrentCulture, Properties.Resources.Microsoft_plugin_folder_truncation_warning_subtitle, PostTruncationCount, PreTruncationCount)),
|
ToolTipData = new ToolTipData(Properties.Resources.Microsoft_plugin_folder_truncation_warning_title, string.Format(CultureInfo.CurrentCulture, MicrosoftPluginFolderTruncationWarningSubtitle, PostTruncationCount, PreTruncationCount)),
|
||||||
IcoPath = WarningIconPath,
|
IcoPath = WarningIconPath,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace Microsoft.Plugin.Folder.Sources
|
|||||||
|
|
||||||
// A network path must start with \\
|
// A network path must start with \\
|
||||||
// Using Ordinal since this is internal and used with a symbol
|
// Using Ordinal since this is internal and used with a symbol
|
||||||
if (!sanitizedPath.StartsWith("\\", StringComparison.Ordinal))
|
if (!sanitizedPath.StartsWith('\\'))
|
||||||
{
|
{
|
||||||
return sanitizedPath;
|
return sanitizedPath;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace Microsoft.Plugin.Folder
|
|||||||
.Select(item => CreateFolderResult(item.Nickname, item.Path, item.Path, search));
|
.Select(item => CreateFolderResult(item.Nickname, item.Path, item.Path, search));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IItemResult CreateFolderResult(string title, string subtitle, string path, string search)
|
private static UserFolderResult CreateFolderResult(string title, string subtitle, string path, string search)
|
||||||
{
|
{
|
||||||
return new UserFolderResult
|
return new UserFolderResult
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
using Microsoft.Plugin.Folder.Sources;
|
using Microsoft.Plugin.Folder.Sources;
|
||||||
using Microsoft.Plugin.Folder.Sources.Result;
|
using Microsoft.Plugin.Folder.Sources.Result;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
@@ -12,7 +13,7 @@ namespace Microsoft.Plugin.Folder
|
|||||||
{
|
{
|
||||||
public class UserFolderResult : IItemResult
|
public class UserFolderResult : IItemResult
|
||||||
{
|
{
|
||||||
private readonly IShellAction _shellAction = new ShellAction();
|
private readonly ShellAction _shellAction = new ShellAction();
|
||||||
|
|
||||||
public string Search { get; set; }
|
public string Search { get; set; }
|
||||||
|
|
||||||
@@ -22,6 +23,8 @@ namespace Microsoft.Plugin.Folder
|
|||||||
|
|
||||||
public string Subtitle { get; set; }
|
public string Subtitle { get; set; }
|
||||||
|
|
||||||
|
private static readonly CompositeFormat WoxPluginFolderSelectFolderResultSubtitle = System.Text.CompositeFormat.Parse(Properties.Resources.wox_plugin_folder_select_folder_result_subtitle);
|
||||||
|
|
||||||
public Result Create(IPublicAPI contextApi)
|
public Result Create(IPublicAPI contextApi)
|
||||||
{
|
{
|
||||||
return new Result(StringMatcher.FuzzySearch(Search, Title).MatchData)
|
return new Result(StringMatcher.FuzzySearch(Search, Title).MatchData)
|
||||||
@@ -30,7 +33,7 @@ namespace Microsoft.Plugin.Folder
|
|||||||
IcoPath = Path,
|
IcoPath = Path,
|
||||||
|
|
||||||
// Using CurrentCulture since this is user facing
|
// Using CurrentCulture since this is user facing
|
||||||
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Subtitle),
|
SubTitle = string.Format(CultureInfo.CurrentCulture, WoxPluginFolderSelectFolderResultSubtitle, Subtitle),
|
||||||
QueryTextDisplay = Path,
|
QueryTextDisplay = Path,
|
||||||
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
|
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
|
||||||
Action = c => _shellAction.Execute(Path, contextApi),
|
Action = c => _shellAction.Execute(Path, contextApi),
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace Microsoft.Plugin.Indexer
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
private IContextMenu _contextMenuLoader;
|
private ContextMenuLoader _contextMenuLoader;
|
||||||
private bool disposedValue;
|
private bool disposedValue;
|
||||||
|
|
||||||
// To save the configurations of plugins
|
// To save the configurations of plugins
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var itemName = "originalItem1";
|
var itemName = "originalItem1";
|
||||||
IRepository<string> repository = new ListRepository<string>() { itemName };
|
ListRepository<string> repository = new ListRepository<string>() { itemName };
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = repository.Contains(itemName);
|
var result = repository.Contains(itemName);
|
||||||
@@ -29,7 +29,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
public void ContainsShouldReturnTrueWhenListIsUpdatedWithAdd()
|
public void ContainsShouldReturnTrueWhenListIsUpdatedWithAdd()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
IRepository<string> repository = new ListRepository<string>();
|
ListRepository<string> repository = new ListRepository<string>();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var itemName = "newItem";
|
var itemName = "newItem";
|
||||||
@@ -45,7 +45,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var itemName = "originalItem1";
|
var itemName = "originalItem1";
|
||||||
IRepository<string> repository = new ListRepository<string>() { itemName };
|
ListRepository<string> repository = new ListRepository<string>() { itemName };
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
repository.Remove(itemName);
|
repository.Remove(itemName);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
|
|
||||||
private List<IFileSystemWatcherWrapper> _fileSystemWatchers;
|
private List<IFileSystemWatcherWrapper> _fileSystemWatchers;
|
||||||
private List<Mock<IFileSystemWatcherWrapper>> _fileSystemMocks;
|
private List<Mock<IFileSystemWatcherWrapper>> _fileSystemMocks;
|
||||||
|
private static readonly string[] Path = new string[] { "URL=steam://rungameid/1258080", "IconFile=iconFile" };
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void SetFileSystemWatchers()
|
public void SetFileSystemWatchers()
|
||||||
@@ -219,7 +220,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
|
|
||||||
// File.ReadAllLines must be mocked for url applications
|
// File.ReadAllLines must be mocked for url applications
|
||||||
var mockFile = new Mock<IFile>();
|
var mockFile = new Mock<IFile>();
|
||||||
mockFile.Setup(m => m.ReadAllLines(It.IsAny<string>())).Returns(new string[] { "URL=steam://rungameid/1258080", "IconFile=iconFile" });
|
mockFile.Setup(m => m.ReadAllLines(It.IsAny<string>())).Returns(Path);
|
||||||
Win32Program.FileWrapper = mockFile.Object;
|
Win32Program.FileWrapper = mockFile.Object;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -268,7 +269,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
|
|
||||||
// File.ReadAllLines must be mocked for url applications
|
// File.ReadAllLines must be mocked for url applications
|
||||||
var mockFile = new Mock<IFile>();
|
var mockFile = new Mock<IFile>();
|
||||||
mockFile.Setup(m => m.ReadLines(It.IsAny<string>())).Returns(new string[] { "URL=steam://rungameid/1258080", "IconFile=iconFile" });
|
mockFile.Setup(m => m.ReadLines(It.IsAny<string>())).Returns(Path);
|
||||||
Win32Program.FileWrapper = mockFile.Object;
|
Win32Program.FileWrapper = mockFile.Object;
|
||||||
|
|
||||||
string fullPath = directory + "\\" + path;
|
string fullPath = directory + "\\" + path;
|
||||||
@@ -292,7 +293,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
|||||||
|
|
||||||
// File.ReadAllLines must be mocked for url applications
|
// File.ReadAllLines must be mocked for url applications
|
||||||
var mockFile = new Mock<IFile>();
|
var mockFile = new Mock<IFile>();
|
||||||
mockFile.Setup(m => m.ReadLines(It.IsAny<string>())).Returns(new string[] { "URL=steam://rungameid/1258080", "IconFile=iconFile" });
|
mockFile.Setup(m => m.ReadLines(It.IsAny<string>())).Returns(Path);
|
||||||
Win32Program.FileWrapper = mockFile.Object;
|
Win32Program.FileWrapper = mockFile.Object;
|
||||||
|
|
||||||
string oldFullPath = directory + "\\" + oldpath;
|
string oldFullPath = directory + "\\" + oldpath;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace Microsoft.Plugin.Program
|
|||||||
.Where(r => r?.Score > 0)
|
.Where(r => r?.Score > 0)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
if (result.Any())
|
if (result.Length != 0)
|
||||||
{
|
{
|
||||||
var maxScore = result.Max(x => x.Score);
|
var maxScore = result.Max(x => x.Score);
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
{
|
{
|
||||||
parsed = prefix + key;
|
parsed = prefix + key;
|
||||||
}
|
}
|
||||||
else if (key.StartsWith("/", StringComparison.Ordinal))
|
else if (key.StartsWith('/'))
|
||||||
{
|
{
|
||||||
parsed = prefix + "//" + key;
|
parsed = prefix + "//" + key;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -761,7 +761,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
.ToList() ?? Enumerable.Empty<string>();
|
.ToList() ?? Enumerable.Empty<string>();
|
||||||
|
|
||||||
// Function to obtain the list of applications, the locations of which have been added to the env variable PATH
|
// Function to obtain the list of applications, the locations of which have been added to the env variable PATH
|
||||||
private static IEnumerable<string> PathEnvironmentProgramPaths(IList<string> suffixes)
|
private static List<string> PathEnvironmentProgramPaths(IList<string> suffixes)
|
||||||
{
|
{
|
||||||
// To get all the locations stored in the PATH env variable
|
// To get all the locations stored in the PATH env variable
|
||||||
var pathEnvVariable = Environment.GetEnvironmentVariable("PATH");
|
var pathEnvVariable = Environment.GetEnvironmentVariable("PATH");
|
||||||
@@ -788,7 +788,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
.SelectMany(indexLocation => ProgramPaths(indexLocation, suffixes))
|
.SelectMany(indexLocation => ProgramPaths(indexLocation, suffixes))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
private static IEnumerable<string> StartMenuProgramPaths(IList<string> suffixes)
|
private static List<string> StartMenuProgramPaths(IList<string> suffixes)
|
||||||
{
|
{
|
||||||
var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
|
var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
|
||||||
var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu);
|
var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu);
|
||||||
@@ -797,7 +797,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
return IndexPath(suffixes, indexLocation);
|
return IndexPath(suffixes, indexLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<string> DesktopProgramPaths(IList<string> suffixes)
|
private static List<string> DesktopProgramPaths(IList<string> suffixes)
|
||||||
{
|
{
|
||||||
var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||||
var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
|
var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
|
||||||
@@ -807,7 +807,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
return IndexPath(suffixes, indexLocation);
|
return IndexPath(suffixes, indexLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<string> RegistryAppProgramPaths(IList<string> suffixes)
|
private static List<string> RegistryAppProgramPaths(IList<string> suffixes)
|
||||||
{
|
{
|
||||||
// https://msdn.microsoft.com/library/windows/desktop/ee872121
|
// https://msdn.microsoft.com/library/windows/desktop/ee872121
|
||||||
const string appPaths = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths";
|
const string appPaths = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths";
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using System.IO;
|
|||||||
using System.IO.Abstractions;
|
using System.IO.Abstractions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
using Microsoft.Plugin.Shell.Properties;
|
using Microsoft.Plugin.Shell.Properties;
|
||||||
@@ -33,6 +34,8 @@ namespace Microsoft.Plugin.Shell
|
|||||||
private readonly ShellPluginSettings _settings;
|
private readonly ShellPluginSettings _settings;
|
||||||
private readonly PluginJsonStorage<ShellPluginSettings> _storage;
|
private readonly PluginJsonStorage<ShellPluginSettings> _storage;
|
||||||
|
|
||||||
|
private static readonly CompositeFormat WoxPluginCmdCmdHasBeenExecutedTimes = System.Text.CompositeFormat.Parse(Properties.Resources.wox_plugin_cmd_cmd_has_been_executed_times);
|
||||||
|
|
||||||
private string IconPath { get; set; }
|
private string IconPath { get; set; }
|
||||||
|
|
||||||
public string Name => Properties.Resources.wox_plugin_cmd_plugin_name;
|
public string Name => Properties.Resources.wox_plugin_cmd_plugin_name;
|
||||||
@@ -71,6 +74,7 @@ namespace Microsoft.Plugin.Shell
|
|||||||
};
|
};
|
||||||
|
|
||||||
private PluginInitContext _context;
|
private PluginInitContext _context;
|
||||||
|
private static readonly char[] Separator = new[] { ' ' };
|
||||||
|
|
||||||
public Main()
|
public Main()
|
||||||
{
|
{
|
||||||
@@ -123,7 +127,7 @@ namespace Microsoft.Plugin.Shell
|
|||||||
if (m.Key == cmd)
|
if (m.Key == cmd)
|
||||||
{
|
{
|
||||||
// Using CurrentCulture since this is user facing
|
// Using CurrentCulture since this is user facing
|
||||||
result.SubTitle = Properties.Resources.wox_plugin_cmd_plugin_name + ": " + string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_cmd_cmd_has_been_executed_times, m.Value);
|
result.SubTitle = Properties.Resources.wox_plugin_cmd_plugin_name + ": " + string.Format(CultureInfo.CurrentCulture, WoxPluginCmdCmdHasBeenExecutedTimes, m.Value);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +136,7 @@ namespace Microsoft.Plugin.Shell
|
|||||||
Title = m.Key,
|
Title = m.Key,
|
||||||
|
|
||||||
// Using CurrentCulture since this is user facing
|
// Using CurrentCulture since this is user facing
|
||||||
SubTitle = Properties.Resources.wox_plugin_cmd_plugin_name + ": " + string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_cmd_cmd_has_been_executed_times, m.Value),
|
SubTitle = Properties.Resources.wox_plugin_cmd_plugin_name + ": " + string.Format(CultureInfo.CurrentCulture, WoxPluginCmdCmdHasBeenExecutedTimes, m.Value),
|
||||||
IcoPath = IconPath,
|
IcoPath = IconPath,
|
||||||
Action = c =>
|
Action = c =>
|
||||||
{
|
{
|
||||||
@@ -171,7 +175,7 @@ namespace Microsoft.Plugin.Shell
|
|||||||
Title = m.Key,
|
Title = m.Key,
|
||||||
|
|
||||||
// Using CurrentCulture since this is user facing
|
// Using CurrentCulture since this is user facing
|
||||||
SubTitle = Properties.Resources.wox_plugin_cmd_plugin_name + ": " + string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_cmd_cmd_has_been_executed_times, m.Value),
|
SubTitle = Properties.Resources.wox_plugin_cmd_plugin_name + ": " + string.Format(CultureInfo.CurrentCulture, WoxPluginCmdCmdHasBeenExecutedTimes, m.Value),
|
||||||
IcoPath = IconPath,
|
IcoPath = IconPath,
|
||||||
Action = c =>
|
Action = c =>
|
||||||
{
|
{
|
||||||
@@ -285,7 +289,7 @@ namespace Microsoft.Plugin.Shell
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var parts = command.Split(new[] { ' ' }, 2);
|
var parts = command.Split(Separator, 2);
|
||||||
if (parts.Length == 2)
|
if (parts.Length == 2)
|
||||||
{
|
{
|
||||||
var filename = parts[0];
|
var filename = parts[0];
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ namespace Microsoft.Plugin.Shell
|
|||||||
|
|
||||||
public void AddCmdHistory(string cmdName)
|
public void AddCmdHistory(string cmdName)
|
||||||
{
|
{
|
||||||
if (Count.ContainsKey(cmdName))
|
if (Count.TryGetValue(cmdName, out int currentCount))
|
||||||
{
|
{
|
||||||
Count[cmdName] += 1;
|
Count[cmdName] = currentCount + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Count.Add(cmdName, 1);
|
Count[cmdName] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
|||||||
|
|
||||||
// Hide menu if Explorer.exe is the shell process or the process name is ApplicationFrameHost.exe
|
// Hide menu if Explorer.exe is the shell process or the process name is ApplicationFrameHost.exe
|
||||||
// In the first case we would crash the windows ui and in the second case we would kill the generic process for uwp apps.
|
// In the first case we would crash the windows ui and in the second case we would kill the generic process for uwp apps.
|
||||||
if (!windowData.Process.IsShellProcess && !(windowData.Process.IsUwpApp & windowData.Process.Name.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "applicationframehost.exe")
|
if (!windowData.Process.IsShellProcess && !(windowData.Process.IsUwpApp && string.Equals(windowData.Process.Name, "ApplicationFrameHost.exe", StringComparison.OrdinalIgnoreCase))
|
||||||
&& !(windowData.Process.IsFullAccessDenied & WindowWalkerSettings.Instance.HideKillProcessOnElevatedProcesses))
|
&& !(windowData.Process.IsFullAccessDenied && WindowWalkerSettings.Instance.HideKillProcessOnElevatedProcesses))
|
||||||
{
|
{
|
||||||
contextMenu.Add(new ContextMenuResult
|
contextMenu.Add(new ContextMenuResult
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) Microsoft Corporation
|
// Copyright (c) Microsoft Corporation
|
||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.Plugin.WindowWalker.Properties;
|
using Microsoft.Plugin.WindowWalker.Properties;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
@@ -26,7 +27,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
|||||||
|
|
||||||
foreach (SearchResult x in searchControllerResults)
|
foreach (SearchResult x in searchControllerResults)
|
||||||
{
|
{
|
||||||
if (x.Result.Process.Name.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "explorer.exe" && x.Result.Process.IsShellProcess)
|
if (string.Equals(x.Result.Process.Name, "explorer.exe", StringComparison.OrdinalIgnoreCase) && x.Result.Process.IsShellProcess)
|
||||||
{
|
{
|
||||||
addExplorerInfo = true;
|
addExplorerInfo = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
|||||||
|
|
||||||
// Correct the process data if the window belongs to a uwp app hosted by 'ApplicationFrameHost.exe'
|
// Correct the process data if the window belongs to a uwp app hosted by 'ApplicationFrameHost.exe'
|
||||||
// (This only works if the window isn't minimized. For minimized windows the required child window isn't assigned.)
|
// (This only works if the window isn't minimized. For minimized windows the required child window isn't assigned.)
|
||||||
if (_handlesToProcessCache[hWindow].Name.ToUpperInvariant() == "APPLICATIONFRAMEHOST.EXE")
|
if (string.Equals(_handlesToProcessCache[hWindow].Name, "ApplicationFrameHost.exe", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
new Task(() =>
|
new Task(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
|||||||
internal WindowProcess(uint pid, uint tid, string name)
|
internal WindowProcess(uint pid, uint tid, string name)
|
||||||
{
|
{
|
||||||
UpdateProcessInfo(pid, tid, name);
|
UpdateProcessInfo(pid, tid, name);
|
||||||
_isUwpApp = Name.ToUpperInvariant().Equals("APPLICATIONFRAMEHOST.EXE", StringComparison.Ordinal);
|
_isUwpApp = string.Equals(Name, "ApplicationFrameHost.exe", StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
|||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException(nameof(direction), direction, "Can't process value");
|
throw new ArgumentOutOfRangeException($"Can't process value (Parameter direction: {direction})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !trailTest.Any();
|
return trailTest.Count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (TrailDirection Direction, TrailType Type) BracketTrail(char @char)
|
private static (TrailDirection Direction, TrailType Type) BracketTrail(char @char)
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
|||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
|
private static readonly CompositeFormat WoxPluginCalculatorInEnFormatDescription = System.Text.CompositeFormat.Parse(Properties.Resources.wox_plugin_calculator_in_en_format_description);
|
||||||
|
private static readonly CompositeFormat WoxPluginCalculatorOutEnFormatDescription = System.Text.CompositeFormat.Parse(Properties.Resources.wox_plugin_calculator_out_en_format_description);
|
||||||
|
|
||||||
public IEnumerable<PluginAdditionalOption> AdditionalOptions => new List<PluginAdditionalOption>()
|
public IEnumerable<PluginAdditionalOption> AdditionalOptions => new List<PluginAdditionalOption>()
|
||||||
{
|
{
|
||||||
// The number examples has to be created at runtime to prevent translation.
|
// The number examples has to be created at runtime to prevent translation.
|
||||||
@@ -41,14 +44,14 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
|||||||
{
|
{
|
||||||
Key = "InputUseEnglishFormat",
|
Key = "InputUseEnglishFormat",
|
||||||
DisplayLabel = Resources.wox_plugin_calculator_in_en_format,
|
DisplayLabel = Resources.wox_plugin_calculator_in_en_format,
|
||||||
DisplayDescription = string.Format(CultureInfo.CurrentCulture, Resources.wox_plugin_calculator_in_en_format_description, 1000.55.ToString("N2", new CultureInfo("en-us"))),
|
DisplayDescription = string.Format(CultureInfo.CurrentCulture, WoxPluginCalculatorInEnFormatDescription, 1000.55.ToString("N2", new CultureInfo("en-us"))),
|
||||||
Value = false,
|
Value = false,
|
||||||
},
|
},
|
||||||
new PluginAdditionalOption()
|
new PluginAdditionalOption()
|
||||||
{
|
{
|
||||||
Key = "OutputUseEnglishFormat",
|
Key = "OutputUseEnglishFormat",
|
||||||
DisplayLabel = Resources.wox_plugin_calculator_out_en_format,
|
DisplayLabel = Resources.wox_plugin_calculator_out_en_format,
|
||||||
DisplayDescription = string.Format(CultureInfo.CurrentCulture, Resources.wox_plugin_calculator_out_en_format_description, 1000.55.ToString("G", new CultureInfo("en-us"))),
|
DisplayDescription = string.Format(CultureInfo.CurrentCulture, WoxPluginCalculatorOutEnFormatDescription, 1000.55.ToString("G", new CultureInfo("en-us"))),
|
||||||
Value = false,
|
Value = false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Registry.Helper
|
|||||||
/// <param name="parentKey">The parent-key, also the root to start the search</param>
|
/// <param name="parentKey">The parent-key, also the root to start the search</param>
|
||||||
/// <param name="searchSubKey">The sub-key to find</param>
|
/// <param name="searchSubKey">The sub-key to find</param>
|
||||||
/// <returns>A list with all found registry sub-keys</returns>
|
/// <returns>A list with all found registry sub-keys</returns>
|
||||||
private static ICollection<RegistryEntry> FindSubKey(in RegistryKey parentKey, in string searchSubKey)
|
private static Collection<RegistryEntry> FindSubKey(in RegistryKey parentKey, in string searchSubKey)
|
||||||
{
|
{
|
||||||
var list = new Collection<RegistryEntry>();
|
var list = new Collection<RegistryEntry>();
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Registry.Helper
|
|||||||
/// <param name="parentKey">The registry parent-key</param>
|
/// <param name="parentKey">The registry parent-key</param>
|
||||||
/// <param name="maxCount">(optional) The maximum count of the results</param>
|
/// <param name="maxCount">(optional) The maximum count of the results</param>
|
||||||
/// <returns>A list with all found registry sub-keys</returns>
|
/// <returns>A list with all found registry sub-keys</returns>
|
||||||
private static ICollection<RegistryEntry> GetAllSubKeys(in RegistryKey parentKey, in int maxCount = 50)
|
private static Collection<RegistryEntry> GetAllSubKeys(in RegistryKey parentKey, in int maxCount = 50)
|
||||||
{
|
{
|
||||||
var list = new Collection<RegistryEntry>();
|
var list = new Collection<RegistryEntry>();
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Registry.Helper
|
|||||||
return new List<Result>(0);
|
return new List<Result>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ICollection<KeyValuePair<string, object>> valueList = new List<KeyValuePair<string, object>>(key.ValueCount);
|
List<KeyValuePair<string, object>> valueList = new List<KeyValuePair<string, object>>(key.ValueCount);
|
||||||
|
|
||||||
var resultList = new List<Result>();
|
var resultList = new List<Result>();
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using System.Linq;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
using Microsoft.PowerToys.Run.Plugin.System.Properties;
|
using Microsoft.PowerToys.Run.Plugin.System.Properties;
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Run.Plugin.System.Components
|
namespace Microsoft.PowerToys.Run.Plugin.System.Components
|
||||||
@@ -114,6 +115,9 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal IPAddressCollection WinsServers { get; private set; }
|
internal IPAddressCollection WinsServers { get; private set; }
|
||||||
|
|
||||||
|
private static readonly CompositeFormat MicrosoftPluginSysGbps = CompositeFormat.Parse(Properties.Resources.Microsoft_plugin_sys_Gbps);
|
||||||
|
private static readonly CompositeFormat MicrosoftPluginSysMbps = CompositeFormat.Parse(Properties.Resources.Microsoft_plugin_sys_Mbps);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="NetworkConnectionProperties"/> class.
|
/// Initializes a new instance of the <see cref="NetworkConnectionProperties"/> class.
|
||||||
/// This private constructor is used when we crete the list of adapter (properties) by calling <see cref="NetworkConnectionProperties.GetList()"/>.
|
/// This private constructor is used when we crete the list of adapter (properties) by calling <see cref="NetworkConnectionProperties.GetList()"/>.
|
||||||
@@ -286,7 +290,7 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Components
|
|||||||
/// <returns>A formatted string like `100 MB/s`</returns>
|
/// <returns>A formatted string like `100 MB/s`</returns>
|
||||||
private static string GetFormattedSpeedValue(long speed)
|
private static string GetFormattedSpeedValue(long speed)
|
||||||
{
|
{
|
||||||
return (speed >= 1000000000) ? string.Format(CultureInfo.InvariantCulture, Resources.Microsoft_plugin_sys_Gbps, speed / 1000000000) : string.Format(CultureInfo.InvariantCulture, Resources.Microsoft_plugin_sys_Mbps, speed / 1000000);
|
return (speed >= 1000000000) ? string.Format(CultureInfo.InvariantCulture, MicrosoftPluginSysGbps, speed / 1000000000) : string.Format(CultureInfo.InvariantCulture, MicrosoftPluginSysMbps, speed / 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
@@ -27,6 +28,8 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate
|
|||||||
|
|
||||||
public static string PluginID => "5D69806A5A474115821C3E4C56B9C793";
|
public static string PluginID => "5D69806A5A474115821C3E4C56B9C793";
|
||||||
|
|
||||||
|
private static readonly CompositeFormat MicrosoftPluginTimedatePluginDescription = System.Text.CompositeFormat.Parse(Properties.Resources.Microsoft_plugin_timedate_plugin_description);
|
||||||
|
|
||||||
public IEnumerable<PluginAdditionalOption> AdditionalOptions
|
public IEnumerable<PluginAdditionalOption> AdditionalOptions
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -93,7 +96,7 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate
|
|||||||
string timeExample = Resources.Microsoft_plugin_timedate_plugin_description_example_time + "::" + DateTime.Now.ToString("T", CultureInfo.CurrentCulture);
|
string timeExample = Resources.Microsoft_plugin_timedate_plugin_description_example_time + "::" + DateTime.Now.ToString("T", CultureInfo.CurrentCulture);
|
||||||
string dayExample = Resources.Microsoft_plugin_timedate_plugin_description_example_day + "::" + DateTime.Now.ToString("d", CultureInfo.CurrentCulture);
|
string dayExample = Resources.Microsoft_plugin_timedate_plugin_description_example_day + "::" + DateTime.Now.ToString("d", CultureInfo.CurrentCulture);
|
||||||
string calendarWeekExample = Resources.Microsoft_plugin_timedate_plugin_description_example_calendarWeek + "::" + DateTime.Now.ToString("d", CultureInfo.CurrentCulture);
|
string calendarWeekExample = Resources.Microsoft_plugin_timedate_plugin_description_example_calendarWeek + "::" + DateTime.Now.ToString("d", CultureInfo.CurrentCulture);
|
||||||
return string.Format(CultureInfo.CurrentCulture, Resources.Microsoft_plugin_timedate_plugin_description, Resources.Microsoft_plugin_timedate_plugin_description_example_day, dayExample, timeExample, calendarWeekExample);
|
return string.Format(CultureInfo.CurrentCulture, MicrosoftPluginTimedatePluginDescription, Resources.Microsoft_plugin_timedate_plugin_description_example_day, dayExample, timeExample, calendarWeekExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ namespace Microsoft.PowerToys.Run.Plugin.WindowsSettings.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const string _settingsFile = "WindowsSettings.json";
|
private const string _settingsFile = "WindowsSettings.json";
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read all possible Windows settings.
|
/// Read all possible Windows settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -42,7 +46,7 @@ namespace Microsoft.PowerToys.Run.Plugin.WindowsSettings.Helper
|
|||||||
throw new ArgumentNullException(nameof(stream), "stream is null");
|
throw new ArgumentNullException(nameof(stream), "stream is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = new JsonSerializerOptions();
|
var options = _serializerOptions;
|
||||||
options.Converters.Add(new JsonStringEnumConverter());
|
options.Converters.Add(new JsonStringEnumConverter());
|
||||||
|
|
||||||
using var reader = new StreamReader(stream);
|
using var reader = new StreamReader(stream);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace Microsoft.PowerToys.Run.Plugin.WindowsTerminal
|
|||||||
private const string OpenNewTab = nameof(OpenNewTab);
|
private const string OpenNewTab = nameof(OpenNewTab);
|
||||||
private const string OpenQuake = nameof(OpenQuake);
|
private const string OpenQuake = nameof(OpenQuake);
|
||||||
private const string ShowHiddenProfiles = nameof(ShowHiddenProfiles);
|
private const string ShowHiddenProfiles = nameof(ShowHiddenProfiles);
|
||||||
private readonly ITerminalQuery _terminalQuery = new TerminalQuery();
|
private readonly TerminalQuery _terminalQuery = new TerminalQuery();
|
||||||
private PluginInitContext _context;
|
private PluginInitContext _context;
|
||||||
private bool _openNewTab;
|
private bool _openNewTab;
|
||||||
private bool _openQuake;
|
private bool _openQuake;
|
||||||
@@ -199,7 +199,7 @@ namespace Microsoft.PowerToys.Run.Plugin.WindowsTerminal
|
|||||||
_showHiddenProfiles = showHiddenProfiles;
|
_showHiddenProfiles = showHiddenProfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageSource GetLogo(TerminalPackage terminal)
|
private BitmapImage GetLogo(TerminalPackage terminal)
|
||||||
{
|
{
|
||||||
var aumid = terminal.AppUserModelId;
|
var aumid = terminal.AppUserModelId;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace PowerLauncher.Converters
|
|||||||
var highlightData = values[1] as List<int>;
|
var highlightData = values[1] as List<int>;
|
||||||
var selected = values[2] as bool? == true;
|
var selected = values[2] as bool? == true;
|
||||||
|
|
||||||
if (highlightData == null || !highlightData.Any())
|
if (highlightData == null || highlightData.Count == 0)
|
||||||
{
|
{
|
||||||
// No highlight data, just return the text
|
// No highlight data, just return the text
|
||||||
return new Run(text);
|
return new Run(text);
|
||||||
|
|||||||
@@ -92,7 +92,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.
|
/// Gets command line args - for ClickOnce deployed applications, command line args may not be passed directly, they have to be retrieved.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>List of command line arg strings.</returns>
|
/// <returns>List of command line arg strings.</returns>
|
||||||
private static IList<string> GetCommandLineArgs(string uniqueApplicationName)
|
private static List<string> GetCommandLineArgs(string uniqueApplicationName)
|
||||||
{
|
{
|
||||||
string[] args = null;
|
string[] args = null;
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ namespace PowerLauncher.Helper
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (TextReader reader = new StreamReader(cmdLinePath, Encoding.Unicode))
|
using (StreamReader reader = new StreamReader(cmdLinePath, Encoding.Unicode))
|
||||||
{
|
{
|
||||||
args = NativeMethods.CommandLineToArgvW(reader.ReadToEnd());
|
args = NativeMethods.CommandLineToArgvW(reader.ReadToEnd());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using System.Globalization;
|
|||||||
using System.IO.Abstractions;
|
using System.IO.Abstractions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using global::PowerToys.GPOWrapper;
|
using global::PowerToys.GPOWrapper;
|
||||||
@@ -29,6 +30,8 @@ namespace PowerLauncher.Plugin
|
|||||||
private static readonly IDirectory Directory = FileSystem.Directory;
|
private static readonly IDirectory Directory = FileSystem.Directory;
|
||||||
private static readonly object AllPluginsLock = new object();
|
private static readonly object AllPluginsLock = new object();
|
||||||
|
|
||||||
|
private static readonly CompositeFormat FailedToInitializePluginsTitle = System.Text.CompositeFormat.Parse(Properties.Resources.FailedToInitializePluginsTitle);
|
||||||
|
|
||||||
private static IEnumerable<PluginPair> _contextMenuPlugins = new List<PluginPair>();
|
private static IEnumerable<PluginPair> _contextMenuPlugins = new List<PluginPair>();
|
||||||
|
|
||||||
private static List<PluginPair> _allPlugins;
|
private static List<PluginPair> _allPlugins;
|
||||||
@@ -53,7 +56,7 @@ namespace PowerLauncher.Plugin
|
|||||||
if (_allPlugins == null)
|
if (_allPlugins == null)
|
||||||
{
|
{
|
||||||
_allPlugins = PluginConfig.Parse(Directories)
|
_allPlugins = PluginConfig.Parse(Directories)
|
||||||
.Where(x => x.Language.ToUpperInvariant() == AllowedLanguage.CSharp)
|
.Where(x => string.Equals(x.Language, AllowedLanguage.CSharp, StringComparison.OrdinalIgnoreCase))
|
||||||
.GroupBy(x => x.ID) // Deduplicates plugins by ID, choosing for each ID the highest DLL product version. This fixes issues such as https://github.com/microsoft/PowerToys/issues/14701
|
.GroupBy(x => x.ID) // Deduplicates plugins by ID, choosing for each ID the highest DLL product version. This fixes issues such as https://github.com/microsoft/PowerToys/issues/14701
|
||||||
.Select(g => g.OrderByDescending(x => // , where an upgrade didn't remove older versions of the plugins.
|
.Select(g => g.OrderByDescending(x => // , where an upgrade didn't remove older versions of the plugins.
|
||||||
{
|
{
|
||||||
@@ -178,10 +181,10 @@ namespace PowerLauncher.Plugin
|
|||||||
|
|
||||||
_contextMenuPlugins = GetPluginsForInterface<IContextMenu>();
|
_contextMenuPlugins = GetPluginsForInterface<IContextMenu>();
|
||||||
|
|
||||||
if (failedPlugins.Any())
|
if (!failedPlugins.IsEmpty)
|
||||||
{
|
{
|
||||||
var failed = string.Join(",", failedPlugins.Select(x => x.Metadata.Name));
|
var failed = string.Join(",", failedPlugins.Select(x => x.Metadata.Name));
|
||||||
var description = string.Format(CultureInfo.CurrentCulture, Resources.FailedToInitializePluginsDescription, failed);
|
var description = string.Format(CultureInfo.CurrentCulture, FailedToInitializePluginsTitle, failed);
|
||||||
Application.Current.Dispatcher.InvokeAsync(() => API.ShowMsg(Resources.FailedToInitializePluginsTitle, description, string.Empty, false));
|
Application.Current.Dispatcher.InvokeAsync(() => API.ShowMsg(Resources.FailedToInitializePluginsTitle, description, string.Empty, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace PowerLauncher
|
|||||||
// Watch for /Local/Microsoft/PowerToys/Launcher/Settings.json changes
|
// Watch for /Local/Microsoft/PowerToys/Launcher/Settings.json changes
|
||||||
public class SettingsReader : BaseModel
|
public class SettingsReader : BaseModel
|
||||||
{
|
{
|
||||||
private readonly ISettingsUtils _settingsUtils;
|
private readonly SettingsUtils _settingsUtils;
|
||||||
|
|
||||||
private const int MaxRetries = 10;
|
private const int MaxRetries = 10;
|
||||||
private static readonly object _readSyncObject = new object();
|
private static readonly object _readSyncObject = new object();
|
||||||
@@ -286,7 +286,7 @@ namespace PowerLauncher
|
|||||||
settings.Plugins = defaultPlugins.Values.ToList();
|
settings.Plugins = defaultPlugins.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<PluginAdditionalOption> CombineAdditionalOptions(IEnumerable<PluginAdditionalOption> defaultAdditionalOptions, IEnumerable<PluginAdditionalOption> additionalOptions)
|
private static Dictionary<string, PluginAdditionalOption>.ValueCollection CombineAdditionalOptions(IEnumerable<PluginAdditionalOption> defaultAdditionalOptions, IEnumerable<PluginAdditionalOption> additionalOptions)
|
||||||
{
|
{
|
||||||
var defaultOptions = defaultAdditionalOptions.ToDictionary(x => x.Key);
|
var defaultOptions = defaultAdditionalOptions.ToDictionary(x => x.Key);
|
||||||
foreach (var option in additionalOptions)
|
foreach (var option in additionalOptions)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Collections.ObjectModel;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -63,6 +64,8 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
internal HotkeyManager HotkeyManager { get; private set; }
|
internal HotkeyManager HotkeyManager { get; private set; }
|
||||||
|
|
||||||
|
private static readonly CompositeFormat RegisterHotkeyFailed = System.Text.CompositeFormat.Parse(Properties.Resources.registerHotkeyFailed);
|
||||||
|
|
||||||
public MainViewModel(PowerToysRunSettings settings, CancellationToken nativeThreadCancelToken)
|
public MainViewModel(PowerToysRunSettings settings, CancellationToken nativeThreadCancelToken)
|
||||||
{
|
{
|
||||||
_saved = false;
|
_saved = false;
|
||||||
@@ -897,7 +900,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
string errorMsg = string.Format(CultureInfo.InvariantCulture, Properties.Resources.registerHotkeyFailed, hotkeyStr);
|
string errorMsg = string.Format(CultureInfo.InvariantCulture, RegisterHotkeyFailed, hotkeyStr);
|
||||||
MessageBox.Show(errorMsg);
|
MessageBox.Show(errorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace Wox.Infrastructure.Exception
|
|||||||
foreach (string versionKeyName in ndpKey.GetSubKeyNames())
|
foreach (string versionKeyName in ndpKey.GetSubKeyNames())
|
||||||
{
|
{
|
||||||
// Using InvariantCulture since this is internal and involves version key
|
// Using InvariantCulture since this is internal and involves version key
|
||||||
if (versionKeyName.StartsWith("v", StringComparison.InvariantCulture))
|
if (versionKeyName.StartsWith('v'))
|
||||||
{
|
{
|
||||||
RegistryKey versionKey = ndpKey.OpenSubKey(versionKeyName);
|
RegistryKey versionKey = ndpKey.OpenSubKey(versionKeyName);
|
||||||
string name = (string)versionKey.GetValue("Version", string.Empty);
|
string name = (string)versionKey.GetValue("Version", string.Empty);
|
||||||
|
|||||||
@@ -21,6 +21,15 @@ namespace Wox.Infrastructure
|
|||||||
private static readonly IFileInfoFactory FileInfo = FileSystem.FileInfo;
|
private static readonly IFileInfoFactory FileInfo = FileSystem.FileInfo;
|
||||||
private static readonly IDirectory Directory = FileSystem.Directory;
|
private static readonly IDirectory Directory = FileSystem.Directory;
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
Converters =
|
||||||
|
{
|
||||||
|
new JsonStringEnumConverter(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// http://www.yinwang.org/blog-cn/2015/11/21/programming-philosophy
|
/// http://www.yinwang.org/blog-cn/2015/11/21/programming-philosophy
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -81,14 +90,7 @@ namespace Wox.Infrastructure
|
|||||||
|
|
||||||
public static string Formatted<T>(this T t)
|
public static string Formatted<T>(this T t)
|
||||||
{
|
{
|
||||||
var formatted = JsonSerializer.Serialize(t, new JsonSerializerOptions
|
var formatted = JsonSerializer.Serialize(t, _serializerOptions);
|
||||||
{
|
|
||||||
WriteIndented = true,
|
|
||||||
Converters =
|
|
||||||
{
|
|
||||||
new JsonStringEnumConverter(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace Wox.Infrastructure.Image
|
|||||||
private static readonly ImageCache ImageCache = new ImageCache();
|
private static readonly ImageCache ImageCache = new ImageCache();
|
||||||
private static readonly ConcurrentDictionary<string, string> GuidToKey = new ConcurrentDictionary<string, string>();
|
private static readonly ConcurrentDictionary<string, string> GuidToKey = new ConcurrentDictionary<string, string>();
|
||||||
|
|
||||||
private static IImageHashGenerator _hashGenerator;
|
private static ImageHashGenerator _hashGenerator;
|
||||||
|
|
||||||
public static string ErrorIconPath { get; set; } = Constant.LightThemedErrorIcon;
|
public static string ErrorIconPath { get; set; } = Constant.LightThemedErrorIcon;
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace Wox.Infrastructure.Storage
|
|||||||
|
|
||||||
public bool Any()
|
public bool Any()
|
||||||
{
|
{
|
||||||
return _items.Any();
|
return !_items.IsEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(T insertedItem)
|
public void Add(T insertedItem)
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ namespace Wox.Infrastructure
|
|||||||
|
|
||||||
public static StringMatcher Instance { get; internal set; }
|
public static StringMatcher Instance { get; internal set; }
|
||||||
|
|
||||||
|
private static readonly char[] Separator = new[] { ' ' };
|
||||||
|
|
||||||
[Obsolete("This method is obsolete and should not be used. Please use the static function StringMatcher.FuzzySearch")]
|
[Obsolete("This method is obsolete and should not be used. Please use the static function StringMatcher.FuzzySearch")]
|
||||||
public static int Score(string source, string target)
|
public static int Score(string source, string target)
|
||||||
{
|
{
|
||||||
@@ -104,7 +106,7 @@ namespace Wox.Infrastructure
|
|||||||
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToUpper(CultureInfo.InvariantCulture) : stringToCompare;
|
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToUpper(CultureInfo.InvariantCulture) : stringToCompare;
|
||||||
var queryWithoutCase = opt.IgnoreCase ? query.ToUpper(CultureInfo.InvariantCulture) : query;
|
var queryWithoutCase = opt.IgnoreCase ? query.ToUpper(CultureInfo.InvariantCulture) : query;
|
||||||
|
|
||||||
var querySubstrings = queryWithoutCase.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
var querySubstrings = queryWithoutCase.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
int currentQuerySubstringIndex = 0;
|
int currentQuerySubstringIndex = 0;
|
||||||
var currentQuerySubstring = querySubstrings[currentQuerySubstringIndex];
|
var currentQuerySubstring = querySubstrings[currentQuerySubstringIndex];
|
||||||
var currentQuerySubstringCharacterIndex = 0;
|
var currentQuerySubstringCharacterIndex = 0;
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ namespace Wox.Plugin
|
|||||||
ArgumentNullException.ThrowIfNull(language);
|
ArgumentNullException.ThrowIfNull(language);
|
||||||
|
|
||||||
// Using InvariantCulture since this is a command line arg
|
// Using InvariantCulture since this is a command line arg
|
||||||
return language.ToUpper(CultureInfo.InvariantCulture) == CSharp.ToUpper(CultureInfo.InvariantCulture)
|
var upperLanguage = language.ToUpper(CultureInfo.InvariantCulture);
|
||||||
|| language.ToUpper(CultureInfo.InvariantCulture) == Executable.ToUpper(CultureInfo.InvariantCulture);
|
|
||||||
|
return string.Equals(upperLanguage, CSharp.ToUpper(CultureInfo.InvariantCulture), StringComparison.Ordinal)
|
||||||
|
|| string.Equals(upperLanguage, Executable.ToUpper(CultureInfo.InvariantCulture), StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace Wox.Plugin.Common
|
|||||||
if (appName != null)
|
if (appName != null)
|
||||||
{
|
{
|
||||||
// Handle indirect strings:
|
// Handle indirect strings:
|
||||||
if (appName.StartsWith("@", StringComparison.Ordinal))
|
if (appName.StartsWith('@'))
|
||||||
{
|
{
|
||||||
appName = GetIndirectString(appName);
|
appName = GetIndirectString(appName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
using Common.UI;
|
using Common.UI;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Wox.Plugin.Common.VirtualDesktop.Interop;
|
using Wox.Plugin.Common.VirtualDesktop.Interop;
|
||||||
@@ -54,6 +55,8 @@ namespace Wox.Plugin.Common.VirtualDesktop.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private Guid _currentDesktop;
|
private Guid _currentDesktop;
|
||||||
|
|
||||||
|
private static readonly CompositeFormat VirtualDesktopHelperDesktop = System.Text.CompositeFormat.Parse(Properties.Resources.VirtualDesktopHelper_Desktop);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="VirtualDesktopHelper"/> class.
|
/// Initializes a new instance of the <see cref="VirtualDesktopHelper"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -260,7 +263,7 @@ namespace Wox.Plugin.Common.VirtualDesktop.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the desktop name was not changed by the user, it isn't saved to the registry. Then we need the default name for the desktop.
|
// If the desktop name was not changed by the user, it isn't saved to the registry. Then we need the default name for the desktop.
|
||||||
var defaultName = string.Format(System.Globalization.CultureInfo.InvariantCulture, Resources.VirtualDesktopHelper_Desktop, GetDesktopNumber(desktop));
|
var defaultName = string.Format(System.Globalization.CultureInfo.InvariantCulture, VirtualDesktopHelperDesktop, GetDesktopNumber(desktop));
|
||||||
|
|
||||||
string registryPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VirtualDesktops\\Desktops\\{" + desktop.ToString().ToUpper(System.Globalization.CultureInfo.InvariantCulture) + "}";
|
string registryPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VirtualDesktops\\Desktops\\{" + desktop.ToString().ToUpper(System.Globalization.CultureInfo.InvariantCulture) + "}";
|
||||||
using RegistryKey deskSubKey = Registry.CurrentUser.OpenSubKey(registryPath, false);
|
using RegistryKey deskSubKey = Registry.CurrentUser.OpenSubKey(registryPath, false);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Peek.FilePreviewer.Models
|
|||||||
{
|
{
|
||||||
private const int MaxNumberOfRetry = 5;
|
private const int MaxNumberOfRetry = 5;
|
||||||
|
|
||||||
private readonly ISettingsUtils _settingsUtils;
|
private readonly SettingsUtils _settingsUtils;
|
||||||
private readonly IFileSystemWatcher _watcher;
|
private readonly IFileSystemWatcher _watcher;
|
||||||
private readonly object _loadingSettingsLock = new();
|
private readonly object _loadingSettingsLock = new();
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Peek.UI
|
|||||||
private const string PeekModuleName = "Peek";
|
private const string PeekModuleName = "Peek";
|
||||||
private const int MaxNumberOfRetry = 5;
|
private const int MaxNumberOfRetry = 5;
|
||||||
|
|
||||||
private readonly ISettingsUtils _settingsUtils;
|
private readonly SettingsUtils _settingsUtils;
|
||||||
private readonly IFileSystemWatcher _watcher;
|
private readonly IFileSystemWatcher _watcher;
|
||||||
private readonly object _loadingSettingsLock = new object();
|
private readonly object _loadingSettingsLock = new object();
|
||||||
|
|
||||||
|
|||||||
@@ -93,9 +93,9 @@ namespace PowerAccent.Core
|
|||||||
// All
|
// All
|
||||||
private static string[] GetDefaultLetterKeyALL(LetterKey letter)
|
private static string[] GetDefaultLetterKeyALL(LetterKey letter)
|
||||||
{
|
{
|
||||||
if (!_allLanguagesCache.ContainsKey(letter))
|
if (!_allLanguagesCache.TryGetValue(letter, out string[] cachedValue))
|
||||||
{
|
{
|
||||||
_allLanguagesCache[letter] = GetDefaultLetterKeyCA(letter)
|
cachedValue = GetDefaultLetterKeyCA(letter)
|
||||||
.Union(GetDefaultLetterKeyCUR(letter))
|
.Union(GetDefaultLetterKeyCUR(letter))
|
||||||
.Union(GetDefaultLetterKeyCY(letter))
|
.Union(GetDefaultLetterKeyCY(letter))
|
||||||
.Union(GetDefaultLetterKeyCZ(letter))
|
.Union(GetDefaultLetterKeyCZ(letter))
|
||||||
@@ -129,9 +129,11 @@ namespace PowerAccent.Core
|
|||||||
.Union(GetDefaultLetterKeyTK(letter))
|
.Union(GetDefaultLetterKeyTK(letter))
|
||||||
.Union(GetDefaultLetterKeyAllLanguagesOnly(letter))
|
.Union(GetDefaultLetterKeyAllLanguagesOnly(letter))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
_allLanguagesCache[letter] = cachedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _allLanguagesCache[letter];
|
return cachedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains all characters that should be shown in all languages but currently don't belong to any of the single languages available for that letter.
|
// Contains all characters that should be shown in all languages but currently don't belong to any of the single languages available for that letter.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace PowerAccent.Core.Services;
|
|||||||
public class SettingsService
|
public class SettingsService
|
||||||
{
|
{
|
||||||
private const string PowerAccentModuleName = "QuickAccent";
|
private const string PowerAccentModuleName = "QuickAccent";
|
||||||
private readonly ISettingsUtils _settingsUtils;
|
private readonly SettingsUtils _settingsUtils;
|
||||||
private readonly IFileSystemWatcher _watcher;
|
private readonly IFileSystemWatcher _watcher;
|
||||||
private readonly object _loadingSettingsLock = new object();
|
private readonly object _loadingSettingsLock = new object();
|
||||||
private KeyboardListener _keyboardListener;
|
private KeyboardListener _keyboardListener;
|
||||||
@@ -28,6 +28,11 @@ public class SettingsService
|
|||||||
_watcher = Helper.GetFileWatcher(PowerAccentModuleName, "settings.json", () => { ReadSettings(); });
|
_watcher = Helper.GetFileWatcher(PowerAccentModuleName, "settings.json", () => { ReadSettings(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
};
|
||||||
|
|
||||||
private void ReadSettings()
|
private void ReadSettings()
|
||||||
{
|
{
|
||||||
// TODO this IO call should by Async, update GetFileWatcher helper to support async
|
// TODO this IO call should by Async, update GetFileWatcher helper to support async
|
||||||
@@ -40,10 +45,7 @@ public class SettingsService
|
|||||||
{
|
{
|
||||||
Logger.LogInfo("QuickAccent settings.json was missing, creating a new one");
|
Logger.LogInfo("QuickAccent settings.json was missing, creating a new one");
|
||||||
var defaultSettings = new PowerAccentSettings();
|
var defaultSettings = new PowerAccentSettings();
|
||||||
var options = new JsonSerializerOptions
|
var options = _serializerOptions;
|
||||||
{
|
|
||||||
WriteIndented = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
_settingsUtils.SaveSettings(JsonSerializer.Serialize(this, options), PowerAccentModuleName);
|
_settingsUtils.SaveSettings(JsonSerializer.Serialize(this, options), PowerAccentModuleName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,16 +34,15 @@ namespace PowerAccent.Core.Tools
|
|||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1854:Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method", Justification = "False positive: https://github.com/dotnet/roslyn-analyzers/issues/6390")]
|
|
||||||
public void IncrementUsageFrequency(string character)
|
public void IncrementUsageFrequency(string character)
|
||||||
{
|
{
|
||||||
if (_characterUsageCounters.ContainsKey(character))
|
if (_characterUsageCounters.TryGetValue(character, out uint currentCount))
|
||||||
{
|
{
|
||||||
_characterUsageCounters[character]++;
|
_characterUsageCounters[character] = currentCount + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_characterUsageCounters.Add(character, 1);
|
_characterUsageCounters[character] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_characterUsageTimestamp[character] = DateTimeOffset.Now.ToUnixTimeSeconds();
|
_characterUsageTimestamp[character] = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace SvgPreviewHandler
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Common.UI.ThemeManager.GetWindowsBaseColor().ToLowerInvariant() == "dark")
|
if (string.Equals(Common.UI.ThemeManager.GetWindowsBaseColor(), "dark", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return Color.FromArgb(30, 30, 30); // #1e1e1e
|
return Color.FromArgb(30, 30, 30); // #1e1e1e
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
using Settings.UI.Library.Enumerations;
|
using Settings.UI.Library.Enumerations;
|
||||||
|
|
||||||
namespace SvgPreviewHandler
|
namespace SvgPreviewHandler
|
||||||
@@ -39,14 +40,17 @@ namespace SvgPreviewHandler
|
|||||||
|
|
||||||
private readonly Settings settings = new();
|
private readonly Settings settings = new();
|
||||||
|
|
||||||
|
private static readonly CompositeFormat HtmlTemplateSolidColorCompositeFormat = System.Text.CompositeFormat.Parse(HtmlTemplateSolidColor);
|
||||||
|
private static readonly CompositeFormat HtmlTemplateCheckeredCompositeFormat = System.Text.CompositeFormat.Parse(HtmlTemplateCheckered);
|
||||||
|
|
||||||
public string GeneratePreview(string svgData)
|
public string GeneratePreview(string svgData)
|
||||||
{
|
{
|
||||||
var colorMode = (SvgPreviewColorMode)settings.ColorMode;
|
var colorMode = (SvgPreviewColorMode)settings.ColorMode;
|
||||||
return colorMode switch
|
return colorMode switch
|
||||||
{
|
{
|
||||||
SvgPreviewColorMode.SolidColor => string.Format(CultureInfo.InvariantCulture, HtmlTemplateSolidColor, ColorTranslator.ToHtml(settings.SolidColor), svgData),
|
SvgPreviewColorMode.SolidColor => string.Format(CultureInfo.InvariantCulture, HtmlTemplateSolidColorCompositeFormat, ColorTranslator.ToHtml(settings.SolidColor), svgData),
|
||||||
SvgPreviewColorMode.Checkered => string.Format(CultureInfo.InvariantCulture, HtmlTemplateCheckered, GetConfiguredCheckeredShadeImage(), svgData),
|
SvgPreviewColorMode.Checkered => string.Format(CultureInfo.InvariantCulture, HtmlTemplateCheckeredCompositeFormat, GetConfiguredCheckeredShadeImage(), svgData),
|
||||||
SvgPreviewColorMode.Default or _ => string.Format(CultureInfo.InvariantCulture, HtmlTemplateSolidColor, ColorTranslator.ToHtml(settings.ThemeColor), svgData),
|
SvgPreviewColorMode.Default or _ => string.Format(CultureInfo.InvariantCulture, HtmlTemplateSolidColorCompositeFormat, ColorTranslator.ToHtml(settings.ThemeColor), svgData),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ namespace RegistryPreview
|
|||||||
// do not track the result of this node, since it should have no children
|
// do not track the result of this node, since it should have no children
|
||||||
AddTextToTree(registryLine, imageName);
|
AddTextToTree(registryLine, imageName);
|
||||||
}
|
}
|
||||||
else if (registryLine.StartsWith("[", StringComparison.InvariantCulture))
|
else if (registryLine.StartsWith('['))
|
||||||
{
|
{
|
||||||
string imageName = KEYIMAGE;
|
string imageName = KEYIMAGE;
|
||||||
CheckKeyLineForBrackets(ref registryLine, ref imageName);
|
CheckKeyLineForBrackets(ref registryLine, ref imageName);
|
||||||
@@ -259,7 +259,7 @@ namespace RegistryPreview
|
|||||||
|
|
||||||
treeViewNode = AddTextToTree(registryLine, imageName);
|
treeViewNode = AddTextToTree(registryLine, imageName);
|
||||||
}
|
}
|
||||||
else if (registryLine.StartsWith("\"", StringComparison.InvariantCulture) && registryLine.EndsWith("=-", StringComparison.InvariantCulture))
|
else if (registryLine.StartsWith('"') && registryLine.EndsWith("=-", StringComparison.InvariantCulture))
|
||||||
{
|
{
|
||||||
// this line deletes this value so it gets special treatment for the UI
|
// this line deletes this value so it gets special treatment for the UI
|
||||||
registryLine = registryLine.Replace("=-", string.Empty);
|
registryLine = registryLine.Replace("=-", string.Empty);
|
||||||
@@ -277,7 +277,7 @@ namespace RegistryPreview
|
|||||||
StoreTheListValue((RegistryKey)treeViewNode.Content, registryValue);
|
StoreTheListValue((RegistryKey)treeViewNode.Content, registryValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (registryLine.StartsWith("\"", StringComparison.InvariantCulture))
|
else if (registryLine.StartsWith('"'))
|
||||||
{
|
{
|
||||||
// this is a named value
|
// this is a named value
|
||||||
|
|
||||||
@@ -310,16 +310,16 @@ namespace RegistryPreview
|
|||||||
registryValue = new RegistryValue(name, "REG_SZ", string.Empty);
|
registryValue = new RegistryValue(name, "REG_SZ", string.Empty);
|
||||||
|
|
||||||
// if the first character is a " then this is a string value, so find the last most " which will avoid comments
|
// if the first character is a " then this is a string value, so find the last most " which will avoid comments
|
||||||
if (value.StartsWith("\"", StringComparison.InvariantCulture))
|
if (value.StartsWith('"'))
|
||||||
{
|
{
|
||||||
int last = value.LastIndexOf("\"", StringComparison.InvariantCulture);
|
int last = value.LastIndexOf('"');
|
||||||
if (last >= 0)
|
if (last >= 0)
|
||||||
{
|
{
|
||||||
value = value.Substring(0, last + 1);
|
value = value.Substring(0, last + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.StartsWith("\"", StringComparison.InvariantCulture) && value.EndsWith("\"", StringComparison.InvariantCulture))
|
if (value.StartsWith('"') && value.EndsWith('"'))
|
||||||
{
|
{
|
||||||
value = StripFirstAndLast(value);
|
value = StripFirstAndLast(value);
|
||||||
}
|
}
|
||||||
@@ -988,7 +988,7 @@ namespace RegistryPreview
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TextReader reader = new StreamReader(storageFile);
|
StreamReader reader = new StreamReader(storageFile);
|
||||||
fileContents = reader.ReadToEnd();
|
fileContents = reader.ReadToEnd();
|
||||||
reader.Close();
|
reader.Close();
|
||||||
}
|
}
|
||||||
@@ -1167,7 +1167,7 @@ namespace RegistryPreview
|
|||||||
private string ScanAndRemoveComments(string value)
|
private string ScanAndRemoveComments(string value)
|
||||||
{
|
{
|
||||||
// scan for comments and remove them
|
// scan for comments and remove them
|
||||||
int indexOf = value.IndexOf(";", StringComparison.InvariantCulture);
|
int indexOf = value.IndexOf(';');
|
||||||
if (indexOf > -1)
|
if (indexOf > -1)
|
||||||
{
|
{
|
||||||
// presume that there is nothing following the start of the comment
|
// presume that there is nothing following the start of the comment
|
||||||
|
|||||||
@@ -26,13 +26,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
|||||||
Name = ModuleName;
|
Name = ModuleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
};
|
||||||
|
|
||||||
public virtual void Save(ISettingsUtils settingsUtils)
|
public virtual void Save(ISettingsUtils settingsUtils)
|
||||||
{
|
{
|
||||||
// Save settings to file
|
// Save settings to file
|
||||||
var options = new JsonSerializerOptions
|
var options = _serializerOptions;
|
||||||
{
|
|
||||||
WriteIndented = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
ArgumentNullException.ThrowIfNull(settingsUtils);
|
ArgumentNullException.ThrowIfNull(settingsUtils);
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
|||||||
{
|
{
|
||||||
public const string ModuleName = "ColorPicker";
|
public const string ModuleName = "ColorPicker";
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
};
|
||||||
|
|
||||||
[JsonPropertyName("properties")]
|
[JsonPropertyName("properties")]
|
||||||
public ColorPickerPropertiesVersion1 Properties { get; set; }
|
public ColorPickerPropertiesVersion1 Properties { get; set; }
|
||||||
|
|
||||||
@@ -26,10 +31,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
|||||||
public virtual void Save(ISettingsUtils settingsUtils)
|
public virtual void Save(ISettingsUtils settingsUtils)
|
||||||
{
|
{
|
||||||
// Save settings to file
|
// Save settings to file
|
||||||
var options = new JsonSerializerOptions
|
var options = _serializerOptions;
|
||||||
{
|
|
||||||
WriteIndented = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
ArgumentNullException.ThrowIfNull(settingsUtils);
|
ArgumentNullException.ThrowIfNull(settingsUtils);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
@@ -9,6 +10,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library.CustomAction
|
|||||||
{
|
{
|
||||||
public class SendCustomAction
|
public class SendCustomAction
|
||||||
{
|
{
|
||||||
|
private static readonly ConcurrentDictionary<string, JsonSerializerOptions> OptionsCache = new ConcurrentDictionary<string, JsonSerializerOptions>();
|
||||||
|
|
||||||
private readonly string moduleName;
|
private readonly string moduleName;
|
||||||
|
|
||||||
public SendCustomAction(string moduleName)
|
public SendCustomAction(string moduleName)
|
||||||
@@ -21,7 +24,13 @@ namespace Microsoft.PowerToys.Settings.UI.Library.CustomAction
|
|||||||
|
|
||||||
public string ToJsonString()
|
public string ToJsonString()
|
||||||
{
|
{
|
||||||
var jsonSerializerOptions = new JsonSerializerOptions
|
var jsonSerializerOptions = OptionsCache.GetOrAdd(moduleName, CreateOptionsForModuleName);
|
||||||
|
return JsonSerializer.Serialize(this, jsonSerializerOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonSerializerOptions CreateOptionsForModuleName(string moduleName)
|
||||||
|
{
|
||||||
|
return new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
PropertyNamingPolicy = new CustomNamePolicy((propertyName) =>
|
PropertyNamingPolicy = new CustomNamePolicy((propertyName) =>
|
||||||
{
|
{
|
||||||
@@ -29,8 +38,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.CustomAction
|
|||||||
return propertyName.Equals("ModuleAction", System.StringComparison.Ordinal) ? moduleName : propertyName;
|
return propertyName.Equals("ModuleAction", System.StringComparison.Ordinal) ? moduleName : propertyName;
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
return JsonSerializer.Serialize(this, jsonSerializerOptions);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
|||||||
{
|
{
|
||||||
public const string ModuleName = "EnvironmentVariables";
|
public const string ModuleName = "EnvironmentVariables";
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
};
|
||||||
|
|
||||||
[JsonPropertyName("properties")]
|
[JsonPropertyName("properties")]
|
||||||
public EnvironmentVariablesProperties Properties { get; set; }
|
public EnvironmentVariablesProperties Properties { get; set; }
|
||||||
|
|
||||||
@@ -26,10 +31,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
|||||||
public virtual void Save(ISettingsUtils settingsUtils)
|
public virtual void Save(ISettingsUtils settingsUtils)
|
||||||
{
|
{
|
||||||
// Save settings to file
|
// Save settings to file
|
||||||
var options = new JsonSerializerOptions
|
var options = _serializerOptions;
|
||||||
{
|
|
||||||
WriteIndented = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
ArgumentNullException.ThrowIfNull(settingsUtils);
|
ArgumentNullException.ThrowIfNull(settingsUtils);
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
|||||||
public const string ModuleName = "Hosts";
|
public const string ModuleName = "Hosts";
|
||||||
|
|
||||||
[JsonPropertyName("properties")]
|
[JsonPropertyName("properties")]
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
};
|
||||||
|
|
||||||
public HostsProperties Properties { get; set; }
|
public HostsProperties Properties { get; set; }
|
||||||
|
|
||||||
public HostsSettings()
|
public HostsSettings()
|
||||||
@@ -26,10 +32,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
|||||||
public virtual void Save(ISettingsUtils settingsUtils)
|
public virtual void Save(ISettingsUtils settingsUtils)
|
||||||
{
|
{
|
||||||
// Save settings to file
|
// Save settings to file
|
||||||
var options = new JsonSerializerOptions
|
var options = _serializerOptions;
|
||||||
{
|
|
||||||
WriteIndented = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
ArgumentNullException.ThrowIfNull(settingsUtils);
|
ArgumentNullException.ThrowIfNull(settingsUtils);
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user