Ejemplo n.º 1
0
        public ForceHeaderRow(Page page, Shape forceHeaderShape) : base(page, false)
        {
            Shape = forceHeaderShape;
            Array        ident  = forceHeaderShape.ContainerProperties.GetMemberShapes((int)VisContainerFlags.visContainerFlagsExcludeNested);
            List <Shape> shapes = new List <int>((int[])ident).Select(i => page.Shapes.ItemFromID[i]).ToList();

            if (Children.Count == 0)
            {
                foreach (Shape shape in shapes)
                {
                    if (ForceAlternativeHeaderComponent.IsForceAlternativeHeaderComponent(shape.Name))
                    {
                        Children.Add(new ForceAlternativeHeaderComponent(page, shape));
                    }
                    else if (shape.CellExistsU[VisioFormulas.Cell_RationallyType, (short)VisExistsFlags.visExistsAnywhere] == Constants.CellExists)
                    {
                        VisioShape toAdd = new VisioShape(page)
                        {
                            Shape = shape
                        };
                        Children.Add(toAdd);
                    }
                }
            }
            MarginTop         = 0.4;
            UsedSizingPolicy |= SizingPolicy.ShrinkYIfNeeded | SizingPolicy.ExpandXIfNeeded;
            LayoutManager     = new InlineLayout(this);
        }
Ejemplo n.º 2
0
 public override void AddToTree(Shape s, bool allowAddOfSubpart)
 {
     if (ForceAlternativeHeaderComponent.IsForceAlternativeHeaderComponent(s.Name))
     {
         ForceAlternativeHeaderComponent com = new ForceAlternativeHeaderComponent(Page, s);
         int index = com.Shape.Text[0] - 63;//text is of the form "A:"; A = 65 and should be inserted at index 2, after the concern and desc column
         if (Children.Count < index)
         {
             Children.Add(com);
         }
         else
         {
             Children.Insert(index, com);
         }
     }
 }
Ejemplo n.º 3
0
        public override void Repaint()
        {
            //foreach alternative in model { add a force value component, if it is not aleady there }
            List <Alternative> alternatives = Globals.RationallyAddIn.Model.Alternatives;
            List <ForceAlternativeHeaderComponent> alreadyThere = Children.Where(c => c is ForceAlternativeHeaderComponent).Cast <ForceAlternativeHeaderComponent>().ToList();

            // ReSharper disable once LoopCanBeConvertedToQuery
            foreach (Alternative alt in alternatives)
            {
                //locate the header cell for the current alternative, if it exsists
                ForceAlternativeHeaderComponent altHeader = (ForceAlternativeHeaderComponent)Children.FirstOrDefault(c => c is ForceAlternativeHeaderComponent && !c.Deleted && (((ForceAlternativeHeaderComponent)c).ForceAlternativeId == alt.Id));
                //if a deleted shape is present, there is no possiblity that we are adding an alternative. Furthermore, the deleted shape still represents an alternative, for each thus no second cell should be added!
                if ((altHeader == null) && Children.All(c => !c.Deleted))
                {
                    alreadyThere.Add(new ForceAlternativeHeaderComponent(Page, alt.IdentifierString, alt.Id));
                }
            }

            //at this point, all alternatives have a component in alreadyThere, but there might be components of removed alternatives in there as well
            List <ForceAlternativeHeaderComponent> toRemove         = alreadyThere.Where(f => !f.Deleted && !alternatives.ToList().Any(alt => alt.Id == f.ForceAlternativeId)).ToList();
            List <ForceAlternativeHeaderComponent> toRemoveFromTree = alreadyThere.Where(f => f.Deleted || !alternatives.ToList().Any(alt => alt.Id == f.ForceAlternativeId)).ToList();

            alreadyThere.RemoveAll(a => toRemoveFromTree.Contains(a));
            //finally, order the alternative columns similar to the alternatives container
            if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
            {
                alreadyThere = alreadyThere.OrderBy(fc => alternatives.IndexOf(alternatives.First(a => a.Id == fc.ForceAlternativeId))).ToList();
            }
            Children.RemoveAll(c => c is ForceAlternativeHeaderComponent);
            Children.AddRange(alreadyThere);

            //remove the shapes of the deleted components; undo redo do this automatically
            if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
            {
                MsvSdContainerLocked = false;
                toRemove.ForEach(c => c.Shape.DeleteEx((short)VisDeleteFlags.visDeleteNormal));
                MsvSdContainerLocked = true;
            }
            base.Repaint();
        }