Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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;
        }