mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request - Removing dead experiments code - Refactoring and simplifying OOBE/SCOOBE windowing code - Removing dead assets - Optimizing CmdPal assets to lower res shaving off a few MBs - Scrolling works better on the What's new page - Should be merged after: #44638 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [X] Closes: #44958 <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed --------- Co-authored-by: Gordon Lam (SH) <yeelam@microsoft.com>
179 lines
7.6 KiB
C#
179 lines
7.6 KiB
C#
// 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 ManagedCommon;
|
|
using Microsoft.PowerToys.Settings.UI.Helpers;
|
|
using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
|
|
using Microsoft.PowerToys.Settings.UI.OOBE.Views;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
using Microsoft.UI.Xaml.Input;
|
|
using PowerToys.Interop;
|
|
using WinRT.Interop;
|
|
using WinUIEx;
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI
|
|
{
|
|
public sealed partial class OobeWindow : WindowEx
|
|
{
|
|
public OobeShellViewModel ViewModel => App.OobeShellViewModel;
|
|
|
|
public static Func<string> RunSharedEventCallback { get; set; }
|
|
|
|
public static void SetRunSharedEventCallback(Func<string> implementation)
|
|
{
|
|
RunSharedEventCallback = implementation;
|
|
}
|
|
|
|
public static Func<string> ColorPickerSharedEventCallback { get; set; }
|
|
|
|
public static void SetColorPickerSharedEventCallback(Func<string> implementation)
|
|
{
|
|
ColorPickerSharedEventCallback = implementation;
|
|
}
|
|
|
|
public static Action<Type> OpenMainWindowCallback { get; set; }
|
|
|
|
public static void SetOpenMainWindowCallback(Action<Type> implementation)
|
|
{
|
|
OpenMainWindowCallback = implementation;
|
|
}
|
|
|
|
public OobeWindow()
|
|
{
|
|
App.ThemeService.ThemeChanged += OnThemeChanged;
|
|
App.ThemeService.ApplyTheme();
|
|
|
|
this.InitializeComponent();
|
|
|
|
SetTitleBar();
|
|
|
|
RootGrid.DataContext = ViewModel;
|
|
|
|
SetRunSharedEventCallback(() =>
|
|
{
|
|
return Constants.PowerLauncherSharedEvent();
|
|
});
|
|
|
|
SetColorPickerSharedEventCallback(() =>
|
|
{
|
|
return Constants.ShowColorPickerSharedEvent();
|
|
});
|
|
|
|
SetOpenMainWindowCallback((Type type) =>
|
|
{
|
|
App.OpenSettingsWindow(type);
|
|
});
|
|
}
|
|
|
|
private void SetTitleBar()
|
|
{
|
|
WindowHelpers.ForceTopBorder1PixelInsetOnWindows10(WindowNative.GetWindowHandle(this));
|
|
this.ExtendsContentIntoTitleBar = true;
|
|
this.SetTitleBar(AppTitleBar);
|
|
Title = ResourceLoaderInstance.ResourceLoader.GetString("OobeWindow_Title");
|
|
}
|
|
|
|
private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
|
{
|
|
if (navigationView.SelectedItem is NavigationViewItem selectedItem)
|
|
{
|
|
switch (selectedItem.Tag)
|
|
{
|
|
case "Overview": NavigationFrame.Navigate(typeof(OobeOverview)); break;
|
|
case "AdvancedPaste": NavigationFrame.Navigate(typeof(OobeAdvancedPaste)); break;
|
|
case "AlwaysOnTop": NavigationFrame.Navigate(typeof(OobeAlwaysOnTop)); break;
|
|
case "Awake": NavigationFrame.Navigate(typeof(OobeAwake)); break;
|
|
case "CmdNotFound": NavigationFrame.Navigate(typeof(OobeCmdNotFound)); break;
|
|
case "CmdPal": NavigationFrame.Navigate(typeof(OobeCmdPal)); break;
|
|
case "ColorPicker": NavigationFrame.Navigate(typeof(OobeColorPicker)); break;
|
|
case "CropAndLock": NavigationFrame.Navigate(typeof(OobeCropAndLock)); break;
|
|
case "EnvironmentVariables": NavigationFrame.Navigate(typeof(OobeEnvironmentVariables)); break;
|
|
case "FancyZones": NavigationFrame.Navigate(typeof(OobeFancyZones)); break;
|
|
case "FileLocksmith": NavigationFrame.Navigate(typeof(OobeFileLocksmith)); break;
|
|
case "Run": NavigationFrame.Navigate(typeof(OobeRun)); break;
|
|
case "ImageResizer": NavigationFrame.Navigate(typeof(OobeImageResizer)); break;
|
|
case "KBM": NavigationFrame.Navigate(typeof(OobeKBM)); break;
|
|
case "LightSwitch": NavigationFrame.Navigate(typeof(OobeLightSwitch)); break;
|
|
case "PowerRename": NavigationFrame.Navigate(typeof(OobePowerRename)); break;
|
|
case "PowerDisplay": NavigationFrame.Navigate(typeof(OobePowerDisplay)); break;
|
|
case "QuickAccent": NavigationFrame.Navigate(typeof(OobePowerAccent)); break;
|
|
case "FileExplorer": NavigationFrame.Navigate(typeof(OobeFileExplorer)); break;
|
|
case "ShortcutGuide": NavigationFrame.Navigate(typeof(OobeShortcutGuide)); break;
|
|
case "TextExtractor": NavigationFrame.Navigate(typeof(OobePowerOCR)); break;
|
|
case "MouseUtils": NavigationFrame.Navigate(typeof(OobeMouseUtils)); break;
|
|
case "MouseWithoutBorders": NavigationFrame.Navigate(typeof(OobeMouseWithoutBorders)); break;
|
|
case "MeasureTool": NavigationFrame.Navigate(typeof(OobeMeasureTool)); break;
|
|
case "Hosts": NavigationFrame.Navigate(typeof(OobeHosts)); break;
|
|
case "RegistryPreview": NavigationFrame.Navigate(typeof(OobeRegistryPreview)); break;
|
|
case "Peek": NavigationFrame.Navigate(typeof(OobePeek)); break;
|
|
case "NewPlus": NavigationFrame.Navigate(typeof(OobeNewPlus)); break;
|
|
case "Workspaces": NavigationFrame.Navigate(typeof(OobeWorkspaces)); break;
|
|
case "ZoomIt": NavigationFrame.Navigate(typeof(OobeZoomIt)); break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void NavigationView_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
|
|
{
|
|
if (args.DisplayMode == NavigationViewDisplayMode.Compact || args.DisplayMode == NavigationViewDisplayMode.Minimal)
|
|
{
|
|
TitleBarIcon.Margin = new Thickness(0, 0, 8, 0); // Workaround, see XAML comment
|
|
AppTitleBar.IsPaneToggleButtonVisible = true;
|
|
}
|
|
else
|
|
{
|
|
TitleBarIcon.Margin = new Thickness(16, 0, 0, 0); // Workaround, see XAML comment
|
|
AppTitleBar.IsPaneToggleButtonVisible = false;
|
|
}
|
|
}
|
|
|
|
private void TitleBar_PaneButtonClick(Microsoft.UI.Xaml.Controls.TitleBar sender, object args)
|
|
{
|
|
navigationView.IsPaneOpen = !navigationView.IsPaneOpen;
|
|
}
|
|
|
|
private void WhatIsNewItem_Tapped(object sender, TappedRoutedEventArgs e)
|
|
{
|
|
((App)App.Current)!.OpenScoobe();
|
|
}
|
|
|
|
private void Window_Activated(object sender, WindowActivatedEventArgs args)
|
|
{
|
|
// Set window icon
|
|
this.SetIcon("Assets\\Settings\\icon.ico");
|
|
}
|
|
|
|
private void Window_Closed(object sender, WindowEventArgs args)
|
|
{
|
|
if (navigationView.SelectedItem is NavigationViewItem selectedItem && selectedItem.Tag is string tag)
|
|
{
|
|
App.OobeShellViewModel.GetModuleFromTag(tag).LogClosingModuleEvent();
|
|
}
|
|
|
|
if (App.GetSettingsWindow() is MainWindow mainWindow)
|
|
{
|
|
mainWindow.CloseHiddenWindow();
|
|
}
|
|
|
|
App.ThemeService.ThemeChanged -= OnThemeChanged;
|
|
}
|
|
|
|
private void OnThemeChanged(object sender, ElementTheme theme)
|
|
{
|
|
WindowHelper.SetTheme(this, theme);
|
|
}
|
|
|
|
private void NavigationView_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
// Select the first module by default
|
|
if (navigationView.MenuItems.Count > 0)
|
|
{
|
|
navigationView.SelectedItem = navigationView.MenuItems[0];
|
|
}
|
|
}
|
|
}
|
|
}
|