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> /// Constuctor. /// </summary> /// <param name="package">Package.</param> protected ShellPackageController(ModelPackage package) { this.modelPackage = package; this.availableShellVMs = new Dictionary <ShellMainViewModel, string>(); this.availableShellVMsReversed = new Dictionary <string, ShellMainViewModel>(); this.Initialize(); }
/// <summary> /// Constructor. /// </summary> /// <param name="package">Visual Studio Package.</param> /// <param name="packageController">Package controller.</param> protected ShellDockingManager(ModelPackage package, ShellPackageController packageController) { this.packageController = packageController; this.viewLookup = new Dictionary <string, Dictionary <string, ViewLookUp> >(); this.viewTypeNameLookup = new Dictionary <string, List <string> >(); this.paneViewLookup = new Dictionary <Guid, string>(); this.package = package; //this.visibleCollection = new ObservableCollection<IDockableViewModel>(); //this.hiddenCollection = new ObservableCollection<IDockableViewModel>(); this.package.ActiveWindowChangedEvent += new ModelPackage.ActiveWindowChangedEventHandler(Package_ActiveWindowChangedEvent); this.closeSelectedDocumentPaneCommand = new DelegateCommand(CloseSDPCommand_Execute, CloseSDPCommand_CanExecute); this.documentPaneControlActivated = new DelegateCommand(DocumentPaneControlActivated_Execute); }
protected ShellMainViewModel(ViewModelStore viewModelStore, ModelPackage package) : base(viewModelStore, false) { if (!this.ViewModelStore.CustomDataBag.ContainsKey(ShellViewModelStoreIds.ModelPackageId)) { this.ViewModelStore.CustomDataBag.Add(ShellViewModelStoreIds.ModelPackageId, package); } if (!this.Store.CustomDataBag.ContainsKey(ShellViewModelStoreIds.ModelPackageId)) { this.Store.CustomDataBag.Add(ShellViewModelStoreIds.ModelPackageId, package); } if (!this.Store.CustomDataBag.ContainsKey(ShellViewModelStoreIds.ViewModelStoreId)) { this.Store.CustomDataBag.Add(ShellViewModelStoreIds.ViewModelStoreId, this.ViewModelStore); } this.saveModelCommand = new DelegateCommand(SaveModelCommandExecuted); this.modelPackage = package; this.EventManager.GetEvent <DocumentClosingEvent>().Subscribe(this.OnDocumentClosingEvent); this.EventManager.GetEvent <DocumentSavedEvent>().Subscribe(this.OnDocumentSavedEvent); this.showModelTreeCommand = new DelegateCommand(ShowModelTreeCommandExecuted); this.showPropertiesCommand = new DelegateCommand(ShowPropertiesCommandExecuted); this.showErrorListCommand = new DelegateCommand(ShowErrorListCommandExecuted); this.showDependenciesCommand = new DelegateCommand(ShowDependenciesCommandExecuted); this.showDiagramSurfaceCommand = new DelegateCommand(ShowDiagramSurfaceCommandCommandExecuted); this.pluginInformationCommand = new DelegateCommand(PluginInformationCommandExecuted); this.visibleCollection = new ObservableCollection <IDockableViewModel>(); this.hiddenCollection = new ObservableCollection <IDockableViewModel>(); this.Initialize(); }
/// <summary> /// Shows a docking window for a given view. /// If is has been shown before, restore its position. Otherwise dock it to the right side. /// </summary> /// <param name="view">View to dock.</param> /// <param name="dockingStyle">Docking style.</param> /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param> /// <param name="dockedInDocumentPane">True if this view should be shown in the document pane window. False otherwise.</param> /// <param name="fullFileName">File name.</param> public virtual void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle, bool dockedInDocumentPane, string fullFileName) { if (!view.IsInitialized) { view.InitializeVM(); } string accessKey = fullFileName; if (this.IsTransientViewModel(view.GetType())) { accessKey = TransientPanesKey; if (viewLookup.ContainsKey(TransientPanesKey)) { if (viewLookup[TransientPanesKey].ContainsKey(view.DockingPaneName)) { ModelToolWindowPane p = viewLookup[TransientPanesKey][view.DockingPaneName].Pane; if (p != null) { if (((IVsWindowFrame)p.Frame).IsVisible() != VSConstants.S_OK) { return; } } } } } if (!viewLookup.ContainsKey(accessKey)) { viewLookup.Add(accessKey, new Dictionary <string, ViewLookUp>()); } if (!viewLookup[accessKey].ContainsKey(view.DockingPaneName)) { if (!dockedInDocumentPane) { int key; if (!this.viewTypeNameLookup.ContainsKey(view.DockingPaneType.FullName)) { key = 0; } else { key = this.viewTypeNameLookup[view.DockingPaneType.FullName].Count; } ModelToolWindowPane window = this.package.FindToolWindow(this.package.GetToolWindowType(view.DockingPaneType), key, true) as ModelToolWindowPane; if ((window == null) || (window.Frame == null)) { throw new NotSupportedException("Can not show window!"); } window.Content.DataContext = view; window.Caption = view.DockingPaneTitle; // subscribe to events window.PaneClosed += new EventHandler(Window_PaneClosed); // get window frame IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame; // add lookup information viewLookup[accessKey][view.DockingPaneName] = new ViewLookUp(view, window); view.IsDockingPaneVisible = true; paneViewLookup.Add(ModelPackage.GetPersistenceSlot(windowFrame), view.DockingPaneName); if (!this.viewTypeNameLookup.ContainsKey(view.DockingPaneType.FullName)) { this.viewTypeNameLookup[view.DockingPaneType.FullName] = new List <string>(); } this.viewTypeNameLookup[view.DockingPaneType.FullName].Add(view.DockingPaneName); // show window windowFrame.Show(); } else { viewLookup[accessKey][view.DockingPaneName] = new ViewLookUp(view); if (accessKey != TransientPanesKey) { this.packageController.AvailableShellVMsReversed[accessKey].VisibleDocumentPanes.Add(view); if (this.packageController.AvailableShellVMsReversed[accessKey].SelectedDocumentPane == null) { this.packageController.AvailableShellVMsReversed[accessKey].SelectedDocumentPane = view; } } else { this.SelectedShellViewModel.VisibleDocumentPanes.Add(view); if (this.SelectedShellViewModel.SelectedDocumentPane == null) { this.SelectedShellViewModel.SelectedDocumentPane = view; } } view.IsDockingPaneVisible = true; } } // show docking window if (!dockedInDocumentPane) { if (viewLookup[accessKey][view.DockingPaneName].Pane != null) { if (((IVsWindowFrame)viewLookup[accessKey][view.DockingPaneName].Pane.Frame).IsVisible() != VSConstants.S_OK) { ((IVsWindowFrame)viewLookup[accessKey][view.DockingPaneName].Pane.Frame).Show(); viewLookup[accessKey][view.DockingPaneName].View.IsDockingPaneVisible = true; } } } else { if (this.SelectedShellViewModel.HiddenDocumentPanes.Contains(view)) { this.SelectedShellViewModel.HiddenDocumentPanes.Remove(view); this.SelectedShellViewModel.VisibleDocumentPanes.Add(view); if (this.SelectedShellViewModel.SelectedDocumentPane == null) { this.SelectedShellViewModel.SelectedDocumentPane = view; } } view.IsDockingPaneVisible = true; } if (this.IsTransientViewModel(view.GetType())) { // update all IsDockingPaneVisible foreach (ShellMainViewModel v in this.packageController.AvailableShellVMs.Keys) { BaseDockingViewModel foundVm = v.FindViewModel(view.GetType()); foundVm.IsDockingPaneVisible = true; } } }