mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 05:06:36 +02:00
[OOBE] Out of box experience window (#9973)
This commit is contained in:
88
src/settings-ui/PowerToys.Settings/OobeWindow.xaml.cs
Normal file
88
src/settings-ui/PowerToys.Settings/OobeWindow.xaml.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
// 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.Windows;
|
||||
using interop;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.OOBE.Views;
|
||||
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
||||
|
||||
namespace PowerToys.Settings
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for OobeWindow.xaml
|
||||
/// </summary>
|
||||
public partial class OobeWindow : Window
|
||||
{
|
||||
private static Window inst;
|
||||
private OobeShellPage shellPage;
|
||||
|
||||
public static bool IsOpened
|
||||
{
|
||||
get
|
||||
{
|
||||
return inst != null;
|
||||
}
|
||||
}
|
||||
|
||||
public OobeWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, EventArgs e)
|
||||
{
|
||||
if (shellPage != null)
|
||||
{
|
||||
shellPage.OnClosing();
|
||||
}
|
||||
|
||||
inst = null;
|
||||
MainWindow.CloseHiddenWindow();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (inst != null)
|
||||
{
|
||||
inst.Close();
|
||||
}
|
||||
|
||||
inst = this;
|
||||
}
|
||||
|
||||
private void WindowsXamlHost_ChildChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WindowsXamlHost windowsXamlHost = sender as WindowsXamlHost;
|
||||
shellPage = windowsXamlHost.GetUwpInternalObject() as OobeShellPage;
|
||||
|
||||
OobeShellPage.SetRunSharedEventCallback(() =>
|
||||
{
|
||||
return Constants.PowerLauncherSharedEvent();
|
||||
});
|
||||
|
||||
OobeShellPage.SetColorPickerSharedEventCallback(() =>
|
||||
{
|
||||
return Constants.ShowColorPickerSharedEvent();
|
||||
});
|
||||
|
||||
OobeShellPage.SetShortcutGuideSharedEventCallback(() =>
|
||||
{
|
||||
NativeMethods.AllowSetForegroundWindow(PowerToys.Settings.Program.PowerToysPID);
|
||||
return Constants.ShowShortcutGuideSharedEvent();
|
||||
});
|
||||
|
||||
OobeShellPage.SetOpenMainWindowCallback((Type type) =>
|
||||
{
|
||||
((App)Application.Current).OpenSettingsWindow(type);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user