mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
shortcutguide, and ocr
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// 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;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using PowerToysExtension.Helpers;
|
||||
|
||||
namespace PowerToysExtension.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the Shortcut Guide UI via the shared trigger event.
|
||||
/// </summary>
|
||||
internal sealed partial class ToggleShortcutGuideCommand : InvokableCommand
|
||||
{
|
||||
public ToggleShortcutGuideCommand()
|
||||
{
|
||||
Name = "Toggle Shortcut Guide";
|
||||
}
|
||||
|
||||
public override CommandResult Invoke()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.ShortcutGuideTrigger);
|
||||
evt.Set();
|
||||
return CommandResult.Dismiss();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return CommandResult.ShowToast($"Failed to toggle Shortcut Guide: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// 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;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using PowerToysExtension.Helpers;
|
||||
|
||||
namespace PowerToysExtension.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the Text Extractor UI via the existing show event.
|
||||
/// </summary>
|
||||
internal sealed partial class ToggleTextExtractorCommand : InvokableCommand
|
||||
{
|
||||
public ToggleTextExtractorCommand()
|
||||
{
|
||||
Name = "Toggle Text Extractor";
|
||||
}
|
||||
|
||||
public override CommandResult Invoke()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.PowerOcrShow);
|
||||
evt.Set();
|
||||
return CommandResult.Dismiss();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return CommandResult.ShowToast($"Failed to toggle Text Extractor: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ internal static class ModuleCommandCatalog
|
||||
new LightSwitchModuleCommandProvider(),
|
||||
new PowerToysRunModuleCommandProvider(),
|
||||
new ScreenRulerModuleCommandProvider(),
|
||||
new ShortcutGuideModuleCommandProvider(),
|
||||
new TextExtractorModuleCommandProvider(),
|
||||
new ColorPickerModuleCommandProvider(),
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// 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 Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using PowerToysExtension.Commands;
|
||||
using PowerToysExtension.Helpers;
|
||||
using static Common.UI.SettingsDeepLink;
|
||||
|
||||
namespace PowerToysExtension.Modules;
|
||||
|
||||
internal sealed class ShortcutGuideModuleCommandProvider : ModuleCommandProvider
|
||||
{
|
||||
public override IEnumerable<ListItem> BuildCommands()
|
||||
{
|
||||
var title = SettingsWindow.ShortcutGuide.ModuleDisplayName();
|
||||
var icon = SettingsWindow.ShortcutGuide.ModuleIcon();
|
||||
|
||||
yield return new ListItem(new ToggleShortcutGuideCommand())
|
||||
{
|
||||
Title = "Toggle Shortcut Guide",
|
||||
Subtitle = "Show or hide Shortcut Guide",
|
||||
Icon = icon,
|
||||
};
|
||||
|
||||
yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.ShortcutGuide, title))
|
||||
{
|
||||
Title = title,
|
||||
Subtitle = "Open Shortcut Guide settings",
|
||||
Icon = icon,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// 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 Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using PowerToysExtension.Commands;
|
||||
using PowerToysExtension.Helpers;
|
||||
using static Common.UI.SettingsDeepLink;
|
||||
|
||||
namespace PowerToysExtension.Modules;
|
||||
|
||||
internal sealed class TextExtractorModuleCommandProvider : ModuleCommandProvider
|
||||
{
|
||||
public override IEnumerable<ListItem> BuildCommands()
|
||||
{
|
||||
var title = SettingsWindow.PowerOCR.ModuleDisplayName();
|
||||
var icon = SettingsWindow.PowerOCR.ModuleIcon();
|
||||
|
||||
yield return new ListItem(new ToggleTextExtractorCommand())
|
||||
{
|
||||
Title = "Toggle Text Extractor",
|
||||
Subtitle = "Start or close Text Extractor",
|
||||
Icon = icon,
|
||||
};
|
||||
|
||||
yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.PowerOCR, title))
|
||||
{
|
||||
Title = title,
|
||||
Subtitle = "Open Text Extractor settings",
|
||||
Icon = icon,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user