private void InitializePanel(BrowserPanel panel, AppConfiguration.PanelConfiguration paneConfiguration) { panel.Scale = paneConfiguration.Scale; panel.RefreshFrequencyMin = paneConfiguration.RefreshFreq; panel.SharedPanelConfiguration = sharedPanelConfig; panel.ScaleChanged += delegate { if (panel.IsMaximized) { paneConfiguration.ScaleMaximized = panel.Scale; } else { paneConfiguration.Scale = panel.Scale; } this.ConfigurationChanged?.Invoke(this, EventArgs.Empty); }; panel.RefreshFrequencyChanged += delegate { paneConfiguration.RefreshFreq = panel.RefreshFrequencyMin; this.ConfigurationChanged?.Invoke(this, EventArgs.Empty); }; panel.MaximizationChanged += delegate { OnPanelMaximizationChanged(paneConfiguration, panel); }; Uri uri; if (Uri.TryCreate(paneConfiguration.Uri, UriKind.Absolute, out uri)) { panel.Navigate(uri); } }
private void OnPanelMaximizationChanged(AppConfiguration.PanelConfiguration paneConfiguration, BrowserPanel panel) { // Restore currently maximized window (if any) first if (this.PopupMainGrid.Children.Count > 0) { var formerParentGrid = (Grid)panel.Tag; this.PopupMainGrid.Children.Clear(); formerParentGrid.Children.Add(panel); // Re-enter this same method with a former panel (should be a no-op) panel.IsMaximized = false; panel.Scale = paneConfiguration.Scale; } // Maximize if needed if (panel.IsMaximized) { var currentParentGrid = (Grid)panel.Parent; currentParentGrid.Children.Remove(panel); panel.Tag = currentParentGrid; this.PopupMainGrid.Children.Add(panel); this.Popup.Height = this.ActualHeight * 0.75 - this.PopupMainGrid.Margin.Top - this.PopupMainGrid.Margin.Bottom; this.Popup.Width = this.ActualWidth - this.PopupMainGrid.Margin.Left - this.PopupMainGrid.Margin.Right; this.Popup.IsOpen = true; panel.Scale = paneConfiguration.ScaleMaximized; } else { this.Popup.IsOpen = false; panel.Scale = paneConfiguration.Scale; } }