mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-22 08:02:24 +08:00
89 lines
2.3 KiB
C#
89 lines
2.3 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 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);
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|