Add the Command Palette module (#37908)

Windows Command Palette ("CmdPal") is the next iteration of PowerToys Run. With extensibility at its core, the Command Palette is your one-stop launcher to start _anything_.

By default, CmdPal is bound to <kbd>Win+Alt+Space</kbd>.

![cmdpal-pr-002](https://github.com/user-attachments/assets/5077ec04-1009-478a-92d6-0a30989d44ac)
![cmdpal-pr-003](https://github.com/user-attachments/assets/63b4762a-9c19-48eb-9242-18ea48240ba0)

----

This brings the current preview version of CmdPal into the upstream PowerToys repo. There are still lots of bugs to work out, but it's reached the state we're ready to start sharing it with the world. From here, we can further collaborate with the community on the features that are important, and ensuring that we've got a most robust API to enable developers to build whatever extensions they want. 

Most of the built-in PT Run modules have already been ported to CmdPal's extension API. Those include:
* Installed apps
* Shell commands
* File search (powered by the indexer)
* Windows Registry search
* Web search
* Windows Terminal Profiles
* Windows Services
* Windows settings


There are a couple new extensions built-in
* You can now search for packages on `winget` and install them right from the palette. This also powers searching for extensions for the palette
* The calculator has an entirely new implementation. This is currently less feature complete than the original PT Run one - we're looking forward to updating it to be more complete for future ingestion in Windows
* "Bookmarks" allow you to save shortcuts to files, folders, and webpages as top-level commands in the palette. 

We've got a bunch of other samples too, in this repo and elsewhere

### PowerToys specific notes

CmdPal will eventually graduate out of PowerToys to live as its own application, which is why it's implemented just a little differently than most other modules. Enabling CmdPal will install its `msix` package. 

The CI was minorly changed to support CmdPal version numbers independent of PowerToys itself. It doesn't make sense for us to start CmdPal at v0.90, and in the future, we want to be able to rev CmdPal independently of PT itself. 


Closes #3200, closes #3600, closes #7770, closes #34273, closes #36471, closes #20976, closes #14495
  
  
-----

TODOs et al


**Blocking:**
- [ ] Images and descriptions in Settings and OOBE need to be properly defined, as mentioned before
  - [ ] Niels is on it
- [x] Doesn't start properly from PowerToys unless the fix PR is merged.
  - https://github.com/zadjii-msft/PowerToys/pull/556 merged
- [x] I seem to lose focus a lot when I press on some limits, like between the search bar and the results.
  - This is https://github.com/zadjii-msft/PowerToys/issues/427
- [x] Turned off an extension like Calculator and it was still working.
  - Need to get rid of that toggle, it doesn't do anything currently
- [x] `ListViewModel.<FetchItems>` crash
  - Pretty confident that was fixed in https://github.com/zadjii-msft/PowerToys/pull/553

**Not blocking / improvements:**
- Show the shortcut through settings, as mentioned before, or create a button that would open CmdPalette settings.
- When PowerToys starts, CmdPalette is always shown if enabled. That's weird when just starting PowerToys/ logging in to the computer with PowerToys auto-start activated. I think this should at least be a setting.
- Needing to double press a result for it to do the default action seems quirky. If one is already selected, I think just pressing should be enough for it to do the action.
  - This is currently a setting, though we're thinking of changing the setting even more: https://github.com/zadjii-msft/PowerToys/issues/392
- There's no URI extension. Was surprised when typing a URL that it only proposed a web search.
- [x] There's no System commands extension. Was expecting to be able to quickly restart the computer by typing restart but it wasn't there.
  - This is in PR https://github.com/zadjii-msft/PowerToys/pull/452  
  
---------

Co-authored-by: joadoumie <98557455+joadoumie@users.noreply.github.com>
Co-authored-by: Jordi Adoumie <jordiadoumie@microsoft.com>
Co-authored-by: Mike Griese <zadjii@gmail.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Michael Hawker <24302614+michael-hawker@users.noreply.github.com>
Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
Co-authored-by: Seraphima <zykovas91@gmail.com>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
Co-authored-by: Kristen Schau <47155823+krschau@users.noreply.github.com>
Co-authored-by: Eric Johnson <ericjohnson327@gmail.com>
Co-authored-by: Ethan Fang <ethanfang@microsoft.com>
Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
Co-authored-by: Clint Rutkas <clint@rutkas.com>
This commit is contained in:
Mike Griese
2025-03-19 03:39:57 -05:00
committed by GitHub
parent a62acf7a71
commit f68f408be3
984 changed files with 69758 additions and 277 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

View File

@@ -0,0 +1,26 @@
// 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.Threading.Tasks;
using Microsoft.CmdPal.Ext.System.Helpers;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.Shell;
public sealed partial class EmptyRecycleBinCommand : InvokableCommand
{
public EmptyRecycleBinCommand(bool settingEmptyRBSuccesMsg)
{
_settingEmptyRBSuccesMsg = settingEmptyRBSuccesMsg;
}
public override CommandResult Invoke()
{
Task.Run(() => ResultHelper.EmptyRecycleBinTask(_settingEmptyRBSuccesMsg));
return CommandResult.Dismiss();
}
private bool _settingEmptyRBSuccesMsg;
}

View File

@@ -0,0 +1,38 @@
// 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 Microsoft.CmdPal.Ext.Shell;
using Microsoft.CmdPal.Ext.System.Helpers;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.System;
public sealed partial class EmptyRecycleBinConfirmation : InvokableCommand
{
public EmptyRecycleBinConfirmation(bool settingEmptyRBSuccesMsg)
{
Name = Resources.Microsoft_plugin_command_name_empty;
_settingEmptyRBSuccesMsg = settingEmptyRBSuccesMsg;
}
public override CommandResult Invoke()
{
if (ResultHelper.ExecutingEmptyRecycleBinTask)
{
return CommandResult.ShowToast(new ToastArgs() { Message = Resources.Microsoft_plugin_sys_RecycleBin_EmptyTaskRunning });
}
var confirmArgs = new ConfirmationArgs()
{
Title = Resources.Microsoft_plugin_sys_confirmation,
Description = Resources.EmptyRecycleBin_ConfirmationDialog_Description,
PrimaryCommand = new EmptyRecycleBinCommand(_settingEmptyRBSuccesMsg),
IsPrimaryCommandCritical = true,
};
return CommandResult.Confirm(confirmArgs);
}
private bool _settingEmptyRBSuccesMsg;
}

View File

@@ -0,0 +1,24 @@
// 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 Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.System;
public sealed partial class ExecuteCommand : InvokableCommand
{
public ExecuteCommand(Action command)
{
_command = command;
}
public override CommandResult Invoke()
{
_command();
return CommandResult.Dismiss();
}
private Action _command;
}

View File

@@ -0,0 +1,42 @@
// 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 Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.System;
public sealed partial class ExecuteCommandConfirmation : InvokableCommand
{
public ExecuteCommandConfirmation(string name, bool confirm, string confirmationMessage, Action command)
{
Name = name;
_command = command;
_confirm = confirm;
_confirmationMessage = confirmationMessage;
}
public override CommandResult Invoke()
{
if (_confirm)
{
var confirmationArgs = new ConfirmationArgs
{
Title = Resources.Microsoft_plugin_sys_confirmation,
Description = _confirmationMessage,
PrimaryCommand = new ExecuteCommand(_command),
IsPrimaryCommandCritical = true,
};
return CommandResult.Confirm(confirmationArgs);
}
_command();
return CommandResult.Dismiss();
}
private bool _confirm;
private string _confirmationMessage;
private Action _command;
}

View File

@@ -0,0 +1,217 @@
// 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.Globalization;
using System.Net.NetworkInformation;
using System.Text;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.System.Helpers;
/// <summary>
/// This class holds all available results
/// </summary>
internal static class Commands
{
internal const int EWXLOGOFF = 0x00000000;
internal const int EWXSHUTDOWN = 0x00000001;
internal const int EWXREBOOT = 0x00000002;
internal const int EWXFORCE = 0x00000004;
internal const int EWXPOWEROFF = 0x00000008;
internal const int EWXFORCEIFHUNG = 0x00000010;
// Cache for network interface information to save query time
private const int UpdateCacheIntervalSeconds = 5;
private static List<NetworkConnectionProperties> networkPropertiesCache = new List<NetworkConnectionProperties>();
private static DateTime timeOfLastNetworkQuery;
/// <summary>
/// Returns a list with all system command results
/// </summary>
/// <param name="isUefi">Value indicating if the system is booted in uefi mode</param>
/// <param name="splitRecycleBinResults">Value indicating if we should show two results for Recycle Bin.</param>
/// <param name="confirmCommands">A value indicating if the user should confirm the system commands</param>
/// <param name="emptyRBSuccessMessage">Show a success message after empty Recycle Bin.</param>
/// <returns>A list of all results</returns>
public static List<IListItem> GetSystemCommands(bool isUefi, bool splitRecycleBinResults, bool confirmCommands, bool emptyRBSuccessMessage)
{
var results = new List<IListItem>();
results.AddRange(new[]
{
new ListItem(new ExecuteCommandConfirmation(Resources.Microsoft_plugin_command_name_shutdown, confirmCommands, Resources.Microsoft_plugin_sys_shutdown_computer_confirmation, () => OpenInShellHelper.OpenInShell("shutdown", "/s /hybrid /t 0")))
{
Title = Resources.Microsoft_plugin_sys_shutdown_computer,
Subtitle = Resources.Microsoft_plugin_sys_shutdown_computer_description,
Icon = Icons.ShutdownIcon,
},
new ListItem(new ExecuteCommandConfirmation(Resources.Microsoft_plugin_command_name_restart, confirmCommands, Resources.Microsoft_plugin_sys_restart_computer_confirmation, () => OpenInShellHelper.OpenInShell("shutdown", "/g /t 0")))
{
Title = Resources.Microsoft_plugin_sys_restart_computer,
Subtitle = Resources.Microsoft_plugin_sys_restart_computer_description,
Icon = Icons.RestartIcon,
},
new ListItem(new ExecuteCommandConfirmation(Resources.Microsoft_plugin_command_name_signout, confirmCommands, Resources.Microsoft_plugin_sys_sign_out_confirmation, () => NativeMethods.ExitWindowsEx(EWXLOGOFF, 0)))
{
Title = Resources.Microsoft_plugin_sys_sign_out,
Subtitle = Resources.Microsoft_plugin_sys_sign_out_description,
Icon = Icons.LogoffIcon,
},
new ListItem(new ExecuteCommandConfirmation(Resources.Microsoft_plugin_command_name_lock, confirmCommands, Resources.Microsoft_plugin_sys_lock_confirmation, () => NativeMethods.LockWorkStation()))
{
Title = Resources.Microsoft_plugin_sys_lock,
Subtitle = Resources.Microsoft_plugin_sys_lock_description,
Icon = Icons.LockIcon,
},
new ListItem(new ExecuteCommandConfirmation(Resources.Microsoft_plugin_command_name_sleep, confirmCommands, Resources.Microsoft_plugin_sys_sleep_confirmation, () => NativeMethods.SetSuspendState(false, true, true)))
{
Title = Resources.Microsoft_plugin_sys_sleep,
Subtitle = Resources.Microsoft_plugin_sys_sleep_description,
Icon = Icons.SleepIcon,
},
new ListItem(new ExecuteCommandConfirmation(Resources.Microsoft_plugin_command_name_hibernate, confirmCommands, Resources.Microsoft_plugin_sys_hibernate_confirmation, () => NativeMethods.SetSuspendState(true, true, true)))
{
Title = Resources.Microsoft_plugin_sys_hibernate,
Subtitle = Resources.Microsoft_plugin_sys_hibernate_description,
Icon = Icons.SleepIcon, // Icon change needed
},
});
// Show Recycle Bin results based on setting.
if (splitRecycleBinResults)
{
results.AddRange(new[]
{
new ListItem(new OpenInShellCommand(Resources.Microsoft_plugin_command_name_empty, "explorer.exe", "shell:RecycleBinFolder"))
{
Title = Resources.Microsoft_plugin_sys_RecycleBinOpen,
Subtitle = Resources.Microsoft_plugin_sys_RecycleBin_description,
Icon = Icons.RecycleBinIcon,
},
new ListItem(new EmptyRecycleBinConfirmation(emptyRBSuccessMessage))
{
Title = Resources.Microsoft_plugin_sys_RecycleBinEmptyResult,
Subtitle = Resources.Microsoft_plugin_sys_RecycleBinEmpty_description,
Icon = Icons.RecycleBinIcon,
},
});
}
else
{
results.Add(
new ListItem(new OpenInShellCommand(Resources.Microsoft_plugin_command_name_empty, "explorer.exe", "shell:RecycleBinFolder"))
{
Title = Resources.Microsoft_plugin_sys_RecycleBin,
Subtitle = Resources.Microsoft_plugin_sys_RecycleBin_description,
Icon = Icons.RecycleBinIcon,
});
}
// UEFI command/result. It is only available on systems booted in UEFI mode.
if (isUefi)
{
results.Add(new ListItem(new ExecuteCommandConfirmation(Resources.Microsoft_plugin_command_name_reboot, confirmCommands, Resources.Microsoft_plugin_sys_uefi_confirmation, () => OpenInShellHelper.OpenInShell("shutdown", "/r /fw /t 0", null, OpenInShellHelper.ShellRunAsType.Administrator)))
{
Title = Resources.Microsoft_plugin_sys_uefi,
Subtitle = Resources.Microsoft_plugin_sys_uefi_description,
Icon = Icons.FirmwareSettingsIcon,
});
}
return results;
}
/// <summary>
/// Returns a list of all ip and mac results
/// </summary>
/// <param name="manager">The tSettingsManager instance</param>
/// <returns>The list of available results</returns>
public static List<IListItem> GetNetworkConnectionResults(SettingsManager manager)
{
var results = new List<IListItem>();
// We update the cache only if the last query is older than 'updateCacheIntervalSeconds' seconds
DateTime timeOfLastNetworkQueryBefore = timeOfLastNetworkQuery;
timeOfLastNetworkQuery = DateTime.Now; // Set time of last query to this query
if ((timeOfLastNetworkQuery - timeOfLastNetworkQueryBefore).TotalSeconds >= UpdateCacheIntervalSeconds)
{
networkPropertiesCache = NetworkConnectionProperties.GetList();
}
CompositeFormat sysIpv4DescriptionCompositeFormate = CompositeFormat.Parse(Resources.Microsoft_plugin_sys_ip4_description);
CompositeFormat sysMacDescriptionCompositeFormate = CompositeFormat.Parse(Resources.Microsoft_plugin_sys_mac_description);
var hideDisconnectedNetworkInfo = manager.HideDisconnectedNetworkInfo;
foreach (NetworkConnectionProperties intInfo in networkPropertiesCache)
{
if (hideDisconnectedNetworkInfo)
{
if (intInfo.State != OperationalStatus.Up)
{
continue;
}
}
if (!string.IsNullOrEmpty(intInfo.IPv4))
{
results.Add(new ListItem(new CopyTextCommand(intInfo.GetConnectionDetails()))
{
Title = intInfo.IPv4,
Subtitle = string.Format(CultureInfo.InvariantCulture, sysIpv4DescriptionCompositeFormate, intInfo.ConnectionName),
Icon = Icons.NetworkAdapterIcon,
Details = new Details() { Title = Resources.Microsoft_plugin_ext_connection_details, Body = intInfo.GetConnectionDetails() },
});
}
if (!string.IsNullOrEmpty(intInfo.IPv6Primary))
{
results.Add(new ListItem(new CopyTextCommand(intInfo.GetConnectionDetails()))
{
Title = intInfo.IPv6Primary,
Subtitle = string.Format(CultureInfo.InvariantCulture, sysIpv4DescriptionCompositeFormate, intInfo.ConnectionName),
Icon = Icons.NetworkAdapterIcon,
Details = new Details() { Title = Resources.Microsoft_plugin_ext_connection_details, Body = intInfo.GetConnectionDetails() },
});
}
if (!string.IsNullOrEmpty(intInfo.PhysicalAddress))
{
results.Add(new ListItem(new CopyTextCommand(intInfo.GetAdapterDetails()))
{
Title = intInfo.PhysicalAddress,
Subtitle = string.Format(CultureInfo.InvariantCulture, sysMacDescriptionCompositeFormate, intInfo.Adapter, intInfo.ConnectionName),
Icon = Icons.NetworkAdapterIcon,
Details = new Details() { Title = Resources.Microsoft_plugin_ext_connection_details, Body = intInfo.GetConnectionDetails() },
});
}
}
return results;
}
public static List<IListItem> GetAllCommands(SettingsManager manager)
{
var list = new List<IListItem>();
var listLock = new object();
// Network (ip and mac) results are slow with many network cards and returned delayed.
// On global queries the first word/part has to be 'ip', 'mac' or 'address' for network results
var networkConnectionResults = Commands.GetNetworkConnectionResults(manager);
var isBootedInUefiMode = Win32Helpers.GetSystemFirmwareType() == FirmwareType.Uefi;
var separateEmptyRB = manager.ShowSeparateResultForEmptyRecycleBin;
var confirmSystemCommands = manager.ShowDialogToConfirmCommand;
var showSuccessOnEmptyRB = manager.ShowSuccessMessageAfterEmptyingRecycleBin;
// normal system commands are fast and can be returned immediately
var systemCommands = Commands.GetSystemCommands(isBootedInUefiMode, separateEmptyRB, confirmSystemCommands, showSuccessOnEmptyRB);
list.AddRange(systemCommands);
list.AddRange(networkConnectionResults);
return list;
}
}

View File

@@ -0,0 +1,26 @@
// 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 Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.System.Helpers;
public static partial class Icons
{
public static IconInfo FirmwareSettingsIcon { get; } = IconHelpers.FromRelativePaths("Microsoft.CmdPal.Ext.System\\Assets\\logoff.light.png", "Microsoft.CmdPal.Ext.System\\Assets\\logoff.dark.png");
public static IconInfo LockIcon { get; } = new IconInfo("\uE72E");
public static IconInfo LogoffIcon { get; } = IconHelpers.FromRelativePaths("Microsoft.CmdPal.Ext.System\\Assets\\logoff.light.png", "Microsoft.CmdPal.Ext.System\\Assets\\logoff.dark.png");
public static IconInfo NetworkAdapterIcon { get; } = new IconInfo("\uEDA3");
public static IconInfo RecycleBinIcon { get; } = new IconInfo("\uE74D");
public static IconInfo RestartIcon { get; } = new IconInfo("\uE777");
public static IconInfo ShutdownIcon { get; } = new IconInfo("\uE7E8");
public static IconInfo SleepIcon { get; } = IconHelpers.FromRelativePaths("Microsoft.CmdPal.Ext.System\\Assets\\sleep.light.png", "Microsoft.CmdPal.Ext.System\\Assets\\sleep.dark.png");
}

View File

@@ -0,0 +1,43 @@
// 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.Runtime.InteropServices;
namespace Microsoft.CmdPal.Ext.System.Helpers;
public sealed partial class MessageBoxHelper
{
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern int MessageBox(IntPtr hWnd, string text, string caption, int type);
public static MessageBoxResult Show(string text, string caption, IconType iconType, MessageBoxType type)
{
return (MessageBoxResult)MessageBox(IntPtr.Zero, text, caption, (int)type | (int)iconType);
}
public enum IconType
{
Error = 0x00000010,
Help = 0x00000020,
Warning = 0x00000030,
Info = 0x00000040,
}
public enum MessageBoxType
{
OK = 0x00000000,
}
public enum MessageBoxResult
{
OK = 1,
Cancel = 2,
Abort = 3,
Retry = 4,
Ignore = 5,
Yes = 6,
No = 7,
}
}

View File

@@ -0,0 +1,144 @@
// 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.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace Microsoft.CmdPal.Ext.System.Helpers;
[SuppressMessage("Interoperability", "CA1401:P/Invokes should not be visible", Justification = "We want plugins to share this NativeMethods class, instead of each one creating its own.")]
public sealed class Native
{
public enum HRESULT : uint
{
/// <summary>
/// Operation successful.
/// </summary>
S_OK = 0x00000000,
/// <summary>
/// Operation successful. (negative condition/no operation)
/// </summary>
S_FALSE = 0x00000001,
/// <summary>
/// Not implemented.
/// </summary>
E_NOTIMPL = 0x80004001,
/// <summary>
/// No such interface supported.
/// </summary>
E_NOINTERFACE = 0x80004002,
/// <summary>
/// Pointer that is not valid.
/// </summary>
E_POINTER = 0x80004003,
/// <summary>
/// Operation aborted.
/// </summary>
E_ABORT = 0x80004004,
/// <summary>
/// Unspecified failure.
/// </summary>
E_FAIL = 0x80004005,
/// <summary>
/// Unexpected failure.
/// </summary>
E_UNEXPECTED = 0x8000FFFF,
/// <summary>
/// General access denied error.
/// </summary>
E_ACCESSDENIED = 0x80070005,
/// <summary>
/// Handle that is not valid.
/// </summary>
E_HANDLE = 0x80070006,
/// <summary>
/// Failed to allocate necessary memory.
/// </summary>
E_OUTOFMEMORY = 0x8007000E,
/// <summary>
/// One or more arguments are not valid.
/// </summary>
E_INVALIDARG = 0x80070057,
/// <summary>
/// The operation was canceled by the user. (Error source 7 means Win32.)
/// </summary>
/// <SeeAlso href="https://learn.microsoft.com/windows/win32/debug/system-error-codes--1000-1299-"/>
/// <SeeAlso href="https://en.wikipedia.org/wiki/HRESULT"/>
E_CANCELLED = 0x800704C7,
}
public static class ShellItemTypeConstants
{
/// <summary>
/// Guid for type IShellItem.
/// </summary>
public static readonly Guid ShellItemGuid = new("43826d1e-e718-42ee-bc55-a1e261c37bfe");
/// <summary>
/// Guid for type IShellItem2.
/// </summary>
public static readonly Guid ShellItem2Guid = new("7E9FB0D3-919F-4307-AB2E-9B1860310C93");
}
/// <summary>
/// The following are ShellItem DisplayName types.
/// </summary>
[Flags]
public enum SIGDN : uint
{
NORMALDISPLAY = 0,
PARENTRELATIVEPARSING = 0x80018001,
PARENTRELATIVEFORADDRESSBAR = 0x8001c001,
DESKTOPABSOLUTEPARSING = 0x80028000,
PARENTRELATIVEEDITING = 0x80031001,
DESKTOPABSOLUTEEDITING = 0x8004c000,
FILESYSPATH = 0x80058000,
URL = 0x80068000,
}
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
public interface IShellItem
{
void BindToHandler(
nint pbc,
[MarshalAs(UnmanagedType.LPStruct)] Guid bhid,
[MarshalAs(UnmanagedType.LPStruct)] Guid riid,
out nint ppv);
void GetParent(out IShellItem ppsi);
void GetDisplayName(SIGDN sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName);
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
void Compare(IShellItem psi, uint hint, out int piOrder);
}
/// <summary>
/// <see href="https://learn.microsoft.com/windows/win32/stg/stgm-constants">see all STGM values</see>
/// </summary>
[Flags]
public enum STGM : long
{
READ = 0x00000000L,
WRITE = 0x00000001L,
READWRITE = 0x00000002L,
CREATE = 0x00001000L,
}
}

View File

@@ -0,0 +1,121 @@
// 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.Runtime.InteropServices;
using SuppressMessageAttribute = System.Diagnostics.CodeAnalysis.SuppressMessageAttribute;
#pragma warning disable SA1649, CA1051, CA1707, CA1028, CA1714, CA1069, SA1402
namespace Microsoft.CmdPal.Ext.System.Helpers;
[SuppressMessage("Interoperability", "CA1401:P/Invokes should not be visible", Justification = "We want plugins to share this NativeMethods class, instead of each one creating its own.")]
public static class NativeMethods
{
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CloseHandle(IntPtr hObject);
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetFirmwareType(ref FirmwareType FirmwareType);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
[DllImport("user32")]
public static extern void LockWorkStation();
[DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent);
[DllImport("Shell32.dll", CharSet = CharSet.Unicode)]
public static extern uint SHEmptyRecycleBin(IntPtr hWnd, uint dwFlags);
}
public enum HRESULT : uint
{
/// <summary>
/// Operation successful.
/// </summary>
S_OK = 0x00000000,
/// <summary>
/// Operation successful. (negative condition/no operation)
/// </summary>
S_FALSE = 0x00000001,
/// <summary>
/// Not implemented.
/// </summary>
E_NOTIMPL = 0x80004001,
/// <summary>
/// No such interface supported.
/// </summary>
E_NOINTERFACE = 0x80004002,
/// <summary>
/// Pointer that is not valid.
/// </summary>
E_POINTER = 0x80004003,
/// <summary>
/// Operation aborted.
/// </summary>
E_ABORT = 0x80004004,
/// <summary>
/// Unspecified failure.
/// </summary>
E_FAIL = 0x80004005,
/// <summary>
/// Unexpected failure.
/// </summary>
E_UNEXPECTED = 0x8000FFFF,
/// <summary>
/// General access denied error.
/// </summary>
E_ACCESSDENIED = 0x80070005,
/// <summary>
/// Handle that is not valid.
/// </summary>
E_HANDLE = 0x80070006,
/// <summary>
/// Failed to allocate necessary memory.
/// </summary>
E_OUTOFMEMORY = 0x8007000E,
/// <summary>
/// One or more arguments are not valid.
/// </summary>
E_INVALIDARG = 0x80070057,
/// <summary>
/// The operation was canceled by the user. (Error source 7 means Win32.)
/// </summary>
/// <SeeAlso href="https://learn.microsoft.com/windows/win32/debug/system-error-codes--1000-1299-"/>
/// <SeeAlso href="https://en.wikipedia.org/wiki/HRESULT"/>
E_CANCELLED = 0x800704C7,
}
/// <remarks>
/// <see href="https://learn.microsoft.com/windows/win32/api/winnt/ne-winnt-firmware_type">see learn.microsoft.com</see>
/// </remarks>
public enum FirmwareType
{
Unknown = 0,
Bios = 1,
Uefi = 2,
Max = 3,
}
public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam);

View File

@@ -0,0 +1,320 @@
// 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.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
namespace Microsoft.CmdPal.Ext.System.Helpers;
/// <summary>
/// This class represents the information for a network connection/interface
/// </summary>
internal sealed class NetworkConnectionProperties
{
/// <summary>
/// Gets the name of the adapter
/// </summary>
internal string Adapter { get; private set; }
/// <summary>
/// Gets the physical address (MAC) of the adapter
/// </summary>
internal string PhysicalAddress { get; private set; }
/// <summary>
/// Gets a value indicating the interface type
/// </summary>
internal NetworkInterfaceType Type { get; private set; }
/// <summary>
/// Gets the speed of the adapter as unformatted value (Static information form the adapter device)
/// </summary>
internal long Speed { get; private set; }
/// <summary>
/// Gets a value indicating the operational state of the adapter
/// </summary>
internal OperationalStatus State { get; private set; }
/// <summary>
/// Gets the name of the network connection
/// </summary>
internal string ConnectionName { get; private set; } = string.Empty;
/// <summary>
/// Gets a string with the suffix of the connection
/// </summary>
internal string Suffix { get; private set; } = string.Empty;
/// <summary>
/// Gets the IPv4 address
/// </summary>
internal string IPv4 { get; private set; } = string.Empty;
/// <summary>
/// Gets the IPv4 subnet mask
/// </summary>
internal string IPv4Mask { get; private set; } = string.Empty;
/// <summary>
/// Gets the primarily used IPv6 address
/// </summary>
internal string IPv6Primary { get; private set; } = string.Empty;
/// <summary>
/// Gets the global IPv6 address
/// </summary>
internal string IPv6Global { get; private set; } = string.Empty;
/// <summary>
/// Gets the temporary IPv6 address
/// </summary>
internal string IPv6Temporary { get; private set; } = string.Empty;
/// <summary>
/// Gets the link local IPv6 address
/// </summary>
internal string IPv6LinkLocal { get; private set; } = string.Empty;
/// <summary>
/// Gets the site local IPv6 address
/// </summary>
internal string IPv6SiteLocal { get; private set; } = string.Empty;
/// <summary>
/// Gets the unique local IPv6 address
/// </summary>
internal string IPv6UniqueLocal { get; private set; } = string.Empty;
/// <summary>
/// Gets the list of gateway IPs as string
/// </summary>
internal List<IPAddress> Gateways { get; private set; } = new List<IPAddress>();
/// <summary>
/// Gets the list of DHCP server IPs as string
/// </summary>
internal IPAddressCollection? DhcpServers { get; private set; }
/// <summary>
/// Gets the list of DNS server IPs as string
/// </summary>
internal IPAddressCollection? DnsServers { get; private set; }
/// <summary>
/// Gets the list of WINS server IPs as string
/// </summary>
internal IPAddressCollection? WinsServers { get; private set; }
private static readonly CompositeFormat MicrosoftPluginSysGbps = CompositeFormat.Parse(Resources.Microsoft_plugin_sys_Gbps);
private static readonly CompositeFormat MicrosoftPluginSysMbps = CompositeFormat.Parse(Resources.Microsoft_plugin_sys_Mbps);
/// <summary>
/// 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()"/>.
/// </summary>
/// <param name="networkInterface">Network interface of the connection</param>
private NetworkConnectionProperties(NetworkInterface networkInterface)
{
// Setting adapter properties
Adapter = networkInterface.Description;
PhysicalAddress = networkInterface.GetPhysicalAddress().ToString();
Type = networkInterface.NetworkInterfaceType;
Speed = networkInterface.Speed;
State = networkInterface.OperationalStatus;
// Connection properties
ConnectionName = networkInterface.Name;
if (State == OperationalStatus.Up)
{
Suffix = networkInterface.GetIPProperties().DnsSuffix;
SetIpProperties(networkInterface.GetIPProperties());
}
}
/// <summary>
/// Creates a list with all network adapters and their properties
/// </summary>
/// <returns>List containing all network adapters</returns>
internal static List<NetworkConnectionProperties> GetList()
{
var interfaces = NetworkInterface.GetAllNetworkInterfaces()
.Where(x => x.NetworkInterfaceType != NetworkInterfaceType.Loopback && x.GetPhysicalAddress() != null)
.Select(i => new NetworkConnectionProperties(i))
.OrderByDescending(i => i.IPv4) // list IPv4 first
.ThenBy(i => i.IPv6Primary) // then IPv6
.ToList();
return interfaces;
}
/// <summary>
/// Gets a formatted string with the adapter details
/// </summary>
/// <returns>String with the details</returns>
internal string GetAdapterDetails()
{
return $"{Resources.Microsoft_plugin_sys_AdapterName}: {Adapter}" +
$"\n{Resources.Microsoft_plugin_sys_PhysicalAddress}: {PhysicalAddress}" +
$"\n{Resources.Microsoft_plugin_sys_Speed}: {GetFormattedSpeedValue(Speed)}" +
$"\n{Resources.Microsoft_plugin_sys_Type}: {GetAdapterTypeAsString(Type)}" +
$"\n{Resources.Microsoft_plugin_sys_State}: " + (State == OperationalStatus.Up ? Resources.Microsoft_plugin_sys_Connected : Resources.Microsoft_plugin_sys_Disconnected) +
$"\n{Resources.Microsoft_plugin_sys_ConnectionName}: {ConnectionName}";
}
/// <summary>
/// Returns a formatted string with the connection details
/// </summary>
/// <returns>String with the details</returns>
internal string GetConnectionDetails()
{
return $"{Resources.Microsoft_plugin_sys_ConnectionName}: {ConnectionName}" +
$"\n{Resources.Microsoft_plugin_sys_State}: " + (State == OperationalStatus.Up ? Resources.Microsoft_plugin_sys_Connected : Resources.Microsoft_plugin_sys_Disconnected) +
$"\n{Resources.Microsoft_plugin_sys_Type}: {GetAdapterTypeAsString(Type)}" +
$"\n{Resources.Microsoft_plugin_sys_Suffix}: {Suffix}" +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Ip4Address}: ", IPv4) +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Ip4SubnetMask}: ", IPv4Mask) +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Ip6Address}:\n\t", IPv6Global) +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Ip6Temp}:\n\t", IPv6Temporary) +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Ip6Link}:\n\t", IPv6LinkLocal) +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Ip6Site}:\n\t", IPv6SiteLocal) +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Ip6Unique}:\n\t", IPv6UniqueLocal) +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Gateways}:\n\t", Gateways) +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Dhcp}:\n\t", DhcpServers == null ? string.Empty : DhcpServers) +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Dns}:\n\t", DnsServers == null ? string.Empty : DnsServers) +
CreateIpInfoForDetailsText($"{Resources.Microsoft_plugin_sys_Wins}:\n\t", WinsServers == null ? string.Empty : WinsServers) +
$"\n\n{Resources.Microsoft_plugin_sys_AdapterName}: {Adapter}" +
$"\n{Resources.Microsoft_plugin_sys_PhysicalAddress}: {PhysicalAddress}" +
$"\n{Resources.Microsoft_plugin_sys_Speed}: {GetFormattedSpeedValue(Speed)}";
}
/// <summary>
/// Set the ip address properties of the <see cref="NetworkConnectionProperties"/> instance.
/// </summary>
/// <param name="properties">Element of the type <see cref="IPInterfaceProperties"/>.</param>
private void SetIpProperties(IPInterfaceProperties properties)
{
DateTime t = DateTime.Now;
UnicastIPAddressInformationCollection ipList = properties.UnicastAddresses;
GatewayIPAddressInformationCollection gwList = properties.GatewayAddresses;
DhcpServers = properties.DhcpServerAddresses;
DnsServers = properties.DnsAddresses;
WinsServers = properties.WinsServersAddresses;
for (var i = 0; i < ipList.Count; i++)
{
IPAddress ip = ipList[i].Address;
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
IPv4 = ip.ToString();
IPv4Mask = ipList[i].IPv4Mask.ToString();
}
else if (ip.AddressFamily == AddressFamily.InterNetworkV6)
{
if (string.IsNullOrEmpty(IPv6Primary))
{
IPv6Primary = ip.ToString();
}
if (ip.IsIPv6LinkLocal)
{
IPv6LinkLocal = ip.ToString();
}
else if (ip.IsIPv6SiteLocal)
{
IPv6SiteLocal = ip.ToString();
}
else if (ip.IsIPv6UniqueLocal)
{
IPv6UniqueLocal = ip.ToString();
}
else if (ipList[i].SuffixOrigin == SuffixOrigin.Random)
{
IPv6Temporary = ip.ToString();
}
else
{
IPv6Global = ip.ToString();
}
}
}
for (var i = 0; i < gwList.Count; i++)
{
Gateways.Add(gwList[i].Address);
}
Debug.Print($"time for getting ips: {DateTime.Now - t}");
}
/// <summary>
/// Gets the interface type as string
/// </summary>
/// <param name="type">The type to convert</param>
/// <returns>A string indicating the interface type</returns>
private string GetAdapterTypeAsString(NetworkInterfaceType type)
{
switch (type)
{
case NetworkInterfaceType.Wman:
case NetworkInterfaceType.Wwanpp:
case NetworkInterfaceType.Wwanpp2:
return Resources.Microsoft_plugin_sys_MobileBroadband;
case NetworkInterfaceType.Wireless80211:
return Resources.Microsoft_plugin_sys_WirelessLan;
case NetworkInterfaceType.Loopback:
return Resources.Microsoft_plugin_sys_Loopback;
case NetworkInterfaceType.Tunnel:
return Resources.Microsoft_plugin_sys_TunnelConnection;
case NetworkInterfaceType.Unknown:
return Resources.Microsoft_plugin_sys_Unknown;
default:
return Resources.Microsoft_plugin_sys_Cable;
}
}
/// <summary>
/// Gets the speed as formatted text value
/// </summary>
/// <param name="speed">The adapter speed as <see langword="long"/>.</param>
/// <returns>A formatted string like `100 MB/s`</returns>
private static string GetFormattedSpeedValue(long speed)
{
return (speed >= 1000000000) ? string.Format(CultureInfo.InvariantCulture, MicrosoftPluginSysGbps, speed / 1000000000) : string.Format(CultureInfo.InvariantCulture, MicrosoftPluginSysMbps, speed / 1000000);
}
/// <summary>
/// Returns IP info or an empty string
/// </summary>
/// <param name="title">Descriptive header for the information.</param>
/// <param name="property">IP value as <see cref="string"/> or <see cref="List{String}"/>.</param>
/// <returns>Formatted string or an empty string.</returns>
/// <exception cref="ArgumentException">If the parameter <paramref name="property"/> is not of the type <see cref="string"/> or <see cref="List{String}"/>.</exception>
private static string CreateIpInfoForDetailsText(string title, dynamic property)
{
switch (property)
{
case string:
return $"\n{title}{property}";
case List<string> listString:
return listString.Count == 0 ? string.Empty : $"\n{title}{string.Join("\n\t", property)}";
case List<IPAddress> listIP:
return listIP.Count == 0 ? string.Empty : $"\n{title}{string.Join("\n\t", property)}";
case IPAddressCollection collectionIP:
return collectionIP.Count == 0 ? string.Empty : $"\n{title}{string.Join("\n\t", property)}";
case null:
return string.Empty;
default:
throw new ArgumentException($"'{property}' is not of type 'string', 'List<string>', 'List<IPAddress>' or 'IPAddressCollection'.", nameof(property));
}
}
}

View File

@@ -0,0 +1,49 @@
// 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.ComponentModel;
using System.Diagnostics;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.System.Helpers;
public static partial class OpenInShellHelper
{
public static bool OpenInShell(string path, string? arguments = null, string? workingDir = null, ShellRunAsType runAs = ShellRunAsType.None, bool runWithHiddenWindow = false)
{
using var process = new Process();
process.StartInfo.FileName = path;
process.StartInfo.WorkingDirectory = string.IsNullOrWhiteSpace(workingDir) ? string.Empty : workingDir;
process.StartInfo.Arguments = string.IsNullOrWhiteSpace(arguments) ? string.Empty : arguments;
process.StartInfo.WindowStyle = runWithHiddenWindow ? ProcessWindowStyle.Hidden : ProcessWindowStyle.Normal;
process.StartInfo.UseShellExecute = true;
if (runAs == ShellRunAsType.Administrator)
{
process.StartInfo.Verb = "RunAs";
}
else if (runAs == ShellRunAsType.OtherUser)
{
process.StartInfo.Verb = "RunAsUser";
}
try
{
process.Start();
return true;
}
catch (Win32Exception ex)
{
ExtensionHost.LogMessage(new LogMessage() { Message = $"Unable to open {path}: {ex.Message}" });
return false;
}
}
public enum ShellRunAsType
{
None,
Administrator,
OtherUser,
}
}

View File

@@ -0,0 +1,52 @@
// 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.Threading.Tasks;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.System;
using static Microsoft.CmdPal.Ext.System.Helpers.MessageBoxHelper;
namespace Microsoft.CmdPal.Ext.System.Helpers;
internal static class ResultHelper
{
public static bool ExecutingEmptyRecycleBinTask { get; set; }
/// <summary>
/// Method to process the empty recycle bin command in a separate task
/// </summary>
public static void EmptyRecycleBinTask(bool settingEmptyRBSuccesMsg)
{
ExecutingEmptyRecycleBinTask = true;
// https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shemptyrecyclebina/
// http://www.pinvoke.net/default.aspx/shell32/SHEmptyRecycleBin.html/
// If the recycle bin is already empty, it will return -2147418113 (0x8000FFFF (E_UNEXPECTED))
// If the user canceled the deletion task it will return 2147943623 (0x800704C7 (E_CANCELLED - The operation was canceled by the user.))
// On success it will return 0 (S_OK)
var result = NativeMethods.SHEmptyRecycleBin(IntPtr.Zero, 0);
if (result == (uint)HRESULT.E_UNEXPECTED)
{
_ = MessageBoxHelper.Show(Resources.Microsoft_plugin_sys_RecycleBin_IsEmpty, "Plugin: " + Resources.Microsoft_plugin_sys_plugin_name, IconType.Info, MessageBoxType.OK);
}
else if (result != (uint)HRESULT.S_OK && result != (uint)HRESULT.E_CANCELLED)
{
var errorDesc = Win32Helpers.MessageFromHResult((int)result);
var name = "Plugin: " + Resources.Microsoft_plugin_sys_plugin_name;
var message = $"{Resources.Microsoft_plugin_sys_RecycleBin_ErrorMsg} {errorDesc}";
ExtensionHost.LogMessage(new LogMessage() { Message = message + " - Please refer to https://msdn.microsoft.com/library/windows/desktop/aa378137 for more information." });
_ = MessageBoxHelper.Show(message, name, IconType.Error, MessageBoxType.OK);
}
if (result == (uint)HRESULT.S_OK && settingEmptyRBSuccesMsg)
{
_ = MessageBoxHelper.Show(Resources.Microsoft_plugin_sys_RecycleBin_EmptySuccessMessage, "Plugin: " + Resources.Microsoft_plugin_sys_plugin_name, IconType.Info, MessageBoxType.OK);
}
ExecutingEmptyRecycleBinTask = false;
}
}

View File

@@ -0,0 +1,71 @@
// 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.IO;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.System.Helpers;
public class SettingsManager : JsonSettingsManager
{
private static readonly string _namespace = "system";
private static string Namespaced(string propertyName) => $"{_namespace}.{propertyName}";
private readonly ToggleSetting _showDialogToConfirmCommand = new(
Namespaced(nameof(ShowDialogToConfirmCommand)),
Resources.confirm_system_commands,
Resources.confirm_system_commands,
false); // TODO -- double check default value
private readonly ToggleSetting _showSuccessMessageAfterEmptyingRecycleBin = new(
Namespaced(nameof(ShowSuccessMessageAfterEmptyingRecycleBin)),
Resources.Microsoft_plugin_sys_RecycleBin_ShowEmptySuccessMessage,
Resources.Microsoft_plugin_sys_RecycleBin_ShowEmptySuccessMessage,
false); // TODO -- double check default value
private readonly ToggleSetting _showSeparateResultForEmptyRecycleBin = new(
Namespaced(nameof(ShowSeparateResultForEmptyRecycleBin)),
Resources.Microsoft_plugin_sys_RecycleBin_ShowEmptySeparate,
Resources.Microsoft_plugin_sys_RecycleBin_ShowEmptySeparate,
true); // TODO -- double check default value
private readonly ToggleSetting _hideDisconnectedNetworkInfo = new(
Namespaced(nameof(HideDisconnectedNetworkInfo)),
Resources.Microsoft_plugin_ext_settings_hideDisconnectedNetworkInfo,
Resources.Microsoft_plugin_ext_settings_hideDisconnectedNetworkInfo,
true); // TODO -- double check default value
public bool ShowDialogToConfirmCommand => _showDialogToConfirmCommand.Value;
public bool ShowSuccessMessageAfterEmptyingRecycleBin => _showSuccessMessageAfterEmptyingRecycleBin.Value;
public bool ShowSeparateResultForEmptyRecycleBin => _showSeparateResultForEmptyRecycleBin.Value;
public bool HideDisconnectedNetworkInfo => _hideDisconnectedNetworkInfo.Value;
internal static string SettingsJsonPath()
{
var directory = Utilities.BaseSettingsPath("Microsoft.CmdPal");
Directory.CreateDirectory(directory);
// now, the state is just next to the exe
return Path.Combine(directory, "settings.json");
}
public SettingsManager()
{
FilePath = SettingsJsonPath();
Settings.Add(_showDialogToConfirmCommand);
Settings.Add(_showSuccessMessageAfterEmptyingRecycleBin);
Settings.Add(_showSeparateResultForEmptyRecycleBin);
Settings.Add(_hideDisconnectedNetworkInfo);
// Load settings from file upon initialization
LoadSettings();
Settings.SettingsChanged += (s, a) => this.SaveSettings();
}
}

View File

@@ -0,0 +1,30 @@
// 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.
namespace Microsoft.CmdPal.Ext.System.Helpers;
internal sealed class SystemPluginContext
{
/// <summary>
/// Gets or sets the type of the result
/// </summary>
public ResultContextType Type { get; set; }
/// <summary>
/// Gets or sets the context data for the command/results
/// </summary>
public string Data { get; set; } = string.Empty;
/// <summary>
/// Gets or sets an additional result name for searching
/// </summary>
public string SearchTag { get; set; } = string.Empty;
}
internal enum ResultContextType
{
Command, // Reserved for later usage
NetworkAdapterInfo,
RecycleBinCommand,
}

View File

@@ -0,0 +1,57 @@
// 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.Runtime.InteropServices;
namespace Microsoft.CmdPal.Ext.System.Helpers;
public static class Win32Helpers
{
/// <summary>
/// Detects the type of system firmware which is equal to the boot type by calling the method <see cref="NativeMethods.GetFirmwareType"/>.
/// </summary>
/// <returns>Firmware type like Uefi or Bios.</returns>
public static FirmwareType GetSystemFirmwareType()
{
FirmwareType firmwareType = default;
_ = NativeMethods.GetFirmwareType(ref firmwareType);
return firmwareType;
}
/// <summary>
/// Returns the last Win32 Error code thrown by a native method if enabled for this method.
/// </summary>
/// <returns>The error code as int value.</returns>
public static int GetLastError()
{
return Marshal.GetLastPInvokeError();
}
/// <summary>
/// Validate that the handle is not null and close it.
/// </summary>
/// <param name="handle">Handle to close.</param>
/// <returns>Zero if native method fails and nonzero if the native method succeeds.</returns>
public static bool CloseHandleIfNotNull(IntPtr handle)
{
if (handle == IntPtr.Zero)
{
// Return true if there is nothing to close.
return true;
}
return NativeMethods.CloseHandle(handle);
}
/// <summary>
/// Gets the description for an HRESULT error code.
/// </summary>
/// <param name="hr">The HRESULT number</param>
/// <returns>A string containing the description.</returns>
public static string MessageFromHResult(int hr)
{
return Marshal.GetExceptionForHR(hr)?.Message ?? string.Empty;
}
}

View File

@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\Common.Dotnet.CsWinRT.props" />
<PropertyGroup>
<Nullable>enable</Nullable>
<RootNamespace>Microsoft.CmdPal.Ext.System</RootNamespace>
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<Generator>PublicResXFileCodeGenerator</Generator>
<CustomToolNamespace>Microsoft.CmdPal.Ext.System</CustomToolNamespace>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,33 @@
// 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 Microsoft.CmdPal.Ext.System.Helpers;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.System;
public sealed partial class OpenInShellCommand : InvokableCommand
{
public OpenInShellCommand(string name, string path, string? arguments = null, string? workingDir = null, OpenInShellHelper.ShellRunAsType runAs = OpenInShellHelper.ShellRunAsType.None, bool runWithHiddenWindow = false)
{
Name = name;
_path = path;
_arguments = arguments;
_workingDir = workingDir;
_runAs = runAs;
_runWithHiddenWindow = runWithHiddenWindow;
}
public override CommandResult Invoke()
{
OpenInShellHelper.OpenInShell(_path, _arguments);
return CommandResult.Dismiss();
}
private string _path;
private string? _workingDir;
private string? _arguments;
private OpenInShellHelper.ShellRunAsType _runAs;
private bool _runWithHiddenWindow;
}

View File

@@ -0,0 +1,24 @@
// 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 Microsoft.CmdPal.Ext.System.Helpers;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.System.Pages;
public sealed partial class SystemCommandPage : ListPage
{
private SettingsManager _settingsManager;
public SystemCommandPage(SettingsManager settingsManager)
{
Title = Resources.Microsoft_plugin_ext_system_page_name;
Icon = new IconInfo("\uE72E");
_settingsManager = settingsManager;
ShowDetails = true;
}
public override IListItem[] GetItems() => Commands.GetAllCommands(_settingsManager).ToArray();
}

View File

@@ -0,0 +1,810 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Microsoft.CmdPal.Ext.System {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CmdPal.Ext.System.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Show a dialog to confirm system commands.
/// </summary>
public static string confirm_system_commands {
get {
return ResourceManager.GetString("confirm_system_commands", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Do you want to empty your Recycle Bin?.
/// </summary>
public static string EmptyRecycleBin_ConfirmationDialog_Description {
get {
return ResourceManager.GetString("EmptyRecycleBin_ConfirmationDialog_Description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Empty.
/// </summary>
public static string Microsoft_plugin_command_name_empty {
get {
return ResourceManager.GetString("Microsoft_plugin_command_name_empty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hibernate.
/// </summary>
public static string Microsoft_plugin_command_name_hibernate {
get {
return ResourceManager.GetString("Microsoft_plugin_command_name_hibernate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lock.
/// </summary>
public static string Microsoft_plugin_command_name_lock {
get {
return ResourceManager.GetString("Microsoft_plugin_command_name_lock", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open.
/// </summary>
public static string Microsoft_plugin_command_name_open {
get {
return ResourceManager.GetString("Microsoft_plugin_command_name_open", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Reboot.
/// </summary>
public static string Microsoft_plugin_command_name_reboot {
get {
return ResourceManager.GetString("Microsoft_plugin_command_name_reboot", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Restart.
/// </summary>
public static string Microsoft_plugin_command_name_restart {
get {
return ResourceManager.GetString("Microsoft_plugin_command_name_restart", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Shutdown.
/// </summary>
public static string Microsoft_plugin_command_name_shutdown {
get {
return ResourceManager.GetString("Microsoft_plugin_command_name_shutdown", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Sign Out.
/// </summary>
public static string Microsoft_plugin_command_name_signout {
get {
return ResourceManager.GetString("Microsoft_plugin_command_name_signout", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Sleep.
/// </summary>
public static string Microsoft_plugin_command_name_sleep {
get {
return ResourceManager.GetString("Microsoft_plugin_command_name_sleep", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Connection Details.
/// </summary>
public static string Microsoft_plugin_ext_connection_details {
get {
return ResourceManager.GetString("Microsoft_plugin_ext_connection_details", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Copy to clipboard.
/// </summary>
public static string Microsoft_plugin_ext_copy {
get {
return ResourceManager.GetString("Microsoft_plugin_ext_copy", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hide disconnected network info.
/// </summary>
public static string Microsoft_plugin_ext_settings_hideDisconnectedNetworkInfo {
get {
return ResourceManager.GetString("Microsoft_plugin_ext_settings_hideDisconnectedNetworkInfo", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Windows System Command.
/// </summary>
public static string Microsoft_plugin_ext_system_page_name {
get {
return ResourceManager.GetString("Microsoft_plugin_ext_system_page_name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Adapter name.
/// </summary>
public static string Microsoft_plugin_sys_AdapterName {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_AdapterName", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cable.
/// </summary>
public static string Microsoft_plugin_sys_Cable {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Cable", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Please confirm..
/// </summary>
public static string Microsoft_plugin_sys_confirmation {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_confirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Connected.
/// </summary>
public static string Microsoft_plugin_sys_Connected {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Connected", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Connection name.
/// </summary>
public static string Microsoft_plugin_sys_ConnectionName {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_ConnectionName", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to DHCP servers.
/// </summary>
public static string Microsoft_plugin_sys_Dhcp {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Dhcp", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Disconnected.
/// </summary>
public static string Microsoft_plugin_sys_Disconnected {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Disconnected", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to DNS servers.
/// </summary>
public static string Microsoft_plugin_sys_Dns {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Dns", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Default Gateway.
/// </summary>
public static string Microsoft_plugin_sys_Gateways {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Gateways", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} Gbps.
/// </summary>
public static string Microsoft_plugin_sys_Gbps {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Gbps", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hibernate.
/// </summary>
public static string Microsoft_plugin_sys_hibernate {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_hibernate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You are about to put this computer into hibernation, are you sure?.
/// </summary>
public static string Microsoft_plugin_sys_hibernate_confirmation {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_hibernate_confirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hibernate computer.
/// </summary>
public static string Microsoft_plugin_sys_hibernate_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_hibernate_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IPv4 address of {0}.
/// </summary>
public static string Microsoft_plugin_sys_ip4_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_ip4_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IPv4 address.
/// </summary>
public static string Microsoft_plugin_sys_Ip4Address {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Ip4Address", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IPv4 subnet mask.
/// </summary>
public static string Microsoft_plugin_sys_Ip4SubnetMask {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Ip4SubnetMask", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IPv6 address of {0}.
/// </summary>
public static string Microsoft_plugin_sys_ip6_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_ip6_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IPv6 Address.
/// </summary>
public static string Microsoft_plugin_sys_Ip6Address {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Ip6Address", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IPv6 link-local address.
/// </summary>
public static string Microsoft_plugin_sys_Ip6Link {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Ip6Link", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IPv6 site-local address.
/// </summary>
public static string Microsoft_plugin_sys_Ip6Site {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Ip6Site", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IPv6 temporary address.
/// </summary>
public static string Microsoft_plugin_sys_Ip6Temp {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Ip6Temp", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IPv6 unique local address.
/// </summary>
public static string Microsoft_plugin_sys_Ip6Unique {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Ip6Unique", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lock.
/// </summary>
public static string Microsoft_plugin_sys_lock {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_lock", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You are about to lock this computer, are you sure?.
/// </summary>
public static string Microsoft_plugin_sys_lock_confirmation {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_lock_confirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lock computer.
/// </summary>
public static string Microsoft_plugin_sys_lock_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_lock_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Loopback.
/// </summary>
public static string Microsoft_plugin_sys_Loopback {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Loopback", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to MAC address of {0} ({1}).
/// </summary>
public static string Microsoft_plugin_sys_mac_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_mac_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} Mbps.
/// </summary>
public static string Microsoft_plugin_sys_Mbps {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Mbps", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Mobile broadband.
/// </summary>
public static string Microsoft_plugin_sys_MobileBroadband {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_MobileBroadband", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Physical address (MAC).
/// </summary>
public static string Microsoft_plugin_sys_PhysicalAddress {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_PhysicalAddress", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Windows System Commands.
/// </summary>
public static string Microsoft_plugin_sys_plugin_name {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_plugin_name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Recycle Bin.
/// </summary>
public static string Microsoft_plugin_sys_RecycleBin {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Empty Recycle Bin (Shift+Delete).
/// </summary>
public static string Microsoft_plugin_sys_RecycleBin_contextMenu {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_contextMenu", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open the Recycle Bin.
/// </summary>
public static string Microsoft_plugin_sys_RecycleBin_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Recycle Bin emptied successfully..
/// </summary>
public static string Microsoft_plugin_sys_RecycleBin_EmptySuccessMessage {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_EmptySuccessMessage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The task to empty the Recycle Bin is already running..
/// </summary>
public static string Microsoft_plugin_sys_RecycleBin_EmptyTaskRunning {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_EmptyTaskRunning", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Failed to empty the Recycle Bin:.
/// </summary>
public static string Microsoft_plugin_sys_RecycleBin_ErrorMsg {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_ErrorMsg", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Recycle Bin is empty..
/// </summary>
public static string Microsoft_plugin_sys_RecycleBin_IsEmpty {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_IsEmpty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Empty Recycle Bin.
/// </summary>
public static string Microsoft_plugin_sys_RecycleBin_searchTag {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_searchTag", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show separate result for Empty Recycle Bin command.
/// </summary>
public static string Microsoft_plugin_sys_RecycleBin_ShowEmptySeparate {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_ShowEmptySeparate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show a success message after emptying the Recycle Bin.
/// </summary>
public static string Microsoft_plugin_sys_RecycleBin_ShowEmptySuccessMessage {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBin_ShowEmptySuccessMessage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Empty Recycle Bin.
/// </summary>
public static string Microsoft_plugin_sys_RecycleBinEmpty_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBinEmpty_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Empty Recycle Bin.
/// </summary>
public static string Microsoft_plugin_sys_RecycleBinEmptyResult {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBinEmptyResult", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open Recycle Bin.
/// </summary>
public static string Microsoft_plugin_sys_RecycleBinOpen {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_RecycleBinOpen", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Restart.
/// </summary>
public static string Microsoft_plugin_sys_restart_computer {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_restart_computer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You are about to restart this computer, are you sure?.
/// </summary>
public static string Microsoft_plugin_sys_restart_computer_confirmation {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_restart_computer_confirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Restart computer.
/// </summary>
public static string Microsoft_plugin_sys_restart_computer_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_restart_computer_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ip; mac; address.
/// </summary>
public static string Microsoft_plugin_sys_Search_NetworkKeywordList {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Search_NetworkKeywordList", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Shutdown.
/// </summary>
public static string Microsoft_plugin_sys_shutdown_computer {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_shutdown_computer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You are about to shut down this computer, are you sure?.
/// </summary>
public static string Microsoft_plugin_sys_shutdown_computer_confirmation {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_shutdown_computer_confirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Shutdown computer.
/// </summary>
public static string Microsoft_plugin_sys_shutdown_computer_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_shutdown_computer_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Sign out.
/// </summary>
public static string Microsoft_plugin_sys_sign_out {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_sign_out", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You are about to sign out of this computer, are you sure?.
/// </summary>
public static string Microsoft_plugin_sys_sign_out_confirmation {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_sign_out_confirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Sign out of computer.
/// </summary>
public static string Microsoft_plugin_sys_sign_out_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_sign_out_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Sleep.
/// </summary>
public static string Microsoft_plugin_sys_sleep {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_sleep", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You are about to put this computer to sleep, are you sure?.
/// </summary>
public static string Microsoft_plugin_sys_sleep_confirmation {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_sleep_confirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Put computer to sleep.
/// </summary>
public static string Microsoft_plugin_sys_sleep_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_sleep_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Speed.
/// </summary>
public static string Microsoft_plugin_sys_Speed {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Speed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to State.
/// </summary>
public static string Microsoft_plugin_sys_State {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_State", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to DNS Suffix.
/// </summary>
public static string Microsoft_plugin_sys_Suffix {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Suffix", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Tunnel.
/// </summary>
public static string Microsoft_plugin_sys_TunnelConnection {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_TunnelConnection", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Type.
/// </summary>
public static string Microsoft_plugin_sys_Type {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Type", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to UEFI Firmware Settings.
/// </summary>
public static string Microsoft_plugin_sys_uefi {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_uefi", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You are about to reboot this computer into UEFI Firmware Settings menu, are you sure?.
/// </summary>
public static string Microsoft_plugin_sys_uefi_confirmation {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_uefi_confirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Reboot computer into UEFI Firmware Settings (Requires administrative permissions.).
/// </summary>
public static string Microsoft_plugin_sys_uefi_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_uefi_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unknown.
/// </summary>
public static string Microsoft_plugin_sys_Unknown {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Unknown", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to WINS servers.
/// </summary>
public static string Microsoft_plugin_sys_Wins {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_Wins", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Wireless LAN.
/// </summary>
public static string Microsoft_plugin_sys_WirelessLan {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_WirelessLan", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,411 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="confirm_system_commands" xml:space="preserve">
<value>Show a dialog to confirm system commands</value>
</data>
<data name="EmptyRecycleBin_ConfirmationDialog_Description" xml:space="preserve">
<value>Do you want to empty your Recycle Bin?</value>
</data>
<data name="Microsoft_plugin_command_name_empty" xml:space="preserve">
<value>Empty</value>
<comment>Empty recycle bin command name</comment>
</data>
<data name="Microsoft_plugin_command_name_hibernate" xml:space="preserve">
<value>Hibernate</value>
</data>
<data name="Microsoft_plugin_command_name_lock" xml:space="preserve">
<value>Lock</value>
</data>
<data name="Microsoft_plugin_command_name_signout" xml:space="preserve">
<value>Sign Out</value>
</data>
<data name="Microsoft_plugin_command_name_open" xml:space="preserve">
<value>Open</value>
</data>
<data name="Microsoft_plugin_command_name_reboot" xml:space="preserve">
<value>Reboot</value>
</data>
<data name="Microsoft_plugin_command_name_restart" xml:space="preserve">
<value>Restart</value>
</data>
<data name="Microsoft_plugin_command_name_shutdown" xml:space="preserve">
<value>Shutdown</value>
</data>
<data name="Microsoft_plugin_ext_connection_details" xml:space="preserve">
<value>Connection Details</value>
</data>
<data name="Microsoft_plugin_ext_copy" xml:space="preserve">
<value>Copy to clipboard</value>
</data>
<data name="Microsoft_plugin_ext_settings_hideDisconnectedNetworkInfo" xml:space="preserve">
<value>Hide disconnected network info</value>
</data>
<data name="Microsoft_plugin_ext_system_page_name" xml:space="preserve">
<value>Windows System Command</value>
</data>
<data name="Microsoft_plugin_sys_AdapterName" xml:space="preserve">
<value>Adapter name</value>
</data>
<data name="Microsoft_plugin_sys_Cable" xml:space="preserve">
<value>Cable</value>
</data>
<data name="Microsoft_plugin_sys_confirmation" xml:space="preserve">
<value>Please confirm.</value>
<comment>Request confirmation</comment>
</data>
<data name="Microsoft_plugin_sys_Connected" xml:space="preserve">
<value>Connected</value>
</data>
<data name="Microsoft_plugin_sys_ConnectionName" xml:space="preserve">
<value>Connection name</value>
</data>
<data name="Microsoft_plugin_sys_Dhcp" xml:space="preserve">
<value>DHCP servers</value>
</data>
<data name="Microsoft_plugin_sys_Disconnected" xml:space="preserve">
<value>Disconnected</value>
</data>
<data name="Microsoft_plugin_sys_Dns" xml:space="preserve">
<value>DNS servers</value>
</data>
<data name="Microsoft_plugin_sys_Gateways" xml:space="preserve">
<value>Default Gateway</value>
</data>
<data name="Microsoft_plugin_sys_Gbps" xml:space="preserve">
<value>{0} Gbps</value>
<comment>Abbreviation of 'Gbits per seconds'. Don't translate the placeholder '{0}' as it is replaced in code.</comment>
</data>
<data name="Microsoft_plugin_sys_hibernate" xml:space="preserve">
<value>Hibernate</value>
<comment>This should align to the action in Windows of a hibernating your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_hibernate_confirmation" xml:space="preserve">
<value>You are about to put this computer into hibernation, are you sure?</value>
<comment>This should align to the action in Windows of a hibernating your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_hibernate_description" xml:space="preserve">
<value>Hibernate computer</value>
<comment>This should align to the action in Windows of a hibernating your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_Ip4Address" xml:space="preserve">
<value>IPv4 address</value>
</data>
<data name="Microsoft_plugin_sys_Ip4SubnetMask" xml:space="preserve">
<value>IPv4 subnet mask</value>
</data>
<data name="Microsoft_plugin_sys_ip4_description" xml:space="preserve">
<value>IPv4 address of {0}</value>
<comment>Don't translate the placeholder '{0}' as it is replaced in code.</comment>
</data>
<data name="Microsoft_plugin_sys_Ip6Address" xml:space="preserve">
<value>IPv6 Address</value>
</data>
<data name="Microsoft_plugin_sys_Ip6Link" xml:space="preserve">
<value>IPv6 link-local address</value>
</data>
<data name="Microsoft_plugin_sys_Ip6Site" xml:space="preserve">
<value>IPv6 site-local address</value>
</data>
<data name="Microsoft_plugin_sys_Ip6Temp" xml:space="preserve">
<value>IPv6 temporary address</value>
</data>
<data name="Microsoft_plugin_sys_Ip6Unique" xml:space="preserve">
<value>IPv6 unique local address</value>
</data>
<data name="Microsoft_plugin_sys_ip6_description" xml:space="preserve">
<value>IPv6 address of {0}</value>
<comment>Don't translate the placeholder '{0}' as it is replaced in code.</comment>
</data>
<data name="Microsoft_plugin_sys_lock" xml:space="preserve">
<value>Lock</value>
<comment>This should align to the action in Windows of a locking your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_lock_confirmation" xml:space="preserve">
<value>You are about to lock this computer, are you sure?</value>
<comment>This should align to the action in Windows of a locking your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_lock_description" xml:space="preserve">
<value>Lock computer</value>
<comment>This should align to the action in Windows of a locking your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_Loopback" xml:space="preserve">
<value>Loopback</value>
</data>
<data name="Microsoft_plugin_sys_mac_description" xml:space="preserve">
<value>MAC address of {0} ({1})</value>
<comment>Don't translate the placeholders '{0}' and '{1}' as they are replaced in code.</comment>
</data>
<data name="Microsoft_plugin_sys_Mbps" xml:space="preserve">
<value>{0} Mbps</value>
<comment>Abbreviation of 'Mbits per seconds'. Don't translate the placeholder '{0}' as it is replaced in code.</comment>
</data>
<data name="Microsoft_plugin_sys_MobileBroadband" xml:space="preserve">
<value>Mobile broadband</value>
</data>
<data name="Microsoft_plugin_sys_PhysicalAddress" xml:space="preserve">
<value>Physical address (MAC)</value>
</data>
<data name="Microsoft_plugin_sys_plugin_name" xml:space="preserve">
<value>Windows System Commands</value>
<comment>Windows operating system commands.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBin" xml:space="preserve">
<value>Recycle Bin</value>
<comment>Means the recycle bin folder in Explorer.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBinEmptyResult" xml:space="preserve">
<value>Empty Recycle Bin</value>
<comment>This should align to the action in Windows of emptying the recycle bin on your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBinEmpty_description" xml:space="preserve">
<value>Empty Recycle Bin</value>
<comment>This should align to the action in Windows of emptying the recycle bin on your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBinOpen" xml:space="preserve">
<value>Open Recycle Bin</value>
<comment>Means the recycle bin folder in Explorer.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBin_contextMenu" xml:space="preserve">
<value>Empty Recycle Bin (Shift+Delete)</value>
<comment>This should align to the action in Windows of emptying the recycle bin on your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBin_description" xml:space="preserve">
<value>Open the Recycle Bin</value>
<comment>This should align to the action in Windows of emptying the recycle bin on your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBin_EmptySuccessMessage" xml:space="preserve">
<value>Recycle Bin emptied successfully.</value>
<comment>Means the recycle bin folder in Explorer.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBin_EmptyTaskRunning" xml:space="preserve">
<value>The task to empty the Recycle Bin is already running.</value>
<comment>Means the recycle bin folder in Explorer.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBin_ErrorMsg" xml:space="preserve">
<value>Failed to empty the Recycle Bin:</value>
</data>
<data name="Microsoft_plugin_sys_RecycleBin_IsEmpty" xml:space="preserve">
<value>Recycle Bin is empty.</value>
<comment>Means the recycle bin folder in Explorer.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBin_searchTag" xml:space="preserve">
<value>Empty Recycle Bin</value>
<comment>This should align to the action in Windows of emptying the recycle bin on your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_RecycleBin_ShowEmptySeparate" xml:space="preserve">
<value>Show separate result for Empty Recycle Bin command</value>
</data>
<data name="Microsoft_plugin_sys_RecycleBin_ShowEmptySuccessMessage" xml:space="preserve">
<value>Show a success message after emptying the Recycle Bin</value>
<comment>Means the recycle bin folder in Explorer and "emptying" refers to "Empty Recycle Bin" command.</comment>
</data>
<data name="Microsoft_plugin_sys_restart_computer" xml:space="preserve">
<value>Restart</value>
<comment>This should align to the action in Windows of a restarting your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_restart_computer_confirmation" xml:space="preserve">
<value>You are about to restart this computer, are you sure?</value>
<comment>This should align to the action in Windows of a restarting your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_restart_computer_description" xml:space="preserve">
<value>Restart computer</value>
<comment>This should align to the action in Windows of a restarting your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_Search_NetworkKeywordList" xml:space="preserve">
<value>ip; mac; address</value>
<comment>Translate 'ip' as 'ip' and not as 'ip address'. Same for 'mac'.)</comment>
</data>
<data name="Microsoft_plugin_sys_shutdown_computer" xml:space="preserve">
<value>Shutdown</value>
<comment>This should align to the action in Windows of a shutting down your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_shutdown_computer_confirmation" xml:space="preserve">
<value>You are about to shut down this computer, are you sure?</value>
<comment>This should align to the action in Windows of a shutting down your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_shutdown_computer_description" xml:space="preserve">
<value>Shutdown computer</value>
<comment>This should align to the action in Windows of a shutting down your computer.</comment>
</data>
<data name="Microsoft_plugin_sys_sign_out" xml:space="preserve">
<value>Sign out</value>
<comment>This should align to the action in windows of a signing out back to the lock screen.</comment>
</data>
<data name="Microsoft_plugin_sys_sign_out_confirmation" xml:space="preserve">
<value>You are about to sign out of this computer, are you sure?</value>
<comment>This should align to the action in windows of a signing out back to the lock screen.</comment>
</data>
<data name="Microsoft_plugin_sys_sign_out_description" xml:space="preserve">
<value>Sign out of computer</value>
<comment>This should align to the action in windows of a signing out back to the lock screen.</comment>
</data>
<data name="Microsoft_plugin_sys_sleep" xml:space="preserve">
<value>Sleep</value>
<comment>This should align to the action in Windows of a making your computer go to sleep.</comment>
</data>
<data name="Microsoft_plugin_sys_sleep_confirmation" xml:space="preserve">
<value>You are about to put this computer to sleep, are you sure?</value>
<comment>This should align to the action in Windows of a making your computer go to sleep.</comment>
</data>
<data name="Microsoft_plugin_sys_sleep_description" xml:space="preserve">
<value>Put computer to sleep</value>
<comment>This should align to the action in Windows of a making your computer go to sleep.</comment>
</data>
<data name="Microsoft_plugin_sys_Speed" xml:space="preserve">
<value>Speed</value>
</data>
<data name="Microsoft_plugin_sys_State" xml:space="preserve">
<value>State</value>
</data>
<data name="Microsoft_plugin_sys_Suffix" xml:space="preserve">
<value>DNS Suffix</value>
</data>
<data name="Microsoft_plugin_sys_TunnelConnection" xml:space="preserve">
<value>Tunnel</value>
</data>
<data name="Microsoft_plugin_sys_Type" xml:space="preserve">
<value>Type</value>
<comment>Means type like category. Here it means network interface type (ethernet, wifi, ...).</comment>
</data>
<data name="Microsoft_plugin_sys_uefi" xml:space="preserve">
<value>UEFI Firmware Settings</value>
<comment>This should align to the action in Windows Recovery Environment that restart into uefi settings.</comment>
</data>
<data name="Microsoft_plugin_sys_uefi_confirmation" xml:space="preserve">
<value>You are about to reboot this computer into UEFI Firmware Settings menu, are you sure?</value>
<comment>This should align to the action in Windows Recovery Environment that restart into uefi settings.</comment>
</data>
<data name="Microsoft_plugin_sys_uefi_description" xml:space="preserve">
<value>Reboot computer into UEFI Firmware Settings (Requires administrative permissions.)</value>
<comment>This should align to the action in Windows Recovery Environment that restart into uefi settings.</comment>
</data>
<data name="Microsoft_plugin_sys_Unknown" xml:space="preserve">
<value>Unknown</value>
</data>
<data name="Microsoft_plugin_sys_Wins" xml:space="preserve">
<value>WINS servers</value>
</data>
<data name="Microsoft_plugin_sys_WirelessLan" xml:space="preserve">
<value>Wireless LAN</value>
</data>
<data name="Microsoft_plugin_command_name_sleep" xml:space="preserve">
<value>Sleep</value>
</data>
</root>

View File

@@ -0,0 +1,37 @@
// 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 Microsoft.CmdPal.Ext.System.Helpers;
using Microsoft.CmdPal.Ext.System.Pages;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.System;
public partial class SystemCommandExtensionProvider : CommandProvider
{
private readonly ICommandItem[] _commands;
private static readonly SettingsManager _settingsManager = new();
public static readonly SystemCommandPage Page = new(_settingsManager);
public SystemCommandExtensionProvider()
{
DisplayName = Resources.Microsoft_plugin_ext_system_page_name;
_commands = [
new CommandItem(Page)
{
Title = DisplayName,
Icon = Page.Icon,
MoreCommands = [new CommandContextItem(_settingsManager.Settings.SettingsPage)],
},
];
Icon = Page.Icon;
}
public override ICommandItem[] TopLevelCommands()
{
return _commands;
}
}

View File

@@ -0,0 +1,51 @@
// 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;
using System.Threading.Tasks;
using Microsoft.CmdPal.Ext.System.Helpers;
using Microsoft.CommandPalette.Extensions;
namespace Microsoft.CmdPal.Ext.System;
public sealed partial class SystemCommandsCache
{
public SystemCommandsCache(SettingsManager manager)
{
var list = new List<IListItem>();
var listLock = new object();
var a = Task.Run(() =>
{
var isBootedInUefiMode = Win32Helpers.GetSystemFirmwareType() == FirmwareType.Uefi;
var separateEmptyRB = manager.ShowSeparateResultForEmptyRecycleBin;
var confirmSystemCommands = manager.ShowDialogToConfirmCommand;
var showSuccessOnEmptyRB = manager.ShowSuccessMessageAfterEmptyingRecycleBin;
// normal system commands are fast and can be returned immediately
var systemCommands = Commands.GetSystemCommands(isBootedInUefiMode, separateEmptyRB, confirmSystemCommands, showSuccessOnEmptyRB);
lock (listLock)
{
list.AddRange(systemCommands);
}
});
var b = Task.Run(() =>
{
// Network (ip and mac) results are slow with many network cards and returned delayed.
// On global queries the first word/part has to be 'ip', 'mac' or 'address' for network results
var networkConnectionResults = Commands.GetNetworkConnectionResults(manager);
lock (listLock)
{
list.AddRange(networkConnectionResults);
}
});
Task.WaitAll(a, b);
CachedCommands = list.ToArray();
}
public IListItem[] CachedCommands { get; }
}