private void WindowsXamlHost_ChildChanged(object sender, EventArgs e) { // Hook up x:Bind source. WindowsXamlHost windowsXamlHost = sender as WindowsXamlHost; ShellPage shellPage = windowsXamlHost.GetUwpInternalObject() as ShellPage; if (shellPage != null) { // send IPC Message shellPage.SetDefaultSndMessageCallback(msg => { //IPC Manager is null when launching runner directly Program.GetTwoWayIPCManager()?.Send(msg); }); // send IPC Message shellPage.SetRestartAdminSndMessageCallback(msg => { Program.GetTwoWayIPCManager().Send(msg); System.Windows.Application.Current.Shutdown(); // close application }); shellPage.SetElevationStatus(Program.IsElevated); shellPage.Refresh(); } }
private void WindowsXamlHost_ChildChanged(object sender, EventArgs e) { // Hook up x:Bind source. WindowsXamlHost windowsXamlHost = sender as WindowsXamlHost; ShellPage shellPage = windowsXamlHost.GetUwpInternalObject() as ShellPage; if (shellPage != null) { // send IPC Message shellPage.SetDefaultSndMessageCallback(msg => { // IPC Manager is null when launching runner directly Program.GetTwoWayIPCManager()?.Send(msg); }); // send IPC Message shellPage.SetRestartAdminSndMessageCallback(msg => { Program.GetTwoWayIPCManager().Send(msg); System.Windows.Application.Current.Shutdown(); // close application }); // send IPC Message shellPage.SetCheckForUpdatesMessageCallback(msg => { Program.GetTwoWayIPCManager().Send(msg); }); // receive IPC Message Program.IPCMessageReceivedCallback = (string msg) => { if (ShellPage.ShellHandler.IPCResponseHandleList != null) { try { JsonObject json = JsonObject.Parse(msg); foreach (Action <JsonObject> handle in ShellPage.ShellHandler.IPCResponseHandleList) { handle(json); } } catch (Exception) { } } }; shellPage.SetElevationStatus(Program.IsElevated); shellPage.SetIsUserAnAdmin(Program.IsUserAnAdmin); shellPage.Refresh(); } // XAML Islands: If the window is open, explicity force it to be shown to solve the blank dialog issue https://github.com/microsoft/PowerToys/issues/3384 if (isOpen) { Show(); } }
private void WindowsXamlHost_ChildChanged(object sender, EventArgs e) { // Hook up x:Bind source. WindowsXamlHost windowsXamlHost = sender as WindowsXamlHost; ShellPage shellPage = windowsXamlHost.GetUwpInternalObject() as ShellPage; if (shellPage != null) { // send IPC Message shellPage.SetDefaultSndMessageCallback(msg => { // IPC Manager is null when launching runner directly Program.GetTwoWayIPCManager()?.Send(msg); }); // send IPC Message shellPage.SetRestartAdminSndMessageCallback(msg => { Program.GetTwoWayIPCManager().Send(msg); System.Windows.Application.Current.Shutdown(); // close application }); // send IPC Message shellPage.SetCheckForUpdatesMessageCallback(msg => { Program.GetTwoWayIPCManager().Send(msg); }); shellPage.SetElevationStatus(Program.IsElevated); shellPage.SetIsUserAnAdmin(Program.IsUserAnAdmin); shellPage.Refresh(); } // If the window is open, explicity force it to be shown to solve the blank dialog issue https://github.com/microsoft/PowerToys/issues/3384 if (isOpen) { Show(); } }
private void WindowsXamlHost_ChildChanged(object sender, EventArgs e) { // If sender is null, it could lead to a NullReferenceException. This might occur on restarting as admin (check https://github.com/microsoft/PowerToys/issues/7393 for details) if (sender == null) { return; } // Hook up x:Bind source. WindowsXamlHost windowsXamlHost = sender as WindowsXamlHost; ShellPage shellPage = windowsXamlHost.GetUwpInternalObject() as ShellPage; if (shellPage != null) { // send IPC Message ShellPage.SetDefaultSndMessageCallback(msg => { // IPC Manager is null when launching runner directly Program.GetTwoWayIPCManager()?.Send(msg); }); // send IPC Message ShellPage.SetRestartAdminSndMessageCallback(msg => { Program.GetTwoWayIPCManager().Send(msg); isOpen = false; System.Windows.Application.Current.Shutdown(); // close application }); // send IPC Message ShellPage.SetCheckForUpdatesMessageCallback(msg => { Program.GetTwoWayIPCManager().Send(msg); }); // open oobe ShellPage.SetOpenOobeCallback(() => { var oobe = new OobeWindow(); oobe.Show(); }); // receive IPC Message Program.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(Program.IsElevated); ShellPage.SetIsUserAnAdmin(Program.IsUserAnAdmin); shellPage.Refresh(); } // XAML Islands: If the window is open, explicitly force it to be shown to solve the blank dialog issue https://github.com/microsoft/PowerToys/issues/3384 if (isOpen) { try { Show(); } catch (InvalidOperationException) { } } }