public override void DoLayout(LayoutVariables vars)
        {
            int[] minimum   = new int[_panels.Count];
            int[] preferred = new int[_panels.Count];

            for (int i = 0; i < _panels.Count; i++)
            {
                minimum[i]   = ((InterfaceNode)_panels[i]).MinimumSize.Height;
                preferred[i] = ((InterfaceNode)_panels[i]).PreferredSize.Height;
            }

            int[] heights = LayoutAlgorithms.AllocateSizeValues(_bounds.Height, minimum, preferred, vars.RowPadding);

            int height = 0;

            for (int i = 0; i < _panels.Count; i++)
            {
                InterfaceNode node = (InterfaceNode)_panels[i];

                node.SetLocation(_bounds.X, _bounds.Y + height);
                node.SetSize(_bounds.Width, heights[i]);
                height += heights[i];

                if ((i == (_panels.Count - 1)) &&
                    (height < _bounds.Height))
                {
                    node.SetSize(_bounds.Width, heights[i] + (_bounds.Height - height));
                }

                node.DoLayout(vars);
            }
        }
Exemplo n.º 2
0
        public override void DoLayout(LayoutVariables vars)
        {
            _lineCIO.GetControl().Size     = new System.Drawing.Size(1, _bounds.Height);
            _lineCIO.GetControl().Location = new System.Drawing.Point(_lineLoc, 0);

            int[] minimum   = new int[_panels.Count];
            int[] preferred = new int[_panels.Count];

            for (int i = 0; i < _panels.Count; i++)
            {
                minimum[i]   = ((InterfaceNode)_panels[i]).MinimumSize.Width;
                preferred[i] = ((InterfaceNode)_panels[i]).PreferredSize.Width;
            }

            int[] widths = LayoutAlgorithms.AllocateSizeValues(_bounds.Width, minimum, preferred, vars.RowPadding);

            int width = 0;

            for (int i = 0; i < _panels.Count; i++)
            {
                InterfaceNode node = (InterfaceNode)_panels[i];

                node.SetLocation(_bounds.X + width, _bounds.Y);
                node.SetSize(widths[i], _bounds.Height);
                width += widths[i];

                if ((i == (_panels.Count - 1)) &&
                    (width < _bounds.Width))
                {
                    node.SetSize(widths[i] + (_bounds.Width - width), _bounds.Height);
                }

                node.DoLayout(vars);
            }
        }
Exemplo n.º 3
0
        public override void DoLayout(ContainerCIO container, LayoutVariables vars)
        {
            LabelCIO       labelCIO  = (LabelCIO)_CIOs[LABEL_INDEX];
            StateLinkedCIO stateCIO1 = (StateLinkedCIO)_CIOs[COMPONENT1_INDEX];
            StateLinkedCIO stateCIO2 = (StateLinkedCIO)_CIOs[COMPONENT2_INDEX];

            System.Windows.Forms.Label label = null;

            if (labelCIO != null)
            {
                label = (Label)labelCIO.GetControl();
            }

            Control control1 = stateCIO1.GetControl();
            Control control2 = stateCIO2.GetControl();

            if (_parent.IsVertical())
            {
                int[] minHeights  = null;
                int[] prefHeights = null;
                int[] heights     = null;

                if (labelCIO != null)
                {
                    labelCIO.UseMinimumLabel();
                    labelCIO.SetAlignment(System.Drawing.ContentAlignment.TopCenter);

                    // determine size allocations based on bounds, and minimum and preferred sizes
                    // Height is the dimension to allocate in this case
                    minHeights = new int[3] {
                        labelCIO.GetMinimumSize().Height,
                                                  stateCIO1.GetMinimumSize().Height,
                                                  stateCIO2.GetMinimumSize().Height
                    };
                    prefHeights = new int[3] {
                        labelCIO.GetPreferredSize().Height,
                                                    stateCIO1.GetPreferredSize().Height,
                                                    stateCIO2.GetPreferredSize().Height
                    };

                    heights =
                        LayoutAlgorithms.AllocateSizeValues(_bounds.Height, minHeights, prefHeights, vars.RowPadding);

                    label.Size     = new System.Drawing.Size(_bounds.Width, heights[0]);
                    label.Location = new System.Drawing.Point(_bounds.X, _bounds.Y);
                    labelCIO.SetLabelText();
                }
                else
                {
                    minHeights = new int[3] {
                        0,
                        stateCIO1.GetMinimumSize().Height,
                        stateCIO2.GetMinimumSize().Height
                    };
                    prefHeights = new int[3] {
                        0,
                        stateCIO1.GetPreferredSize().Height,
                        stateCIO2.GetPreferredSize().Height
                    };

                    heights =
                        LayoutAlgorithms.AllocateSizeValues(_bounds.Height, minHeights, prefHeights, vars.RowPadding);
                }

                control1.Size     = new System.Drawing.Size(_bounds.Width, heights[1]);
                control1.Location = new System.Drawing.Point(_bounds.X, label.Size.Height + label.Location.Y + vars.RowPadding);

                if (stateCIO1 is LabelLinkedCIO)
                {
                    ((Label)control1).TextAlign = System.Drawing.ContentAlignment.TopCenter;
                }

                control2.Size     = new System.Drawing.Size(_bounds.Width, heights[2]);
                control2.Location = new System.Drawing.Point(_bounds.X, control1.Size.Height + control1.Location.Y + vars.RowPadding);

                if (stateCIO2 is LabelLinkedCIO)
                {
                    ((Label)control2).TextAlign = System.Drawing.ContentAlignment.TopCenter;
                }
            }
            else
            {
                int labelWidth = (int)Math.Round(vars.OneColLabelPcnt * (_bounds.Width - vars.RowPadding));
                int compWidth  = (_bounds.Width - labelWidth) / 2 - vars.RowPadding;

                int[] textOffsets =
                    LayoutAlgorithms.GetTextHeightOffsets(LayoutAlgorithms.GetArrayFromArrayList(_CIOs));

                if (labelCIO != null)
                {
                    label.TextAlign = System.Drawing.ContentAlignment.TopRight;
                    label.Size      = new System.Drawing.Size(labelWidth, _bounds.Height);
                    label.Location  = new System.Drawing.Point(_bounds.X, _bounds.Y + textOffsets[0]);
                    labelCIO.SetLabelText();
                }

                control1.Size     = new System.Drawing.Size(compWidth, _bounds.Height);
                control1.Location = new System.Drawing.Point(_bounds.X + labelWidth + vars.RowPadding,
                                                             _bounds.Y + textOffsets[1]);

                control2.Size     = new System.Drawing.Size(compWidth, _bounds.Height);
                control2.Location = new System.Drawing.Point(control1.Location.X + compWidth + vars.RowPadding,
                                                             _bounds.Y + textOffsets[2]);
            }
        }
Exemplo n.º 4
0
        public override void DoLayout(ContainerCIO container, LayoutVariables vars)
        {
            LabelCIO        labelCIO = (LabelCIO)_CIOs[LABEL_INDEX];
            ControlBasedCIO stateCIO = (ControlBasedCIO)_CIOs[COMPONENT_INDEX];

            System.Windows.Forms.Label label = null;
            Control control = stateCIO.GetControl();
            int     topY    = 0;

            if (_parent.IsVertical())
            {
                if (labelCIO != null)
                {
                    labelCIO.UseMinimumLabel();
                    label = (Label)labelCIO.GetControl();
                    labelCIO.SetAlignment(System.Drawing.ContentAlignment.TopCenter);
                    label.Size     = new System.Drawing.Size(_bounds.Width, labelCIO.GetMinimumSize().Height);
                    label.Location = new System.Drawing.Point(_bounds.X, _bounds.Y);
                    labelCIO.SetLabelText();

                    topY = label.Size.Height + vars.RowPadding;
                }

                if (stateCIO is LabelLinkedCIO)
                {
                    ((Label)control).TextAlign = System.Drawing.ContentAlignment.TopCenter;
                }

                int[] size = LayoutAlgorithms.AllocateSizeValues(
                    _bounds.Height - topY,
                    new int[1] {
                    stateCIO.GetMinimumSize().Height
                },
                    new int[1] {
                    stateCIO.GetPreferredSize().Height
                },
                    vars.RowPadding);

                control.Size     = new System.Drawing.Size(_bounds.Width, size[0]);
                control.Location = new System.Drawing.Point(_bounds.X, _bounds.Y + topY);
            }
            else
            {
                int labelWidth = (int)Math.Round(vars.OneColLabelPcnt * (_bounds.Width - vars.RowPadding));
                int compWidth  = _bounds.Width - labelWidth - vars.RowPadding;

                int[] textOffsets =
                    LayoutAlgorithms.GetTextHeightOffsets(LayoutAlgorithms.GetArrayFromArrayList(_CIOs));

                control.Size     = new System.Drawing.Size(compWidth, _bounds.Height);
                control.Location = new System.Drawing.Point(_bounds.X + labelWidth + vars.RowPadding,
                                                            _bounds.Y + textOffsets[1]);

                if (labelCIO != null)
                {
                    labelCIO.UseMinimumLabel();
                    label           = (Label)labelCIO.GetControl();
                    label.TextAlign = System.Drawing.ContentAlignment.TopRight;
                    label.Size      = new System.Drawing.Size(labelWidth, _bounds.Height - textOffsets[0]);
                    label.Location  = new System.Drawing.Point(_bounds.X, _bounds.Y + textOffsets[0]);
                    labelCIO.SetLabelText();
                }
            }
        }
Exemplo n.º 5
0
        public override void DoLayout(LayoutVariables vars)
        {
            _savedVars  = vars;
            _doneLayout = true;

            int[] minimum   = new int[_rows.Count];
            int[] preferred = new int[_rows.Count];
            int[] offsets   = new int[_rows.Count];

            for (int i = 0; i < _rows.Count; i++)
            {
                minimum[i]   = ((Row)_rows[i]).MinimumSize.Height;
                preferred[i] = ((Row)_rows[i]).PreferredSize.Height;
                offsets[i]   = ((Row)_rows[i]).MaximumTextOffset;
            }

            int[] heights = LayoutAlgorithms.AllocateSizeValues(_bounds.Height - 2 * vars.RowPadding, minimum, preferred, offsets, vars.RowPadding, vars.BaselineSpacing);

            int height = vars.RowPadding;

            for (int i = 0; i < _rows.Count; i++)
            {
                Row r = (Row)_rows[i];

                r.SetLocation(_bounds.X + vars.RowPadding, _bounds.Y + height);
                r.SetSize(_bounds.Width - 2 * vars.RowPadding, heights[i]);

                if ((i + 1) < _rows.Count)
                {
                    int baselineSpace = (heights[i] - r.MaximumTextOffset) +
                                        ((Row)_rows[i + 1]).MaximumTextOffset + vars.RowPadding;

                    if (baselineSpace < vars.BaselineSpacing)
                    {
                        int incr = vars.BaselineSpacing - baselineSpace;
                        if (r.PreferredSize.Height != PreferredSize.INFINITE)
                        {
                            r.SetSize(r.GetBounds().Width,
                                      Math.Min(r.GetBounds().Height + incr, r.PreferredSize.Height));
                        }
                        else
                        {
                            r.SetSize(r.GetBounds().Width,
                                      r.GetBounds().Height + incr);
                        }

                        height += vars.BaselineSpacing - baselineSpace;
                    }
                }

                height += heights[i] + vars.RowPadding;

                r.DoLayout(Container, vars);
            }

            if (height > _bounds.Height)
            {
                vars.LayoutProblems[this] = new InsufficientHeight(this);
            }

            if (_updateScroll < 3)
            {
                ((ScrollingPanel)_panel.GetControl()).UpdateScroll();
            }
        }