Beispiel #1
0
 public override void AddToTree(Shape s, bool allowAddInChildren)
 {
     if (AlternativeStateShape.IsAlternativeState(s.Name))
     {
         AlternativeStateShape com = AlternativeStateShape.CreateFromShape(Page, s);
         if (com.Index == Index)
         {
             Children.Add(com);
         }
     }
     else if (AlternativeIdentifierShape.IsAlternativeIdentifier(s.Name))
     {
         AlternativeIdentifierShape com = new AlternativeIdentifierShape(Page, s);
         if (com.Index == Index)
         {
             Children.Add(com);
         }
     }
     else if (AlternativeTitleComponent.IsAlternativeTitle(s.Name))
     {
         AlternativeTitleComponent com = new AlternativeTitleComponent(Page, s);
         if (com.Index == Index)
         {
             Children.Add(com);
         }
     }
     else if (AlternativeDescriptionShape.IsAlternativeDescription(s.Name))
     {
         AlternativeDescriptionShape com = new AlternativeDescriptionShape(Page, s);
         if (com.Index == Index)
         {
             Children.Add(com);
         }
     }
 }
Beispiel #2
0
        public AlternativeShape(Page page, Shape alternative) : base(page, false)
        {
            Shape = alternative;
            string title = null, state = null;

            foreach (int shapeIdentifier in alternative.ContainerProperties.GetMemberShapes((int)VisContainerFlags.visContainerFlagsExcludeNested))
            {
                Shape alternativeComponent = page.Shapes.ItemFromID[shapeIdentifier];
                if (AlternativeTitleComponent.IsAlternativeTitle(alternativeComponent.Name))
                {
                    AlternativeTitleComponent comp = new AlternativeTitleComponent(page, alternativeComponent);
                    Children.Add(comp);
                    title = comp.Text;
                }
                else if (AlternativeStateShape.IsAlternativeState(alternativeComponent.Name))
                {
                    AlternativeStateShape comp = AlternativeStateShape.CreateFromShape(page, alternativeComponent);
                    Children.Add(comp);
                    state = comp.Text;
                }
                else if (AlternativeIdentifierShape.IsAlternativeIdentifier(alternativeComponent.Name))
                {
                    Children.Add(new AlternativeIdentifierShape(page, alternativeComponent));
                }
                else if (AlternativeDescriptionShape.IsAlternativeDescription(alternativeComponent.Name))
                {
                    AlternativeDescriptionShape comp = new AlternativeDescriptionShape(page, alternativeComponent);
                    Children.Add(comp);
                }
            }
            if ((title != null) && (state != null))
            {
                if (Index <= Globals.RationallyAddIn.Model.Alternatives.Count)
                {
                    Alternative newAlternative = new Alternative(title, state, Id);
                    newAlternative.GenerateIdentifier(Index);
                    Globals.RationallyAddIn.Model.Alternatives.Insert(Index, newAlternative);
                    int index = Index;
                    foreach (Alternative alt in Globals.RationallyAddIn.Model.Alternatives.Skip(index + 1).ToList()) //Skip up till and including the new Alternative
                    {
                        alt.GenerateIdentifier(++index);
                    }
                }
                else
                {
                    Alternative newAlternative = new Alternative(title, state, Id);
                    newAlternative.GenerateIdentifier(Globals.RationallyAddIn.Model.Alternatives.Count);
                    Globals.RationallyAddIn.Model.Alternatives.Add(newAlternative);
                }
            }
            UsedSizingPolicy = SizingPolicy.ExpandYIfNeeded | SizingPolicy.ShrinkYIfNeeded | SizingPolicy.ShrinkXIfNeeded;
            MarginTop        = Index == 0 ? 0.3 : 0.0;
        }
Beispiel #3
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 (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));
                }
            }
        }