private void Window_PaneClosed(object sender, EventArgs e) { if (this.viewLookup.Count == 0 || this.paneViewLookup.Count == 0) { return; } ModelToolWindowPane pane = (ModelToolWindowPane)sender; IVsWindowFrame windowFrame = (IVsWindowFrame)pane.Frame; Guid g = ModelPackage.GetPersistenceSlot(windowFrame); string accessKey = this.SelectedShellViewModel.FullFileName; if (this.viewLookup.ContainsKey(accessKey)) { if (this.viewLookup[accessKey].ContainsKey(this.paneViewLookup[g])) { ViewLookUp v = this.viewLookup[accessKey][this.paneViewLookup[g]]; v.View.IsDockingPaneVisible = false; } } if (this.viewLookup.ContainsKey(TransientPanesKey)) { if (this.viewLookup[TransientPanesKey].ContainsKey(this.paneViewLookup[g])) { ViewLookUp v = this.viewLookup[TransientPanesKey][this.paneViewLookup[g]]; v.View.IsDockingPaneVisible = false; } } }
/// <summary> /// Tries to bring the view displaying the given view model to the front. /// </summary> /// <param name="view"></param> public void BringToFrontWindow(IDockableViewModel view) { string accessKey = this.SelectedShellViewModel.FullFileName; if (this.IsTransientViewModel(view.GetType())) { accessKey = TransientPanesKey; } if (!viewLookup.ContainsKey(accessKey)) { return; } if (viewLookup[accessKey].ContainsKey(view.DockingPaneName)) { ViewLookUp v = viewLookup[accessKey][view.DockingPaneName]; if (v.Pane != null) { (v.Pane.Frame as IVsWindowFrame).Show(); } else { this.SelectedShellViewModel.SelectedDocumentPane = view; } } }
/// <summary> /// Tries to close a specified window.. /// </summary> /// <param name="view"></param> /// <param name="bRemove"></param> public void CloseWindow(IDockableViewModel view, bool bRemove) { string accessKey = this.SelectedShellViewModel.FullFileName; if (this.IsTransientViewModel(view.GetType())) { accessKey = TransientPanesKey; } if (!viewLookup.ContainsKey(accessKey)) { return; } if (viewLookup[accessKey].ContainsKey(view.DockingPaneName)) { ViewLookUp v = viewLookup[view.DockingPaneName][accessKey]; if (v.Pane != null) { (v.Pane.Frame as IVsWindowFrame).CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave); } else { view.IsDockingPaneVisible = false; if (this.SelectedShellViewModel.VisibleDocumentPanes.Contains(view)) { this.SelectedShellViewModel.HiddenDocumentPanes.Add(this.SelectedShellViewModel.SelectedDocumentPane); this.SelectedShellViewModel.VisibleDocumentPanes.Remove(this.SelectedShellViewModel.SelectedDocumentPane); } if (this.SelectedShellViewModel.VisibleDocumentPanes.Count == 0) { this.SelectedShellViewModel.SelectedDocumentPane = null; } } // TODO ? if (bRemove) { // remove pane from lookup //this.viewLookup.Remove(view.DockingPaneName); } } if (this.IsTransientViewModel(view.GetType())) { // update all IsDockingPaneVisible foreach (ShellMainViewModel v in this.packageController.AvailableShellVMs.Keys) { BaseDockingViewModel foundVm = v.FindViewModel(view.GetType()); foundVm.IsDockingPaneVisible = false; } } }