protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); (this.Content as Grid).Children.Remove(KCVUIHelper.KCVContent); if (PluginSettings.Current.Layout == KCVContentLayout.Separate) LandscapeViewModel.Instance.IsWindowOpenButtonShow = true; Current = null; }
public MainContentWindow() { InitializeComponent(); Current = this; MainWindow.Current.Closed += (sender, args) => this.Close(); var content = KCVUIHelper.KCVContent; (this.Content as Grid).Children.Add(content); Grid.SetRow(content, 1); }
public void OpenWindow() { if (CurrentLayout == KCVContentLayout.Separate && MainContentWindow.Current == null) { var window = new MainContentWindow { DataContext = KCVApp.ViewModelRoot }; window.Show(); this.IsWindowOpenButtonShow = false; } }
protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); (this.Content as Grid).Children.Remove(KCVUIHelper.KCVContent); if (PluginSettings.Current.Layout == KCVContentLayout.Separate) { LandscapeViewModel.Instance.IsWindowOpenButtonShow = true; } Current = null; }
private void switchLayout(KCVContentLayout oldValue, KCVContentLayout newValue, bool initializing = false) { if (oldValue == newValue) return; if (oldValue == KCVContentLayout.Separate) { if (newValue == KCVContentLayout.Portrait) { resizeWindow(Math.Max(this.HostWidth, MainContentWindow.Current.ActualWidth), this.HostHeight + MainContentWindow.Current.ActualHeight); } else { resizeWindow(this.HostWidth + MainContentWindow.Current.ActualWidth, Math.Max(this.HostHeight, MainContentWindow.Current.ActualHeight)); } MainContentWindow.Current.Close(); contentContainer.Children.Add(pluginControl); this.IsWindowOpenButtonShow = false; } contentContainer.RowDefinitions.Clear(); contentContainer.ColumnDefinitions.Clear(); if (newValue == KCVContentLayout.Separate) { contentContainer.Children.Remove(pluginControl); var window = new MainContentWindow { DataContext = KCVApp.ViewModelRoot }; window.Show(); resizeWindow(this.HostWidth, this.HostHeight); } else { if (newValue == KCVContentLayout.Portrait) { if (oldValue != KCVContentLayout.Separate) { resizeWindow(Math.Max(this.HostWidth, pluginControl.ActualWidth), this.HostHeight + pluginControl.ActualHeight); } contentContainer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); contentContainer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }); Grid.SetRow(pluginControl, 1); } else { if (newValue == KCVContentLayout.LandscapeLeft) { if (oldValue == KCVContentLayout.Portrait && !initializing) { resizeWindow(this.HostWidth + pluginControl.ActualWidth, Math.Max(this.HostHeight, pluginControl.ActualHeight)); } contentContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); contentContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); Grid.SetColumn(hostControl, 0); Grid.SetColumn(pluginControl, 1); } else { if (oldValue == KCVContentLayout.Portrait && !initializing) { resizeWindow(this.HostWidth + pluginControl.ActualWidth, Math.Max(this.HostHeight, pluginControl.ActualHeight)); } contentContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); contentContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); Grid.SetColumn(hostControl, 1); Grid.SetColumn(pluginControl, 0); } } } }
private void switchLayout(KCVContentLayout oldValue, KCVContentLayout newValue, bool initializing = false) { if (oldValue == newValue) { return; } if (oldValue == KCVContentLayout.Separate) { if (newValue == KCVContentLayout.Portrait) { resizeWindow(Math.Max(this.HostWidth, MainContentWindow.Current.ActualWidth), this.HostHeight + MainContentWindow.Current.ActualHeight); } else { resizeWindow(this.HostWidth + MainContentWindow.Current.ActualWidth, Math.Max(this.HostHeight, MainContentWindow.Current.ActualHeight)); } MainContentWindow.Current.Close(); contentContainer.Children.Add(pluginControl); this.IsWindowOpenButtonShow = false; } contentContainer.RowDefinitions.Clear(); contentContainer.ColumnDefinitions.Clear(); if (newValue == KCVContentLayout.Separate) { contentContainer.Children.Remove(pluginControl); var window = new MainContentWindow { DataContext = KCVApp.ViewModelRoot }; window.Show(); resizeWindow(this.HostWidth, this.HostHeight); } else { if (newValue == KCVContentLayout.Portrait) { if (oldValue != KCVContentLayout.Separate) { resizeWindow(Math.Max(this.HostWidth, pluginControl.ActualWidth), this.HostHeight + pluginControl.ActualHeight); } contentContainer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); contentContainer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }); Grid.SetRow(pluginControl, 1); } else { if (newValue == KCVContentLayout.LandscapeLeft) { if (oldValue == KCVContentLayout.Portrait && !initializing) { resizeWindow(this.HostWidth + pluginControl.ActualWidth, Math.Max(this.HostHeight, pluginControl.ActualHeight)); } contentContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); contentContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); Grid.SetColumn(hostControl, 0); Grid.SetColumn(pluginControl, 1); } else { if (oldValue == KCVContentLayout.Portrait && !initializing) { resizeWindow(this.HostWidth + pluginControl.ActualWidth, Math.Max(this.HostHeight, pluginControl.ActualHeight)); } contentContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); contentContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); Grid.SetColumn(hostControl, 1); Grid.SetColumn(pluginControl, 0); } } } }