[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

@@ -6,16 +6,14 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Services;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Navigation;
using Windows.System;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;
using WinUI = Microsoft.UI.Xaml.Controls;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
@@ -27,8 +25,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private bool isBackEnabled;
private IList<KeyboardAccelerator> keyboardAccelerators;
private WinUI.NavigationView navigationView;
private WinUI.NavigationViewItem selected;
private NavigationView navigationView;
private NavigationViewItem selected;
private ICommand loadedCommand;
private ICommand itemInvokedCommand;
@@ -43,7 +41,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
get
{
var mfHandle = NativeMethods.LoadLibrary("mf.dll");
bool mfAvailable = mfHandle != null;
bool mfAvailable = mfHandle != IntPtr.Zero;
if (mfAvailable)
{
NativeMethods.FreeLibrary(mfHandle);
@@ -53,7 +51,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
public WinUI.NavigationViewItem Selected
public NavigationViewItem Selected
{
get { return selected; }
set { Set(ref selected, value); }
@@ -61,13 +59,13 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public ICommand LoadedCommand => loadedCommand ?? (loadedCommand = new RelayCommand(OnLoaded));
public ICommand ItemInvokedCommand => itemInvokedCommand ?? (itemInvokedCommand = new RelayCommand<WinUI.NavigationViewItemInvokedEventArgs>(OnItemInvoked));
public ICommand ItemInvokedCommand => itemInvokedCommand ?? (itemInvokedCommand = new RelayCommand<NavigationViewItemInvokedEventArgs>(OnItemInvoked));
public ShellViewModel()
{
}
public void Initialize(Frame frame, WinUI.NavigationView navigationView, IList<KeyboardAccelerator> keyboardAccelerators)
public void Initialize(Frame frame, NavigationView navigationView, IList<KeyboardAccelerator> keyboardAccelerators)
{
this.navigationView = navigationView;
this.keyboardAccelerators = keyboardAccelerators;
@@ -104,16 +102,16 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
await Task.CompletedTask.ConfigureAwait(false);
}
private void OnItemInvoked(WinUI.NavigationViewItemInvokedEventArgs args)
private void OnItemInvoked(NavigationViewItemInvokedEventArgs args)
{
var item = navigationView.MenuItems
.OfType<WinUI.NavigationViewItem>()
.OfType<NavigationViewItem>()
.First(menuItem => (string)menuItem.Content == (string)args.InvokedItem);
var pageType = item.GetValue(NavHelper.NavigateToProperty) as Type;
NavigationService.Navigate(pageType);
}
private void OnBackRequested(WinUI.NavigationView sender, WinUI.NavigationViewBackRequestedEventArgs args)
private void OnBackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args)
{
NavigationService.GoBack();
}
@@ -127,11 +125,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
IsBackEnabled = NavigationService.CanGoBack;
Selected = navigationView.MenuItems
.OfType<WinUI.NavigationViewItem>()
.OfType<NavigationViewItem>()
.FirstOrDefault(menuItem => IsMenuItemForPageType(menuItem, e.SourcePageType));
}
private static bool IsMenuItemForPageType(WinUI.NavigationViewItem menuItem, Type sourcePageType)
private static bool IsMenuItemForPageType(NavigationViewItem menuItem, Type sourcePageType)
{
var pageType = menuItem.GetValue(NavHelper.NavigateToProperty) as Type;
return pageType == sourcePageType;