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 StakeholdersContainer stakeholdersContainer = (StakeholdersContainer)Globals.RationallyAddIn.View.Children.First(c => c is StakeholdersContainer); StakeholderContainer toChange = (StakeholderContainer)stakeholdersContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex); StakeholderContainer other = (StakeholderContainer)stakeholdersContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex - 1); //swap Stakeholder one = model.Stakeholders[currentIndex]; model.Stakeholders[currentIndex] = model.Stakeholders[currentIndex - 1]; model.Stakeholders[currentIndex - 1] = one; //update the index of the component and his children toChange.SetStakeholderIndex(currentIndex - 1); //same, for the other component other.SetStakeholderIndex(currentIndex); //swap the elements VisioShape temp = stakeholdersContainer.Children[currentIndex]; stakeholdersContainer.Children[currentIndex] = stakeholdersContainer.Children[currentIndex - 1]; stakeholdersContainer.Children[currentIndex - 1] = temp; RepaintHandler.Repaint(); }
public ForceTotalsRow(Page page, Shape forceTotalsShape) : base(page, false) { Shape = forceTotalsShape; UsedSizingPolicy |= SizingPolicy.ShrinkYIfNeeded | SizingPolicy.ExpandXIfNeeded; LayoutManager = new InlineLayout(this); MarginBottom = 0.4; Array ident = forceTotalsShape.ContainerProperties.GetMemberShapes((int)VisContainerFlags.visContainerFlagsExcludeNested); List <Shape> shapes = new List <int>((int[])ident).Select(i => page.Shapes.ItemFromID[i]).ToList(); if (Children.Count == 0) { foreach (Shape shape in shapes) { if (ForceTotalComponent.IsForceTotalComponent(shape.Name)) { Children.Add(new ForceTotalComponent(page, shape)); } else if (shape.CellExistsU[VisioFormulas.Cell_RationallyType, (short)VisExistsFlags.visExistsAnywhere] == Constants.CellExists) { VisioShape toAdd = new VisioShape(page) { Shape = shape }; Children.Add(toAdd); } } } }
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; ForcesContainer forcesContainer = (ForcesContainer)Globals.RationallyAddIn.View.Children.First(c => c is ForcesContainer); if (forcesContainer.Children.Count == 0) { //insert header, if it is absent if ((forcesContainer.Children.Count == 0) || !forcesContainer.Children.Any(c => c is ForceHeaderRow)) { forcesContainer.Children.Insert(0, new ForceHeaderRow(Globals.RationallyAddIn.Application.ActivePage)); } //insert footer, if it is absent if ((forcesContainer.Children.Count == 0) || !forcesContainer.Children.Any(c => c is ForceTotalsRow)) { forcesContainer.Children.Add(new ForceTotalsRow(Globals.RationallyAddIn.Application.ActivePage)); } else if (forcesContainer.Children.Any(c => c is ForceTotalsRow)) { VisioShape toMove = forcesContainer.Children.First(c => c is ForceTotalsRow); int toMoveIndex = forcesContainer.Children.IndexOf(toMove); VisioShape toSwapWith = forcesContainer.Children.Last(); forcesContainer.Children[forcesContainer.Children.Count - 1] = toMove; forcesContainer.Children[toMoveIndex] = toSwapWith; } } Force newForce = new Force(ForceConcernComponent.DefaultConcern, ForceDescriptionComponent.DefaultDescription); model.Forces.Add(newForce); forcesContainer.Children.Insert(forcesContainer.Children.Count - 1, new ForceContainer(Globals.RationallyAddIn.Application.ActivePage, forcesContainer.Children.Count - 2, newForce.Id)); //update the model as well RepaintHandler.Repaint(forcesContainer); }
public override void Repaint() { if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { List <VisioShape> toDelete = new List <VisioShape>(); int i = Children.Count - 2; //2 = header row + total row, that we both want to ignore //for each force container, that is not in the model (checked by id), increase the to-delete-counter. Children.Where(force => force is ForceContainer && !Globals.RationallyAddIn.Model.Forces.Select(frc => frc.Id).Contains(force.Id)).ToList().ForEach(force => { toDelete.Add(force); i--; }); //for each model force that is not yet in the view, add it. Globals.RationallyAddIn.Model.Forces.Where(modelForce => Children.All(force => !(force is ForceContainer) || modelForce.Id != force.Id)).ToList().ForEach(modelForce => Children.Add(new ForceContainer(Page, i++, modelForce.Id)) ); toDelete.ForEach(force => force.Shape.Delete()); if (Children.Any(c => c is ForceTotalsRow)) { VisioShape toMove = Children.First(c => c is ForceTotalsRow); while (toMove != Children.Last()) { int toMoveIndex = Children.IndexOf(toMove); VisioShape toSwapWith = Children[toMoveIndex + 1]; Children[toMoveIndex + 1] = toMove; Children[toMoveIndex] = toSwapWith; } } } base.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 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 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(); } }
private ContextMenuItem(VisioShape shape, string eventId, string name, bool isFlyOut = false) { Shape = shape; EventId = eventId; IsFlyOut = isFlyOut; ActionId = Shape.Shape.UniqueID[(short)VisUniqueIDArgs.visGetOrMakeGUID] + EventId; }
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(); }
public static ContextMenuItem CreateAndRegister(VisioShape shape, string eventId, string name, bool isFlyOut = false) { ContextMenuItem menuItem = new ContextMenuItem(shape, eventId, name, isFlyOut); if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { //Assign to local varibale and not field to avoid updatemenuitem being called menuItem.name = name; menuItem.isEnabled = true; menuItem.Shape.AddMenuItem(menuItem); } else { if ( menuItem.Shape.Shape.CellExists[ string.Format(VisioFormulas.Action_Action, menuItem.EventId), (short)VisExistsFlags.visExistsAnywhere] == Constants.CellExists) { menuItem.name = menuItem.Shape.Shape.CellsU[string.Format(VisioFormulas.Action_MenuName, menuItem.EventId)].ResultStr["Value"]; menuItem.isEnabled = !(menuItem.Shape.Shape.CellsU[string.Format(VisioFormulas.Action_Disabled, menuItem.EventId)].ResultIU > 0); } } return(menuItem); }
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 override void Repaint() { if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) //Visio takes care of this { UpdateReorderFunctions(Globals.RationallyAddIn.Model.Alternatives.Count - 1); } if (Children.Count == 4) { if (!(Children[0] is AlternativeIdentifierShape)) { VisioShape c = Children.Find(x => x is AlternativeIdentifierShape); Children.Remove(c); Children.Insert(0, c); } if (!(Children[1] is AlternativeTitleComponent)) { VisioShape c = Children.Find(x => x is AlternativeTitleComponent); Children.Remove(c); Children.Insert(1, c); } if (!(Children[2] is AlternativeStateShape)) { VisioShape c = Children.Find(x => x is AlternativeStateShape); Children.Remove(c); Children.Insert(2, c); } } base.Repaint(); }
public void Execute(RationallyView view, Shape changedShape) { VisioShape comp = view.Children.Find(x => x is PlanningContainer); if (comp is PlanningContainer) { comp.MsvSdContainerLocked = false; } }
public void Execute(RationallyView view, Shape changedShape) { VisioShape comp = view.Children.Find(x => x is RelatedDocumentsContainer); if (comp is RelatedDocumentsContainer) { comp.MsvSdContainerLocked = false; //Child shapes can now be removed. } }
public override void AddToTree(Shape s, bool allowAddInChildren) { //make s into an rcomponent for access to wrapper VisioShape shapeComponent = new VisioShape(Page) { Shape = s }; if (shapeComponent.Index == Index) { if (CheckBoxComponent.IsCheckBoxComponent(s.Name)) { if (Children.All(c => c.Index != shapeComponent.Index)) //there is no stub with this index { Children.Add(new CheckBoxComponent(Page, s)); } else { //remove stub, insert s as new containers CheckBoxStubComponent stub = (CheckBoxStubComponent)Children.First(c => c.Index == shapeComponent.Index); Children.Remove(stub); CheckBoxComponent con = new CheckBoxComponent(Page, s); if (Children.Count < con.Index) //TODO implement index { Children.Add(con); } else { Children.Insert(con.Index, con); } } } else if (PlanningItemTextComponent.IsPlanningItemTextComponent(s.Name)) { PlanningItemTextComponent com = new PlanningItemTextComponent(Page, s); if (com.Index == Index) //TODO implement index { Children.Add(com); } } else { if (CheckBoxStateComponent.IsCheckBoxStateComponent(s.Name) && Children.All(c => c.Index != shapeComponent.Index)) //if parent not exists { CheckBoxStubComponent stub = new CheckBoxStubComponent(Page, shapeComponent.Index); Children.Insert(stub.Index, stub); Children.ForEach(r => r.AddToTree(s, allowAddInChildren)); } else { Children.ForEach(r => r.AddToTree(s, allowAddInChildren)); } } } }
public void Execute(Shape changedShape, string identifier) { //get the corresponding view tree component VisioShape forceComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape); //get his parent, or himself, if changedShape is the container already ForcesContainer forcesContainer = (ForcesContainer)Globals.RationallyAddIn.View.Children.First(c => c is ForcesContainer); //loop over forcecontainers. Return the one that a child matching changedShape OR forceComponent, for changedShape is the container itself ForceContainer forceContainer = forcesContainer.Children.Where(c => c is ForceContainer).Cast <ForceContainer>().ToList().FirstOrDefault(c => c.Children.Any(x => x.Shape.Equals(changedShape))) ?? (ForceContainer)forceComponent; forceContainer.Deleted = true; forceContainer.Shape.Delete(); }
public static void Repaint(VisioShape component) { if (component != null) { Log.Debug("Repaint on:" + component.Name); component.Repaint(); if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) //Shapes may not be updated during an undo or redo, so don't place the children ourselves { component.PlaceChildren(); } } }
public ForcesContainer(Page page, Shape forcesContainer) : base(page) { Shape = forcesContainer; Array ident = forcesContainer.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 (ForceHeaderRow.IsForceHeaderRow(shape.Name)) { Children.Add(new ForceHeaderRow(page, shape)); } else if (ForceContainer.IsForceContainer(shape.Name)) { Children.Add(new ForceContainer(page, shape)); } else if (ForceTotalsRow.IsForceTotalsRow(shape.Name)) { Children.Add(new ForceTotalsRow(page, shape)); } } if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { //insert header, if it is absent if ((Children.Count == 0) || !Children.Any(c => c is ForceHeaderRow)) { Children.Insert(0, new ForceHeaderRow(Page)); } //insert footer, if it is absent if ((Children.Count == 0) || !Children.Any(c => c is ForceTotalsRow)) { Children.Add(new ForceTotalsRow(Page)); } else if (Children.Any(c => c is ForceTotalsRow)) { VisioShape toMove = Children.First(c => c is ForceTotalsRow); int toMoveIndex = Children.IndexOf(toMove); VisioShape toSwapWith = Children.Last(); Children[Children.Count - 1] = toMove; Children[toMoveIndex] = toSwapWith; } } //fix the order of the force containers, using ForceIndex Children = Children.OrderBy(c => (c is ForceHeaderRow ? -1 : (c is ForceTotalsRow ? Children.Count : c.Index))).ToList(); UsedSizingPolicy |= SizingPolicy.ExpandYIfNeeded; LayoutManager = new VerticalStretchLayout(this); }
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(); }
public void Execute(RationallyView view, Shape changedShape) { VisioShape alternativeTitleComponent = new VisioShape(view.Page) { Shape = changedShape }; if (Globals.RationallyAddIn.Model.Alternatives.Count <= alternativeTitleComponent.Index) { return; } Alternative alternativeToUpdate = Globals.RationallyAddIn.Model.Alternatives[alternativeTitleComponent.Index]; alternativeToUpdate.Title = alternativeTitleComponent.Text; }
public void Execute(RationallyView view, Shape changedShape) { VisioShape stakeholderRoleComponent = new VisioShape(view.Page) { Shape = changedShape }; if (Globals.RationallyAddIn.Model.Stakeholders.Count <= stakeholderRoleComponent.Index) { return; } Stakeholder toUpdate = Globals.RationallyAddIn.Model.Stakeholders[stakeholderRoleComponent.Index]; toUpdate.Role = stakeholderRoleComponent.Text; }
public void Execute(RationallyView view, Shape changedShape) { VisioShape planningItemTextComponent = new VisioShape(view.Page) { Shape = changedShape }; if (Globals.RationallyAddIn.Model.PlanningItems.Count <= planningItemTextComponent.Index) { return; } PlanningItem toUpdate = Globals.RationallyAddIn.Model.PlanningItems[planningItemTextComponent.Index]; toUpdate.ItemText = planningItemTextComponent.Text; }
private void Application_DeleteShapeEvent(Shape s) //Fired when a shape is deleted. Shape now no longer exists { if (s.Document.Template.Contains(Information.TemplateName)) { try { Log.Debug("shape deleted event for: " + s.Name); if (s.CellExistsU[VisioFormulas.Cell_Stub, (short)VisExistsFlags.visExistsAnywhere] == Constants.CellExists) { return; } if (s.CellExistsU[VisioFormulas.Cell_RationallyType, (short)VisExistsFlags.visExistsAnywhere] == Constants.CellExists) { string rationallyType = s.CellsU[VisioFormulas.Cell_RationallyType].ResultStr[VisioFormulas.Value]; //mark the deleted shape as 'deleted' in the view tree VisioShape deleted = View.GetComponentByShape(s); if (deleted != null) { deleted.Deleted = true; } DeleteEventHandlerRegistry.HandleEvent(rationallyType, Model, s); } else { if (StartedUndoState == 0) { RebuildTree(s.ContainingPage.Document); } } if ((StartedUndoState != 0) && (s.Name == LastDelete)) { Log.Debug("ending undo scope"); Application.EndUndoScope(StartedUndoState, true); StartedUndoState = 0; LastDelete = ""; } } catch (Exception ex) { Log.Error(ex, ex); #if DEBUG throw; #endif } } }
public override void AddToTree(Shape s, bool allowAddOfSubpart) { //make s into an rcomponent for access to wrapper VisioShape shapeComponent = new VisioShape(Page) { Shape = s }; if (AlternativeShape.IsAlternativeContainer(s.Name)) { if (Children.All(c => c.Index != shapeComponent.Index)) //there is no forcecontainer stub with this index { Children.Add(new AlternativeShape(Page, s)); } else { //remove stub, insert s as new containers AlternativeStubContainer stub = (AlternativeStubContainer)Children.First(c => c.Index == shapeComponent.Index); Children.Remove(stub); AlternativeShape con = new AlternativeShape(Page, s); if (Children.Count < con.Index) { Children.Add(con); } else { Children.Insert(con.Index, con); } } } else { bool isAlternativeChild = AlternativeStateShape.IsAlternativeState(s.Name) || AlternativeIdentifierShape.IsAlternativeIdentifier(s.Name) || AlternativeTitleComponent.IsAlternativeTitle(s.Name) || AlternativeDescriptionShape.IsAlternativeDescription(s.Name); if (isAlternativeChild && Children.All(c => c.Index != shapeComponent.Index)) //if parent not exists { AlternativeStubContainer stub = new AlternativeStubContainer(Page, shapeComponent.Index); Children.Insert(stub.Index, stub); Children.ForEach(r => r.AddToTree(s, allowAddOfSubpart)); } else { Children.ForEach(r => r.AddToTree(s, allowAddOfSubpart)); } } }
public override void AddToTree(Shape s, bool allowAddOfSubpart) { //make s into an rcomponent for access to wrapper VisioShape shapeComponent = new VisioShape(Page) { Shape = s }; if (PlanningItemComponent.IsPlanningItem(s.Name)) { if (Children.All(c => c.Index != shapeComponent.Index)) //there is no forcecontainer stub with this index { Children.Add(new PlanningItemComponent(Page, s)); } else { //remove stub, insert s as new containers PlanningStubItem stub = (PlanningStubItem)Children.First(c => c.Index == shapeComponent.Index); Children.Remove(stub); PlanningItemComponent con = new PlanningItemComponent(Page, s); if (Children.Count < con.Index) { Children.Add(con); } else { Children.Insert(con.Index, con); } } } else { bool isPlanningChild = CheckBoxComponent.IsCheckBoxComponent(s.Name) || PlanningItemTextComponent.IsPlanningItemTextComponent(s.Name); if (isPlanningChild && Children.All(c => c.Index != shapeComponent.Index)) //if parent not exists { PlanningStubItem stub = new PlanningStubItem(Page, shapeComponent.Index); Children.Insert(stub.Index, stub); Children.ForEach(r => r.AddToTree(s, allowAddOfSubpart)); } else { Children.ForEach(r => r.AddToTree(s, allowAddOfSubpart)); } } }
public override void AddToTree(Shape s, bool allowAddOfSubpart) { //make s into an rcomponent for access to wrapper VisioShape shapeComponent = new VisioShape(Page) { Shape = s }; if (StakeholderContainer.IsStakeholderContainer(s.Name)) { if (Children.All(c => c.Index != shapeComponent.Index)) //there is no stakeholder stub with this index { Children.Add(new StakeholderContainer(Page, s)); } else { //remove stub, insert s as new containers StakeholderStubContainer stub = (StakeholderStubContainer)Children.First(c => c.Index == shapeComponent.Index); Children.Remove(stub); StakeholderContainer con = new StakeholderContainer(Page, s); if (Children.Count < con.Index) { Children.Add(con); } else { Children.Insert(con.Index, con); } } } else { bool isStakeholderChild = StakeholderNameComponent.IsStakeholderName(s.Name) || StakeholderRoleComponent.IsStakeholderRole(s.Name); if (isStakeholderChild && Children.All(c => c.Index != shapeComponent.Index)) //if parent not exists { StakeholderStubContainer stub = new StakeholderStubContainer(Page, shapeComponent.Index); Children.Insert(stub.Index, stub); Children.ForEach(r => r.AddToTree(s, allowAddOfSubpart)); } else { Children.ForEach(r => r.AddToTree(s, allowAddOfSubpart)); } } }
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(); } }
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 InitChildren(Page page) { Document basicDocument = Globals.RationallyAddIn.Application.Documents.OpenEx(VisioFormulas.BasicStencil, (short)VisOpenSaveArgs.visOpenHidden); Master rectMaster = basicDocument.Masters["Rectangle"]; //dummy element for concern VisioShape concernDummy = new VisioShape(page) { Shape = page.Drop(rectMaster, 0, 0), LinePattern = 0, Width = 1, Height = 0.33, Name = "ConcernDummy", Text = "Total:", BackgroundColor = "RGB(255,255,255)", FontColor = "RGB(89,131,168)", LineColor = "RGB(89,131,168)", LockDelete = true }; concernDummy.LinePattern = 1; concernDummy.RationallyType = "concernDummy"; concernDummy.ToggleBoldFont(true); Children.Add(concernDummy); VisioShape descDummy = new VisioShape(page) { Shape = page.Drop(rectMaster, 0, 0), LinePattern = 0, Width = 2, Height = 0.33, Name = "DescDummy", BackgroundColor = "RGB(255,255,255)", FontColor = "RGB(89,131,168)", LineColor = "RGB(89,131,168)", LockDelete = true }; descDummy.LinePattern = 1; descDummy.RationallyType = "descDummy"; Children.Add(descDummy); basicDocument.Close(); }