Beispiel #1
0
        public override void CalculatePreferredSize(LayoutVariables vars)
        {
            LabelCIO        labelCIO = (LabelCIO)_CIOs[LABEL_INDEX];
            ControlBasedCIO stateCIO = (ControlBasedCIO)_CIOs[COMPONENT_INDEX];

            PreferredSize cioSize = stateCIO.GetPreferredSize();
            int           prefWidth = cioSize.Width, prefHeight = cioSize.Height;

            if (_parent.IsVertical())
            {
                if (labelCIO != null)
                {
                    labelCIO.UseMinimumLabel();
                    PreferredSize labelSize = labelCIO.GetPreferredSize();

                    if (prefHeight != PreferredSize.INFINITE)
                    {
                        prefHeight += labelSize.Height + vars.RowPadding;
                    }

                    if (prefWidth != PreferredSize.INFINITE)
                    {
                        prefWidth = Math.Max(prefWidth, labelSize.Width);
                    }
                }
            }
            else
            {
                if (prefWidth != PreferredSize.INFINITE)
                {
                    prefWidth = vars.RowPadding +
                                (int)Math.Ceiling(prefWidth / (1.0 - vars.OneColLabelPcnt));
                }

                if (labelCIO != null && prefHeight != PreferredSize.INFINITE)
                {
                    prefHeight = Math.Max(labelCIO.GetPreferredSize().Height, prefHeight);
                }
            }

            _prefSize = new PreferredSize(prefWidth, prefHeight);
        }
Beispiel #2
0
        public override void CalculatePreferredSize(LayoutVariables vars)
        {
            ControlBasedCIO stateCIO = (ControlBasedCIO)_CIOs[COMPONENT_INDEX];

            this.PreferredSize = stateCIO.GetPreferredSize();
        }
Beispiel #3
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();
                }
            }
        }