Crop And Lock added to Run plugin (#27927)
@ -27,6 +27,7 @@ namespace Common.UI
|
||||
MeasureTool,
|
||||
PowerOCR,
|
||||
RegistryPreview,
|
||||
CropAndLock,
|
||||
}
|
||||
|
||||
private static string SettingsWindowNameToString(SettingsWindow value)
|
||||
@ -65,6 +66,8 @@ namespace Common.UI
|
||||
return "PowerOCR";
|
||||
case SettingsWindow.RegistryPreview:
|
||||
return "RegistryPreview";
|
||||
case SettingsWindow.CropAndLock:
|
||||
return "CropAndLock";
|
||||
default:
|
||||
{
|
||||
return string.Empty;
|
||||
|
@ -254,5 +254,13 @@ public
|
||||
static String ^ ShowHostsAdminSharedEvent() {
|
||||
return gcnew String(CommonSharedConstants::SHOW_HOSTS_ADMIN_EVENT);
|
||||
}
|
||||
|
||||
static String ^ CropAndLockThumbnailEvent() {
|
||||
return gcnew String(CommonSharedConstants::CROP_AND_LOCK_THUMBNAIL_EVENT);
|
||||
}
|
||||
|
||||
static String ^ CropAndLockReparentEvent() {
|
||||
return gcnew String(CommonSharedConstants::CROP_AND_LOCK_REPARENT_EVENT);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// 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.Threading;
|
||||
using System.Windows.Input;
|
||||
@ -15,17 +16,20 @@ namespace Microsoft.PowerToys.Run.Plugin.PowerToys.Components
|
||||
{
|
||||
public class Utility
|
||||
{
|
||||
public UtilityKey Key { get; }
|
||||
public UtilityKey Key { get; private set; }
|
||||
|
||||
public string Name { get; }
|
||||
public string Name { get; private set; }
|
||||
|
||||
public bool Enabled { get; private set; }
|
||||
|
||||
public Utility(UtilityKey key, string name, bool enabled)
|
||||
public Func<ActionContext, bool> Action { get; private set; }
|
||||
|
||||
public Utility(UtilityKey key, string name, bool enabled, Func<ActionContext, bool> action)
|
||||
{
|
||||
Key = key;
|
||||
Name = name;
|
||||
Enabled = enabled;
|
||||
Action = action;
|
||||
}
|
||||
|
||||
public Result CreateResult(MatchResult matchResult)
|
||||
@ -35,7 +39,7 @@ namespace Microsoft.PowerToys.Run.Plugin.PowerToys.Components
|
||||
Title = Name,
|
||||
SubTitle = Resources.Subtitle_Powertoys_Utility,
|
||||
IcoPath = UtilityHelper.GetIcoPath(Key),
|
||||
Action = UtilityHelper.GetAction(Key),
|
||||
Action = Action,
|
||||
ContextData = this,
|
||||
Score = matchResult.Score,
|
||||
TitleHighlightData = matchResult.MatchData,
|
||||
|
@ -2,11 +2,7 @@
|
||||
// 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;
|
||||
using Common.UI;
|
||||
using interop;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Microsoft.PowerToys.Run.Plugin.PowerToys.Components
|
||||
{
|
||||
@ -23,6 +19,7 @@ namespace Microsoft.PowerToys.Run.Plugin.PowerToys.Components
|
||||
UtilityKey.PowerOCR => "Images/PowerOcr.png",
|
||||
UtilityKey.ShortcutGuide => "Images/ShortcutGuide.png",
|
||||
UtilityKey.RegistryPreview => "Images/RegistryPreview.png",
|
||||
UtilityKey.CropAndLock => "Images/CropAndLock.png",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
@ -38,78 +35,9 @@ namespace Microsoft.PowerToys.Run.Plugin.PowerToys.Components
|
||||
UtilityKey.PowerOCR => SettingsDeepLink.SettingsWindow.PowerOCR,
|
||||
UtilityKey.ShortcutGuide => SettingsDeepLink.SettingsWindow.ShortcutGuide,
|
||||
UtilityKey.RegistryPreview => SettingsDeepLink.SettingsWindow.RegistryPreview,
|
||||
UtilityKey.CropAndLock => SettingsDeepLink.SettingsWindow.CropAndLock,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
public static Func<ActionContext, bool> GetAction(UtilityKey key)
|
||||
{
|
||||
return (context) =>
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case UtilityKey.ColorPicker: // Launch ColorPicker
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShowColorPickerSharedEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
}
|
||||
|
||||
break;
|
||||
case UtilityKey.FancyZones: // Launch FancyZones Editor
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.FZEToggleEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UtilityKey.Hosts: // Launch Hosts
|
||||
{
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShowHostsSharedEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UtilityKey.MeasureTool: // Launch Screen Ruler
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.MeasureToolTriggerEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
}
|
||||
|
||||
break;
|
||||
case UtilityKey.PowerOCR: // Launch Text Extractor
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShowPowerOCRSharedEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UtilityKey.ShortcutGuide: // Launch Shortcut Guide
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShortcutGuideTriggerEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UtilityKey.RegistryPreview: // Launch Registry Preview
|
||||
using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.RegistryPreviewTriggerEvent()))
|
||||
{
|
||||
eventHandle.Set();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,5 +13,6 @@ namespace Microsoft.PowerToys.Run.Plugin.PowerToys.Components
|
||||
PowerOCR = 4,
|
||||
ShortcutGuide = 5,
|
||||
RegistryPreview = 6,
|
||||
CropAndLock = 7,
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using interop;
|
||||
using Microsoft.PowerToys.Run.Plugin.PowerToys.Components;
|
||||
using Microsoft.PowerToys.Run.Plugin.PowerToys.Properties;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
@ -32,37 +33,141 @@ namespace Microsoft.PowerToys.Run.Plugin.PowerToys
|
||||
|
||||
if (GPOWrapper.GetConfiguredColorPickerEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
_utilities.Add(new Utility(UtilityKey.ColorPicker, Resources.Color_Picker, generalSettings.Enabled.ColorPicker));
|
||||
_utilities.Add(new Utility(
|
||||
UtilityKey.ColorPicker,
|
||||
Resources.Color_Picker,
|
||||
generalSettings.Enabled.ColorPicker,
|
||||
(_) =>
|
||||
{
|
||||
using var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShowColorPickerSharedEvent());
|
||||
eventHandle.Set();
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredFancyZonesEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
_utilities.Add(new Utility(UtilityKey.FancyZones, Resources.FancyZones_Editor, generalSettings.Enabled.FancyZones));
|
||||
_utilities.Add(new Utility(
|
||||
UtilityKey.FancyZones,
|
||||
Resources.FancyZones_Editor,
|
||||
generalSettings.Enabled.FancyZones,
|
||||
(_) =>
|
||||
{
|
||||
using var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.FZEToggleEvent());
|
||||
eventHandle.Set();
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredHostsFileEditorEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
_utilities.Add(new Utility(UtilityKey.Hosts, Resources.Hosts_File_Editor, generalSettings.Enabled.Hosts));
|
||||
_utilities.Add(new Utility(
|
||||
UtilityKey.Hosts,
|
||||
Resources.Hosts_File_Editor,
|
||||
generalSettings.Enabled.Hosts,
|
||||
(_) =>
|
||||
{
|
||||
using var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShowHostsSharedEvent());
|
||||
eventHandle.Set();
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredScreenRulerEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
_utilities.Add(new Utility(UtilityKey.MeasureTool, Resources.Screen_Ruler, generalSettings.Enabled.MeasureTool));
|
||||
_utilities.Add(new Utility(
|
||||
UtilityKey.MeasureTool,
|
||||
Resources.Screen_Ruler,
|
||||
generalSettings.Enabled.MeasureTool,
|
||||
(_) =>
|
||||
{
|
||||
using var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.MeasureToolTriggerEvent());
|
||||
eventHandle.Set();
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredTextExtractorEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
_utilities.Add(new Utility(UtilityKey.PowerOCR, Resources.Text_Extractor, generalSettings.Enabled.PowerOCR));
|
||||
_utilities.Add(new Utility(
|
||||
UtilityKey.PowerOCR,
|
||||
Resources.Text_Extractor,
|
||||
generalSettings.Enabled.PowerOCR,
|
||||
(_) =>
|
||||
{
|
||||
using var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShowPowerOCRSharedEvent());
|
||||
eventHandle.Set();
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredShortcutGuideEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
_utilities.Add(new Utility(UtilityKey.ShortcutGuide, Resources.Shortcut_Guide, generalSettings.Enabled.ShortcutGuide));
|
||||
_utilities.Add(new Utility(
|
||||
UtilityKey.ShortcutGuide,
|
||||
Resources.Shortcut_Guide,
|
||||
generalSettings.Enabled.ShortcutGuide,
|
||||
(_) =>
|
||||
{
|
||||
using var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.ShortcutGuideTriggerEvent());
|
||||
eventHandle.Set();
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredRegistryPreviewEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
_utilities.Add(new Utility(UtilityKey.RegistryPreview, Resources.Registry_Preview, generalSettings.Enabled.RegistryPreview));
|
||||
_utilities.Add(new Utility(
|
||||
UtilityKey.RegistryPreview,
|
||||
Resources.Registry_Preview,
|
||||
generalSettings.Enabled.RegistryPreview,
|
||||
(_) =>
|
||||
{
|
||||
using var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.RegistryPreviewTriggerEvent());
|
||||
eventHandle.Set();
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
|
||||
if (GPOWrapper.GetConfiguredCropAndLockEnabledValue() != GpoRuleConfigured.Disabled)
|
||||
{
|
||||
_utilities.Add(new Utility(
|
||||
UtilityKey.CropAndLock,
|
||||
Resources.Crop_And_Lock_Thumbnail,
|
||||
generalSettings.Enabled.CropAndLock,
|
||||
(_) =>
|
||||
{
|
||||
// Wait for the Launcher window to be hidden and activate Crop And Lock in the correct window
|
||||
var timer = new System.Timers.Timer(TimeSpan.FromMilliseconds(500));
|
||||
timer.Elapsed += (_, _) =>
|
||||
{
|
||||
timer.Stop();
|
||||
using var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.CropAndLockThumbnailEvent());
|
||||
eventHandle.Set();
|
||||
};
|
||||
|
||||
timer.Start();
|
||||
return true;
|
||||
}));
|
||||
|
||||
_utilities.Add(new Utility(
|
||||
UtilityKey.CropAndLock,
|
||||
Resources.Crop_And_Lock_Reparent,
|
||||
generalSettings.Enabled.CropAndLock,
|
||||
(_) =>
|
||||
{
|
||||
// Wait for the Launcher window to be hidden and activate Crop And Lock in the correct window
|
||||
var timer = new System.Timers.Timer(TimeSpan.FromMilliseconds(500));
|
||||
timer.Elapsed += (_, _) =>
|
||||
{
|
||||
timer.Stop();
|
||||
using var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.CropAndLockReparentEvent());
|
||||
eventHandle.Set();
|
||||
};
|
||||
|
||||
timer.Start();
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
|
||||
_watcher = new FileSystemWatcher
|
||||
@ -108,6 +213,7 @@ namespace Microsoft.PowerToys.Run.Plugin.PowerToys
|
||||
case UtilityKey.MeasureTool: u.Enable(generalSettings.Enabled.MeasureTool); break;
|
||||
case UtilityKey.ShortcutGuide: u.Enable(generalSettings.Enabled.ShortcutGuide); break;
|
||||
case UtilityKey.RegistryPreview: u.Enable(generalSettings.Enabled.RegistryPreview); break;
|
||||
case UtilityKey.CropAndLock: u.Enable(generalSettings.Enabled.CropAndLock); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 968 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 921 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.2 KiB |
@ -66,33 +66,45 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Images\ColorPicker.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\FancyZones.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\Hosts.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\PowerOcr.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\PowerToys.dark.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\PowerToys.light.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\RegistryPreview.png">
|
||||
|
||||
<Content Include="..\..\..\..\settings-ui\Settings.UI\Assets\Settings\FluentIcons\FluentIconsColorPicker.png">
|
||||
<Link>Images\ColorPicker.png</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\ScreenRuler.png">
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\settings-ui\Settings.UI\Assets\Settings\FluentIcons\FluentIconsFancyZones.png">
|
||||
<Link>Images\FancyZones.png</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\ShortcutGuide.png">
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\settings-ui\Settings.UI\Assets\Settings\FluentIcons\FluentIconsCropAndLock.png">
|
||||
<Link>Images\CropAndLock.png</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\settings-ui\Settings.UI\Assets\Settings\FluentIcons\FluentIconsHosts.png">
|
||||
<Link>Images\Hosts.png</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\settings-ui\Settings.UI\Assets\Settings\FluentIcons\FluentIconsPowerOcr.png">
|
||||
<Link>Images\PowerOcr.png</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\settings-ui\Settings.UI\Assets\Settings\FluentIcons\FluentIconsRegistryPreview.png">
|
||||
<Link>Images\RegistryPreview.png</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\settings-ui\Settings.UI\Assets\Settings\FluentIcons\FluentIconsScreenRuler.png">
|
||||
<Link>Images\ScreenRuler.png</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\settings-ui\Settings.UI\Assets\Settings\FluentIcons\FluentIconsShortcutGuide.png">
|
||||
<Link>Images\ShortcutGuide.png</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -87,6 +87,24 @@ namespace Microsoft.PowerToys.Run.Plugin.PowerToys.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Crop And Lock (Reparent).
|
||||
/// </summary>
|
||||
internal static string Crop_And_Lock_Reparent {
|
||||
get {
|
||||
return ResourceManager.GetString("Crop_And_Lock_Reparent", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Crop And Lock (Thumbnail).
|
||||
/// </summary>
|
||||
internal static string Crop_And_Lock_Thumbnail {
|
||||
get {
|
||||
return ResourceManager.GetString("Crop_And_Lock_Thumbnail", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to FancyZones Editor.
|
||||
/// </summary>
|
||||
|
@ -127,6 +127,14 @@
|
||||
<value>Color Picker</value>
|
||||
<comment>"Color Picker" is the name of the utility</comment>
|
||||
</data>
|
||||
<data name="Crop_And_Lock_Reparent" xml:space="preserve">
|
||||
<value>Crop And Lock (Reparent)</value>
|
||||
<comment>"Crop And Lock" is the name of the utility, "Reparent" is the activation mode</comment>
|
||||
</data>
|
||||
<data name="Crop_And_Lock_Thumbnail" xml:space="preserve">
|
||||
<value>Crop And Lock (Thumbnail)</value>
|
||||
<comment>"Crop And Lock" is the name of the utility, "Thumbnail" is the activation mode</comment>
|
||||
</data>
|
||||
<data name="FancyZones_Editor" xml:space="preserve">
|
||||
<value>FancyZones Editor</value>
|
||||
<comment>"FancyZones" is the name of the utility</comment>
|
||||
|
@ -685,6 +685,8 @@ std::string ESettingsWindowNames_to_string(ESettingsWindowNames value)
|
||||
return "PowerOCR";
|
||||
case ESettingsWindowNames::RegistryPreview:
|
||||
return "RegistryPreview";
|
||||
case ESettingsWindowNames::CropAndLock:
|
||||
return "CropAndLock";
|
||||
default:
|
||||
{
|
||||
Logger::error(L"Can't convert ESettingsWindowNames value={} to string", static_cast<int>(value));
|
||||
@ -760,6 +762,10 @@ ESettingsWindowNames ESettingsWindowNames_from_string(std::string value)
|
||||
{
|
||||
return ESettingsWindowNames::RegistryPreview;
|
||||
}
|
||||
else if (value == "CropAndLock")
|
||||
{
|
||||
return ESettingsWindowNames::CropAndLock;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::error(L"Can't convert string value={} to ESettingsWindowNames", winrt::to_hstring(value));
|
||||
|
@ -20,6 +20,7 @@ enum class ESettingsWindowNames
|
||||
MeasureTool,
|
||||
PowerOCR,
|
||||
RegistryPreview,
|
||||
CropAndLock,
|
||||
};
|
||||
|
||||
std::string ESettingsWindowNames_to_string(ESettingsWindowNames value);
|
||||
|
@ -401,6 +401,7 @@ namespace Microsoft.PowerToys.Settings.UI
|
||||
case "RegistryPreview": return typeof(RegistryPreviewPage);
|
||||
case "PastePlain": return typeof(PastePlainPage);
|
||||
case "Peek": return typeof(PeekPage);
|
||||
case "CropAndLock": return typeof(CropAndLockPage);
|
||||
default:
|
||||
// Fallback to general
|
||||
Debug.Assert(false, "Unexpected SettingsWindow argument value");
|
||||
|