Exemple #1
0
        public void Execute(Shape changedShape, string identifier)
        {
            RationallyModel   model             = Globals.RationallyAddIn.Model;
            PlanningContainer planningContainer = (PlanningContainer)Globals.RationallyAddIn.View.Children.First(c => c is PlanningContainer);

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

            PlanningItemComponent toChange = (PlanningItemComponent)planningContainer.Children.First(c => c.Index == currentIndex);
            //locate the stakeholder that we are going to swap with
            PlanningItemComponent other = (PlanningItemComponent)planningContainer.Children.First(c => c.Index == currentIndex + 1);

            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 in the view tree
            VisioShape temp = planningContainer.Children[currentIndex];

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


            RepaintHandler.Repaint();
        }
Exemple #2
0
        public void Execute(Shape s, string identifier)
        {
            VisioShape component = new VisioShape(Globals.RationallyAddIn.Application.ActivePage)
            {
                Shape = s
            };


            DialogResult confirmResult = MessageBox.Show("Are you sure you want to delete this item?", "Confirm Deletion", MessageBoxButtons.YesNo);

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

                if (PlanningItemComponent.IsPlanningItem(s.Name))
                {
                    shapeToPass = s;
                }
                else //subpart of planning item component
                {
                    //trace planning container
                    PlanningContainer planningContainer = (PlanningContainer)Globals.RationallyAddIn.View.Children.First(c => c is PlanningContainer);
                    //trace the correct planningItemComponent
                    PlanningItemComponent planningItemComponent = (PlanningItemComponent)planningContainer.Children.First(c => c is PlanningItemComponent && (component.Index == c.Index));

                    shapeToPass = planningItemComponent.Shape;
                }
                //initiate a delete handler with the container's shape
                shapeToPass.Delete();
            }
        }
        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();
        }
Exemple #4
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();
            }
        }