mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-21 03:27:08 +01:00
Compare commits
39 Commits
dev/jaime/
...
pr35429
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1c1161d3b | ||
|
|
64845b7fd8 | ||
|
|
83d3c85f3e | ||
|
|
4208e05826 | ||
|
|
a0138cec5e | ||
|
|
207b5dae50 | ||
|
|
6828961262 | ||
|
|
265e52967a | ||
|
|
f1308fad5e | ||
|
|
235a299b73 | ||
|
|
f60b294dcb | ||
|
|
5149ed4c00 | ||
|
|
b92db8134b | ||
|
|
b18652ad6c | ||
|
|
9bbda17811 | ||
|
|
ee4440f65f | ||
|
|
2234db6c6b | ||
|
|
cf5afc6c1c | ||
|
|
3de225c8fe | ||
|
|
9324162007 | ||
|
|
e21783473e | ||
|
|
e1fa78c50f | ||
|
|
8cb70648d3 | ||
|
|
d45ae2c197 | ||
|
|
5c0e14656e | ||
|
|
f9b1588375 | ||
|
|
5596a32e3d | ||
|
|
51a33afbdb | ||
|
|
ce010f5f7a | ||
|
|
27b234e38e | ||
|
|
c716aa65ae | ||
|
|
3c6d882e91 | ||
|
|
c87a344007 | ||
|
|
f97cc86f67 | ||
|
|
e7cc3a04f7 | ||
|
|
9c0ef91fd9 | ||
|
|
f2ed58f329 | ||
|
|
96c09532fa | ||
|
|
65a313fb4e |
@@ -91,6 +91,10 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
return CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT;
|
||||
}
|
||||
hstring Constants::TerminateMouseJumpSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::TERMINATE_MOUSE_JUMP_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::AwakeExitEvent()
|
||||
{
|
||||
return CommonSharedConstants::AWAKE_EXIT_EVENT;
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
static hstring ShowPowerOCRSharedEvent();
|
||||
static hstring TerminatePowerOCRSharedEvent();
|
||||
static hstring MouseJumpShowPreviewEvent();
|
||||
static hstring TerminateMouseJumpSharedEvent();
|
||||
static hstring AwakeExitEvent();
|
||||
static hstring ShowPeekEvent();
|
||||
static hstring TerminatePeekEvent();
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace PowerToys
|
||||
static String ShowPowerOCRSharedEvent();
|
||||
static String TerminatePowerOCRSharedEvent();
|
||||
static String MouseJumpShowPreviewEvent();
|
||||
static String TerminateMouseJumpSharedEvent();
|
||||
static String AwakeExitEvent();
|
||||
static String ShowPeekEvent();
|
||||
static String TerminatePeekEvent();
|
||||
|
||||
@@ -81,6 +81,8 @@ namespace CommonSharedConstants
|
||||
// Path to the events used by Mouse Jump
|
||||
const wchar_t MOUSE_JUMP_SHOW_PREVIEW_EVENT[] = L"Local\\MouseJumpEvent-aa0be051-3396-4976-b7ba-1a9cc7d236a5";
|
||||
|
||||
const wchar_t TERMINATE_MOUSE_JUMP_SHARED_EVENT[] = L"Local\\TerminateMouseJumpEvent-252fa337-317f-4c37-a61f-99464c3f9728";
|
||||
|
||||
// Path to the event used by RegistryPreview
|
||||
const wchar_t REGISTRY_PREVIEW_TRIGGER_EVENT[] = L"Local\\RegistryPreviewEvent-4C559468-F75A-4E7F-BC4F-9C9688316687";
|
||||
|
||||
|
||||
@@ -178,7 +178,8 @@ void notifications::show_toast_with_activations(std::wstring message,
|
||||
std::wstring title,
|
||||
std::wstring_view background_handler_id,
|
||||
std::vector<action_t> actions,
|
||||
toast_params params)
|
||||
toast_params params,
|
||||
std::wstring launch_uri)
|
||||
{
|
||||
// DO NOT LOCALIZE any string in this function, because they're XML tags and a subject to
|
||||
// https://learn.microsoft.com/windows/uwp/design/shell/tiles-and-notifications/toast-xml-schema
|
||||
@@ -189,7 +190,18 @@ void notifications::show_toast_with_activations(std::wstring message,
|
||||
// We must set toast's title and contents immediately, because some of the toasts we send could be snoozed.
|
||||
// Windows instantiates the snoozed toast from scratch before showing it again, so all bindings that were set
|
||||
// using NotificationData would be empty.
|
||||
toast_xml += LR"(<?xml version="1.0"?><toast><visual><binding template="ToastGeneric">)";
|
||||
// Add the launch attribute if launch_uri is provided, otherwise omit it
|
||||
toast_xml += LR"(<?xml version="1.0"?>)";
|
||||
if (!launch_uri.empty())
|
||||
{
|
||||
toast_xml += LR"(<toast launch=")" + launch_uri + LR"(" activationType="protocol">)"; // Use the launch URI if provided
|
||||
}
|
||||
else
|
||||
{
|
||||
toast_xml += LR"(<toast>)"; // No launch attribute if empty
|
||||
}
|
||||
|
||||
toast_xml += LR"(<visual><binding template="ToastGeneric">)";
|
||||
toast_xml += LR"(<text id="1">)";
|
||||
toast_xml += std::move(title);
|
||||
toast_xml += LR"(</text>)";
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace notifications
|
||||
using action_t = std::variant<link_button, background_activated_button, snooze_button>;
|
||||
|
||||
void show_toast(std::wstring plaintext_message, std::wstring title, toast_params params = {});
|
||||
void show_toast_with_activations(std::wstring plaintext_message, std::wstring title, std::wstring_view background_handler_id, std::vector<action_t> actions, toast_params params = {});
|
||||
void show_toast_with_activations(std::wstring plaintext_message, std::wstring title, std::wstring_view background_handler_id, std::vector<action_t> actions, toast_params params = {}, std::wstring launch_uri = L"");
|
||||
void update_toast_progress_bar(std::wstring_view tag, progress_bar_params params);
|
||||
void remove_toasts_by_tag(std::wstring_view tag);
|
||||
void remove_all_scheduled_toasts();
|
||||
|
||||
@@ -62,9 +62,12 @@ private:
|
||||
|
||||
Hotkey m_hotkey;
|
||||
|
||||
// Handle to event used to invoke PowerOCR
|
||||
// Handle to event used to invoke MouseJump
|
||||
HANDLE m_hInvokeEvent;
|
||||
|
||||
// Handle to event used to terminate MouseJump
|
||||
HANDLE m_hTerminateEvent;
|
||||
|
||||
void parse_hotkey(PowerToysSettings::PowerToyValues& settings)
|
||||
{
|
||||
auto settingsObject = settings.get_raw_json();
|
||||
@@ -154,6 +157,7 @@ public:
|
||||
{
|
||||
LoggerHelpers::init_logger(MODULE_NAME, L"ModuleInterface", LogSettings::mouseJumpLoggerName);
|
||||
m_hInvokeEvent = CreateDefaultEvent(CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT);
|
||||
m_hTerminateEvent = CreateDefaultEvent(CommonSharedConstants::TERMINATE_MOUSE_JUMP_SHARED_EVENT);
|
||||
init_settings();
|
||||
};
|
||||
|
||||
@@ -245,6 +249,8 @@ public:
|
||||
if (m_enabled)
|
||||
{
|
||||
ResetEvent(m_hInvokeEvent);
|
||||
SetEvent(m_hTerminateEvent);
|
||||
WaitForSingleObject(m_hProcess, 1500);
|
||||
TerminateProcess(m_hProcess, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,6 +166,7 @@ internal sealed partial class MainForm : Form
|
||||
|
||||
// move mouse pointer
|
||||
Logger.LogInfo($"clicked location = {clickedLocation}");
|
||||
Microsoft.PowerToys.Telemetry.PowerToysTelemetry.Log.WriteEvent(new Telemetry.MouseJumpTeleportCursorEvent());
|
||||
MouseHelper.SetCursorPosition(clickedLocation);
|
||||
}
|
||||
|
||||
@@ -202,6 +203,8 @@ internal sealed partial class MainForm : Form
|
||||
|
||||
stopwatch.Stop();
|
||||
|
||||
Microsoft.PowerToys.Telemetry.PowerToysTelemetry.Log.WriteEvent(new Telemetry.MouseJumpShowEvent());
|
||||
|
||||
// we have to activate the form to make sure the deactivate event fires
|
||||
this.Activate();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Windows.Threading;
|
||||
using Common.UI;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using MouseJumpUI.Helpers;
|
||||
using PowerToys.Interop;
|
||||
|
||||
@@ -20,6 +21,8 @@ namespace MouseJumpUI;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
private static CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@@ -27,6 +30,7 @@ internal static class Program
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
Logger.InitializeLogger("\\MouseJump\\Logs");
|
||||
ETWTrace etwTrace = new ETWTrace();
|
||||
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
@@ -62,13 +66,10 @@ internal static class Program
|
||||
|
||||
Logger.LogInfo($"Mouse Jump started from the PowerToys Runner. Runner pid={runnerPid}");
|
||||
|
||||
var cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
RunnerHelper.WaitForPowerToysRunner(runnerPid, () =>
|
||||
{
|
||||
Logger.LogInfo("PowerToys Runner exited. Exiting Mouse Jump");
|
||||
cancellationTokenSource.Cancel();
|
||||
Application.Exit();
|
||||
Logger.LogInfo("PowerToys Runner exited.");
|
||||
TerminateApp();
|
||||
});
|
||||
|
||||
var settingsHelper = new SettingsHelper();
|
||||
@@ -80,7 +81,21 @@ internal static class Program
|
||||
Dispatcher.CurrentDispatcher,
|
||||
cancellationTokenSource.Token);
|
||||
|
||||
NativeEventWaiter.WaitForEventLoop(
|
||||
Constants.TerminateMouseJumpSharedEvent(),
|
||||
TerminateApp,
|
||||
Dispatcher.CurrentDispatcher,
|
||||
cancellationTokenSource.Token);
|
||||
|
||||
Application.Run();
|
||||
etwTrace?.Dispose();
|
||||
}
|
||||
|
||||
private static void TerminateApp()
|
||||
{
|
||||
Logger.LogInfo("Exiting Mouse Jump.");
|
||||
cancellationTokenSource.Cancel();
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private static MouseJumpSettings ReadSettings()
|
||||
|
||||
@@ -53,8 +53,9 @@ void ShowNewVersionAvailable(const new_version_download_info& info)
|
||||
{ link_button{ GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UPDATE_NOW),
|
||||
L"powertoys://update_now/" },
|
||||
link_button{ GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_MORE_INFO),
|
||||
L"powertoys://open_settings/" } },
|
||||
std::move(toast_params));
|
||||
L"powertoys://open_overview/" } },
|
||||
std::move(toast_params),
|
||||
L"powertoys://open_overview/");
|
||||
}
|
||||
|
||||
void ShowOpenSettingsForUpdate()
|
||||
@@ -65,13 +66,14 @@ void ShowOpenSettingsForUpdate()
|
||||
|
||||
std::vector<action_t> actions = {
|
||||
link_button{ GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_MORE_INFO),
|
||||
L"powertoys://open_settings/" },
|
||||
L"powertoys://open_overview/" },
|
||||
};
|
||||
show_toast_with_activations(GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_AVAILABLE),
|
||||
GET_RESOURCE_STRING(IDS_TOAST_TITLE),
|
||||
{},
|
||||
std::move(actions),
|
||||
std::move(toast_params));
|
||||
std::move(toast_params),
|
||||
L"powertoys://open_overview/");
|
||||
}
|
||||
|
||||
SHELLEXECUTEINFOW LaunchPowerToysUpdate(const wchar_t* cmdline)
|
||||
|
||||
@@ -275,6 +275,7 @@ toast_notification_handler_result toast_notification_handler(const std::wstring_
|
||||
const std::wstring_view cant_drag_elevated_disable = L"cant_drag_elevated_disable/";
|
||||
const std::wstring_view couldnt_toggle_powerpreview_modules_disable = L"couldnt_toggle_powerpreview_modules_disable/";
|
||||
const std::wstring_view open_settings = L"open_settings/";
|
||||
const std::wstring_view open_overview = L"open_overview/";
|
||||
const std::wstring_view update_now = L"update_now/";
|
||||
|
||||
if (param == cant_drag_elevated_disable)
|
||||
@@ -296,6 +297,11 @@ toast_notification_handler_result toast_notification_handler(const std::wstring_
|
||||
open_menu_from_another_instance(std::nullopt);
|
||||
return toast_notification_handler_result::exit_success;
|
||||
}
|
||||
else if (param == open_overview)
|
||||
{
|
||||
open_menu_from_another_instance("Overview");
|
||||
return toast_notification_handler_result::exit_success;
|
||||
}
|
||||
else
|
||||
{
|
||||
return toast_notification_handler_result::exit_error;
|
||||
|
||||
@@ -625,7 +625,7 @@ void close_settings_window()
|
||||
if (g_settings_process_id != 0)
|
||||
{
|
||||
SetEvent(g_terminateSettingsEvent);
|
||||
wil::unique_handle proc{ OpenProcess(PROCESS_TERMINATE, false, g_settings_process_id) };
|
||||
wil::unique_handle proc{ OpenProcess(PROCESS_ALL_ACCESS, false, g_settings_process_id) };
|
||||
if (proc)
|
||||
{
|
||||
WaitForSingleObject(proc.get(), 1500);
|
||||
|
||||
BIN
src/settings-ui/Settings.UI/Assets/Settings/Icons/Advanced.png
Normal file
BIN
src/settings-ui/Settings.UI/Assets/Settings/Icons/Advanced.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -4,7 +4,7 @@
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.UI.Dispatching;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
@@ -14,7 +14,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
public static void WaitForEventLoop(string eventName, Action callback)
|
||||
{
|
||||
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
||||
new Thread(() =>
|
||||
new Task(() =>
|
||||
{
|
||||
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
|
||||
while (true)
|
||||
|
||||
@@ -105,135 +105,159 @@
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItemSeparator />
|
||||
|
||||
<!-- System Tools -->
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_AdvancedPaste"
|
||||
helpers:NavHelper.NavigateTo="views:AdvancedPastePage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/AdvancedPaste.png}" />
|
||||
x:Uid="Shell_TopLevelSystemTools"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/SystemTools.png}"
|
||||
SelectsOnInvoked="False">
|
||||
<NavigationViewItem.MenuItems>
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_AdvancedPaste"
|
||||
helpers:NavHelper.NavigateTo="views:AdvancedPastePage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/AdvancedPaste.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_Awake"
|
||||
helpers:NavHelper.NavigateTo="views:AwakePage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Awake.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_ColorPicker"
|
||||
helpers:NavHelper.NavigateTo="views:ColorPickerPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/ColorPicker.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_PowerLauncher"
|
||||
helpers:NavHelper.NavigateTo="views:PowerLauncherPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/PowerToysRun.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_MeasureTool"
|
||||
helpers:NavHelper.NavigateTo="views:MeasureToolPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/ScreenRuler.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_ShortcutGuide"
|
||||
helpers:NavHelper.NavigateTo="views:ShortcutGuidePage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/ShortcutGuide.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_TextExtractor"
|
||||
helpers:NavHelper.NavigateTo="views:PowerOcrPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/TextExtractor.png}" />
|
||||
</NavigationViewItem.MenuItems>
|
||||
</NavigationViewItem>
|
||||
|
||||
<!-- Windowing & Layouts -->
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_AlwaysOnTop"
|
||||
helpers:NavHelper.NavigateTo="views:AlwaysOnTopPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/AlwaysOnTop.png}" />
|
||||
x:Uid="Shell_TopLevelWindowsAndLayouts "
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/WindowingAndLayouts.png}"
|
||||
SelectsOnInvoked="False">
|
||||
<NavigationViewItem.MenuItems>
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_AlwaysOnTop"
|
||||
helpers:NavHelper.NavigateTo="views:AlwaysOnTopPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/AlwaysOnTop.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_CropAndLock"
|
||||
helpers:NavHelper.NavigateTo="views:CropAndLockPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/CropAndLock.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_FancyZones"
|
||||
helpers:NavHelper.NavigateTo="views:FancyZonesPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/FancyZones.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_Workspaces"
|
||||
helpers:NavHelper.NavigateTo="views:WorkspacesPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Workspaces.png}" />
|
||||
</NavigationViewItem.MenuItems>
|
||||
</NavigationViewItem>
|
||||
|
||||
<!-- Input / Output -->
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_Awake"
|
||||
helpers:NavHelper.NavigateTo="views:AwakePage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Awake.png}" />
|
||||
x:Uid="Shell_TopLevelInputOutput"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/InputOutput.png}"
|
||||
SelectsOnInvoked="False">
|
||||
<NavigationViewItem.MenuItems>
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_KeyboardManager"
|
||||
helpers:NavHelper.NavigateTo="views:KeyboardManagerPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/KeyboardManager.png}" />
|
||||
<!-- Find my mouse -->
|
||||
<!-- Mouse Highlighter -->
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_MouseUtilities"
|
||||
helpers:NavHelper.NavigateTo="views:MouseUtilsPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/MouseUtils.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_MouseWithoutBorders"
|
||||
helpers:NavHelper.NavigateTo="views:MouseWithoutBordersPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/MouseWithoutBorders.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_QuickAccent"
|
||||
helpers:NavHelper.NavigateTo="views:PowerAccentPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/QuickAccent.png}" />
|
||||
<!-- Mouse pointer cross hair -->
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_VideoConference"
|
||||
helpers:NavHelper.NavigateTo="views:VideoConferencePage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/VideoConferenceMute.png}"
|
||||
IsEnabled="{x:Bind ViewModel.IsVideoConferenceBuild, Mode=OneWay}" />
|
||||
</NavigationViewItem.MenuItems>
|
||||
</NavigationViewItem>
|
||||
|
||||
<!-- File Management -->
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_ColorPicker"
|
||||
helpers:NavHelper.NavigateTo="views:ColorPickerPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/ColorPicker.png}" />
|
||||
x:Uid="Shell_TopLevelFileManagement"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/FileManagement.png}"
|
||||
SelectsOnInvoked="False">
|
||||
<NavigationViewItem.MenuItems>
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_PowerPreview"
|
||||
helpers:NavHelper.NavigateTo="views:PowerPreviewPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/FileExplorerPreview.png}" />
|
||||
<!-- File Explorer Thumbnails -->
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_FileLocksmith"
|
||||
helpers:NavHelper.NavigateTo="views:FileLocksmithPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/FileLocksmith.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_ImageResizer"
|
||||
helpers:NavHelper.NavigateTo="views:ImageResizerPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/ImageResizer.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="NewPlus_Product_Name"
|
||||
helpers:NavHelper.NavigateTo="views:NewPlusPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/NewPlus.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_Peek"
|
||||
helpers:NavHelper.NavigateTo="views:PeekPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Peek.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_PowerRename"
|
||||
helpers:NavHelper.NavigateTo="views:PowerRenamePage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/PowerRename.png}" />
|
||||
</NavigationViewItem.MenuItems>
|
||||
</NavigationViewItem>
|
||||
|
||||
<!-- Advanced -->
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_CmdNotFound"
|
||||
helpers:NavHelper.NavigateTo="views:CmdNotFoundPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/CommandNotFound.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_CropAndLock"
|
||||
helpers:NavHelper.NavigateTo="views:CropAndLockPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/CropAndLock.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_EnvironmentVariables"
|
||||
helpers:NavHelper.NavigateTo="views:EnvironmentVariablesPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/EnvironmentVariables.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_FancyZones"
|
||||
helpers:NavHelper.NavigateTo="views:FancyZonesPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/FancyZones.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_PowerPreview"
|
||||
helpers:NavHelper.NavigateTo="views:PowerPreviewPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/FileExplorerPreview.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_FileLocksmith"
|
||||
helpers:NavHelper.NavigateTo="views:FileLocksmithPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/FileLocksmith.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_Hosts"
|
||||
helpers:NavHelper.NavigateTo="views:HostsPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Hosts.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_ImageResizer"
|
||||
helpers:NavHelper.NavigateTo="views:ImageResizerPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/ImageResizer.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_KeyboardManager"
|
||||
helpers:NavHelper.NavigateTo="views:KeyboardManagerPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/KeyboardManager.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_MouseUtilities"
|
||||
helpers:NavHelper.NavigateTo="views:MouseUtilsPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/MouseUtils.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_MouseWithoutBorders"
|
||||
helpers:NavHelper.NavigateTo="views:MouseWithoutBordersPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/MouseWithoutBorders.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="NewPlus_Product_Name"
|
||||
helpers:NavHelper.NavigateTo="views:NewPlusPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/NewPlus.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_Peek"
|
||||
helpers:NavHelper.NavigateTo="views:PeekPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Peek.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_PowerRename"
|
||||
helpers:NavHelper.NavigateTo="views:PowerRenamePage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/PowerRename.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_PowerLauncher"
|
||||
helpers:NavHelper.NavigateTo="views:PowerLauncherPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/PowerToysRun.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_QuickAccent"
|
||||
helpers:NavHelper.NavigateTo="views:PowerAccentPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/QuickAccent.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_RegistryPreview"
|
||||
helpers:NavHelper.NavigateTo="views:RegistryPreviewPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/RegistryPreview.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_MeasureTool"
|
||||
helpers:NavHelper.NavigateTo="views:MeasureToolPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/ScreenRuler.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_ShortcutGuide"
|
||||
helpers:NavHelper.NavigateTo="views:ShortcutGuidePage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/ShortcutGuide.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_TextExtractor"
|
||||
helpers:NavHelper.NavigateTo="views:PowerOcrPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/TextExtractor.png}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_VideoConference"
|
||||
helpers:NavHelper.NavigateTo="views:VideoConferencePage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/VideoConferenceMute.png}"
|
||||
IsEnabled="{x:Bind ViewModel.IsVideoConferenceBuild, Mode=OneWay}" />
|
||||
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_Workspaces"
|
||||
helpers:NavHelper.NavigateTo="views:WorkspacesPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Workspaces.png}" />
|
||||
x:Uid="Shell_TopLevelAdvanced"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Advanced.png}"
|
||||
SelectsOnInvoked="False">
|
||||
<NavigationViewItem.MenuItems>
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_CmdNotFound"
|
||||
helpers:NavHelper.NavigateTo="views:CmdNotFoundPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/CommandNotFound.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_EnvironmentVariables"
|
||||
helpers:NavHelper.NavigateTo="views:EnvironmentVariablesPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/EnvironmentVariables.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_Hosts"
|
||||
helpers:NavHelper.NavigateTo="views:HostsPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Hosts.png}" />
|
||||
<NavigationViewItem
|
||||
x:Uid="Shell_RegistryPreview"
|
||||
helpers:NavHelper.NavigateTo="views:RegistryPreviewPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/RegistryPreview.png}" />
|
||||
</NavigationViewItem.MenuItems>
|
||||
</NavigationViewItem>
|
||||
</NavigationView.MenuItems>
|
||||
<NavigationView.PaneFooter>
|
||||
<StackPanel Orientation="Vertical">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Linq;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Services;
|
||||
@@ -122,6 +122,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
|
||||
public static bool IsUserAnAdmin { get; set; }
|
||||
|
||||
private Dictionary<Type, NavigationViewItem> _navViewParentLookup = new Dictionary<Type, NavigationViewItem>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ShellPage"/> class.
|
||||
/// Shell page constructor.
|
||||
@@ -138,6 +140,21 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
// shellFrame.Navigate(typeof(GeneralPage));
|
||||
IPCResponseHandleList.Add(ReceiveMessage);
|
||||
SetTitleBar();
|
||||
|
||||
if (_navViewParentLookup.Count > 0)
|
||||
{
|
||||
_navViewParentLookup.Clear();
|
||||
}
|
||||
|
||||
var topLevelItems = navigationView.MenuItems.OfType<NavigationViewItem>().ToArray();
|
||||
|
||||
foreach (var parent in topLevelItems)
|
||||
{
|
||||
foreach (var child in parent.MenuItems.OfType<NavigationViewItem>())
|
||||
{
|
||||
_navViewParentLookup.TryAdd(child.GetValue(NavHelper.NavigateToProperty) as Type, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int SendDefaultIPCMessage(string msg)
|
||||
@@ -277,7 +294,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
|
||||
private bool navigationViewInitialStateProcessed; // avoid announcing initial state of the navigation pane.
|
||||
|
||||
private void NavigationView_PaneOpened(Microsoft.UI.Xaml.Controls.NavigationView sender, object args)
|
||||
private void NavigationView_PaneOpened(NavigationView sender, object args)
|
||||
{
|
||||
if (!navigationViewInitialStateProcessed)
|
||||
{
|
||||
@@ -293,7 +310,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
|
||||
if (AutomationPeer.ListenerExists(AutomationEvents.MenuOpened))
|
||||
{
|
||||
var loader = Helpers.ResourceLoaderInstance.ResourceLoader;
|
||||
var loader = ResourceLoaderInstance.ResourceLoader;
|
||||
peer.RaiseNotificationEvent(
|
||||
AutomationNotificationKind.ActionCompleted,
|
||||
AutomationNotificationProcessing.ImportantMostRecent,
|
||||
@@ -302,7 +319,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
}
|
||||
}
|
||||
|
||||
private void NavigationView_PaneClosed(Microsoft.UI.Xaml.Controls.NavigationView sender, object args)
|
||||
private void NavigationView_PaneClosed(NavigationView sender, object args)
|
||||
{
|
||||
if (!navigationViewInitialStateProcessed)
|
||||
{
|
||||
@@ -318,7 +335,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
|
||||
if (AutomationPeer.ListenerExists(AutomationEvents.MenuClosed))
|
||||
{
|
||||
var loader = Helpers.ResourceLoaderInstance.ResourceLoader;
|
||||
var loader = ResourceLoaderInstance.ResourceLoader;
|
||||
peer.RaiseNotificationEvent(
|
||||
AutomationNotificationKind.ActionCompleted,
|
||||
AutomationNotificationProcessing.ImportantMostRecent,
|
||||
@@ -348,6 +365,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
if (selectedItem != null)
|
||||
{
|
||||
Type pageType = selectedItem.GetValue(NavHelper.NavigateToProperty) as Type;
|
||||
|
||||
if (_navViewParentLookup.TryGetValue(pageType, out var parentItem) && !parentItem.IsExpanded)
|
||||
{
|
||||
parentItem.IsExpanded = true;
|
||||
}
|
||||
|
||||
NavigationService.Navigate(pageType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,10 +59,7 @@
|
||||
: 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: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>
|
||||
@@ -4563,4 +4560,19 @@ Activate by holding the key for the character you want to add an accent to, then
|
||||
<data name="GeneralPage_ViewDiagnosticDataViewerInfoButton.Content" xml:space="preserve">
|
||||
<value>Restart</value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="Shell_TopLevelAdvanced.Content" xml:space="preserve">
|
||||
<value>Advanced</value>
|
||||
</data>
|
||||
<data name="Shell_TopLevelFileManagement.Content" xml:space="preserve">
|
||||
<value>File Management</value>
|
||||
</data>
|
||||
<data name="Shell_TopLevelInputOutput.Content" xml:space="preserve">
|
||||
<value>Input / Output</value>
|
||||
</data>
|
||||
<data name="Shell_TopLevelWindowsAndLayouts.Content" xml:space="preserve">
|
||||
<value>Windowing & Layouts</value>
|
||||
</data>
|
||||
<data name="Shell_TopLevelSystemTools.Content" xml:space="preserve">
|
||||
<value>System Tools</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -5,7 +5,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
@@ -32,6 +31,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
private NavigationViewItem selected;
|
||||
private ICommand loadedCommand;
|
||||
private ICommand itemInvokedCommand;
|
||||
private NavigationViewItem[] _fullListOfNavViewItems;
|
||||
|
||||
public bool IsBackEnabled
|
||||
{
|
||||
@@ -76,6 +76,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
NavigationService.NavigationFailed += Frame_NavigationFailed;
|
||||
NavigationService.Navigated += Frame_Navigated;
|
||||
this.navigationView.BackRequested += OnBackRequested;
|
||||
var topLevelItems = navigationView.MenuItems.OfType<NavigationViewItem>();
|
||||
_fullListOfNavViewItems = topLevelItems.Union(topLevelItems.SelectMany(menuItem => menuItem.MenuItems.OfType<NavigationViewItem>())).ToArray();
|
||||
}
|
||||
|
||||
private static KeyboardAccelerator BuildKeyboardAccelerator(VirtualKey key, VirtualKeyModifiers? modifiers = null)
|
||||
@@ -107,11 +109,12 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
private void OnItemInvoked(NavigationViewItemInvokedEventArgs args)
|
||||
{
|
||||
var item = navigationView.MenuItems
|
||||
.OfType<NavigationViewItem>()
|
||||
.First(menuItem => (string)menuItem.Content == (string)args.InvokedItem);
|
||||
var pageType = item.GetValue(NavHelper.NavigateToProperty) as Type;
|
||||
NavigationService.Navigate(pageType);
|
||||
var pageType = args.InvokedItemContainer.GetValue(NavHelper.NavigateToProperty) as Type;
|
||||
|
||||
if (pageType != null)
|
||||
{
|
||||
NavigationService.Navigate(pageType);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args)
|
||||
@@ -127,9 +130,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
private void Frame_Navigated(object sender, NavigationEventArgs e)
|
||||
{
|
||||
IsBackEnabled = NavigationService.CanGoBack;
|
||||
Selected = navigationView.MenuItems
|
||||
.OfType<NavigationViewItem>()
|
||||
.FirstOrDefault(menuItem => IsMenuItemForPageType(menuItem, e.SourcePageType));
|
||||
Selected = _fullListOfNavViewItems.FirstOrDefault(menuItem => IsMenuItemForPageType(menuItem, e.SourcePageType));
|
||||
}
|
||||
|
||||
private static bool IsMenuItemForPageType(NavigationViewItem menuItem, Type sourcePageType)
|
||||
|
||||
Reference in New Issue
Block a user