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

        public AlternativeShape(Page page, int index, Alternative alternative) : base(page)
        {
            //1) state box
            AlternativeState alternativeState;

            Enum.TryParse(alternative.Status, out alternativeState);
            AlternativeStateShape stateShape = AlternativeStateShape.CreateWithNewShape(page, index, alternativeState);

            Log.Debug("Created state component");

            //2) identifier ("A:")
            string identifier = (char)(65 + index) + ":";
            AlternativeIdentifierShape identifierShape = new AlternativeIdentifierShape(page, index, identifier);

            identifierShape.ToggleBoldFont(true);
            Log.Debug("created identifier component");
            //3) title
            AlternativeTitleComponent titleComponent = new AlternativeTitleComponent(page, index, alternative.Title);

            Log.Debug("created title component");
            //4) description area
            AlternativeDescriptionShape descShape = new AlternativeDescriptionShape(page, index);

            Log.Debug("created description component");

            Children.Add(identifierShape);
            Children.Add(titleComponent);
            Children.Add(stateShape);
            Children.Add(descShape);

            Name           = ShapeNames.Alternative;
            RationallyType = ShapeNames.TypeAlternative;
            Index          = index;
            Id             = alternative.Id;

            Log.Debug("Done with shapesheet identifying properties");
            //locks
            MsvSdContainerLocked = true;

            //Events
            AddAction("deleteAlternative", string.Format(VisioFormulas.Formula_QUEUMARKEREVENT, "delete"), Messages.Menu_DeleteAlternative, false);

            LinePattern = 16;
            InitStyle();
        }