public void RegenerateDocumentIdentifiers()
        {
            int i = 0;
            RelatedDocumentsContainer docsContainer = (RelatedDocumentsContainer)Globals.RationallyAddIn.View.Children.First(c => c is RelatedDocumentsContainer);

            docsContainer.Children.Where(c => c is RelatedDocumentContainer).ToList().ForEach(c => ((RelatedDocumentContainer)c).SetDocumentIdentifier(i++));
        }
        public void Execute(Shape changedShape, string identifier)
        {
            RationallyModel           model         = Globals.RationallyAddIn.Model;
            RelatedDocumentsContainer docsContainer = (RelatedDocumentsContainer)Globals.RationallyAddIn.View.Children.First(c => c is RelatedDocumentsContainer);

            VisioShape currentComponent = new VisioShape(changedShape.ContainingPage)
            {
                Shape = changedShape
            };
            int currentIndex = currentComponent.Index;

            //swap the forces in the model
            RelatedDocument currentDoc = model.Documents[currentIndex];

            model.Documents[currentIndex]     = model.Documents[currentIndex + 1];
            model.Documents[currentIndex + 1] = currentDoc;

            RelatedDocumentContainer toMove     = docsContainer.Children.Where(c => c is RelatedDocumentContainer).Cast <RelatedDocumentContainer>().First(c => c.Index == currentIndex);
            RelatedDocumentContainer toSwapWith = docsContainer.Children.Where(c => c is RelatedDocumentContainer).Cast <RelatedDocumentContainer>().First(c => c.Index == currentIndex + 1);

            //update the index of the component and his children
            toMove.SetDocumentIdentifier(currentIndex + 1);

            //same, for the other component
            toSwapWith.SetDocumentIdentifier(currentIndex);

            VisioShape temp = docsContainer.Children[currentIndex];

            docsContainer.Children[currentIndex]     = docsContainer.Children[currentIndex + 1];
            docsContainer.Children[currentIndex + 1] = temp;

            RepaintHandler.Repaint(docsContainer);
        }
Example #3
0
        public void Execute(Shape s, string identifier)
        {
            RationallyModel model     = Globals.RationallyAddIn.Model;
            VisioShape      component = new VisioShape(Globals.RationallyAddIn.Application.ActivePage)
            {
                Shape = s
            };

            int             index         = component.Index;
            RelatedDocument document      = model.Documents[index];
            DialogResult    confirmResult = MessageBox.Show("Are you sure you want to delete " + document.Name + "?", "Confirm Deletion", MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                Shape shapeToPass;

                if (RelatedDocumentContainer.IsRelatedDocumentContainer(s.Name))
                {
                    shapeToPass = s;
                }
                else //subpart of document container
                {
                    //trace documents container
                    RelatedDocumentsContainer documentsContainer = (RelatedDocumentsContainer)Globals.RationallyAddIn.View.Children.First(c => c is RelatedDocumentsContainer);
                    //trace the correct document container
                    RelatedDocumentContainer documentContainer = (RelatedDocumentContainer)documentsContainer.Children.First(c => c is RelatedDocumentContainer && (component.Index == c.Index));

                    shapeToPass = documentContainer.Shape;
                }
                //initiate a delete handler with the container's shape
                shapeToPass.Delete();
            }
        }
        public void Execute(Shape changedShape, string context)
        {
            RationallyModel model          = Globals.RationallyAddIn.Model;
            OpenFileDialog  openFileDialog = new OpenFileDialog
            {
                CheckFileExists = true,
                CheckPathExists = true
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                VisioShape comp = new VisioShape(Globals.RationallyAddIn.Application.ActivePage)
                {
                    Shape = changedShape
                };
                int index = comp.Index;

                //container of all related documents:
                RelatedDocumentsContainer relatedDocumentsContainer = (RelatedDocumentsContainer)Globals.RationallyAddIn.View.Children.First(c => c is RelatedDocumentsContainer);
                //find the the RelatedDocumentContainer of the selected file
                RelatedDocumentContainer documentContainer = (RelatedDocumentContainer)relatedDocumentsContainer.Children.First(f => f.Index == index);

                RelatedDocument doc = model.Documents[index];
                doc.Name = openFileDialog.FileName;
                doc.Path = openFileDialog.FileName;
                documentContainer.EditFile(doc, index);
                RepaintHandler.Repaint(relatedDocumentsContainer);
            }
        }
Example #5
0
        public void Execute(RationallyView view, Shape changedShape)
        {
            RelatedDocumentsContainer relatedDocumentsContainer = (RelatedDocumentsContainer)view.Children.First(x => x is RelatedDocumentsContainer);

            foreach (RelatedDocumentContainer relatedDocumentContainer in relatedDocumentsContainer.Children.Where(c => c is RelatedDocumentContainer).Cast <RelatedDocumentContainer>().ToList())
            {
                if ((relatedDocumentContainer.Children.Where(c => c.Shape.Equals(changedShape)).ToList().Count > 0) && !relatedDocumentContainer.Deleted) //check if this related document contains the to be deleted component and is not already deleted
                {
                    relatedDocumentContainer.Deleted = true;
                    relatedDocumentContainer.Shape.Delete(); //delete the parent wrapper of s
                }
            }
        }
        public void Execute(RationallyModel model, Shape changedShape)
        {
            Log.Debug("Entered DeletedRelatedUrlUrlEventHandler.");
            RelatedDocumentsContainer relatedDocumentsContainer = Globals.RationallyAddIn.View.Children.FirstOrDefault(c => c is RelatedDocumentsContainer) as RelatedDocumentsContainer;

            if (relatedDocumentsContainer != null)
            {
                foreach (RelatedDocumentContainer relatedDocumentContainer in relatedDocumentsContainer.Children.Where(c => c is RelatedDocumentContainer).Cast <RelatedDocumentContainer>().ToList())
                {
                    Log.Debug("Removing the actual url url component from the view tree...");
                    relatedDocumentContainer.Children.RemoveAll(c => c.Shape.Equals(changedShape)); //Remove the component from the tree
                }
            }
        }
        public void Execute(RationallyModel model, Shape changedShape)
        {
            Log.Debug("Entered DeleteRelatedDocumentEventHandler.");
            //trace documents container in view tree
            VisioShape documentComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape);

            if (documentComponent is RelatedDocumentContainer)
            {
                RelatedDocumentContainer containerToDelete = (RelatedDocumentContainer)documentComponent;
                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    Log.Debug("Deleting child shapes of related document...");
                    containerToDelete.Children.Where(c => !c.Deleted).ToList().ForEach(c =>
                    {
                        c.Deleted = true;
                        c.Shape.Delete();
                    }); //schedule the missing delete events (children not selected during the manual delete)
                }

                RelatedDocumentsContainer relatedDocumentsContainer = (RelatedDocumentsContainer)Globals.RationallyAddIn.View.Children.First(c => c is RelatedDocumentsContainer);
                //update model
                int docIndex = containerToDelete.Index;

                /*if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                 * {
                 *
                 * }*/
                Log.Debug("Document being removed from model list...");
                model.Documents.RemoveAll(doc => doc.Id == containerToDelete.Id);
                //update view tree
                relatedDocumentsContainer.Children.Remove(containerToDelete);


                Log.Debug("Regenerated identifiers of document list in model.");

                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    model.RegenerateDocumentIdentifiers();
                    relatedDocumentsContainer.MsvSdContainerLocked = true;
                }

                RepaintHandler.Repaint(relatedDocumentsContainer);
            }
        }
        private void Application_CellChangedEvent(Cell cell)
        {
            Shape changedShape = cell.Shape;

            // ReSharper disable once MergeSequentialChecksWhenPossible
            if ((changedShape == null) || !changedShape.Document.Template.Contains(Information.TemplateName) || (changedShape.CellExistsU[VisioFormulas.Cell_RationallyType, (short)VisExistsFlags.visExistsAnywhere] != Constants.CellExists)) //No need to continue when the shape is not part of our model.
            {
                return;
            }
            try
            {
                if (RelatedUrlComponent.IsRelatedUrlComponent(changedShape.Name) && cell.LocalName.Equals(VisioFormulas.Cell_HyperlinkAddress)) //Link has updated
                {
                    Log.Debug("Cell changed of hyperlink shape:" + changedShape.Name);
                    //find the container that holds all Related Documents
                    RelatedDocumentsContainer relatedDocumentsContainer = (RelatedDocumentsContainer)View.Children.First(c => c is RelatedDocumentsContainer);
                    //find the related document holding the changed shape (one of his children has Shape equal to changedShape)
                    RelatedDocumentContainer relatedDocumentContainer = relatedDocumentsContainer.Children.Where(c => c is RelatedDocumentContainer).Cast <RelatedDocumentContainer>().First(dc => dc.Children.Where(c => c.Shape.Equals(changedShape)).ToList().Count > 0);
                    //update the text of the URL display component to the new url
                    RelatedURLURLComponent relatedURLURLComponent = (RelatedURLURLComponent)relatedDocumentContainer.Children.First(c => c is RelatedURLURLComponent);
                    relatedURLURLComponent.Text = changedShape.Hyperlink.Address;
                }
                else if (Application.IsUndoingOrRedoing && CheckBoxStateComponent.IsCheckBoxStateComponent(changedShape.Name) && cell.LocalName.Equals(VisioFormulas.Cell_BackGroundColour))
                {
                    CheckBoxStateComponent checkBoxState = View.GetComponentByShape(changedShape) as CheckBoxStateComponent;
                    if (checkBoxState != null)
                    {
                        Model.PlanningItems[checkBoxState.Index].Finished = checkBoxState.Checked;
                    }
                }
                else if (Application.IsUndoingOrRedoing && ForceContainer.IsForceContainer(changedShape.Name) && cell.LocalName.Equals(VisioFormulas.Cell_Index))
                {
                    Log.Debug("Forceindex cell changed of forcecontainer. shape:" + changedShape.Name);
                    VisioShape forcesComponent = View.Children.FirstOrDefault(x => x is ForcesContainer);
                    if (forcesComponent != null)
                    {
                        rebuildTree = true; //Wait with the rebuild till the undo is done
                    }
                }
                else if (Application.IsUndoingOrRedoing && AlternativeShape.IsAlternativeContainer(changedShape.Name) && cell.LocalName.Equals(VisioFormulas.Cell_Index))
                {
                    Log.Debug("Alternative index cell changed of alternativecontainer. shape:" + changedShape.Name);
                    VisioShape alternativesComponent = View.Children.FirstOrDefault(x => x is AlternativesContainer);
                    if (alternativesComponent != null)
                    {
                        rebuildTree = true; //Wait with the rebuild till the undo is done
                    }
                }
                else if (Application.IsUndoingOrRedoing && RelatedDocumentContainer.IsRelatedDocumentContainer(changedShape.Name) && cell.LocalName.Equals(VisioFormulas.Cell_Index))
                {
                    Log.Debug("Document index cell changed of documentcontainer. shape:" + changedShape.Name);
                    VisioShape docComponent = View.Children.FirstOrDefault(x => x is RelatedDocumentsContainer);
                    if (docComponent != null)
                    {
                        rebuildTree = true; //Wait with the rebuild till the undo is done
                    }
                }
                else if (Application.IsUndoingOrRedoing && StakeholderContainer.IsStakeholderContainer(changedShape.Name) && cell.LocalName.Equals(VisioFormulas.Cell_Index))
                {
                    Log.Debug("Stakeholder index cell changed of stakeholdercontainer. shape:" + changedShape.Name);
                    VisioShape stakeholderComponent = View.Children.FirstOrDefault(x => x is StakeholdersContainer);
                    if (stakeholderComponent != null)
                    {
                        rebuildTree = true; //Wait with the rebuild till the undo is done
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, ex);
#if DEBUG
                throw;
#endif
            }
        }
Example #9
0
 public override void AddToTree(Shape s, bool allowAddOfSubpart)
 {
     if (AlternativesContainer.IsAlternativesContainer(s.Name))
     {
         if (Children.Exists(x => AlternativesContainer.IsAlternativesContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneAlternativesContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             Children.Add(new AlternativesContainer(Page, s));
         }
     }
     else if (RelatedDocumentsContainer.IsRelatedDocumentsContainer(s.Name))
     {
         if (Children.Exists(x => RelatedDocumentsContainer.IsRelatedDocumentsContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneRelatedDocumentsContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             RelatedDocumentsContainer rdc = new RelatedDocumentsContainer(Page, s);
             Children.Add(rdc);
         }
     }
     else if (ForcesContainer.IsForcesContainer(s.Name))
     {
         if (Children.Exists(x => ForcesContainer.IsForcesContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneForcesContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             ForcesContainer forcesContainer = new ForcesContainer(Page, s);
             Children.Add(forcesContainer);
         }
     }
     else if (InformationContainer.IsInformationContainer(s.Name))
     {
         if (Children.Exists(x => InformationContainer.IsInformationContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneInformationContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             InformationContainer informationContainer = new InformationContainer(Page, s);
             Children.Add(informationContainer);
         }
     }
     else if (TitleLabel.IsTitleLabel(s.Name))
     {
         if (Children.Exists(x => TitleLabel.IsTitleLabel(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneTitleAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             TitleLabel titleLabel = new TitleLabel(Page, s);
             Children.Add(titleLabel);
         }
     }
     else if (StakeholdersContainer.IsStakeholdersContainer(s.Name))
     {
         if (Children.Exists(x => StakeholdersContainer.IsStakeholdersContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OneStakeholdersContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             StakeholdersContainer stakeholdersContainer = new StakeholdersContainer(Page, s);
             Children.Add(stakeholdersContainer);
         }
     }
     else if (PlanningContainer.IsPlanningContainer(s.Name))
     {
         if (Children.Exists(x => PlanningContainer.IsPlanningContainer(x.Name)))
         {
             if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
             {
                 MessageBox.Show(Messages.OnePlanningContainerAllowed, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 s.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
             }
         }
         else
         {
             PlanningContainer planningContainer = new PlanningContainer(Page, s);
             Children.Add(planningContainer);
         }
     }
     else if (allowAddOfSubpart)
     {
         Children.ForEach(r => r.AddToTree(s, true));
     }
 }