85 lines
2.7 KiB
C#
85 lines
2.7 KiB
C#
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
|
using Microsoft.PowerToys.Settings.UI.WinUI3.Views;
|
|
using Microsoft.UI.Xaml;
|
|
using System;
|
|
using Windows.Data.Json;
|
|
using Windows.ApplicationModel.Resources;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
// To learn more about WinUI, the WinUI project structure,
|
|
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.WinUI3
|
|
{
|
|
/// <summary>
|
|
/// An empty window that can be used on its own or navigated to within a Frame.
|
|
/// </summary>
|
|
public sealed partial class MainWindow : Window
|
|
{
|
|
public MainWindow()
|
|
{
|
|
this.InitializeComponent();
|
|
ExtendsContentIntoTitleBar = true;
|
|
SetTitleBar(CustomTitleBar); // This should work according to docs, but it doesn't.... So disabling for now together with ExtendsContentIntoTitleBar
|
|
|
|
// send IPC Message
|
|
ShellPage.SetDefaultSndMessageCallback(msg =>
|
|
{
|
|
// IPC Manager is null when launching runner directly
|
|
App.GetTwoWayIPCManager()?.Send(msg);
|
|
});
|
|
|
|
// send IPC Message
|
|
ShellPage.SetRestartAdminSndMessageCallback(msg =>
|
|
{
|
|
App.GetTwoWayIPCManager()?.Send(msg);
|
|
Environment.Exit(0);
|
|
});
|
|
|
|
// send IPC Message
|
|
ShellPage.SetCheckForUpdatesMessageCallback(msg =>
|
|
{
|
|
App.GetTwoWayIPCManager()?.Send(msg);
|
|
});
|
|
|
|
// open oobe
|
|
ShellPage.SetOpenOobeCallback(() =>
|
|
{
|
|
/* var oobe = new OobeWindow();
|
|
oobe.Show();
|
|
*/ });
|
|
|
|
// receive IPC Message
|
|
App.IPCMessageReceivedCallback = (string msg) =>
|
|
{
|
|
if (ShellPage.ShellHandler.IPCResponseHandleList != null)
|
|
{
|
|
var success = JsonObject.TryParse(msg, out JsonObject json);
|
|
if (success)
|
|
{
|
|
foreach (Action<JsonObject> handle in ShellPage.ShellHandler.IPCResponseHandleList)
|
|
{
|
|
handle(json);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Logger.LogError("Failed to parse JSON from IPC message.");
|
|
}
|
|
}
|
|
};
|
|
|
|
ShellPage.SetElevationStatus(App.IsElevated);
|
|
ShellPage.SetIsUserAnAdmin(App.IsUserAnAdmin);
|
|
//shellPage.Refresh();
|
|
|
|
}
|
|
|
|
public void NavigateToSection(Type type)
|
|
{
|
|
Activate();
|
|
ShellPage.Navigate(type);
|
|
}
|
|
}
|
|
}
|