2022-04-20 04:00:28 +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 interop;
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.OOBE.Views;
|
|
|
|
|
using Microsoft.UI;
|
|
|
|
|
using Microsoft.UI.Windowing;
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
using Windows.ApplicationModel.Resources;
|
2022-04-20 23:08:25 +08:00
|
|
|
|
using Windows.Graphics;
|
2022-04-20 04:00:28 +08:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An empty window that can be used on its own or navigated to within a Frame.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed partial class OobeWindow : Window
|
|
|
|
|
{
|
|
|
|
|
private PowerToysModules initialModule;
|
|
|
|
|
|
|
|
|
|
public OobeWindow(PowerToysModules initialModule)
|
|
|
|
|
{
|
|
|
|
|
this.InitializeComponent();
|
|
|
|
|
|
|
|
|
|
// Set window icon
|
|
|
|
|
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
|
|
|
|
|
WindowId windowId = Win32Interop.GetWindowIdFromWindow(hWnd);
|
|
|
|
|
AppWindow appWindow = AppWindow.GetFromWindowId(windowId);
|
|
|
|
|
appWindow.SetIcon("icon.ico");
|
|
|
|
|
|
2022-04-20 23:08:25 +08:00
|
|
|
|
OverlappedPresenter presenter = appWindow.Presenter as OverlappedPresenter;
|
|
|
|
|
presenter.IsResizable = false;
|
|
|
|
|
presenter.IsMinimizable = false;
|
|
|
|
|
presenter.IsMaximizable = false;
|
|
|
|
|
|
|
|
|
|
SizeInt32 size;
|
|
|
|
|
size.Width = 1650;
|
|
|
|
|
size.Height = 1050;
|
|
|
|
|
appWindow.Resize(size);
|
|
|
|
|
|
2022-04-20 04:00:28 +08:00
|
|
|
|
this.initialModule = initialModule;
|
|
|
|
|
|
|
|
|
|
ResourceLoader loader = ResourceLoader.GetForViewIndependentUse();
|
|
|
|
|
Title = loader.GetString("OobeWindow_Title");
|
|
|
|
|
|
|
|
|
|
if (shellPage != null)
|
|
|
|
|
{
|
|
|
|
|
shellPage.NavigateToModule(this.initialModule);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OobeShellPage.SetRunSharedEventCallback(() =>
|
|
|
|
|
{
|
|
|
|
|
return Constants.PowerLauncherSharedEvent();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
OobeShellPage.SetColorPickerSharedEventCallback(() =>
|
|
|
|
|
{
|
|
|
|
|
return Constants.ShowColorPickerSharedEvent();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
OobeShellPage.SetOpenMainWindowCallback((Type type) =>
|
|
|
|
|
{
|
|
|
|
|
App.OpenSettingsWindow(type);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Window_Closed(object sender, WindowEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
App.ClearOobeWindow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|