public StakeholdersContainer(Page page, Shape stakeholderContainer) : base(page) { Shape = stakeholderContainer; Array ident = stakeholderContainer.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.Where(shape => StakeholderContainer.IsStakeholderContainer(shape.Name))) { Children.Add(new StakeholderContainer(page, shape)); } Children = Children.OrderBy(c => c.Index).ToList(); LayoutManager = new VerticalStretchLayout(this); InitStyle(); }
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)); } } }