2020-04-08 00:19:00 -07:00
|
|
|
|
// 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.
|
|
|
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
|
using System;
|
2020-09-04 11:56:52 +03:00
|
|
|
|
using System.Collections.Generic;
|
2024-10-27 15:21:27 -07:00
|
|
|
|
using System.Linq;
|
2023-11-07 17:38:06 +01:00
|
|
|
|
using ManagedCommon;
|
2022-12-12 17:34:21 +01:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Helpers;
|
2021-03-02 20:56:37 +03:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Services;
|
2020-04-08 00:19:00 -07:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
2025-05-26 05:03:35 -04:00
|
|
|
|
using Microsoft.UI.Windowing;
|
2022-04-19 22:00:28 +02:00
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Automation.Peers;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
2020-09-04 11:56:52 +03:00
|
|
|
|
using Windows.Data.Json;
|
2022-04-19 22:00:28 +02:00
|
|
|
|
using Windows.System;
|
2025-01-13 17:13:16 +02:00
|
|
|
|
using WinRT.Interop;
|
2020-03-11 10:43:32 -07:00
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Views
|
|
|
|
|
|
{
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Root page.
|
|
|
|
|
|
/// </summary>
|
2020-03-11 10:43:32 -07:00
|
|
|
|
public sealed partial class ShellPage : UserControl
|
|
|
|
|
|
{
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// <summary>
|
2020-05-26 11:02:36 -04:00
|
|
|
|
/// Declaration for the ipc callback function.
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="msg">message.</param>
|
|
|
|
|
|
public delegate void IPCMessageCallback(string msg);
|
|
|
|
|
|
|
2023-01-31 00:00:11 +01:00
|
|
|
|
/// <summary>
|
Updates for check-spelling v0.0.25 (#40386)
## Summary of the Pull Request
- #39572 updated check-spelling but ignored:
> 🐣 Breaking Changes
[Code Scanning action requires a Code Scanning
Ruleset](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset)
If you use SARIF reporting, then instead of the workflow yielding an ❌
when it fails, it will rely on [github-advanced-security
🤖](https://github.com/apps/github-advanced-security) to report the
failure. You will need to adjust your checks for PRs.
This means that check-spelling hasn't been properly doing its job 😦.
I'm sorry, I should have pushed a thing to this repo earlier,...
Anyway, as with most refreshes, this comes with a number of fixes, some
are fixes for typos that snuck in before the 0.0.25 upgrade, some are
for things that snuck in after, some are based on new rules in
spell-check-this, and some are hand written patterns based on running
through this repository a few times.
About the 🐣 **breaking change**: someone needs to create a ruleset for
this repository (see [Code Scanning action requires a Code Scanning
Ruleset: Sample ruleset
](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset#sample-ruleset)).
The alternative to adding a ruleset is to change the condition to not
use sarif for this repository. In general, I think the github
integration from sarif is prettier/more helpful, so I think that it's
the better choice.
You can see an example of it working in:
- https://github.com/check-spelling-sandbox/PowerToys/pull/23
---------
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
2025-07-08 18:16:52 -04:00
|
|
|
|
/// Declaration for opening main window callback function.
|
2023-01-31 00:00:11 +01:00
|
|
|
|
/// </summary>
|
2023-05-02 13:10:54 +02:00
|
|
|
|
public delegate void MainOpeningCallback(Type type);
|
2023-01-31 00:00:11 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
Updates for check-spelling v0.0.25 (#40386)
## Summary of the Pull Request
- #39572 updated check-spelling but ignored:
> 🐣 Breaking Changes
[Code Scanning action requires a Code Scanning
Ruleset](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset)
If you use SARIF reporting, then instead of the workflow yielding an ❌
when it fails, it will rely on [github-advanced-security
🤖](https://github.com/apps/github-advanced-security) to report the
failure. You will need to adjust your checks for PRs.
This means that check-spelling hasn't been properly doing its job 😦.
I'm sorry, I should have pushed a thing to this repo earlier,...
Anyway, as with most refreshes, this comes with a number of fixes, some
are fixes for typos that snuck in before the 0.0.25 upgrade, some are
for things that snuck in after, some are based on new rules in
spell-check-this, and some are hand written patterns based on running
through this repository a few times.
About the 🐣 **breaking change**: someone needs to create a ruleset for
this repository (see [Code Scanning action requires a Code Scanning
Ruleset: Sample ruleset
](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset#sample-ruleset)).
The alternative to adding a ruleset is to change the condition to not
use sarif for this repository. In general, I think the github
integration from sarif is prettier/more helpful, so I think that it's
the better choice.
You can see an example of it working in:
- https://github.com/check-spelling-sandbox/PowerToys/pull/23
---------
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
2025-07-08 18:16:52 -04:00
|
|
|
|
/// Declaration for updating the general settings callback function.
|
2023-01-31 00:00:11 +01:00
|
|
|
|
/// </summary>
|
2023-11-07 17:38:06 +01:00
|
|
|
|
public delegate bool UpdatingGeneralSettingsCallback(ModuleType moduleType, bool isEnabled);
|
2023-01-31 00:00:11 +01:00
|
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
|
/// <summary>
|
Updates for check-spelling v0.0.25 (#40386)
## Summary of the Pull Request
- #39572 updated check-spelling but ignored:
> 🐣 Breaking Changes
[Code Scanning action requires a Code Scanning
Ruleset](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset)
If you use SARIF reporting, then instead of the workflow yielding an ❌
when it fails, it will rely on [github-advanced-security
🤖](https://github.com/apps/github-advanced-security) to report the
failure. You will need to adjust your checks for PRs.
This means that check-spelling hasn't been properly doing its job 😦.
I'm sorry, I should have pushed a thing to this repo earlier,...
Anyway, as with most refreshes, this comes with a number of fixes, some
are fixes for typos that snuck in before the 0.0.25 upgrade, some are
for things that snuck in after, some are based on new rules in
spell-check-this, and some are hand written patterns based on running
through this repository a few times.
About the 🐣 **breaking change**: someone needs to create a ruleset for
this repository (see [Code Scanning action requires a Code Scanning
Ruleset: Sample ruleset
](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset#sample-ruleset)).
The alternative to adding a ruleset is to change the condition to not
use sarif for this repository. In general, I think the github
integration from sarif is prettier/more helpful, so I think that it's
the better choice.
You can see an example of it working in:
- https://github.com/check-spelling-sandbox/PowerToys/pull/23
---------
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
2025-07-08 18:16:52 -04:00
|
|
|
|
/// Declaration for opening oobe window callback function.
|
2021-03-02 20:56:37 +03:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public delegate void OobeOpeningCallback();
|
|
|
|
|
|
|
2023-11-21 14:19:11 -05:00
|
|
|
|
/// <summary>
|
Updates for check-spelling v0.0.25 (#40386)
## Summary of the Pull Request
- #39572 updated check-spelling but ignored:
> 🐣 Breaking Changes
[Code Scanning action requires a Code Scanning
Ruleset](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset)
If you use SARIF reporting, then instead of the workflow yielding an ❌
when it fails, it will rely on [github-advanced-security
🤖](https://github.com/apps/github-advanced-security) to report the
failure. You will need to adjust your checks for PRs.
This means that check-spelling hasn't been properly doing its job 😦.
I'm sorry, I should have pushed a thing to this repo earlier,...
Anyway, as with most refreshes, this comes with a number of fixes, some
are fixes for typos that snuck in before the 0.0.25 upgrade, some are
for things that snuck in after, some are based on new rules in
spell-check-this, and some are hand written patterns based on running
through this repository a few times.
About the 🐣 **breaking change**: someone needs to create a ruleset for
this repository (see [Code Scanning action requires a Code Scanning
Ruleset: Sample ruleset
](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset#sample-ruleset)).
The alternative to adding a ruleset is to change the condition to not
use sarif for this repository. In general, I think the github
integration from sarif is prettier/more helpful, so I think that it's
the better choice.
You can see an example of it working in:
- https://github.com/check-spelling-sandbox/PowerToys/pull/23
---------
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
2025-07-08 18:16:52 -04:00
|
|
|
|
/// Declaration for opening whats new window callback function.
|
2023-11-21 14:19:11 -05:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public delegate void WhatIsNewOpeningCallback();
|
|
|
|
|
|
|
2023-01-31 00:00:11 +01:00
|
|
|
|
/// <summary>
|
Updates for check-spelling v0.0.25 (#40386)
## Summary of the Pull Request
- #39572 updated check-spelling but ignored:
> 🐣 Breaking Changes
[Code Scanning action requires a Code Scanning
Ruleset](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset)
If you use SARIF reporting, then instead of the workflow yielding an ❌
when it fails, it will rely on [github-advanced-security
🤖](https://github.com/apps/github-advanced-security) to report the
failure. You will need to adjust your checks for PRs.
This means that check-spelling hasn't been properly doing its job 😦.
I'm sorry, I should have pushed a thing to this repo earlier,...
Anyway, as with most refreshes, this comes with a number of fixes, some
are fixes for typos that snuck in before the 0.0.25 upgrade, some are
for things that snuck in after, some are based on new rules in
spell-check-this, and some are hand written patterns based on running
through this repository a few times.
About the 🐣 **breaking change**: someone needs to create a ruleset for
this repository (see [Code Scanning action requires a Code Scanning
Ruleset: Sample ruleset
](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset#sample-ruleset)).
The alternative to adding a ruleset is to change the condition to not
use sarif for this repository. In general, I think the github
integration from sarif is prettier/more helpful, so I think that it's
the better choice.
You can see an example of it working in:
- https://github.com/check-spelling-sandbox/PowerToys/pull/23
---------
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
2025-07-08 18:16:52 -04:00
|
|
|
|
/// Declaration for opening flyout window callback function.
|
2023-01-31 00:00:11 +01:00
|
|
|
|
/// </summary>
|
2023-02-03 15:10:14 +00:00
|
|
|
|
public delegate void FlyoutOpeningCallback(POINT? point);
|
2023-01-31 00:00:11 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
Updates for check-spelling v0.0.25 (#40386)
## Summary of the Pull Request
- #39572 updated check-spelling but ignored:
> 🐣 Breaking Changes
[Code Scanning action requires a Code Scanning
Ruleset](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset)
If you use SARIF reporting, then instead of the workflow yielding an ❌
when it fails, it will rely on [github-advanced-security
🤖](https://github.com/apps/github-advanced-security) to report the
failure. You will need to adjust your checks for PRs.
This means that check-spelling hasn't been properly doing its job 😦.
I'm sorry, I should have pushed a thing to this repo earlier,...
Anyway, as with most refreshes, this comes with a number of fixes, some
are fixes for typos that snuck in before the 0.0.25 upgrade, some are
for things that snuck in after, some are based on new rules in
spell-check-this, and some are hand written patterns based on running
through this repository a few times.
About the 🐣 **breaking change**: someone needs to create a ruleset for
this repository (see [Code Scanning action requires a Code Scanning
Ruleset: Sample ruleset
](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset#sample-ruleset)).
The alternative to adding a ruleset is to change the condition to not
use sarif for this repository. In general, I think the github
integration from sarif is prettier/more helpful, so I think that it's
the better choice.
You can see an example of it working in:
- https://github.com/check-spelling-sandbox/PowerToys/pull/23
---------
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
2025-07-08 18:16:52 -04:00
|
|
|
|
/// Declaration for disabling hide of flyout window callback function.
|
2023-01-31 00:00:11 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public delegate void DisablingFlyoutHidingCallback();
|
|
|
|
|
|
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// <summary>
|
2020-04-07 10:19:14 -07:00
|
|
|
|
/// Gets or sets a shell handler to be used to update contents of the shell dynamically from page within the frame.
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// </summary>
|
2020-04-07 10:19:14 -07:00
|
|
|
|
public static ShellPage ShellHandler { get; set; }
|
2020-03-11 10:43:32 -07:00
|
|
|
|
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// <summary>
|
2020-05-05 10:02:31 -07:00
|
|
|
|
/// Gets or sets iPC default callback function.
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// </summary>
|
2020-04-07 10:19:14 -07:00
|
|
|
|
public static IPCMessageCallback DefaultSndMSGCallback { get; set; }
|
2020-03-24 19:55:02 -07:00
|
|
|
|
|
2020-05-05 10:02:31 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets iPC callback function for restart as admin.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static IPCMessageCallback SndRestartAsAdminMsgCallback { get; set; }
|
|
|
|
|
|
|
2020-06-23 15:53:02 +03:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets iPC callback function for checking updates.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static IPCMessageCallback CheckForUpdatesMsgCallback { get; set; }
|
|
|
|
|
|
|
2023-01-31 00:00:11 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets callback function for opening main window
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static MainOpeningCallback OpenMainWindowCallback { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets callback function for updating the general settings
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static UpdatingGeneralSettingsCallback UpdateGeneralSettingsCallback { get; set; }
|
|
|
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets callback function for opening oobe window
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static OobeOpeningCallback OpenOobeWindowCallback { get; set; }
|
|
|
|
|
|
|
2023-11-21 14:19:11 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets callback function for opening oobe window
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static WhatIsNewOpeningCallback OpenWhatIsNewWindowCallback { get; set; }
|
|
|
|
|
|
|
2023-01-31 00:00:11 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets callback function for opening flyout window
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static FlyoutOpeningCallback OpenFlyoutCallback { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets callback function for disabling hide of flyout window
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static DisablingFlyoutHidingCallback DisableFlyoutHidingCallback { get; set; }
|
|
|
|
|
|
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// <summary>
|
2020-04-07 10:19:14 -07:00
|
|
|
|
/// Gets view model.
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// </summary>
|
2020-04-07 10:19:14 -07:00
|
|
|
|
public ShellViewModel ViewModel { get; } = new ShellViewModel();
|
2020-03-24 19:55:02 -07:00
|
|
|
|
|
2020-09-04 11:56:52 +03:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets a collection of functions that handle IPC responses.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public List<System.Action<JsonObject>> IPCResponseHandleList { get; } = new List<System.Action<JsonObject>>();
|
|
|
|
|
|
|
2020-05-05 10:02:31 -07:00
|
|
|
|
public static bool IsElevated { get; set; }
|
|
|
|
|
|
|
2020-05-14 12:36:27 +03:00
|
|
|
|
public static bool IsUserAnAdmin { get; set; }
|
|
|
|
|
|
|
2024-10-27 15:21:27 -07:00
|
|
|
|
private Dictionary<Type, NavigationViewItem> _navViewParentLookup = new Dictionary<Type, NavigationViewItem>();
|
|
|
|
|
|
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="ShellPage"/> class.
|
|
|
|
|
|
/// Shell page constructor.
|
|
|
|
|
|
/// </summary>
|
2020-03-11 10:43:32 -07:00
|
|
|
|
public ShellPage()
|
|
|
|
|
|
{
|
2020-04-10 15:22:07 -07:00
|
|
|
|
InitializeComponent();
|
2020-03-24 19:55:02 -07:00
|
|
|
|
|
2020-04-10 15:22:07 -07:00
|
|
|
|
DataContext = ViewModel;
|
2020-03-30 02:02:25 -07:00
|
|
|
|
ShellHandler = this;
|
2020-04-10 15:22:07 -07:00
|
|
|
|
ViewModel.Initialize(shellFrame, navigationView, KeyboardAccelerators);
|
2023-01-31 00:00:11 +01:00
|
|
|
|
|
|
|
|
|
|
// NL moved navigation to general page to the moment when the window is first activated (to not make flyout window disappear)
|
|
|
|
|
|
// shellFrame.Navigate(typeof(GeneralPage));
|
|
|
|
|
|
IPCResponseHandleList.Add(ReceiveMessage);
|
2025-08-20 09:31:52 +08:00
|
|
|
|
Services.IPCResponseService.Instance.RegisterForIPC();
|
2023-06-11 17:54:01 +02:00
|
|
|
|
SetTitleBar();
|
2024-10-27 15:21:27 -07:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-03-24 19:55:02 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-13 15:02:05 -07:00
|
|
|
|
public static int SendDefaultIPCMessage(string msg)
|
|
|
|
|
|
{
|
2021-06-04 10:13:56 -07:00
|
|
|
|
DefaultSndMSGCallback?.Invoke(msg);
|
2020-08-13 15:02:05 -07:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int SendCheckForUpdatesIPCMessage(string msg)
|
|
|
|
|
|
{
|
2021-06-04 10:13:56 -07:00
|
|
|
|
CheckForUpdatesMsgCallback?.Invoke(msg);
|
|
|
|
|
|
|
2020-08-13 15:02:05 -07:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int SendRestartAdminIPCMessage(string msg)
|
|
|
|
|
|
{
|
2021-06-04 10:13:56 -07:00
|
|
|
|
SndRestartAsAdminMsgCallback?.Invoke(msg);
|
2020-08-13 15:02:05 -07:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// <summary>
|
2020-05-05 10:02:31 -07:00
|
|
|
|
/// Set Default IPC Message callback function.
|
2020-03-24 19:55:02 -07:00
|
|
|
|
/// </summary>
|
2020-05-27 11:06:17 -04:00
|
|
|
|
/// <param name="implementation">delegate function implementation.</param>
|
2020-10-29 14:24:16 -07:00
|
|
|
|
public static void SetDefaultSndMessageCallback(IPCMessageCallback implementation)
|
2020-03-24 19:55:02 -07:00
|
|
|
|
{
|
2020-05-27 11:06:17 -04:00
|
|
|
|
DefaultSndMSGCallback = implementation;
|
2020-03-24 19:55:02 -07:00
|
|
|
|
}
|
2020-05-05 10:02:31 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set restart as admin IPC callback function.
|
|
|
|
|
|
/// </summary>
|
2020-05-27 11:06:17 -04:00
|
|
|
|
/// <param name="implementation">delegate function implementation.</param>
|
2020-10-29 14:24:16 -07:00
|
|
|
|
public static void SetRestartAdminSndMessageCallback(IPCMessageCallback implementation)
|
2020-05-05 10:02:31 -07:00
|
|
|
|
{
|
2020-05-27 11:06:17 -04:00
|
|
|
|
SndRestartAsAdminMsgCallback = implementation;
|
2020-05-05 10:02:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-23 15:53:02 +03:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set check for updates IPC callback function.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="implementation">delegate function implementation.</param>
|
2020-10-29 14:24:16 -07:00
|
|
|
|
public static void SetCheckForUpdatesMessageCallback(IPCMessageCallback implementation)
|
2020-06-23 15:53:02 +03:00
|
|
|
|
{
|
|
|
|
|
|
CheckForUpdatesMsgCallback = implementation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-31 00:00:11 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set main window opening callback function
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="implementation">delegate function implementation.</param>
|
|
|
|
|
|
public static void SetOpenMainWindowCallback(MainOpeningCallback implementation)
|
|
|
|
|
|
{
|
|
|
|
|
|
OpenMainWindowCallback = implementation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set updating the general settings callback function
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="implementation">delegate function implementation.</param>
|
|
|
|
|
|
public static void SetUpdatingGeneralSettingsCallback(UpdatingGeneralSettingsCallback implementation)
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateGeneralSettingsCallback = implementation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set oobe opening callback function
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="implementation">delegate function implementation.</param>
|
|
|
|
|
|
public static void SetOpenOobeCallback(OobeOpeningCallback implementation)
|
|
|
|
|
|
{
|
|
|
|
|
|
OpenOobeWindowCallback = implementation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-11-21 14:19:11 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set whats new opening callback function
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="implementation">delegate function implementation.</param>
|
|
|
|
|
|
public static void SetOpenWhatIsNewCallback(WhatIsNewOpeningCallback implementation)
|
|
|
|
|
|
{
|
|
|
|
|
|
OpenWhatIsNewWindowCallback = implementation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-31 00:00:11 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set flyout opening callback function
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="implementation">delegate function implementation.</param>
|
|
|
|
|
|
public static void SetOpenFlyoutCallback(FlyoutOpeningCallback implementation)
|
|
|
|
|
|
{
|
|
|
|
|
|
OpenFlyoutCallback = implementation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set disable flyout hiding callback function
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="implementation">delegate function implementation.</param>
|
|
|
|
|
|
public static void SetDisableFlyoutHidingCallback(DisablingFlyoutHidingCallback implementation)
|
|
|
|
|
|
{
|
|
|
|
|
|
DisableFlyoutHidingCallback = implementation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-29 14:24:16 -07:00
|
|
|
|
public static void SetElevationStatus(bool isElevated)
|
2020-05-05 10:02:31 -07:00
|
|
|
|
{
|
|
|
|
|
|
IsElevated = isElevated;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-29 14:24:16 -07:00
|
|
|
|
public static void SetIsUserAnAdmin(bool isAdmin)
|
2020-05-14 12:36:27 +03:00
|
|
|
|
{
|
|
|
|
|
|
IsUserAnAdmin = isAdmin;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
|
public static void Navigate(Type type)
|
|
|
|
|
|
{
|
|
|
|
|
|
NavigationService.Navigate(type);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-05 10:02:31 -07:00
|
|
|
|
public void Refresh()
|
|
|
|
|
|
{
|
[Settings]Adding a Dashboard Panel (#29023)
* Dashboard: modifying page content + adding SW version button.
* Visual tweaks and minor viewmodel changes
* Updated spacing
* Adding Settings icon
* Settiing the Dashboard page as the default one. Adding functionality to switch to settings pages from the Dashboard page. Localizing texts.
* fixing csproj file
* Reimplementing Active modules handling, showing only the active modules (and not having invisible inactive modules).
* Removing unneccessary binding
* Fix text wrapping
* Adding Registry previewer launch, adding activation mode for FindMyMouse and QuickAccent, modify File Locksmith description.
* Spell checker fix typo
* Adding GPO-blocked state, modifying buttons: adding description, icon.
* Modifying dashboard button layout
* Use SettingsCard instead of button
* Restructuring the dashboard panel
* Removing togglebuttons from the left panel. Showing only active modules. Adding key remappings (to KBM)
* Removing settings buttons, removing descriptions, icons from buttons. Add update of remapped keys, shortcuts.
* Refactoring dashboard
* Making list always visible and fixing scrolling behavior
* Adding background gradient to cards
* Removing keyboard manager's key mappings, minor changes in texts, fixing enabled state when GPO-enabled.
* Use ListView instead of ItemsRepeater
* Updates
* removing right panel with all modules. Extending "left" panel with toggleswitches, showing all modules.
* Separate lists
* Adding Flyout with key remappings for KBM module, adding IsLocked property, icons
* Visual tweaks
* Tweaks
* Fixing lock icon margin
* Minor fixes.
* Removing unused resources
* Make Dashboard default when coming from the OOBE General
* Removed the Previous, Next Layout buttons from FancyZones. Added activation information
---------
Co-authored-by: Niels Laute <niels.laute@live.nl>
2023-10-20 14:23:25 +02:00
|
|
|
|
shellFrame.Navigate(typeof(DashboardPage));
|
2020-05-05 10:02:31 -07:00
|
|
|
|
}
|
2021-01-05 16:01:42 +01:00
|
|
|
|
|
2023-01-31 00:00:11 +01:00
|
|
|
|
// Tell the current page view model to update
|
|
|
|
|
|
public void SignalGeneralDataUpdate()
|
|
|
|
|
|
{
|
|
|
|
|
|
IRefreshablePage currentPage = shellFrame?.Content as IRefreshablePage;
|
|
|
|
|
|
if (currentPage != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentPage.RefreshEnabledState();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-23 19:48:52 +02:00
|
|
|
|
private void OobeButton_Click(object sender, RoutedEventArgs e)
|
2021-01-05 16:01:42 +01:00
|
|
|
|
{
|
2021-08-23 19:48:52 +02:00
|
|
|
|
OpenOobeWindowCallback();
|
2021-01-05 16:01:42 +01:00
|
|
|
|
}
|
2021-08-10 15:03:04 +01:00
|
|
|
|
|
|
|
|
|
|
private bool navigationViewInitialStateProcessed; // avoid announcing initial state of the navigation pane.
|
|
|
|
|
|
|
2024-10-27 15:21:27 -07:00
|
|
|
|
private void NavigationView_PaneOpened(NavigationView sender, object args)
|
2021-08-10 15:03:04 +01:00
|
|
|
|
{
|
|
|
|
|
|
if (!navigationViewInitialStateProcessed)
|
|
|
|
|
|
{
|
|
|
|
|
|
navigationViewInitialStateProcessed = true;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var peer = FrameworkElementAutomationPeer.FromElement(sender);
|
|
|
|
|
|
if (peer == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
peer = FrameworkElementAutomationPeer.CreatePeerForElement(sender);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (AutomationPeer.ListenerExists(AutomationEvents.MenuOpened))
|
|
|
|
|
|
{
|
2024-10-27 15:21:27 -07:00
|
|
|
|
var loader = ResourceLoaderInstance.ResourceLoader;
|
2021-08-10 15:03:04 +01:00
|
|
|
|
peer.RaiseNotificationEvent(
|
|
|
|
|
|
AutomationNotificationKind.ActionCompleted,
|
|
|
|
|
|
AutomationNotificationProcessing.ImportantMostRecent,
|
|
|
|
|
|
loader.GetString("Shell_NavigationMenu_Announce_Open"),
|
|
|
|
|
|
"navigationMenuPaneOpened");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-27 15:21:27 -07:00
|
|
|
|
private void NavigationView_PaneClosed(NavigationView sender, object args)
|
2021-08-10 15:03:04 +01:00
|
|
|
|
{
|
|
|
|
|
|
if (!navigationViewInitialStateProcessed)
|
|
|
|
|
|
{
|
|
|
|
|
|
navigationViewInitialStateProcessed = true;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var peer = FrameworkElementAutomationPeer.FromElement(sender);
|
|
|
|
|
|
if (peer == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
peer = FrameworkElementAutomationPeer.CreatePeerForElement(sender);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (AutomationPeer.ListenerExists(AutomationEvents.MenuClosed))
|
|
|
|
|
|
{
|
2024-10-27 15:21:27 -07:00
|
|
|
|
var loader = ResourceLoaderInstance.ResourceLoader;
|
2021-08-10 15:03:04 +01:00
|
|
|
|
peer.RaiseNotificationEvent(
|
|
|
|
|
|
AutomationNotificationKind.ActionCompleted,
|
|
|
|
|
|
AutomationNotificationProcessing.ImportantMostRecent,
|
|
|
|
|
|
loader.GetString("Shell_NavigationMenu_Announce_Collapse"),
|
|
|
|
|
|
"navigationMenuPaneClosed");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-08-23 19:48:52 +02:00
|
|
|
|
|
2022-04-19 22:00:28 +02:00
|
|
|
|
private void OOBEItem_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
|
2021-08-23 19:48:52 +02:00
|
|
|
|
{
|
|
|
|
|
|
OpenOobeWindowCallback();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-19 22:00:28 +02:00
|
|
|
|
private async void FeedbackItem_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
|
2021-08-23 19:48:52 +02:00
|
|
|
|
{
|
2022-04-19 22:00:28 +02:00
|
|
|
|
await Launcher.LaunchUriAsync(new Uri("https://aka.ms/powerToysGiveFeedback"));
|
2021-08-23 19:48:52 +02:00
|
|
|
|
}
|
2022-12-12 17:34:21 +01:00
|
|
|
|
|
2023-11-21 14:19:11 -05:00
|
|
|
|
private void WhatIsNewItem_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
OpenWhatIsNewWindowCallback();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-12 17:34:21 +01:00
|
|
|
|
private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
NavigationViewItem selectedItem = args.SelectedItem as NavigationViewItem;
|
|
|
|
|
|
if (selectedItem != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Type pageType = selectedItem.GetValue(NavHelper.NavigateToProperty) as Type;
|
2024-10-27 15:21:27 -07:00
|
|
|
|
|
|
|
|
|
|
if (_navViewParentLookup.TryGetValue(pageType, out var parentItem) && !parentItem.IsExpanded)
|
|
|
|
|
|
{
|
|
|
|
|
|
parentItem.IsExpanded = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-12 17:34:21 +01:00
|
|
|
|
NavigationService.Navigate(pageType);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-01-31 00:00:11 +01:00
|
|
|
|
|
|
|
|
|
|
private void ReceiveMessage(JsonObject json)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (json != null)
|
|
|
|
|
|
{
|
2023-02-03 15:10:14 +00:00
|
|
|
|
IJsonValue whatToShowJson;
|
|
|
|
|
|
if (json.TryGetValue("ShowYourself", out whatToShowJson))
|
2023-01-31 00:00:11 +01:00
|
|
|
|
{
|
2023-03-16 15:51:31 +01:00
|
|
|
|
if (whatToShowJson.ValueType == JsonValueType.String && whatToShowJson.GetString().Equals("flyout", StringComparison.Ordinal))
|
2023-01-31 00:00:11 +01:00
|
|
|
|
{
|
2023-02-03 15:10:14 +00:00
|
|
|
|
POINT? p = null;
|
|
|
|
|
|
|
|
|
|
|
|
IJsonValue flyoutPointX;
|
|
|
|
|
|
IJsonValue flyoutPointY;
|
|
|
|
|
|
if (json.TryGetValue("x_position", out flyoutPointX) && json.TryGetValue("y_position", out flyoutPointY))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (flyoutPointX.ValueType == JsonValueType.Number && flyoutPointY.ValueType == JsonValueType.Number)
|
|
|
|
|
|
{
|
|
|
|
|
|
int flyout_x = (int)flyoutPointX.GetNumber();
|
|
|
|
|
|
int flyout_y = (int)flyoutPointY.GetNumber();
|
|
|
|
|
|
p = new POINT(flyout_x, flyout_y);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OpenFlyoutCallback(p);
|
2023-01-31 00:00:11 +01:00
|
|
|
|
}
|
2023-05-02 13:10:54 +02:00
|
|
|
|
else if (whatToShowJson.ValueType == JsonValueType.String)
|
2023-01-31 00:00:11 +01:00
|
|
|
|
{
|
2023-05-02 13:10:54 +02:00
|
|
|
|
OpenMainWindowCallback(App.GetPage(whatToShowJson.GetString()));
|
2023-01-31 00:00:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal static void EnsurePageIsSelected()
|
|
|
|
|
|
{
|
[Settings]Adding a Dashboard Panel (#29023)
* Dashboard: modifying page content + adding SW version button.
* Visual tweaks and minor viewmodel changes
* Updated spacing
* Adding Settings icon
* Settiing the Dashboard page as the default one. Adding functionality to switch to settings pages from the Dashboard page. Localizing texts.
* fixing csproj file
* Reimplementing Active modules handling, showing only the active modules (and not having invisible inactive modules).
* Removing unneccessary binding
* Fix text wrapping
* Adding Registry previewer launch, adding activation mode for FindMyMouse and QuickAccent, modify File Locksmith description.
* Spell checker fix typo
* Adding GPO-blocked state, modifying buttons: adding description, icon.
* Modifying dashboard button layout
* Use SettingsCard instead of button
* Restructuring the dashboard panel
* Removing togglebuttons from the left panel. Showing only active modules. Adding key remappings (to KBM)
* Removing settings buttons, removing descriptions, icons from buttons. Add update of remapped keys, shortcuts.
* Refactoring dashboard
* Making list always visible and fixing scrolling behavior
* Adding background gradient to cards
* Removing keyboard manager's key mappings, minor changes in texts, fixing enabled state when GPO-enabled.
* Use ListView instead of ItemsRepeater
* Updates
* removing right panel with all modules. Extending "left" panel with toggleswitches, showing all modules.
* Separate lists
* Adding Flyout with key remappings for KBM module, adding IsLocked property, icons
* Visual tweaks
* Tweaks
* Fixing lock icon margin
* Minor fixes.
* Removing unused resources
* Make Dashboard default when coming from the OOBE General
* Removed the Previous, Next Layout buttons from FancyZones. Added activation information
---------
Co-authored-by: Niels Laute <niels.laute@live.nl>
2023-10-20 14:23:25 +02:00
|
|
|
|
NavigationService.EnsurePageIsSelected(typeof(DashboardPage));
|
2023-01-31 00:00:11 +01:00
|
|
|
|
}
|
2023-06-11 17:54:01 +02:00
|
|
|
|
|
|
|
|
|
|
private void SetTitleBar()
|
|
|
|
|
|
{
|
|
|
|
|
|
var u = App.GetSettingsWindow();
|
|
|
|
|
|
if (u != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// A custom title bar is required for full window theme and Mica support.
|
|
|
|
|
|
// https://docs.microsoft.com/windows/apps/develop/title-bar?tabs=winui3#full-customization
|
|
|
|
|
|
u.ExtendsContentIntoTitleBar = true;
|
2025-05-26 05:03:35 -04:00
|
|
|
|
u.AppWindow.TitleBar.PreferredHeightOption = TitleBarHeightOption.Tall;
|
2025-01-13 17:13:16 +02:00
|
|
|
|
WindowHelpers.ForceTopBorder1PixelInsetOnWindows10(WindowNative.GetWindowHandle(u));
|
2023-06-11 17:54:01 +02:00
|
|
|
|
u.SetTitleBar(AppTitleBar);
|
2023-09-12 12:11:26 +02:00
|
|
|
|
var loader = ResourceLoaderInstance.ResourceLoader;
|
|
|
|
|
|
AppTitleBarText.Text = App.IsElevated ? loader.GetString("SettingsWindow_AdminTitle") : loader.GetString("SettingsWindow_Title");
|
2023-06-11 17:54:01 +02:00
|
|
|
|
#if DEBUG
|
|
|
|
|
|
DebugMessage.Visibility = Visibility.Visible;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ShellPage_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetTitleBar();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void NavigationView_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (args.DisplayMode == NavigationViewDisplayMode.Compact || args.DisplayMode == NavigationViewDisplayMode.Minimal)
|
|
|
|
|
|
{
|
|
|
|
|
|
PaneToggleBtn.Visibility = Visibility.Visible;
|
|
|
|
|
|
AppTitleBar.Margin = new Thickness(48, 0, 0, 0);
|
|
|
|
|
|
AppTitleBarText.Margin = new Thickness(12, 0, 0, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
PaneToggleBtn.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
AppTitleBar.Margin = new Thickness(16, 0, 0, 0);
|
|
|
|
|
|
AppTitleBarText.Margin = new Thickness(16, 0, 0, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void PaneToggleBtn_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
navigationView.IsPaneOpen = !navigationView.IsPaneOpen;
|
|
|
|
|
|
}
|
2025-05-26 05:03:35 -04:00
|
|
|
|
|
|
|
|
|
|
private void ExitPTItem_Tapped(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
const string ptTrayIconWindowClass = "PToyTrayIconWindow"; // Defined in runner/tray_icon.h
|
|
|
|
|
|
const nuint ID_EXIT_MENU_COMMAND = 40001; // Generated resource from runner/runner.base.rc
|
|
|
|
|
|
|
|
|
|
|
|
// Exit the XAML application
|
|
|
|
|
|
Application.Current.Exit();
|
|
|
|
|
|
|
|
|
|
|
|
// Invoke the exit command from the tray icon
|
|
|
|
|
|
IntPtr hWnd = NativeMethods.FindWindow(ptTrayIconWindowClass, ptTrayIconWindowClass);
|
|
|
|
|
|
NativeMethods.SendMessage(hWnd, NativeMethods.WM_COMMAND, ID_EXIT_MENU_COMMAND, 0);
|
|
|
|
|
|
}
|
2020-03-11 10:43:32 -07:00
|
|
|
|
}
|
2020-04-07 10:19:14 -07:00
|
|
|
|
}
|