Beispiel #1
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]);
            }
        }
Beispiel #2
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();
                }
            }
        }