Exemplo n.º 1
0
 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);
             }
         }
     }
 }
Exemplo n.º 2
0
        /// <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.BindTab(diagram);
                newTab.DiagramView.SuspendBindingInChildren = true;
                newTab.DiagramView.LoadDiagram(diagram);
                newTab.DiagramView.SelectionChanged += SelectedItems_CollectionChanged;
                newTab.Name = "D" + diagram.ID.ToString().Replace("-", "_");
                ActivePane.Items.Add(newTab);
                ActivePane.UpdateLayout();
                //ActivePane.BringHeaderToFront(newTab);
                if (newTab.ContainerPane != null)
                {
                    DockManager.ActiveDocument = newTab;
                }
                newTab.DiagramView.SuspendBindingInChildren = false;
            }

            return(newTab);
        }
Exemplo n.º 3
0
 internal void RemoveTab(DiagramTab tab)
 {
     tab.Close();
     if (DockManager.ActiveDocument == null && DockManager.Documents.Count() > 0)
     {
         DockManager.ActiveDocument = DockManager.Documents.Last();
     }
 }
Exemplo n.º 4
0
        internal void project_DiagramRemoved(object sender, DiagramEventArgs e)
        {
            DiagramTab tab = FindTab(e.Diagram);

            if (tab != null)
            {
                RemoveTab(tab);
            }
        }
Exemplo n.º 5
0
        public DiagramView GetOpenedDiagramView(Diagram diagram)
        {
            DiagramTab diagramTab = FindTab(diagram);

            if (diagramTab != null)
            {
                return(diagramTab.DiagramView);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Activates given diagram and selects given element on it
        /// </summary>
        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;
        }
Exemplo n.º 7
0
 /// <summary>
 /// Closes active PanelWindow
 /// </summary>
 public void CloseActiveTab()
 {
     if (DockManager.ActiveDocument != null)
     {
         int        index = DockManager.MainDocumentPane.Items.IndexOf(DockManager.ActiveDocument);
         DiagramTab pw    = DockManager.ActiveDocument as DiagramTab;
         if (pw != null)
         {
             RemoveTab(pw);
         }
         else
         {
             DockManager.ActiveDocument.Close();
         }
     }
 }
Exemplo n.º 8
0
 /// <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.ActivateTab(false);
         }
         return(tab);
     }
     else
     {
         return(DockManager.ActiveDocument as DiagramTab);
     }
 }
Exemplo n.º 9
0
        /// <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
                {
                    if (System.Environment.MachineName.Contains("TRUPIK") && DockManager.ActiveDocument is IFilePresenterTab)
                    {
                        return;
                    }

                    Current.ActiveDiagram = null;
                }
            }
            else
            {
                Current.InvokeSelectionChanged();
            }
        }