private void WindowsXamlHost_ChildChanged(object sender, EventArgs e) { if (sender == null) { return; } WindowsXamlHost windowsXamlHost = sender as WindowsXamlHost; shellPage = windowsXamlHost.GetUwpInternalObject() as OobeShellPage; OobeShellPage.SetRunSharedEventCallback(() => { return(Constants.PowerLauncherSharedEvent()); }); OobeShellPage.SetColorPickerSharedEventCallback(() => { return(Constants.ShowColorPickerSharedEvent()); }); OobeShellPage.SetOpenMainWindowCallback((Type type) => { ((App)Application.Current).OpenSettingsWindow(type); }); }
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(); } }
internal TXamlContent GetHostContent() { if (_xamlHost == null) { return(null); } return(_xamlHost.GetUwpInternalObject() as TXamlContent); }
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 MyUWPPage_ChildChanged(object sender, EventArgs e) { // Hook up x:Bind source WindowsXamlHost windowsXamlHost = (WindowsXamlHost)sender; global::MyUWPControls.BlankPage1 myUWPPage = windowsXamlHost.GetUwpInternalObject() as global::MyUWPControls.BlankPage1; if (myUWPPage != null) { myUWPPage.WPFMessage = this.WPFMessage; } }
private void SharedXamlHost_ChildChanged(object sender, EventArgs e) { if (EventSet == false) { WindowsXamlHost windowsXamlHost = sender as Microsoft.Toolkit.Wpf.UI.XamlHost.WindowsXamlHost;; UWPSharedPanel.RealEstateComponent sharedPanel = windowsXamlHost.GetUwpInternalObject() as UWPSharedPanel.RealEstateComponent; sharedPanel.StringChanged += OnStringChanged; EventSet = true; } }
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) { } } }