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;
            Stakeholder  stakeholder   = model.Stakeholders[index];
            DialogResult confirmResult = MessageBox.Show("Are you sure you want to remove " + stakeholder.Name + "?", "Confirm Deletion", MessageBoxButtons.YesNo);

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

                if (StakeholderContainer.IsStakeholderContainer(s.Name))
                {
                    shapeToPass = s;
                }
                else //subpart of stakeholder container
                {
                    //trace stakeholders container
                    StakeholdersContainer stakeholdersContainer = (StakeholdersContainer)Globals.RationallyAddIn.View.Children.First(c => c is StakeholdersContainer);
                    //trace the correct stakeholder container
                    StakeholderContainer stakeholderContainer = (StakeholderContainer)stakeholdersContainer.Children.First(c => c is StakeholderContainer && (component.Index == c.Index));

                    shapeToPass = stakeholderContainer.Shape;
                }
                //initiate a delete handler with the container's shape
                shapeToPass.Delete();
            }
        }
        public void Execute(Shape s, string context)
        {
            RationallyModel model = Globals.RationallyAddIn.Model;

            Log.Debug("Model found: " + (model != null));
            AlternativesContainer alternativesContainer = (AlternativesContainer)Globals.RationallyAddIn.View.Children.First(ch => ch is AlternativesContainer);

            Log.Debug("Alternatives container found in view tree: " + (alternativesContainer != null));
            Log.Debug("Alternatives count: " + model.Alternatives.Count);
            if (model.Alternatives.Count >= Constants.SupportedAmountOfAlternatives) //The view does not handling more than 3 alternatives well, by default.
            {
                AddAlternativeWithWarning alternativePopUp = new AddAlternativeWithWarning(model);
                if (alternativePopUp.ShowDialog() == DialogResult.OK)
                {
                    alternativesContainer?.AddAlternative(alternativePopUp.alternativeName.Text, alternativePopUp.alternativeStatus.SelectedItem.ToString());
                }
                alternativePopUp.Dispose();
            }
            else
            {
                AddAlternative alternativePopUp = new AddAlternative(model);
                if (alternativePopUp.ShowDialog() == DialogResult.OK)
                {
                    Log.Debug("About to enter AddAlternative method");
                    alternativesContainer?.AddAlternative(alternativePopUp.alternativeName.Text, alternativePopUp.alternativeStatus.SelectedItem.ToString());
                }
                alternativePopUp.Dispose();
            }
        }
        public void Execute(Shape changedShape, string identifier)
        {
            RationallyModel model = Globals.RationallyAddIn.Model;
            //locate the stakeholder(component) to move
            VisioShape toChangeComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape);
            int        currentIndex      = toChangeComponent.Index;
            //locate the stakeholder to swap with
            PlanningContainer     planningContainer = (PlanningContainer)Globals.RationallyAddIn.View.Children.First(c => c is PlanningContainer);
            PlanningItemComponent toChange          = (PlanningItemComponent)planningContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex);
            PlanningItemComponent other             = (PlanningItemComponent)planningContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex - 1);

            //swap
            PlanningItem one = model.PlanningItems[currentIndex];

            model.PlanningItems[currentIndex]     = model.PlanningItems[currentIndex - 1];
            model.PlanningItems[currentIndex - 1] = one;

            //update the index of the component and his children
            toChange.SetPlanningItemIndex(currentIndex - 1);
            //same, for the other component
            other.SetPlanningItemIndex(currentIndex);
            //swap the elements
            VisioShape temp = planningContainer.Children[currentIndex];

            planningContainer.Children[currentIndex]     = planningContainer.Children[currentIndex - 1];
            planningContainer.Children[currentIndex - 1] = temp;


            RepaintHandler.Repaint();
        }
        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);
            }
        }
        public void Execute(Shape s, string context)
        {
            RationallyModel model     = Globals.RationallyAddIn.Model;
            VisioShape      component = new VisioShape(Globals.RationallyAddIn.Application.ActivePage)
            {
                Shape = s
            };

            int          index         = component.Index;
            Alternative  alternative   = model.Alternatives[index];
            DialogResult confirmResult = MessageBox.Show("Are you sure you want to delete " + alternative.Title + "?", "Confirm Deletion", MessageBoxButtons.YesNo);

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

                if (AlternativeShape.IsAlternativeContainer(s.Name))
                {
                    shapeToPass = s;
                }
                else //subpart of alternative container
                {
                    //trace alternatives container
                    AlternativesContainer alternativesContainer = (AlternativesContainer)Globals.RationallyAddIn.View.Children.First(c => c is AlternativesContainer);
                    //trace the correct alternative container
                    AlternativeShape alternativeShape = (AlternativeShape)alternativesContainer.Children.First(c => c is AlternativeShape && (component.Index == c.Index));

                    shapeToPass = alternativeShape.Shape;
                }
                //initiate a delete handler with the container's shape
                shapeToPass.Delete();
            }
        }
        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);
        }
 public void Execute(RationallyModel model, Shape changedShape)
 {
     Globals.RationallyAddIn.View.Children.RemoveAll(obj => obj.Shape.Equals(changedShape));
     Log.Debug("Handler of delete stakeholders entered.");
     if (!Globals.RationallyAddIn.View.Children.Any(x => x is StakeholdersContainer))
     {
         model.Stakeholders.Clear();
         Log.Debug("model stakeholders list emptied.");
         RepaintHandler.Repaint();
     }
 }
Exemplo n.º 8
0
 public void Execute(RationallyModel model, Shape changedShape)
 {
     Log.Debug("Entered DeleteRelatedDocumentsEventHandler.");
     Globals.RationallyAddIn.View.Children.RemoveAll(obj => obj.Shape.Equals(changedShape));
     if (!Globals.RationallyAddIn.View.Children.Any(x => x is RelatedDocumentsContainer))
     {
         Log.Debug("Deleting documents in document list in model.");
         model.Documents.Clear();
         RepaintHandler.Repaint();
     }
 }
 public void Execute(RationallyModel model, Shape changedShape)
 {
     Globals.RationallyAddIn.View.Children.RemoveAll(obj => obj.Shape.Equals(changedShape));
     Log.Debug("Handler of delete planning container entered.");
     if (!Globals.RationallyAddIn.View.Children.Any(x => x is PlanningContainer))
     {
         model.PlanningItems.Clear();
         Log.Debug("model planning items list emptied.");
         RepaintHandler.Repaint();
     }
 }
 public void Execute(RationallyModel model, Shape forcesContainer)
 {
     Log.Debug("Entered DeleteForcesEventHandler.");
     Globals.RationallyAddIn.View.Children.RemoveAll(obj => obj.Shape.Equals(forcesContainer));
     if (!Globals.RationallyAddIn.View.Children.Any(x => x is ForcesContainer))
     {
         model.Forces.Clear();
         Log.Debug("Cleared model forces list.");
         RepaintHandler.Repaint();
     }
 }
Exemplo n.º 11
0
        public void InitData()
        {
            RationallyModel model = ProjectSetupWizard.Instance.ModelCopy;

            Alternatives.Clear();
            //for each present alternative in the model, create a representing row in the wizard panel
            model.Alternatives.ForEach(alt => Alternatives.Add(new FlowLayoutAlternative(alt)));

            UpdateRows();
            Alternatives.ForEach(d => d.UpdateData());
            Log.Debug("Initialized alternatives wizard page.");
        }
        public void InitData()
        {
            RationallyModel model = ProjectSetupWizard.Instance.ModelCopy;

            PlanningItems.Clear();
            for (int i = 0; i < model.PlanningItems.Count; i++)
            {
                PlanningItems.Add(new FlowLayoutPlanningItem(i));
            }
            UpdateRows();
            PlanningItems.ForEach(d => d.UpdateData());
            Log.Debug("Initialized planning items wizard page.");
        }
        public void Execute(Shape changedShape, string context)
        {
            RationallyModel model           = Globals.RationallyAddIn.Model;
            UrlSelecter     selectUrlDialog = new UrlSelecter();

            if (selectUrlDialog.ShowDialog() == DialogResult.OK)
            {
                RelatedDocument document = new RelatedDocument(selectUrlDialog.urlTextBox.Text, selectUrlDialog.nameTextbox.Text, false);
                model.Documents.Add(document);
                (Globals.RationallyAddIn.View.Children.FirstOrDefault(c => c is RelatedDocumentsContainer) as RelatedDocumentsContainer)?.AddRelatedDocument(document);
            }
            selectUrlDialog.Dispose();
        }
        public void InitData()
        {
            RationallyModel model = ProjectSetupWizard.Instance.ModelCopy;

            Documents.Clear();
            for (int i = 0; i < model.Documents.Count; i++)
            {
                Documents.Add(new FlowLayoutDocument(i));
            }
            UpdateRows();
            Documents.ForEach(d => d.UpdateData());
            Log.Debug("Initialized documents wizard page.");
        }
        private static void UpdateGeneralInformationInModel(string author, string decisionName, string date, string version)
        {
            Log.Debug("About to start a tree rebuild.");
            Globals.RationallyAddIn.RebuildTree(Globals.RationallyAddIn.Application.ActiveDocument);
            Log.Debug("Rebuild tree was completed.");
            RationallyModel model = ProjectSetupWizard.Instance.ModelCopy;

            // Read the contents of setupDialog's TextBox.
            model.Author       = author;
            model.DecisionName = decisionName;
            model.DateString   = date;
            model.Version      = version;
            Log.Debug("Wrote data to copy of model: (" + author + "," + decisionName + "," + date + "," + version + ")");
        }
        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
                }
            }
        }
Exemplo n.º 17
0
        public void Execute(Shape changedShape, string identifier)
        {
            RationallyModel       model = Globals.RationallyAddIn.Model;
            AlternativesContainer alternativesContainer = (AlternativesContainer)Globals.RationallyAddIn.View.Children.First(c => c is AlternativesContainer);

            VisioShape toChangeComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape);
            int        currentIndex      = toChangeComponent.Index;

            AlternativeShape toChange = (AlternativeShape)alternativesContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex);
            //locate the alternative that we are going to swap with
            AlternativeShape other = (AlternativeShape)alternativesContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex + 1);

            //swap the items in the model
            model.Alternatives[currentIndex].GenerateIdentifier(currentIndex + 1);
            model.Alternatives[currentIndex + 1].GenerateIdentifier(currentIndex);

            string higherIndex = model.Alternatives[currentIndex].IdentifierString;
            string oldIndex    = model.Alternatives[currentIndex + 1].IdentifierString;

            Alternative one = model.Alternatives[currentIndex];

            model.Alternatives[currentIndex]     = model.Alternatives[currentIndex + 1];
            model.Alternatives[currentIndex + 1] = one;

            //update the index of the component and his children
            toChange.Index = currentIndex + 1;

            //same, for the other component
            other.Index = currentIndex;

            //update the related force column value identifiers
            ForcesContainer forcesContainer = (ForcesContainer)Globals.RationallyAddIn.View.Children.FirstOrDefault(c => c is ForcesContainer);

            //set all force value cells with id "higherIndex" to "temp"
            //set all force value cells with id "oldIndex" to "higherIndex"
            //set all force value cells with id "temp" to "oldIndex"
            forcesContainer?.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().ToList().ForEach(fc => fc.Children.Where(fcc => fcc is ForceValueComponent && (((ForceValueComponent)fcc).AlternativeIdentifierString == higherIndex)).Cast <ForceValueComponent>().ToList().ForEach(fvc => fvc.AlternativeIdentifierString = "temp"));
            forcesContainer?.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().ToList().ForEach(fc => fc.Children.Where(fcc => fcc is ForceValueComponent && (((ForceValueComponent)fcc).AlternativeIdentifierString == oldIndex)).Cast <ForceValueComponent>().ToList().ForEach(fvc => fvc.AlternativeIdentifierString    = higherIndex));
            forcesContainer?.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().ToList().ForEach(fc => fc.Children.Where(fcc => fcc is ForceValueComponent && (((ForceValueComponent)fcc).AlternativeIdentifierString == "temp")).Cast <ForceValueComponent>().ToList().ForEach(fvc => fvc.AlternativeIdentifierString      = oldIndex));
            //swap the elements in the view tree
            VisioShape temp = alternativesContainer.Children[currentIndex];

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


            RepaintHandler.Repaint();
        }
Exemplo n.º 18
0
        public static void HandleEvent(string eventKey, RationallyModel model, Shape changedShape)
        {
            if (registry == null)
            {
                registry = new Dictionary <string, List <IDeleteEventHandler> >();
            }

            if (registry.ContainsKey(eventKey))
            {
                registry[eventKey].ForEach(eh => eh.Execute(model, changedShape));
            }
            else
            {
                Log.Info("NOTICE: delete event requested on key with to registered handlers: " + eventKey);
            }
        }
Exemplo n.º 19
0
        public void Execute(RationallyModel model, Shape changedShape)
        {
            Log.Debug("Entered delete alternative event handler.");
            //store the rationally type of the last shape, which is responsible for ending the undo scope
            if (string.IsNullOrEmpty(Globals.RationallyAddIn.LastDelete) && (Globals.RationallyAddIn.StartedUndoState == 0) && !Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
            {
                Log.Debug("Starting undo scope.");
                Globals.RationallyAddIn.LastDelete       = changedShape.Name;
                Globals.RationallyAddIn.StartedUndoState = Globals.RationallyAddIn.Application.BeginUndoScope(DeleteUndoScope);
            }

            //trace alternative container in view tree
            VisioShape alternativeComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape);

            AlternativeShape delete = alternativeComponent as AlternativeShape;

            if (delete != null)
            {
                model.Forces.ForEach(force => force.ForceValueDictionary.Remove(delete.Id));
                AlternativeShape containerToDelete = delete;
                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    Log.Debug("deleting children of the alternative to delete");
                    containerToDelete.Children.Where(c => !c.Deleted).ToList().ForEach(c =>
                    {
                        c.Deleted = true;
                        c.Shape.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
                    }); //schedule the missing delete events (children not selected during the manual delete)
                }
                AlternativesContainer alternativesContainer = (AlternativesContainer)Globals.RationallyAddIn.View.Children.First(c => c is AlternativesContainer);
                //update model
                model.Alternatives.RemoveAll(a => a.Id == containerToDelete.Id);
                Log.Debug("Alternative removed from alternatives container.");
                //update view tree
                alternativesContainer.Children.Remove(containerToDelete);

                model.RegenerateAlternativeIdentifiers();
                Log.Debug("Identifiers regenerated of alternatives.");
                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    alternativesContainer.MsvSdContainerLocked = true;
                }
                RepaintHandler.Repaint();
            }
        }
Exemplo n.º 20
0
        public void Execute(RationallyModel model, Shape changedShape)
        {
            Log.Debug("Entered delete planningitem event handler.");
            //store the rationally type of the last shape, which is responsible for ending the undo scope
            if (string.IsNullOrEmpty(Globals.RationallyAddIn.LastDelete) && (Globals.RationallyAddIn.StartedUndoState == 0) && !Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
            {
                Log.Debug("Starting undo scope.");
                Globals.RationallyAddIn.LastDelete       = changedShape.Name;
                Globals.RationallyAddIn.StartedUndoState = Globals.RationallyAddIn.Application.BeginUndoScope(DeleteUndoScope);
            }

            //trace planning item container in view tree
            VisioShape planningComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape);

            PlanningItemComponent delete = planningComponent as PlanningItemComponent;

            if (delete != null)
            {
                PlanningItemComponent containerToDelete = delete;
                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    Log.Debug("deleting children of the planning item to delete");
                    containerToDelete.Children.Where(c => !c.Deleted).ToList().ForEach(c =>
                    {
                        c.Deleted = true;
                        c.Shape.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
                    }); //schedule the missing delete events (children not selected during the manual delete)
                }
                PlanningContainer planningContainer = (PlanningContainer)Globals.RationallyAddIn.View.Children.First(c => c is PlanningContainer);
                //update model
                model.PlanningItems.RemoveAll(p => p.Id == containerToDelete.Id);
                Log.Debug("Planning item removed from planning container.");
                //update view tree
                planningContainer.Children.Remove(containerToDelete);

                model.RegeneratePlanningIdentifiers();//one index no longer exists, so let the view adapt to the new index range

                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    planningContainer.MsvSdContainerLocked = true;
                }
                RepaintHandler.Repaint();
            }
        }
        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);
            }
        }
Exemplo n.º 22
0
        public void Execute(RationallyModel model, Shape changedShape)
        {
            Log.Debug("Entered delete stakeholder event handler.");
            //store the rationally type of the last shape, which is responsible for ending the undo scope
            if (string.IsNullOrEmpty(Globals.RationallyAddIn.LastDelete) && (Globals.RationallyAddIn.StartedUndoState == 0) && !Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
            {
                Log.Debug("Starting undo scope.");
                Globals.RationallyAddIn.LastDelete       = changedShape.Name;
                Globals.RationallyAddIn.StartedUndoState = Globals.RationallyAddIn.Application.BeginUndoScope(DeleteUndoScope);
            }

            //trace stakeholder container in view tree
            VisioShape stakeholderComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape);

            StakeholderContainer delete = stakeholderComponent as StakeholderContainer;

            if (delete != null)
            {
                StakeholderContainer containerToDelete = delete;
                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    Log.Debug("killing children of the stakeholder to kill");
                    containerToDelete.Children.Where(c => !c.Deleted).ToList().ForEach(c =>
                    {
                        c.Deleted = true;
                        c.Shape.DeleteEx((short)VisDeleteFlags.visDeleteNormal);
                    }); //schedule the missing delete events (children not selected during the manual delete)
                }
                StakeholdersContainer stakeholdersContainer = (StakeholdersContainer)Globals.RationallyAddIn.View.Children.First(c => c is StakeholdersContainer);
                //update model
                model.Stakeholders.RemoveAll(sth => sth.Id == containerToDelete.Id);
                Log.Debug("stakeholder removed from stakeholders container.");
                //update view tree
                stakeholdersContainer.Children.Remove(containerToDelete);

                model.RegenerateStakeholderIdentifiers();
                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    stakeholdersContainer.MsvSdContainerLocked = true;
                }
                RepaintHandler.Repaint();
            }
        }
        public void Execute(Shape changedShape, string identifier)
        {
            RationallyModel model          = Globals.RationallyAddIn.Model;
            OpenFileDialog  openFileDialog = new OpenFileDialog
            {
                CheckFileExists = true,
                CheckPathExists = true
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //AddToModel
                RelatedDocument document = new RelatedDocument(openFileDialog.FileName, openFileDialog.FileName, true);
                model.Documents.Add(document);

                (Globals.RationallyAddIn.View.Children.FirstOrDefault(c => c is RelatedDocumentsContainer) as RelatedDocumentsContainer)?.AddRelatedDocument(document);
            }
            openFileDialog.Dispose();
        }
Exemplo n.º 24
0
        public void Execute(RationallyModel model, Shape changedShape)
        {
            Log.Debug("Entered DeleteForceEventHandler.");
            //trace force row in view tree
            VisioShape forceComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape);

            if (forceComponent is ForceContainer)
            {
                ForceContainer containerToDelete = (ForceContainer)forceComponent;
                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    Log.Debug("Deleting all child components of the force container...");
                    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)
                }

                ForcesContainer forcesContainer = (ForcesContainer)Globals.RationallyAddIn.View.Children.First(c => c is ForcesContainer);
                //update model
                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    model.Forces.RemoveAll(force => force.Id == containerToDelete.Id);
                    Log.Debug("Deleting force from model list of forces.");
                }
                //update view tree
                forcesContainer.Children.Remove(containerToDelete);
                if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
                {
                    model.RegenerateForceIdentifiers();
                    Log.Debug("Regenerated force identifiers in model.");
                    forcesContainer.MsvSdContainerLocked = true;
                }

                RepaintHandler.Repaint(forcesContainer);
            }
        }
Exemplo n.º 25
0
        public InformationContainer(Page page, Shape s) : base(page, false)
        {
            Shape = s;
            RationallyModel model = Globals.RationallyAddIn.Model;

            if ((s.ContainerProperties.GetMemberShapes((int)VisContainerFlags.visContainerFlagsExcludeNested).Length == 0) && !Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
            {
                InitContent(page, model.Author, model.DateString, model.Version);
            }
            else
            {
                Array        ident  = Shape.ContainerProperties.GetMemberShapes((int)VisContainerFlags.visContainerFlagsExcludeNested);
                List <Shape> shapes = (new List <int>((int[])ident)).Select(i => page.Shapes.ItemFromID[i]).ToList();
                foreach (Shape shape in shapes)
                {
                    if (TextLabel.IsTextLabel(shape.Name))
                    {
                        Children.Add(new PaddedTextLabel(page, shape));
                    }
                    else if (AuthorLabel.IsAuthorLabel(shape.Name))
                    {
                        Children.Add(new AuthorLabel(page, shape));
                        model.Author = shape.Text;
                    }
                    else if (DateLabel.IsDateLabel(shape.Name))
                    {
                        Children.Add(new DateLabel(page, shape));
                        model.DateString = shape.Text;
                    }
                    else if (VersionLabel.IsVersionLabel(shape.Name))
                    {
                        Children.Add(new VersionLabel(page, shape));
                        model.Version = shape.Text;
                    }
                }
                Children = Children.OrderBy(c => c.Order).ToList();
            }
        }
Exemplo n.º 26
0
        private void RationallyAddIn_Startup(object sender, EventArgs e)
        {
            //init for logger
            XmlConfigurator.Configure();
            Log.Info("======== NEW SESSION ========");
            Model       = new RationallyModel();
            View        = new RationallyView(Application.ActivePage);
            rebuildTree = false;

            Application.MarkerEvent                += Application_MarkerEvent;
            Application.TemplatePaths               = Constants.MyShapesFolder;
            Application.DocumentCreated            += DelegateCreateDocumentEvent;
            Application.DocumentOpened             += Application_DocumentOpenendEvent;
            Application.ShapeAdded                 += Application_ShapeAddedEvent;
            Application.QueryCancelSelectionDelete += Application_QueryCancelSelectionDelete;
            Application.BeforeShapeDelete          += Application_DeleteShapeEvent;
            Application.CellChanged                += Application_CellChangedEvent;
            Application.TextChanged                += Application_TextChangedEvent;
            Application.NoEventsPending            += NoEventsPendingEventHandler;

            Application.BeforePageDelete += Application_BeforePageDeleteEvent;
            Application.WindowActivated  += Application_WindowActivatedEvent;

            Application.MouseDown += Application_MouseDown;

            RegisterDeleteEventHandlers();
            RegisterQueryDeleteEventHandlers();
            RegisterMarkerEventHandlers();
            RegisterTextChangedEventHandlers();

            Log.Info($"MyShapesFolder is {Constants.MyShapesFolder}");
            Log.Info("Eventhandlers registered");


            showRationallyUpdatePopup = NewVersionAvailable = CheckRationallyVersion();
        }
        public void Execute(Shape changedShape, string identifier)
        {
            RationallyModel model           = Globals.RationallyAddIn.Model;
            ForcesContainer forcesContainer = (ForcesContainer)Globals.RationallyAddIn.View.Children.First(c => c is ForcesContainer);

            VisioShape currentComponent = new VisioShape(changedShape.ContainingPage)
            {
                Shape = changedShape
            };
            int currentForceIndex = currentComponent.Index;
            int currentChildIndex = currentForceIndex + 1;

            //swap the forces in the model
            Force currentForce = model.Forces[currentForceIndex];

            model.Forces[currentForceIndex]     = model.Forces[currentForceIndex - 1];
            model.Forces[currentForceIndex - 1] = currentForce;

            ForceContainer toMove     = forcesContainer.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().First(c => c.Index == currentForceIndex);
            ForceContainer toSwapWith = forcesContainer.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().First(c => c.Index == currentForceIndex - 1);

            //update the index of the component and his children
            toMove.Children.ForEach(c => c.Index = currentForceIndex - 1);
            toMove.Index = currentForceIndex - 1;

            //same, for the other component
            toSwapWith.Children.ForEach(c => c.Index = currentForceIndex);
            toSwapWith.Index = currentForceIndex;

            VisioShape temp = forcesContainer.Children[currentChildIndex];

            forcesContainer.Children[currentChildIndex]     = forcesContainer.Children[currentChildIndex - 1];
            forcesContainer.Children[currentChildIndex - 1] = temp;

            RepaintHandler.Repaint();
        }
        public void ShowDialog(bool onDocumentCreation, WizardFieldTypes type)
        {
            ModelCopy = Globals.RationallyAddIn.Model.DeepCopy();
            Log.Debug("Entered showDialog.");
            if (WindowState == FormWindowState.Minimized)
            {
                WindowState = FormWindowState.Normal;
            }
            BringToFront();
            DocumentCreation = onDocumentCreation;

            if (DocumentCreation)
            {
                CreateButton.Text = Messages.Wizard_CreateButton_CreateView;
                Text = Messages.Wizard_Label_CreateView;
            }
            else
            {
                CreateButton.Text = Messages.Wizard_CreateButton_UpdateView;
                Text = Messages.Wizard_Label_UpdateView;
            }
            selectedFieldType = type;
            ShowDialog();
        }
Exemplo n.º 29
0
 public void Execute(RationallyModel model, Shape changedShape)
 {
     Log.Debug("Deleting information box.");
     Globals.RationallyAddIn.View.Children.RemoveAll(obj => obj.Shape.Equals(changedShape));
 }