mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:12:32 +08:00
Merge branch 'main' into dev/ani/advanced-paste-semantic-kernel
This commit is contained in:
commit
1654716923
@ -26,7 +26,7 @@ namespace Microsoft.PowerToys.Telemetry
|
||||
|
||||
private readonly bool telemetryEnabled = DataDiagnosticsSettings.GetEnabledValue(); // This is the global telemetry setting on whether to log events
|
||||
private readonly bool telemetryRecordingEnabled = DataDiagnosticsSettings.GetViewEnabledValue(); // This is the setting for recording telemetry events to disk for viewing
|
||||
private readonly string etwFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\PowerToys\", "etw");
|
||||
private string etwFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\PowerToys\", "etw");
|
||||
private bool disposedValue;
|
||||
private string sessionName;
|
||||
private string etwFilePath;
|
||||
@ -49,6 +49,18 @@ namespace Microsoft.PowerToys.Telemetry
|
||||
/// Initializes a new instance of the <see cref="ETWTrace"/> class.
|
||||
/// </summary>
|
||||
public ETWTrace()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public ETWTrace(string etwPath)
|
||||
{
|
||||
this.etwFolderPath = etwPath;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (File.Exists(etwFolderPath))
|
||||
{
|
||||
|
@ -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();
|
||||
|
@ -14,7 +14,7 @@ namespace Hosts.Helpers
|
||||
public static void WaitForEventLoop(string eventName, Action callback)
|
||||
{
|
||||
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
||||
new Thread(() =>
|
||||
var t = new Thread(() =>
|
||||
{
|
||||
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
|
||||
while (true)
|
||||
@ -24,7 +24,10 @@ namespace Hosts.Helpers
|
||||
dispatcherQueue.TryEnqueue(() => callback());
|
||||
}
|
||||
}
|
||||
}).Start();
|
||||
});
|
||||
|
||||
t.IsBackground = true;
|
||||
t.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -216,6 +216,12 @@ public:
|
||||
m_hShowAdminEvent = nullptr;
|
||||
}
|
||||
|
||||
if (m_hTerminateEvent)
|
||||
{
|
||||
CloseHandle(m_hTerminateEvent);
|
||||
m_hTerminateEvent = nullptr;
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
@ -280,6 +286,7 @@ public:
|
||||
SetEvent(m_hTerminateEvent);
|
||||
WaitForSingleObject(m_hProcess, 1500);
|
||||
TerminateProcess(m_hProcess, 1);
|
||||
ResetEvent(m_hTerminateEvent);
|
||||
}
|
||||
|
||||
m_enabled = false;
|
||||
|
@ -38,18 +38,6 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdline, int cm
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||
if (mutex == nullptr)
|
||||
{
|
||||
Logger::error(L"Failed to create mutex. {}", get_last_error_or_default(GetLastError()));
|
||||
}
|
||||
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
Logger::warn(L"WorkspacesLauncher instance is already running");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring cmdLineStr{ GetCommandLineW() };
|
||||
auto cmdArgs = split(cmdLineStr, L" ");
|
||||
if (cmdArgs.workspaceId.empty())
|
||||
@ -59,6 +47,9 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdline, int cm
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!cmdArgs.isRestarted)
|
||||
{
|
||||
// check if restart is needed. Only check it if not yet restarted to avoid endless restarting. Restart is needed if the process is elevated.
|
||||
if (is_process_elevated())
|
||||
{
|
||||
Logger::warn("Workspaces Launcher is elevated, restart");
|
||||
@ -72,11 +63,24 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdline, int cm
|
||||
std::string cmdLineStr(cmdline);
|
||||
std::wstring cmdLineWStr(cmdLineStr.begin(), cmdLineStr.end());
|
||||
|
||||
std::wstring cmd = cmdArgs.workspaceId + L" " + std::to_wstring(cmdArgs.invokePoint);
|
||||
std::wstring cmd = cmdArgs.workspaceId + L" " + std::to_wstring(cmdArgs.invokePoint) + L" " + NonLocalizable::restartedString;
|
||||
|
||||
RunNonElevatedEx(exe_path.get(), cmd, modulePath);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
auto mutex = CreateMutex(nullptr, true, instanceMutexName.c_str());
|
||||
if (mutex == nullptr)
|
||||
{
|
||||
Logger::error(L"Failed to create mutex. {}", get_last_error_or_default(GetLastError()));
|
||||
}
|
||||
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
Logger::warn(L"WorkspacesLauncher instance is already running");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// COM should be initialized before ShellExecuteEx is called.
|
||||
if (FAILED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
|
||||
|
@ -6,15 +6,22 @@
|
||||
#include <workspaces-common/GuidUtils.h>
|
||||
#include <workspaces-common/InvokePoint.h>
|
||||
|
||||
namespace NonLocalizable
|
||||
{
|
||||
const wchar_t restartedString[] = L"restarted";
|
||||
}
|
||||
|
||||
struct CommandLineArgs
|
||||
{
|
||||
std::wstring workspaceId;
|
||||
InvokePoint invokePoint;
|
||||
bool isRestarted;
|
||||
};
|
||||
|
||||
CommandLineArgs split(std::wstring s, const std::wstring& delimiter)
|
||||
{
|
||||
CommandLineArgs cmdArgs{};
|
||||
cmdArgs.isRestarted = false;
|
||||
|
||||
size_t pos = 0;
|
||||
std::wstring token;
|
||||
@ -29,7 +36,11 @@ CommandLineArgs split(std::wstring s, const std::wstring& delimiter)
|
||||
|
||||
for (const auto& token : tokens)
|
||||
{
|
||||
if (!cmdArgs.workspaceId.empty())
|
||||
if (token == NonLocalizable::restartedString)
|
||||
{
|
||||
cmdArgs.isRestarted = true;
|
||||
}
|
||||
else if (!cmdArgs.workspaceId.empty())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ namespace Peek.UI.Native
|
||||
public static void WaitForEventLoop(string eventName, Action callback)
|
||||
{
|
||||
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
||||
new Thread(() =>
|
||||
var t = new Thread(() =>
|
||||
{
|
||||
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
|
||||
while (true)
|
||||
@ -24,7 +24,10 @@ namespace Peek.UI.Native
|
||||
dispatcherQueue.TryEnqueue(() => callback());
|
||||
}
|
||||
}
|
||||
}).Start();
|
||||
});
|
||||
|
||||
t.IsBackground = true;
|
||||
t.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
using Common;
|
||||
using Microsoft.PowerToys.FilePreviewCommon;
|
||||
using Microsoft.PowerToys.PreviewHandler.Gcode.Telemetry.Events;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Gcode
|
||||
{
|
||||
@ -84,6 +86,13 @@ namespace Microsoft.PowerToys.PreviewHandler.Gcode
|
||||
|
||||
Resize += FormResized;
|
||||
base.DoPreview(fs);
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new GcodeFilePreviewed());
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -153,6 +162,14 @@ namespace Microsoft.PowerToys.PreviewHandler.Gcode
|
||||
/// <param name="dataSource">Stream reference to access source file.</param>
|
||||
private void PreviewError<T>(Exception exception, T dataSource)
|
||||
{
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new GcodeFilePreviewError { Message = exception.Message });
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
|
||||
Controls.Clear();
|
||||
_infoBarAdded = true;
|
||||
AddTextBoxControl(Properties.Resource.GcodeNotPreviewedError);
|
||||
|
@ -6,6 +6,7 @@ using System.Globalization;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using Common.UI;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Gcode
|
||||
@ -27,6 +28,8 @@ namespace Microsoft.PowerToys.PreviewHandler.Gcode
|
||||
{
|
||||
if (args.Length == 6)
|
||||
{
|
||||
ETWTrace etwTrace = new ETWTrace(Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "AppData", "LocalLow", "Microsoft", "PowerToys", "etw"));
|
||||
|
||||
string filePath = args[0];
|
||||
IntPtr hwnd = IntPtr.Parse(args[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
|
||||
@ -52,12 +55,16 @@ namespace Microsoft.PowerToys.PreviewHandler.Gcode
|
||||
Rectangle s = default;
|
||||
if (!_previewHandlerControl.SetRect(s))
|
||||
{
|
||||
etwTrace?.Dispose();
|
||||
|
||||
// When the parent HWND became invalid, the application won't respond to Application.Exit().
|
||||
Environment.Exit(0);
|
||||
}
|
||||
},
|
||||
Dispatcher.CurrentDispatcher,
|
||||
_tokenSource.Token);
|
||||
|
||||
etwTrace?.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -0,0 +1,21 @@
|
||||
// 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.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Gcode.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event to be raised when a svg file has been viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class GcodeFileHandlerLoaded : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Gcode.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event to be raised when an error has occurred in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class GcodeFilePreviewError : EventBase, IEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the error message to log as part of the telemetry event.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// 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.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Gcode.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event to be raised when a svg file has been viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class GcodeFilePreviewed : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
@ -9,6 +9,8 @@ using System.Text.RegularExpressions;
|
||||
|
||||
using Common;
|
||||
using Microsoft.PowerToys.PreviewHandler.Markdown.Properties;
|
||||
using Microsoft.PowerToys.PreviewHandler.Markdown.Telemetry.Events;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using Microsoft.Web.WebView2.WinForms;
|
||||
using Windows.System;
|
||||
@ -215,9 +217,25 @@ namespace Microsoft.PowerToys.PreviewHandler.Markdown
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new MarkdownFilePreviewed());
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new MarkdownFilePreviewError { Message = ex.Message });
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
|
||||
Controls.Clear();
|
||||
_infoBarDisplayed = true;
|
||||
_infoBar = GetTextBoxControl(Resources.MarkdownNotPreviewedError);
|
||||
|
@ -6,6 +6,7 @@ using System.Globalization;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using Common.UI;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Markdown
|
||||
@ -27,6 +28,8 @@ namespace Microsoft.PowerToys.PreviewHandler.Markdown
|
||||
{
|
||||
if (args.Length == 6)
|
||||
{
|
||||
ETWTrace etwTrace = new ETWTrace(Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "AppData", "LocalLow", "Microsoft", "PowerToys", "etw"));
|
||||
|
||||
string filePath = args[0];
|
||||
IntPtr hwnd = IntPtr.Parse(args[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
|
||||
@ -52,12 +55,16 @@ namespace Microsoft.PowerToys.PreviewHandler.Markdown
|
||||
Rectangle s = default;
|
||||
if (!_previewHandlerControl.SetRect(s))
|
||||
{
|
||||
etwTrace?.Dispose();
|
||||
|
||||
// When the parent HWND became invalid, the application won't respond to Application.Exit().
|
||||
Environment.Exit(0);
|
||||
}
|
||||
},
|
||||
Dispatcher.CurrentDispatcher,
|
||||
_tokenSource.Token);
|
||||
|
||||
etwTrace?.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -0,0 +1,21 @@
|
||||
// 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.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Markdown.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event that is triggered when a markdown file is viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class MarkdownFileHandlerLoaded : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Markdown.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event that is triggered when an error occurs while attempting to view a markdown file in the preview pane.
|
||||
/// </summary>
|
||||
public class MarkdownFilePreviewError : EventBase, IEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the error message.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// 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.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Markdown.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event that is triggered when a markdown file is viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class MarkdownFilePreviewed : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
@ -1,8 +1,17 @@
|
||||
// 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.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Common;
|
||||
using Common.Utilities;
|
||||
using Microsoft.PowerToys.PreviewHandler.Pdf.Properties;
|
||||
using Microsoft.PowerToys.PreviewHandler.Pdf.Telemetry.Events;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Windows.Data.Pdf;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.UI.ViewManagement;
|
||||
@ -149,9 +158,25 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
memStream.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new PdfFilePreviewed());
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new PdfFilePreviewError { Message = ex.Message });
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
|
||||
Controls.Clear();
|
||||
_infoBar = GetTextBoxControl(Resources.PdfNotPreviewedError);
|
||||
Controls.Add(_infoBar);
|
||||
|
@ -5,6 +5,7 @@ using System.Globalization;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using Common.UI;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
@ -26,6 +27,8 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
{
|
||||
if (args.Length == 6)
|
||||
{
|
||||
ETWTrace etwTrace = new ETWTrace(Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "AppData", "LocalLow", "Microsoft", "PowerToys", "etw"));
|
||||
|
||||
string filePath = args[0];
|
||||
IntPtr hwnd = IntPtr.Parse(args[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
|
||||
@ -51,12 +54,16 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
Rectangle s = default;
|
||||
if (!_previewHandlerControl.SetRect(s))
|
||||
{
|
||||
etwTrace?.Dispose();
|
||||
|
||||
// When the parent HWND became invalid, the application won't respond to Application.Exit().
|
||||
Environment.Exit(0);
|
||||
}
|
||||
},
|
||||
Dispatcher.CurrentDispatcher,
|
||||
_tokenSource.Token);
|
||||
|
||||
etwTrace?.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -0,0 +1,21 @@
|
||||
// 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.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Pdf.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event that is triggered when a pdf file is viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class PdfFileHandlerLoaded : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Pdf.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event that is triggered when an error occurs while attempting to view a markdown file in the preview pane.
|
||||
/// </summary>
|
||||
public class PdfFilePreviewError : EventBase, IEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the error message.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// 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.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Pdf.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event that is triggered when a markdown file is viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class PdfFilePreviewed : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using System.Globalization;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using Common.UI;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Qoi
|
||||
@ -27,6 +28,8 @@ namespace Microsoft.PowerToys.PreviewHandler.Qoi
|
||||
{
|
||||
if (args.Length == 6)
|
||||
{
|
||||
ETWTrace etwTrace = new ETWTrace(Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "AppData", "LocalLow", "Microsoft", "PowerToys", "etw"));
|
||||
|
||||
string filePath = args[0];
|
||||
IntPtr hwnd = IntPtr.Parse(args[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
|
||||
@ -52,12 +55,16 @@ namespace Microsoft.PowerToys.PreviewHandler.Qoi
|
||||
Rectangle s = default;
|
||||
if (!_previewHandlerControl.SetRect(s))
|
||||
{
|
||||
etwTrace?.Dispose();
|
||||
|
||||
// When the parent HWND became invalid, the application won't respond to Application.Exit().
|
||||
Environment.Exit(0);
|
||||
}
|
||||
},
|
||||
Dispatcher.CurrentDispatcher,
|
||||
_tokenSource.Token);
|
||||
|
||||
etwTrace?.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
using Common;
|
||||
using Microsoft.PowerToys.FilePreviewCommon;
|
||||
using Microsoft.PowerToys.PreviewHandler.Qoi.Telemetry.Events;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Qoi
|
||||
{
|
||||
@ -71,6 +73,13 @@ namespace Microsoft.PowerToys.PreviewHandler.Qoi
|
||||
|
||||
Resize += FormResized;
|
||||
base.DoPreview(fs);
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new QoiFilePreviewed());
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -140,6 +149,14 @@ namespace Microsoft.PowerToys.PreviewHandler.Qoi
|
||||
/// <param name="dataSource">Stream reference to access source file.</param>
|
||||
private void PreviewError<T>(Exception exception, T dataSource)
|
||||
{
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new QoiFilePreviewError { Message = exception.Message });
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
|
||||
Controls.Clear();
|
||||
_infoBarAdded = true;
|
||||
AddTextBoxControl(Properties.Resource.QoiNotPreviewedError);
|
||||
|
@ -0,0 +1,26 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Qoi.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event to be raised when an error has occurred in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class QoiFilePreviewError : EventBase, IEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the error message to log as part of the telemetry event.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// 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.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Qoi.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event to be raised when a Qoi file has been viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class QoiFilePreviewed : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using System.Globalization;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using Common.UI;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Svg
|
||||
@ -27,6 +28,8 @@ namespace Microsoft.PowerToys.PreviewHandler.Svg
|
||||
{
|
||||
if (args.Length == 6)
|
||||
{
|
||||
ETWTrace etwTrace = new ETWTrace(Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "AppData", "LocalLow", "Microsoft", "PowerToys", "etw"));
|
||||
|
||||
string filePath = args[0];
|
||||
IntPtr hwnd = IntPtr.Parse(args[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
|
||||
@ -52,12 +55,16 @@ namespace Microsoft.PowerToys.PreviewHandler.Svg
|
||||
Rectangle s = default;
|
||||
if (!_previewHandlerControl.SetRect(s))
|
||||
{
|
||||
etwTrace?.Dispose();
|
||||
|
||||
// When the parent HWND became invalid, the application won't respond to Application.Exit().
|
||||
Environment.Exit(0);
|
||||
}
|
||||
},
|
||||
Dispatcher.CurrentDispatcher,
|
||||
_tokenSource.Token);
|
||||
|
||||
etwTrace?.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2,11 +2,14 @@
|
||||
// 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.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using Common;
|
||||
using Common.Utilities;
|
||||
using Microsoft.PowerToys.PreviewHandler.Svg.Telemetry.Events;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using Microsoft.Web.WebView2.WinForms;
|
||||
using SvgPreviewHandler;
|
||||
@ -139,8 +142,15 @@ namespace Microsoft.PowerToys.PreviewHandler.Svg
|
||||
svgData = SvgPreviewHandlerHelper.SwapNamespaces(svgData);
|
||||
svgData = SvgPreviewHandlerHelper.AddStyleSVG(svgData);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new SvgFilePreviewError { Message = ex.Message });
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
@ -157,6 +167,13 @@ namespace Microsoft.PowerToys.PreviewHandler.Svg
|
||||
AddWebViewControl(svgData);
|
||||
Resize += FormResized;
|
||||
base.DoPreview(dataSource);
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new SvgFilePreviewed());
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -284,6 +301,14 @@ namespace Microsoft.PowerToys.PreviewHandler.Svg
|
||||
/// <param name="dataSource">Stream reference to access source file.</param>
|
||||
private void PreviewError<T>(Exception exception, T dataSource)
|
||||
{
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new SvgFilePreviewError { Message = exception.Message });
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
|
||||
Controls.Clear();
|
||||
_infoBarAdded = true;
|
||||
AddTextBoxControl(Properties.Resource.SvgNotPreviewedError);
|
||||
|
@ -0,0 +1,21 @@
|
||||
// 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.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Svg.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event to be raised when a svg file has been viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class SvgFileHandlerLoaded : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Svg.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event to be raised when an error has occurred in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class SvgFilePreviewError : EventBase, IEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the error message to log as part of the telemetry event.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// 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.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Svg.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event to be raised when a svg file has been viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class SvgFilePreviewed : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
@ -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 |
@ -14,7 +14,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
public static void WaitForEventLoop(string eventName, Action callback)
|
||||
{
|
||||
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
||||
new Thread(() =>
|
||||
var t = new Thread(() =>
|
||||
{
|
||||
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
|
||||
while (true)
|
||||
@ -24,7 +24,10 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
dispatcherQueue.TryEnqueue(() => callback());
|
||||
}
|
||||
}
|
||||
}).Start();
|
||||
});
|
||||
|
||||
t.IsBackground = true;
|
||||
t.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,135 +105,159 @@
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItemSeparator />
|
||||
|
||||
<!-- System Tools -->
|
||||
<NavigationViewItem
|
||||
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_AlwaysOnTop"
|
||||
helpers:NavHelper.NavigateTo="views:AlwaysOnTopPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/AlwaysOnTop.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_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.MenuItems>
|
||||
</NavigationViewItem>
|
||||
|
||||
<!-- Windowing & Layouts -->
|
||||
<NavigationViewItem
|
||||
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_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_Workspaces"
|
||||
helpers:NavHelper.NavigateTo="views:WorkspacesPage"
|
||||
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/Workspaces.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_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>
|
||||
@ -4569,4 +4566,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>
|
||||
<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>
|
@ -168,6 +168,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
string etwDirPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\PowerToys\\etw");
|
||||
DeleteDiagnosticDataOlderThan28Days(etwDirPath);
|
||||
|
||||
string localLowEtwDirPath = Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "AppData", "LocalLow", "Microsoft", "PowerToys", "etw");
|
||||
DeleteDiagnosticDataOlderThan28Days(localLowEtwDirPath);
|
||||
|
||||
InitializeLanguages();
|
||||
}
|
||||
|
||||
@ -1253,7 +1256,34 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
internal void ViewDiagnosticData()
|
||||
{
|
||||
string localLowEtwDirPath = Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "AppData", "LocalLow", "Microsoft", "PowerToys", "etw");
|
||||
string etwDirPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\PowerToys\\etw");
|
||||
|
||||
if (Directory.Exists(localLowEtwDirPath))
|
||||
{
|
||||
if (!Directory.Exists(etwDirPath))
|
||||
{
|
||||
Directory.CreateDirectory(etwDirPath);
|
||||
}
|
||||
|
||||
string[] localLowEtlFiles = Directory.GetFiles(localLowEtwDirPath, "*.etl");
|
||||
|
||||
foreach (string file in localLowEtlFiles)
|
||||
{
|
||||
string fileName = Path.GetFileName(file);
|
||||
string destFile = Path.Combine(etwDirPath, fileName);
|
||||
|
||||
try
|
||||
{
|
||||
File.Copy(file, destFile, overwrite: true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"Failed to copy etl file: {fileName}. Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string tracerptPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "system32");
|
||||
|
||||
ETLConverter converter = new ETLConverter(etwDirPath, tracerptPath);
|
||||
|
@ -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,12 +109,13 @@ 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;
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user