diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Main.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Main.cs index 2ffd30c18a..624f6610ad 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Main.cs @@ -1,28 +1,33 @@ -using Microsoft.PowerToys.Settings.UI.Lib; +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; +using System.Windows.Input; +using Microsoft.PowerToys.Settings.UI.Lib; using Wox.Infrastructure.Logger; using Wox.Infrastructure.Storage; -using Wox.Plugin.SharedCommands; using Wox.Plugin; +using Wox.Plugin.SharedCommands; using Control = System.Windows.Controls.Control; -using System.Windows.Input; -using System.Reflection; namespace Microsoft.Plugin.Shell { public class Main : IPlugin, ISettingProvider, IPluginI18n, IContextMenu, ISavable { - private string IconPath { get; set; } - private PluginInitContext _context; - private readonly Settings _settings; private readonly PluginJsonStorage _storage; + private string IconPath { get; set; } + + private PluginInitContext _context; + public Main() { _storage = new PluginJsonStorage(); @@ -34,7 +39,6 @@ namespace Microsoft.Plugin.Shell _storage.Save(); } - public List Query(Query query) { List results = new List(); @@ -83,7 +87,7 @@ namespace Microsoft.Plugin.Shell { Execute(Process.Start, PrepareProcessStartInfo(m)); return true; - } + }, })); } } @@ -91,6 +95,7 @@ namespace Microsoft.Plugin.Shell { Log.Exception($"|Microsoft.Plugin.Shell.Main.Query|Exception when query for <{query}>", e); } + return results; } } @@ -116,7 +121,7 @@ namespace Microsoft.Plugin.Shell { Execute(Process.Start, PrepareProcessStartInfo(m.Key)); return true; - } + }, }; return ret; }).Where(o => o != null).Take(4); @@ -135,7 +140,7 @@ namespace Microsoft.Plugin.Shell { Execute(Process.Start, PrepareProcessStartInfo(cmd)); return true; - } + }, }; return result; @@ -153,7 +158,7 @@ namespace Microsoft.Plugin.Shell { Execute(Process.Start, PrepareProcessStartInfo(m.Key)); return true; - } + }, }).Take(5); return history.ToList(); } @@ -163,7 +168,7 @@ namespace Microsoft.Plugin.Shell command = command.Trim(); command = Environment.ExpandEnvironmentVariables(command); var workingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - var runAsAdministratorArg = !runAsAdministrator && !_settings.RunAsAdministrator ? "" : "runas"; + var runAsAdministratorArg = !runAsAdministrator && !_settings.RunAsAdministrator ? string.Empty : "runas"; ProcessStartInfo info; if (_settings.Shell == Shell.Cmd) @@ -188,7 +193,7 @@ namespace Microsoft.Plugin.Shell } else if (_settings.Shell == Shell.RunCommand) { - //Open explorer if the path is a file or directory + // Open explorer if the path is a file or directory if (Directory.Exists(command) || File.Exists(command)) { info = ShellCommand.SetProcessStartInfo("explorer.exe", arguments: command, verb: runAsAdministratorArg); @@ -267,6 +272,7 @@ namespace Microsoft.Plugin.Shell return true; } } + return false; } else @@ -296,7 +302,7 @@ namespace Microsoft.Plugin.Shell } } - private void OnThemeChanged(Theme _, Theme newTheme) + private void OnThemeChanged(Theme currentTheme, Theme newTheme) { UpdateIconPath(newTheme); } @@ -327,13 +333,13 @@ namespace Microsoft.Plugin.Shell Glyph = "\xE7EF", FontFamily = "Segoe MDL2 Assets", AcceleratorKey = Key.Enter, - AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift), + AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift, Action = c => { Execute(Process.Start, PrepareProcessStartInfo(selectedResult.Title, true)); return true; - } - } + }, + }, }; return resultlist; diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Microsoft.Plugin.Shell.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Microsoft.Plugin.Shell.csproj index f9be8bf1bd..b0c7e57876 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Microsoft.Plugin.Shell.csproj +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Microsoft.Plugin.Shell.csproj @@ -108,5 +108,19 @@ PreserveNewest - + + + GlobalSuppressions.cs + + + StyleCop.json + + + + + 1.1.118 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + \ No newline at end of file diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Settings.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Settings.cs index 2c248a1e18..89225b5e25 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Settings.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Settings.cs @@ -1,4 +1,8 @@ -using System.Collections.Generic; +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; namespace Microsoft.Plugin.Shell { @@ -6,12 +10,15 @@ namespace Microsoft.Plugin.Shell { public Shell Shell { get; set; } = Shell.RunCommand; - // not overriding Win+R + // not overriding Win+R // crutkas we need to earn the right for Win+R override public bool ReplaceWinR { get; set; } = false; + public bool LeaveShellOpen { get; set; } + public bool RunAsAdministrator { get; set; } = false; + [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "StyleCop error, actually used in main.cs")] public Dictionary Count = new Dictionary(); public void AddCmdHistory(string cmdName) @@ -32,6 +39,5 @@ namespace Microsoft.Plugin.Shell Cmd = 0, Powershell = 1, RunCommand = 2, - } } diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/ShellSetting.xaml.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/ShellSetting.xaml.cs index 1499319253..8c1939b33f 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/ShellSetting.xaml.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Shell/ShellSetting.xaml.cs @@ -1,4 +1,8 @@ -using System.Windows; +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Windows; using System.Windows.Controls; namespace Microsoft.Plugin.Shell