/// <summary> /// Adds a new tab to the tab panel, associated with given <paramref name="diagram"/> /// <param name="diagram">Diagram to which the new tab should be bound</param> /// </summary> internal DiagramTab AddTab(Diagram diagram) { DiagramTab newTab = null; if (diagram is PIMDiagram) { newTab = new PIMDiagramTab(); } else if (diagram is PSMDiagram) { newTab = new PSMDiagramTab(); } if (newTab != null) { newTab.Title = diagram.Caption; newTab.DiagramView.LoadDiagram(diagram); newTab.DiagramView.SelectionChanged += SelectedItems_CollectionChanged; DockManager.Items.Add(newTab); DockManager.UpdateLayout(); //ActivePane.BringHeaderToFront(newTab); DockManager.ActiveDocument = newTab; } return(newTab); }
private void Diagrams_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action.IsAmong(NotifyCollectionChangedAction.Replace, NotifyCollectionChangedAction.Reset)) { CloseAllTabs(); OpenTabsForProjectVersion(Current.ProjectVersion); } if (e.Action == NotifyCollectionChangedAction.Add) { foreach (Diagram newItem in e.NewItems) { AddTab(newItem); } } if (e.Action == NotifyCollectionChangedAction.Remove) { foreach (Diagram oldItem in e.OldItems) { DiagramTab diagramTab = FindTab(oldItem); if (diagramTab != null) { RemoveTab(diagramTab); } } } }
internal void project_DiagramRemoved(object sender, DiagramEventArgs e) { DiagramTab tab = FindTab(e.Diagram); if (tab != null) { RemoveTab(tab); } }
public DiagramView GetOpenedDiagramView(Diagram diagram) { DiagramTab diagramTab = FindTab(diagram); if (diagramTab != null) { return(diagramTab.DiagramView); } else { return(null); } }
/// <summary> /// Activates given diagram and selects given element on it /// </summary> /// <param name="diagram"></param> /// <param name="selectedComponent"></param> public void ActivateDiagramWithElement(Diagram diagram, Component selectedComponent, bool activateDiagramTab = true) { DiagramTab tab = ActivateDiagram(diagram, activateDiagramTab); tab.DiagramView.ClearSelection(); if (selectedComponent != null) { tab.DiagramView.SetSelection(selectedComponent, true); } Current.ActiveDiagram = diagram; }
/// <summary> /// Reaction on change of active document. /// Invokes ActiveDiagramChanged event. /// </summary> private void DockManager_ActiveTabChanged(object sender, EventArgs eventArgs) { if (!MainWindow.CommandsDisabled) { DiagramTab diagramTab = DockManager.ActiveDocument as DiagramTab; if (diagramTab != null) { Current.ActiveDiagram = diagramTab.DiagramView.Diagram; } else { Current.ActiveDiagram = null; } } else { Current.InvokeSelectionChanged(); } }
/// <summary> /// Activates a diagram /// </summary> /// <param name="diagram">Diagram to be activated</param> /// <param name="activateDiagramTab"></param> public DiagramTab ActivateDiagram(Diagram diagram, bool activateDiagramTab = true) { if (ActiveDiagram != diagram && diagram != null) { DiagramTab tab = FindTab(diagram); if (tab == null) { tab = AddTab(diagram); } else { DockManager.ActiveDocument = tab; } if (activateDiagramTab) { tab.BringDocumentHeaderToView(false); } return(tab); } else { return(DockManager.ActiveDocument as DiagramTab); } }
internal void RemoveTab(DiagramTab tab) { DockManager.Items.Remove(tab); }