[PT Run] Sys Plugin Port from Wox.Plugins.Sys (#8062)

* Initial Port of Wox.Plugin.Sys

* Add Unit Tests for Microsoft.Plugin.Sys

* Modified Microsoft.Plugin.Sys.UnitTests Properties

* Microsoft.Plugin.Sys x64 Launch

* Fix Styling for Microsoft.Plugin.Sys.UnitTests

* Fixed Misspelling

* Remove Any CPU from Configuration Manager

* Removed Old Icons and Added New Images

* Updated Titles for Localization and Added & Updated Light/Dark Theme Icons

* Added Light/Dark Icon Theme Unit Tests

* Updated QueryTest Expected Results for Microsoft.Plugin.Sys.UnitTests

* Added Spell-Check Expects for Microsoft.Plugin.Sys

* Updated Spell-Check Expects for Microsoft.Plugin.Sys

* Corrected Format in Microsoft.Plugin.Sys

* Corrected Descriptions and Added Comments for Localization

* Added StyleCop and Version Props

* Corrected Format of Microsoft.Plugin.Sys.Main

* Updated Unit Tests for Microsoft.Plugin.Sys

* Updated Spell-Check Expects for Microsoft.Plugin.Sys

* fixing build issue

Co-authored-by: Clint Rutkas <clint@rutkas.com>
This commit is contained in:
Benjamin Hooper 2020-11-26 03:35:48 -06:00 committed by GitHub
parent 3bd18af816
commit 9757a4574f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 949 additions and 0 deletions

View file

@ -662,6 +662,7 @@ Elems
ELogo
elseif
Emoji
emptyrecyclebin
ENABLEDPOPUP
endforeach
endif
@ -698,6 +699,13 @@ eventdatemissed
eventlog
everytime
evt
EWX
EWXFORCE
EWXFORCEIFHUNG
EWXLOGOFF
EWXPOWEROFF
EWXREBOOT
EWXSHUTDOWN
examplehandler
examplepowertoy
EXCLUDEFILES
@ -773,6 +781,7 @@ FOFX
FOLDERID
folderpath
fonttbl
FORCEIFHUNG
FORCEOFFLINE
foreach
formatetc
@ -1690,6 +1699,7 @@ Portugu
posix
powerappscds
powerlauncher
POWEROFF
powerpreview
powerrename
POWERRENAMETEST
@ -1698,6 +1708,7 @@ powertoy
POWERTOYNAME
powertoysinterop
powertoyssetup
Powrprof
ppenum
ppidl
pprm

View file

@ -271,6 +271,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest-ColorPickerUI", "s
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logging", "src\logging\logging.vcxproj", "{7E1E3F13-2BD6-3F75-A6A7-873A2B55C60F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Plugin.Sys", "src\modules\launcher\Plugins\Microsoft.Plugin.Sys\Microsoft.Plugin.Sys.csproj", "{FD8EB419-FF9C-4D88-BB6F-BF6CED37747B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Plugin.Sys.UnitTests", "src\modules\launcher\Plugins\Microsoft.Plugin.Sys.UnitTests\Microsoft.Plugin.Sys.UnitTests.csproj", "{DA5A6FE9-0040-40CC-83CC-764AE5306590}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logger", "src\common\logger\logger.vcxproj", "{D9B8FC84-322A-4F9F-BBB9-20915C47DDFD}"
EndProject
Global
@ -551,6 +555,14 @@ Global
{7E1E3F13-2BD6-3F75-A6A7-873A2B55C60F}.Debug|x64.Build.0 = Debug|x64
{7E1E3F13-2BD6-3F75-A6A7-873A2B55C60F}.Release|x64.ActiveCfg = Release|x64
{7E1E3F13-2BD6-3F75-A6A7-873A2B55C60F}.Release|x64.Build.0 = Release|x64
{FD8EB419-FF9C-4D88-BB6F-BF6CED37747B}.Debug|x64.ActiveCfg = Debug|x64
{FD8EB419-FF9C-4D88-BB6F-BF6CED37747B}.Debug|x64.Build.0 = Debug|x64
{FD8EB419-FF9C-4D88-BB6F-BF6CED37747B}.Release|x64.ActiveCfg = Release|x64
{FD8EB419-FF9C-4D88-BB6F-BF6CED37747B}.Release|x64.Build.0 = Release|x64
{DA5A6FE9-0040-40CC-83CC-764AE5306590}.Debug|x64.ActiveCfg = Debug|x64
{DA5A6FE9-0040-40CC-83CC-764AE5306590}.Debug|x64.Build.0 = Debug|x64
{DA5A6FE9-0040-40CC-83CC-764AE5306590}.Release|x64.ActiveCfg = Release|x64
{DA5A6FE9-0040-40CC-83CC-764AE5306590}.Release|x64.Build.0 = Release|x64
{D9B8FC84-322A-4F9F-BBB9-20915C47DDFD}.Debug|x64.ActiveCfg = Debug|x64
{D9B8FC84-322A-4F9F-BBB9-20915C47DDFD}.Debug|x64.Build.0 = Debug|x64
{D9B8FC84-322A-4F9F-BBB9-20915C47DDFD}.Release|x64.ActiveCfg = Release|x64
@ -634,6 +646,8 @@ Global
{4FA206A5-F69F-4193-BF8F-F6EEB496734C} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
{090CD7B7-3B0C-4D1D-BC98-83EB5D799BC1} = {1D78B84B-CA39-406C-98F4-71F7EC266CC0}
{7E1E3F13-2BD6-3F75-A6A7-873A2B55C60F} = {1AFB6476-670D-4E80-A464-657E01DFF482}
{FD8EB419-FF9C-4D88-BB6F-BF6CED37747B} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
{DA5A6FE9-0040-40CC-83CC-764AE5306590} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
{D9B8FC84-322A-4F9F-BBB9-20915C47DDFD} = {1AFB6476-670D-4E80-A464-657E01DFF482}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution

View file

@ -0,0 +1,67 @@
// 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.Linq;
using System.Text;
using Mono.Collections.Generic;
using Moq;
using NUnit.Framework;
using Wox.Infrastructure;
using Wox.Plugin;
namespace Microsoft.Plugin.Sys.UnitTests
{
public class ImageTests
{
[SetUp]
public void Setup()
{
StringMatcher.Instance = new StringMatcher();
}
[TestCase("shutdown", "Images\\shutdown.dark.png")]
[TestCase("restart", "Images\\restart.dark.png")]
[TestCase("sign out", "Images\\logoff.dark.png")]
[TestCase("lock", "Images\\lock.dark.png")]
[TestCase("sleep", "Images\\sleep.dark.png")]
[TestCase("hibernate", "Images\\sleep.dark.png")]
[TestCase("empty recycle", "Images\\recyclebin.dark.png")]
public void IconThemeDarkTest(string typedString, string expectedResult)
{
// Setup
Mock<Main> main = new Mock<Main>();
main.Object.IconTheme = "dark";
string[] terms = { typedString };
Query expectedQuery = new Query(typedString, typedString, new ReadOnlyCollection<string>(terms), string.Empty);
// Act
var result = main.Object.Query(expectedQuery).FirstOrDefault().IcoPath;
// Assert
Assert.AreEqual(expectedResult, result);
}
[TestCase("shutdown", "Images\\shutdown.light.png")]
[TestCase("restart", "Images\\restart.light.png")]
[TestCase("sign out", "Images\\logoff.light.png")]
[TestCase("lock", "Images\\lock.light.png")]
[TestCase("sleep", "Images\\sleep.light.png")]
[TestCase("hibernate", "Images\\sleep.light.png")]
[TestCase("empty recycle", "Images\\recyclebin.light.png")]
public void IconThemeLightTest(string typedString, string expectedResult)
{
// Setup
Mock<Main> main = new Mock<Main>();
main.Object.IconTheme = "light";
string[] terms = { typedString };
Query expectedQuery = new Query(typedString, typedString, new ReadOnlyCollection<string>(terms), string.Empty);
// Act
var result = main.Object.Query(expectedQuery).FirstOrDefault().IcoPath;
// Assert
Assert.AreEqual(expectedResult, result);
}
}
}

View file

@ -0,0 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>x64</Platforms>
<RootNamespace>Microsoft.Plugin.Sys.UnitTests</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.14.7" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Plugin.Sys\Microsoft.Plugin.Sys.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<AdditionalFiles Include="..\..\..\..\codeAnalysis\StyleCop.json">
<Link>StyleCop.json</Link>
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<Version>3.3.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

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.Linq;
using Mono.Collections.Generic;
using Moq;
using NUnit.Framework;
using Wox.Infrastructure;
using Wox.Plugin;
namespace Microsoft.Plugin.Sys.UnitTests
{
public class QueryTests
{
[SetUp]
public void Setup()
{
StringMatcher.Instance = new StringMatcher();
}
[TestCase("shutdown", "Shutdown computer")]
[TestCase("restart", "Restart computer")]
[TestCase("sign out", "Sign out of computer")]
[TestCase("lock", "Lock computer")]
[TestCase("sleep", "Put computer to sleep")]
[TestCase("hibernate", "Hibernate computer")]
[TestCase("empty recycle", "Empty Recycle Bin")]
public void QueryResults(string typedString, string expectedResult)
{
// Setup
Mock<Main> main = new Mock<Main>();
string[] terms = { typedString };
Query expectedQuery = new Query(typedString, typedString, new ReadOnlyCollection<string>(terms), string.Empty);
// Act
var result = main.Object.Query(expectedQuery).FirstOrDefault().SubTitle;
// Assert
Assert.AreEqual(expectedResult, result);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -0,0 +1,185 @@
// 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.Windows;
using System.Windows.Interop;
using ManagedCommon;
using Microsoft.Plugin.Sys.Win32;
using Wox.Infrastructure;
using Wox.Plugin;
namespace Microsoft.Plugin.Sys
{
public class Main : IPlugin, IPluginI18n
{
private PluginInitContext _context;
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;
public string IconTheme { get; set; }
public void Init(PluginInitContext context)
{
this._context = context;
_context.API.ThemeChanged += OnThemeChanged;
UpdateIconTheme(_context.API.GetCurrentTheme());
}
public List<Result> Query(Query query)
{
if (query == null)
{
throw new ArgumentNullException(paramName: nameof(query));
}
var commands = Commands();
var results = new List<Result>();
foreach (var c in commands)
{
var titleMatch = StringMatcher.FuzzySearch(query.Search, c.Title);
if (titleMatch.Score > 0)
{
c.Score = titleMatch.Score;
c.SetTitleHighlightData(titleMatch.MatchData);
results.Add(c);
}
}
return results;
}
private List<Result> Commands()
{
var results = new List<Result>();
results.AddRange(new[]
{
new Result
{
Title = Properties.Resources.Microsoft_plugin_sys_shutdown_computer,
SubTitle = Properties.Resources.Microsoft_plugin_sys_shutdown_computer_description,
IcoPath = $"Images\\shutdown.{IconTheme}.png",
Action = c =>
{
Process.Start("shutdown", "/s /t 0");
return true;
},
},
new Result
{
Title = Properties.Resources.Microsoft_plugin_sys_restart_computer,
SubTitle = Properties.Resources.Microsoft_plugin_sys_restart_computer_description,
IcoPath = $"Images\\restart.{IconTheme}.png",
Action = c =>
{
Process.Start("shutdown", "/r /t 0");
return true;
},
},
new Result
{
Title = Properties.Resources.Microsoft_plugin_sys_sign_out,
SubTitle = Properties.Resources.Microsoft_plugin_sys_sign_out_description,
IcoPath = $"Images\\logoff.{IconTheme}.png",
Action = c =>
{
NativeMethods.ExitWindowsEx(EWXLOGOFF, 0);
return true;
},
},
new Result
{
Title = Properties.Resources.Microsoft_plugin_sys_lock,
SubTitle = Properties.Resources.Microsoft_plugin_sys_lock_description,
IcoPath = $"Images\\lock.{IconTheme}.png",
Action = c =>
{
NativeMethods.LockWorkStation();
return true;
},
},
new Result
{
Title = Properties.Resources.Microsoft_plugin_sys_sleep,
SubTitle = Properties.Resources.Microsoft_plugin_sys_sleep_description,
IcoPath = $"Images\\sleep.{IconTheme}.png",
Action = c =>
{
NativeMethods.SetSuspendState(false, true, true);
return true;
},
},
new Result
{
Title = Properties.Resources.Microsoft_plugin_sys_hibernate,
SubTitle = Properties.Resources.Microsoft_plugin_sys_hibernate_description,
IcoPath = $"Images\\sleep.{IconTheme}.png", // Icon change needed
Action = c =>
{
NativeMethods.SetSuspendState(true, true, true);
return true;
},
},
new Result
{
Title = Properties.Resources.Microsoft_plugin_sys_emptyrecyclebin,
SubTitle = Properties.Resources.Microsoft_plugin_sys_emptyrecyclebin_description,
IcoPath = $"Images\\recyclebin.{IconTheme}.png",
Action = c =>
{
// http://www.pinvoke.net/default.aspx/shell32/SHEmptyRecycleBin.html
// FYI, couldn't find documentation for this but if the recycle bin is already empty, it will return -2147418113 (0x8000FFFF (E_UNEXPECTED))
// 0 for nothing
var result = NativeMethods.SHEmptyRecycleBin(new WindowInteropHelper(Application.Current.MainWindow).Handle, 0);
if (result != (uint)NativeMethods.HRESULT.S_OK && result != 0x8000FFFF)
{
var name = "Plugin: " + Properties.Resources.Microsoft_plugin_sys_plugin_name;
var message = $"Error emptying recycle bin, error code: {result}\n" +
"please refer to https://msdn.microsoft.com/en-us/library/windows/desktop/aa378137";
_context.API.ShowMsg(name, message);
}
return true;
},
},
});
return results;
}
private void UpdateIconTheme(Theme theme)
{
if (theme == Theme.Light || theme == Theme.HighContrastWhite)
{
IconTheme = "light";
}
else
{
IconTheme = "dark";
}
}
private void OnThemeChanged(Theme currentTheme, Theme newTheme)
{
UpdateIconTheme(newTheme);
}
public string GetTranslatedPluginDescription()
{
return Properties.Resources.Microsoft_plugin_sys_plugin_description;
}
public string GetTranslatedPluginTitle()
{
return Properties.Resources.Microsoft_plugin_sys_plugin_name;
}
}
}

View file

@ -0,0 +1,144 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Import Project="..\..\..\..\Version.props" />
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Plugin.Sys</RootNamespace>
<AssemblyName>Microsoft.Plugin.Sys</AssemblyName>
<Version>$(Version).0</Version>
<useWPF>true</useWPF>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Platforms>x64</Platforms>
<NeutralLanguage>en-US</NeutralLanguage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\..\..\..\x64\Debug\modules\launcher\Plugins\Microsoft.Plugin.Sys\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutputPath>..\..\..\..\..\x64\Release\modules\launcher\Plugins\Microsoft.Plugin.Sys\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj" />
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<AdditionalFiles Include="..\..\..\..\codeAnalysis\StyleCop.json">
<Link>StyleCop.json</Link>
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<Version>3.3.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Runtime" Version="4.3.1" />
</ItemGroup>
<ItemGroup>
<None Update="Images\lock.light.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\lock.dark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\logoff.light.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\logoff.dark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\recyclebin.light.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\recyclebin.dark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\restart.light.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\restart.dark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\shutdown.light.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\shutdown.dark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\sleep.light.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\sleep.dark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View file

@ -0,0 +1,207 @@
//------------------------------------------------------------------------------
// <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.Plugin.Sys.Properties {
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", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal 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)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Plugin.Sys.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)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Empty Recycle Bin.
/// </summary>
internal static string Microsoft_plugin_sys_emptyrecyclebin {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_emptyrecyclebin", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Empty Recycle Bin.
/// </summary>
internal static string Microsoft_plugin_sys_emptyrecyclebin_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_emptyrecyclebin_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hibernate.
/// </summary>
internal static string Microsoft_plugin_sys_hibernate {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_hibernate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hibernate computer.
/// </summary>
internal 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 Lock.
/// </summary>
internal static string Microsoft_plugin_sys_lock {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_lock", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lock computer.
/// </summary>
internal 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 Provides Windows related commands, shutdown, lock, sleep .....
/// </summary>
internal static string Microsoft_plugin_sys_plugin_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_plugin_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Windows System Commands.
/// </summary>
internal 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 Restart.
/// </summary>
internal 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 Restart computer.
/// </summary>
internal 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 Shutdown.
/// </summary>
internal 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 Shutdown computer.
/// </summary>
internal 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>
internal 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 Sign out of computer.
/// </summary>
internal 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>
internal static string Microsoft_plugin_sys_sleep {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_sleep", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Put computer to sleep.
/// </summary>
internal static string Microsoft_plugin_sys_sleep_description {
get {
return ResourceManager.GetString("Microsoft_plugin_sys_sleep_description", resourceCulture);
}
}
}
}

View file

@ -0,0 +1,184 @@
<?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="Microsoft_plugin_sys_emptyrecyclebin" 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_emptyrecyclebin_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_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_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_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_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_plugin_description" xml:space="preserve">
<value>Provides Windows related commands, shutdown, lock, sleep ....</value>
<comment>This should align to the actions in Windows relating to shutting down, signing out, locking, sleeping, restarting, emptying the recycle bin, and hibernating your computer. </comment>
</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_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_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_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_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_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_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>
</root>

View file

@ -0,0 +1,31 @@
// 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.Plugin.Sys.Win32
{
internal class NativeMethods
{
[DllImport("user32")]
internal static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
[DllImport("user32")]
internal static extern void LockWorkStation();
[DllImport("Shell32.dll", CharSet = CharSet.Unicode)]
internal static extern uint SHEmptyRecycleBin(IntPtr hWnd, uint dwFlags);
[DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
internal static extern bool SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent);
// http://www.pinvoke.net/default.aspx/Enums/HRESULT.html
public enum HRESULT : uint
{
S_FALSE = 0x0001,
S_OK = 0x0000,
}
}
}

View file

@ -0,0 +1,12 @@
{
"ID":"CEA08895D2544B019B2E9C5009600DF4",
"ActionKeyword":"*",
"Name":"System Commands",
"Description":"Provide System related commands. e.g. shutdown,lock,setting etc.",
"Author":"Wox",
"Version":"1.0.0",
"Language":"csharp",
"Website":"https://aka.ms/powertoys",
"ExecuteFileName":"Microsoft.Plugin.Sys.dll",
"IcoPath":"Images\\lock.png"
}

View file

@ -9,6 +9,7 @@ using System.Linq;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.Plugin.Program.UnitTests")]
[assembly: InternalsVisibleTo("Microsoft.Plugin.Sys.UnitTests")]
namespace Wox.Infrastructure
{