public AlternativesContainer(Page page, Shape alternativesContainer) : base(page) { Shape = alternativesContainer; Array ident = alternativesContainer.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 => AlternativeShape.IsAlternativeContainer(shape.Name))) { Children.Add(new AlternativeShape(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 (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)); } } }