public OobeWindow(PowerToysModules initialModule) { this.InitializeComponent(); // Set window icon _hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this); _windowId = Win32Interop.GetWindowIdFromWindow(_hWnd); _appWindow = AppWindow.GetFromWindowId(_windowId); _appWindow.SetIcon("icon.ico"); OverlappedPresenter presenter = _appWindow.Presenter as OverlappedPresenter; presenter.IsResizable = false; presenter.IsMinimizable = false; presenter.IsMaximizable = false; var dpi = NativeMethods.GetDpiForWindow(_hWnd); _currentDPI = dpi; float scalingFactor = (float)dpi / DefaultDPI; int width = (int)(ExpectedWidth * scalingFactor); int height = (int)(ExpectedHeight * scalingFactor); SizeInt32 size; size.Width = width; size.Height = height; _appWindow.Resize(size); this.initialModule = initialModule; this.SizeChanged += OobeWindow_SizeChanged; 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 InitWindow() { IntPtr hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this); WindowId windowId = Win32Interop.GetWindowIdFromWindow(hWnd); AppWindow appWindow = AppWindow.GetFromWindowId(windowId); var size = new Windows.Graphics.SizeInt32(); size.Width = 1280; size.Height = 960; appWindow.Resize(size); appWindow.SetIcon("icon.ico"); this.Title = "LR(1)语义分析过程表"; }
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"); 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); 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 SetTitleBarColorsAndIcon() { IntPtr hWnd = WindowNative.GetWindowHandle(this); WindowId windowId = Win32Interop.GetWindowIdFromWindow(hWnd); AppWindow appWindow = AppWindow.GetFromWindowId(windowId); // Title bar customization is not supported on Windows 10 if (AppWindowTitleBar.IsCustomizationSupported()) { AppWindowTitleBar titleBar = appWindow.TitleBar; ResourceDictionary dictionary = null; switch (Settings.Instance.AppTheme) { case ElementTheme.Default: dictionary = Application.Current.Resources; break; case ElementTheme.Light: dictionary = (ResourceDictionary)Application.Current.Resources.ThemeDictionaries["Light"]; break; case ElementTheme.Dark: dictionary = (ResourceDictionary)Application.Current.Resources.ThemeDictionaries["Dark"]; break; } titleBar.BackgroundColor = (Color?)dictionary["TitleBarBackgroundColor"]; titleBar.ForegroundColor = (Color?)dictionary["TitleBarForegroundColor"]; titleBar.InactiveBackgroundColor = (Color?)dictionary["TitleBarInactiveBackgroundColor"]; titleBar.InactiveForegroundColor = (Color?)dictionary["TitleBarInactiveForegroundColor"]; titleBar.ButtonBackgroundColor = (Color?)dictionary["TitleBarButtonBackgroundColor"]; titleBar.ButtonHoverBackgroundColor = (Color?)dictionary["TitleBarButtonHoverBackgroundColor"]; titleBar.ButtonForegroundColor = (Color?)dictionary["TitleBarButtonForegroundColor"]; titleBar.ButtonHoverForegroundColor = (Color?)dictionary["TitleBarButtonHoverForegroundColor"]; titleBar.ButtonPressedBackgroundColor = (Color?)dictionary["TitleBarButtonPressedBackgroundColor"]; titleBar.ButtonPressedForegroundColor = (Color?)dictionary["TitleBarButtonPressedForegroundColor"]; titleBar.ButtonInactiveBackgroundColor = (Color?)dictionary["TitleBarButtonInactiveBackgroundColor"]; titleBar.ButtonInactiveForegroundColor = (Color?)dictionary["TitleBarButtonInactiveForegroundColor"]; } string applicationRoot = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); appWindow.SetIcon(Path.Combine(applicationRoot, @"Assets\Logo.ico")); }
private void InitWindow() { IntPtr hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this); WindowId windowId = Win32Interop.GetWindowIdFromWindow(hWnd); AppWindow appWindow = AppWindow.GetFromWindowId(windowId); var size = new Windows.Graphics.SizeInt32(); size.Width = 710; size.Height = 850; appWindow.Resize(size); appWindow.SetIcon("icon.ico"); this.Title = "C--文法产生式"; this.Closed += (o, e) => { MainWebView.Close(); }; LoadedWebview(); }
public MainWindow() { this.InitializeComponent(); IntPtr hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this); WindowId windowId = Win32Interop.GetWindowIdFromWindow(hWnd); AppWindow appWindow = AppWindow.GetFromWindowId(windowId); var size = new Windows.Graphics.SizeInt32(); size.Width = 1280; size.Height = 960; appWindow.Resize(size); appWindow.SetIcon("icon.ico"); this.Title = "C--编译器"; Lexcial.IsEnabled = false; Syntactic.IsEnabled = false; Semantic.IsEnabled = false; Mips.IsEnabled = false; LoadedWebview(); this.Closed += (o, e) => { MainWebView.Close(); }; }
public MainWindow(bool createHidden = false) { var bootTime = new System.Diagnostics.Stopwatch(); bootTime.Start(); ShellPage.SetElevationStatus(App.IsElevated); ShellPage.SetIsUserAnAdmin(App.IsUserAnAdmin); // Set window icon var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this); WindowId windowId = Win32Interop.GetWindowIdFromWindow(hWnd); AppWindow appWindow = AppWindow.GetFromWindowId(windowId); appWindow.SetIcon("icon.ico"); var placement = Utils.DeserializePlacementOrDefault(hWnd); if (createHidden) { placement.ShowCmd = NativeMethods.SW_HIDE; } NativeMethods.SetWindowPlacement(hWnd, ref placement); ResourceLoader loader = ResourceLoader.GetForViewIndependentUse(); Title = loader.GetString("SettingsWindow_Title"); // 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); // close application }); // send IPC Message ShellPage.SetCheckForUpdatesMessageCallback(msg => { App.GetTwoWayIPCManager()?.Send(msg); }); // open oobe ShellPage.SetOpenOobeCallback(() => { if (App.GetOobeWindow() == null) { App.SetOobeWindow(new OobeWindow(Microsoft.PowerToys.Settings.UI.OOBE.Enums.PowerToysModules.Overview)); } App.GetOobeWindow().Activate(); }); this.InitializeComponent(); // 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."); } } }; bootTime.Stop(); PowerToysTelemetry.Log.WriteEvent(new SettingsBootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds }); }