[settings-ui] Settings WinUI3 (#17797)

* Add Settings.WinUI3 project

* New namespace

* Activation and Services

* Assets and Behaviors

* Converters and Helpers

* Controls

* View and ViewModels

* Styles and Themes

* OOBE

* Strings

* Small App moves

* [check] Project files - publish profiles and launchSettings.json

* [using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name workaround

* [WIP] Workarounds to make it work

* Fix suppressed warnings - naming

* Add code analysis

* Fix KBMPage and App dispatcher
Fix MessageBox - replace with MessageDialog

* Fix ImageResizerPage & mark ColorPickerButton with TODO

* Add icon to windows
Cleanup MainWindow.xaml.cs and OobeWindow.xaml.cs
MainWindows and OobeWindow management

* App Icon
No framework and runtime subdirs

* Remove PowerToys.Settings and Settings.UI from solution
Update output paths

* Installer work & publish.cmd

* Fix dispatcher crashes

* Fix crashes

* Add all dlls to installer
Cleanup installer
Add OpenOOBE and OpenScoobe logic
Fix minor issues
Fix update scenario - REINSTALLMODE

* Rename back namespaces, project name and project dir

* [wip] move to winappsdk 1.1

* Fix propagating isElevated & installer runtimes dlls

* Remove obsolete dir/file

* PowerToys.Interop to netstandard2.0

* Move everything to .Net6

* [Settings] Always launch settings process non-elevated (#17791)

* Move back to WinAppSdk 1.0.1

* Add Settings.WinUI3 project

* New namespace

* Activation and Services

* Assets and Behaviors

* Converters and Helpers

* Controls

* View and ViewModels

* Styles and Themes

* OOBE

* Strings

* Small App moves

* [check] Project files - publish profiles and launchSettings.json

* [using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name workaround

* [WIP] Workarounds to make it work

* Fix suppressed warnings - naming

* Add code analysis

* Fix KBMPage and App dispatcher
Fix MessageBox - replace with MessageDialog

* Fix ImageResizerPage & mark ColorPickerButton with TODO

* Add icon to windows
Cleanup MainWindow.xaml.cs and OobeWindow.xaml.cs
MainWindows and OobeWindow management

* App Icon
No framework and runtime subdirs

* Remove PowerToys.Settings and Settings.UI from solution
Update output paths

* Installer work & publish.cmd

* Fix dispatcher crashes

* Fix crashes

* Add all dlls to installer
Cleanup installer
Add OpenOOBE and OpenScoobe logic
Fix minor issues
Fix update scenario - REINSTALLMODE

* Rename back namespaces, project name and project dir

* [wip] move to winappsdk 1.1

* Fix propagating isElevated & installer runtimes dlls

* Remove obsolete dir/file

* PowerToys.Interop to netstandard2.0

* Move everything to .Net6

* [Settings] Always launch settings process non-elevated (#17791)

* Move back to WinAppSdk 1.0.1

* Revert merge conflict ARM64 removal

* Fix KBM Browse overlay image button

* Bring back settings publish profile

* Update release.yml

* Change target frameworkd windows version

* [Setup] Add Windows Application Runtime SDK (#17809)

* Update requirements doc

* Update compiling docs

* Fix signing

* Fix Settings exe and dll versions

* Add exception for dlls that have version 1.0.0.0

* Fix powershell condition

Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>
This commit is contained in:
Stefan Markovic
2022-04-19 22:00:28 +02:00
committed by GitHub
parent 42afc4f4fc
commit 27c4b1be0e
160 changed files with 1179 additions and 2120 deletions

View File

@@ -5,14 +5,12 @@
using System;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Automation;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Windows.ApplicationModel.Resources;
using Windows.System.Diagnostics;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Automation;
using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.System;
namespace Microsoft.PowerToys.Settings.UI.Controls
{
@@ -89,7 +87,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
this.Unloaded += ShortcutControl_Unloaded;
hook = new HotkeySettingsControlHook(Hotkey_KeyDown, Hotkey_KeyUp, Hotkey_IsActive, FilterAccessibleKeyboardEvents);
ResourceLoader resourceLoader = ResourceLoader.GetForCurrentView();
ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse();
// We create the Dialog in C# because doing it in XAML is giving WinUI/XAML Island bugs when using dark theme.
shortcutDialog = new ContentDialog
@@ -118,29 +116,29 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
private void KeyEventHandler(int key, bool matchValue, int matchValueCode)
{
switch ((Windows.System.VirtualKey)key)
switch ((VirtualKey)key)
{
case Windows.System.VirtualKey.LeftWindows:
case Windows.System.VirtualKey.RightWindows:
case VirtualKey.LeftWindows:
case VirtualKey.RightWindows:
internalSettings.Win = matchValue;
break;
case Windows.System.VirtualKey.Control:
case Windows.System.VirtualKey.LeftControl:
case Windows.System.VirtualKey.RightControl:
case VirtualKey.Control:
case VirtualKey.LeftControl:
case VirtualKey.RightControl:
internalSettings.Ctrl = matchValue;
break;
case Windows.System.VirtualKey.Menu:
case Windows.System.VirtualKey.LeftMenu:
case Windows.System.VirtualKey.RightMenu:
case VirtualKey.Menu:
case VirtualKey.LeftMenu:
case VirtualKey.RightMenu:
internalSettings.Alt = matchValue;
break;
case Windows.System.VirtualKey.Shift:
case Windows.System.VirtualKey.LeftShift:
case Windows.System.VirtualKey.RightShift:
case VirtualKey.Shift:
case VirtualKey.LeftShift:
case VirtualKey.RightShift:
_shiftToggled = true;
internalSettings.Shift = matchValue;
break;
case Windows.System.VirtualKey.Escape:
case VirtualKey.Escape:
internalSettings = new HotkeySettings();
shortcutDialog.IsPrimaryButtonEnabled = false;
return;
@@ -183,7 +181,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
}
// If the current key press is tab, based on the other keys ignore the key press so as to shift focus out of the hotkey control.
if ((Windows.System.VirtualKey)key == Windows.System.VirtualKey.Tab)
if ((VirtualKey)key == VirtualKey.Tab)
{
// Shift was not pressed while entering and Shift is not pressed while leaving the hotkey control, treat it as a normal tab key press.
if (!internalSettings.Shift && !_shiftKeyDownOnEntering && !internalSettings.Win && !internalSettings.Alt && !internalSettings.Ctrl)
@@ -197,7 +195,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
// This is to reset the shift key press within the control as it was not used within the control but rather was used to leave the hotkey.
internalSettings.Shift = false;
SendSingleKeyboardInput((short)Windows.System.VirtualKey.Shift, (uint)NativeKeyboardHelper.KeyEventF.KeyDown);
SendSingleKeyboardInput((short)VirtualKey.Shift, (uint)NativeKeyboardHelper.KeyEventF.KeyDown);
return false;
}
@@ -223,7 +221,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
// The system still has shift in the key pressed status, therefore pass a Shift KeyUp message to the system, to release the shift key, therefore simulating only the Tab key press.
else if (!internalSettings.Shift && _shiftKeyDownOnEntering && _shiftToggled && !internalSettings.Win && !internalSettings.Alt && !internalSettings.Ctrl)
{
SendSingleKeyboardInput((short)Windows.System.VirtualKey.Shift, (uint)NativeKeyboardHelper.KeyEventF.KeyUp);
SendSingleKeyboardInput((short)VirtualKey.Shift, (uint)NativeKeyboardHelper.KeyEventF.KeyUp);
return false;
}
@@ -238,50 +236,47 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
return true;
}
private async void Hotkey_KeyDown(int key)
private void Hotkey_KeyDown(int key)
{
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
KeyEventHandler(key, true, key);
c.Keys = internalSettings.GetKeysList();
if (internalSettings.GetKeysList().Count == 0)
{
KeyEventHandler(key, true, key);
// Empty, disable save button
shortcutDialog.IsPrimaryButtonEnabled = false;
}
else if (internalSettings.GetKeysList().Count == 1)
{
// 1 key, disable save button
shortcutDialog.IsPrimaryButtonEnabled = false;
c.Keys = internalSettings.GetKeysList();
if (internalSettings.GetKeysList().Count == 0)
// Check if the one key is a hotkey
if (internalSettings.Shift || internalSettings.Win || internalSettings.Alt || internalSettings.Ctrl)
{
// Empty, disable save button
shortcutDialog.IsPrimaryButtonEnabled = false;
c.IsError = false;
}
else if (internalSettings.GetKeysList().Count == 1)
else
{
// 1 key, disable save button
shortcutDialog.IsPrimaryButtonEnabled = false;
// Check if the one key is a hotkey
if (internalSettings.Shift || internalSettings.Win || internalSettings.Alt || internalSettings.Ctrl)
{
c.IsError = false;
}
else
{
c.IsError = true;
}
c.IsError = true;
}
}
// Tab and Shift+Tab are accessible keys and should not be displayed in the hotkey control.
if (internalSettings.Code > 0 && !internalSettings.IsAccessibleShortcut())
// Tab and Shift+Tab are accessible keys and should not be displayed in the hotkey control.
if (internalSettings.Code > 0 && !internalSettings.IsAccessibleShortcut())
{
lastValidSettings = internalSettings.Clone();
if (!ComboIsValid(lastValidSettings))
{
lastValidSettings = internalSettings.Clone();
if (!ComboIsValid(lastValidSettings))
{
DisableKeys();
}
else
{
EnableKeys();
}
DisableKeys();
}
});
else
{
EnableKeys();
}
}
}
private void EnableKeys()
@@ -300,12 +295,9 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
// WarningLabel.Style = (Style)App.Current.Resources["SecondaryWarningTextStyle"];
}
private async void Hotkey_KeyUp(int key)
private void Hotkey_KeyUp(int key)
{
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
KeyEventHandler(key, false, 0);
});
KeyEventHandler(key, false, 0);
}
private bool Hotkey_IsActive()
@@ -331,7 +323,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
_shiftToggled = false;
// To keep track of the shift key, whether it was pressed on entering.
if ((NativeMethods.GetAsyncKeyState((int)Windows.System.VirtualKey.Shift) & 0x8000) != 0)
if ((NativeMethods.GetAsyncKeyState((int)VirtualKey.Shift) & 0x8000) != 0)
{
_shiftKeyDownOnEntering = true;
}

View File

@@ -5,9 +5,9 @@
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkitcontrols="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:toolkitcontrols="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
xmlns:converters="using:CommunityToolkit.WinUI.UI.Converters"
mc:Ignorable="d"
x:Name="ShortcutContentControl">
<UserControl.Resources>
@@ -69,11 +69,11 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!--TODO(stefan) InfoBadge not available
<muxc:InfoBadge AutomationProperties.AccessibilityView="Raw"
Margin="2,0,12,0"
Style="{StaticResource CriticalIconInfoBadgeStyle}" />
-->
<TextBlock x:Name="InvalidShortcutWarningLabel"
x:Uid="InvalidShortcut"

View File

@@ -2,21 +2,9 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.PowerToys.Settings.UI.Library;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace Microsoft.PowerToys.Settings.UI.Controls
{

View File

@@ -6,7 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:toolkitcontrols="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:toolkitcontrols="using:CommunityToolkit.WinUI.UI.Controls"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">

View File

@@ -2,20 +2,9 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace Microsoft.PowerToys.Settings.UI.Controls
{