2020-04-08 05:19:33 +08:00
|
|
|
|
// 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 Microsoft.PowerToys.Settings.UI.Views;
|
2020-04-08 01:19:14 +08:00
|
|
|
|
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
2020-04-27 08:34:03 +08:00
|
|
|
|
using Windows.UI.Popups;
|
2020-04-08 05:19:33 +08:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Runner
|
|
|
|
|
{
|
|
|
|
|
// Interaction logic for MainWindow.xaml.
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
{
|
|
|
|
|
public MainWindow()
|
|
|
|
|
{
|
|
|
|
|
this.InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WindowsXamlHost_ChildChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Hook up x:Bind source.
|
|
|
|
|
WindowsXamlHost windowsXamlHost = sender as WindowsXamlHost;
|
|
|
|
|
ShellPage shellPage = windowsXamlHost.GetUwpInternalObject() as ShellPage;
|
|
|
|
|
|
2020-03-25 10:55:02 +08:00
|
|
|
|
if (shellPage != null)
|
|
|
|
|
{
|
2020-03-30 17:02:25 +08:00
|
|
|
|
// send IPC Message
|
2020-04-08 01:19:14 +08:00
|
|
|
|
shellPage.SetDefaultSndMessageCallback(msg =>
|
2020-03-25 10:55:02 +08:00
|
|
|
|
{
|
2020-04-24 08:11:02 +08:00
|
|
|
|
Program.GetTwoWayIPCManager().Send(msg);
|
2020-03-25 10:55:02 +08:00
|
|
|
|
});
|
2020-05-06 01:02:31 +08:00
|
|
|
|
|
|
|
|
|
// send IPC Message
|
|
|
|
|
shellPage.SetRestartAdminSndMessageCallback(msg =>
|
|
|
|
|
{
|
|
|
|
|
Program.GetTwoWayIPCManager().Send(msg);
|
|
|
|
|
System.Windows.Application.Current.Shutdown(); // close application
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
shellPage.SetElevationStatus(Program.IsElevated);
|
|
|
|
|
shellPage.Refresh();
|
2020-04-08 05:19:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-11 06:22:07 +08:00
|
|
|
|
}
|