public StakeholderContainer(Page page, int index, Stakeholder stakeholder, int id) : base(page) { StakeholderNameComponent nameComponent = new StakeholderNameComponent(page, index, stakeholder.Name); StakeholderRoleComponent roleComponent = new StakeholderRoleComponent(page, index, stakeholder.Role); Children.Add(nameComponent); Children.Add(roleComponent); Log.Debug("Starting shapesheet initing of stakeholdercontainer."); Name = "Stakeholder"; //NameU = "Stakeholder"; RationallyType = "stakeholder"; Index = index; Id = id; //locks MsvSdContainerLocked = true; //Events AddAction("addStakeholder", "QUEUEMARKEREVENT(\"add\")", "Add stakeholde", false); AddAction("deleteStakeholder", "QUEUEMARKEREVENT(\"delete\")", "Delete stakeholder", false); Width = 5.26; LinePattern = 0; InitStyle(); if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing) { Shape.ContainerProperties.ResizeAsNeeded = 0; ContainerPadding = 0; } }
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 override void AddToTree(Shape s, bool allowAddInChildren) { if (StakeholderNameComponent.IsStakeholderName(s.Name)) { StakeholderNameComponent com = new StakeholderNameComponent(Page, s); if (com.Index == Index) { Children.Add(com); } } else if (StakeholderRoleComponent.IsStakeholderRole(s.Name)) { StakeholderRoleComponent com = new StakeholderRoleComponent(Page, s); if (com.Index == Index) { Children.Add(com); } } }
public StakeholderContainer(Page page, Shape stakeholder) : base(page, false) { Shape = stakeholder; string name = null; string role = null; foreach (int shapeIdentifier in stakeholder.ContainerProperties.GetMemberShapes((int)VisContainerFlags.visContainerFlagsExcludeNested)) { Shape stakeholderComponent = page.Shapes.ItemFromID[shapeIdentifier]; if (StakeholderNameComponent.IsStakeholderName(stakeholderComponent.Name)) { StakeholderNameComponent comp = new StakeholderNameComponent(page, stakeholderComponent); Children.Add(comp); name = comp.Text; } else if (StakeholderRoleComponent.IsStakeholderRole(stakeholderComponent.Name)) { StakeholderRoleComponent comp = new StakeholderRoleComponent(page, stakeholderComponent); Children.Add(comp); role = comp.Text; } } if ((name != null) && (role != null)) { Stakeholder newStakeholder = new Stakeholder(name, role, Id); if (Index <= Globals.RationallyAddIn.Model.Stakeholders.Count) { Globals.RationallyAddIn.Model.Stakeholders.Insert(Index, newStakeholder); } else { Globals.RationallyAddIn.Model.Stakeholders.Add(newStakeholder); } } InitStyle(); }