Example #1
0
        public override void CalculateMinimumSize(LayoutVariables vars)
        {
            LabelCIO       labelCIO  = (LabelCIO)_CIOs[LABEL_INDEX];
            StateLinkedCIO stateCIO1 = (StateLinkedCIO)_CIOs[COMPONENT1_INDEX];
            StateLinkedCIO stateCIO2 = (StateLinkedCIO)_CIOs[COMPONENT2_INDEX];

            System.Drawing.Size lblSize = new System.Drawing.Size(0, 0);

            if (labelCIO != null)
            {
                labelCIO.UseMinimumLabel();
                lblSize = labelCIO.GetMinimumSize();
            }

            System.Drawing.Size cio1Size = stateCIO1.GetMinimumSize();
            System.Drawing.Size cio2Size = stateCIO2.GetMinimumSize();

            if (_parent.IsVertical())
            {
                _minSize.Height = lblSize.Height +
                                  cio1Size.Height +
                                  cio2Size.Height +
                                  2 * vars.RowPadding;

                _minSize.Width = Math.Max(lblSize.Width, Math.Max(cio1Size.Width, cio2Size.Width));
            }
            else
            {
                _minSize.Height = Math.Max(cio1Size.Height, cio2Size.Height);

                _minSize.Width =
                    (int)Math.Ceiling((cio1Size.Width + cio2Size.Width + 2 * vars.RowPadding) / (1.0 - vars.OneColLabelPcnt));
            }
        }
Example #2
0
        public override string ToString()
        {
            String ret = "FullWidthRow\r\n";

            StateLinkedCIO stateCIO = (StateLinkedCIO)_CIOs[COMPONENT_INDEX];

            ret += "0. StateCIO = " + stateCIO.GetApplObj().Name + " - [" + stateCIO.GetControl().Bounds.X + "," + stateCIO.GetControl().Bounds.Y + "," + stateCIO.GetControl().Bounds.Width + "," + stateCIO.GetControl().Bounds.Height + "]\r\n";

            return(ret);
        }
Example #3
0
        /*
         * Member Methods
         */

        public override void AddComponents(ContainerCIO container)
        {
            LabelCIO       labelCIO1 = (LabelCIO)_CIOs[LABEL1_INDEX];
            StateLinkedCIO stateCIO1 = (StateLinkedCIO)_CIOs[COMPONENT1_INDEX];
            LabelCIO       labelCIO2 = (LabelCIO)_CIOs[LABEL2_INDEX];
            StateLinkedCIO stateCIO2 = (StateLinkedCIO)_CIOs[COMPONENT2_INDEX];

            container.AddCIO(labelCIO1);
            container.AddCIO(stateCIO1);
            container.AddCIO(labelCIO2);
            container.AddCIO(stateCIO2);
        }
Example #4
0
        public override int DoLayout(ContainerCIO container, int topY, LayoutVariables vars)
        {
            LabelCIO       labelCIO1 = (LabelCIO)_CIOs[LABEL1_INDEX];
            StateLinkedCIO stateCIO1 = (StateLinkedCIO)_CIOs[COMPONENT1_INDEX];
            LabelCIO       labelCIO2 = (LabelCIO)_CIOs[LABEL2_INDEX];
            StateLinkedCIO stateCIO2 = (StateLinkedCIO)_CIOs[COMPONENT2_INDEX];

            System.Windows.Forms.Label label = (Label)labelCIO1.GetControl();
            Control control = stateCIO1.GetControl();

            System.Drawing.Size prefSize1 = stateCIO1.GetPreferredSize();
            System.Drawing.Size prefSize2 = stateCIO2.GetPreferredSize();

            int rowHeight      = Math.Max(prefSize1.Height, prefSize2.Height);
            int columnWidth    = (container.InternalSize.Width - 3 * vars.RowPadding) / 2;
            int col1LabelWidth = (int)Math.Round(columnWidth * vars.TwoColLabel1Pcnt);
            int col1CompWidth  = columnWidth - col1LabelWidth;
            int col2LabelWidth = (int)Math.Round(columnWidth * vars.TwoColLabel2Pcnt);
            int col2CompWidth  = columnWidth = col2LabelWidth;

            control          = stateCIO1.GetControl();
            control.Size     = new System.Drawing.Size(col1CompWidth, rowHeight);
            control.Location = new System.Drawing.Point(col1LabelWidth + 2 * vars.RowPadding,
                                                        topY - stateCIO1.GetControlOffset().Y);

            if (labelCIO1 != null)
            {
                label           = (Label)labelCIO1.GetControl();
                label.TextAlign = System.Drawing.ContentAlignment.TopRight;
                label.Size      = new System.Drawing.Size(col1LabelWidth, rowHeight);
                label.Location  = new System.Drawing.Point(vars.RowPadding,
                                                           topY - labelCIO1.GetControlOffset().Y);
                labelCIO1.SetLabelText();
            }

            control          = stateCIO2.GetControl();
            control.Size     = new System.Drawing.Size(col2CompWidth, rowHeight);
            control.Location = new System.Drawing.Point(columnWidth + col2LabelWidth + 3 * vars.RowPadding,
                                                        topY - stateCIO2.GetControlOffset().Y);

            if (labelCIO2 != null)
            {
                label           = (Label)labelCIO2.GetControl();
                label.TextAlign = System.Drawing.ContentAlignment.TopRight;
                label.Size      = new System.Drawing.Size(col2LabelWidth, rowHeight);
                label.Location  = new System.Drawing.Point(columnWidth + 2 * vars.RowPadding,
                                                           topY - labelCIO2.GetControlOffset().Y);
                labelCIO2.SetLabelText();
            }

            return(1);
        }
Example #5
0
        /*
         * Process Method
         */

        public override ConcreteInteractionObject Process(ListItemNode node,
                                                          ConcreteInteractionObject cio,
                                                          UIGenerator ui)
        {
            if (node.Decorations[ItemDecision.DECISION_KEY] == null &&
                node is PanelListNode &&
                cio is PhoneListViewCIO)
            {
                // the item node represents an appliance object and it will be
                // contained within a list
                PanelListNode             newPanel = (PanelListNode)node;
                PhoneListViewCIO          list     = (PhoneListViewCIO)cio;
                ListViewItemCIO           listItem = null;
                ConcreteInteractionObject panel    = null;

                if (((ListNode)node).Items.Count == 1)
                {
                    ConcreteInteractionObject statecio = ((CIOListItemNode)newPanel.Items[0]).CIO;
                    if (statecio is StateLinkedCIO)
                    {
                        StateLinkedCIO childCIO =
                            (StateLinkedCIO)statecio;
                        listItem = new SingleItemPanelListViewItemCIO(
                            list,
                            (ApplianceState)childCIO.GetApplObj());
                        panel = ((SingleItemPanelListViewItemCIO)listItem).Panel;
                    }
                    else
                    {
                        listItem = new PanelListViewItemCIO(list, newPanel.Labels);
                        panel    = ((PanelListViewItemCIO)listItem).Panel;
                    }
                }
                else
                {
                    listItem = new PanelListViewItemCIO(list, newPanel.Labels);
                    panel    = ((PanelListViewItemCIO)listItem).Panel;
                }

                list.AddItem(listItem);
                newPanel.Decorations[ItemDecision.DECISION_KEY] =
                    new ListItemDecision(listItem);

                return(panel);
            }

            return(cio);
        }
Example #6
0
        public override string ToString()
        {
            String ret = "OneColumnRow\r\n";

            LabelCIO       labelCIO = (LabelCIO)_CIOs[LABEL_INDEX];
            StateLinkedCIO stateCIO = (StateLinkedCIO)_CIOs[COMPONENT_INDEX];

            if (labelCIO != null)
            {
                ret += "0. LabelCIO - [" + labelCIO.GetControl().Bounds.X + "," + labelCIO.GetControl().Bounds.Y + "," + labelCIO.GetControl().Bounds.Width + "," + labelCIO.GetControl().Bounds.Height + "]\r\n";
            }

            ret += "1. StateCIO = " + stateCIO.GetApplObj().Name + " - [" + stateCIO.GetControl().Bounds.X + "," + stateCIO.GetControl().Bounds.Y + "," + stateCIO.GetControl().Bounds.Width + "," + stateCIO.GetControl().Bounds.Height + "]\r\n";

            return(ret);
        }
Example #7
0
        public override System.Drawing.Size GetPreferredSize(LayoutVariables vars)
        {
            LabelCIO       labelCIO1 = (LabelCIO)_CIOs[LABEL1_INDEX];
            StateLinkedCIO stateCIO1 = (StateLinkedCIO)_CIOs[COMPONENT1_INDEX];
            LabelCIO       labelCIO2 = (LabelCIO)_CIOs[LABEL2_INDEX];
            StateLinkedCIO stateCIO2 = (StateLinkedCIO)_CIOs[COMPONENT2_INDEX];

            System.Drawing.Size ret = new System.Drawing.Size(0, 0);

            ret.Height = Math.Max(stateCIO1.GetPreferredSize().Height,
                                  stateCIO2.GetPreferredSize().Height);

            ret.Width = (labelCIO1 != null ? labelCIO1.GetPreferredSize().Width : 0) +
                        stateCIO1.GetPreferredSize().Width +
                        (labelCIO2 != null ? labelCIO2.GetPreferredSize().Width : 0) +
                        stateCIO2.GetPreferredSize().Width;

            ret.Height += vars.RowPadding;
            ret.Width  += 3 * vars.RowPadding;

            return(ret);
        }
Example #8
0
        /*
         * Member Methods
         */

        public override void AddComponents(ContainerCIO container, LayoutVariables vars)
        {
            LabelCIO       labelCIO  = (LabelCIO)_CIOs[LABEL_INDEX];
            StateLinkedCIO stateCIO1 = (StateLinkedCIO)_CIOs[COMPONENT1_INDEX];
            StateLinkedCIO stateCIO2 = (StateLinkedCIO)_CIOs[COMPONENT2_INDEX];

            if (labelCIO != null)
            {
                container.AddCIO(labelCIO);
            }

            container.AddCIO(stateCIO1);
            container.AddCIO(stateCIO2);

            _maxTextOffset = Math.Max(stateCIO1.GetControlOffset().Y, stateCIO2.GetControlOffset().Y);

            if (labelCIO != null)
            {
                _maxTextOffset = Math.Max(labelCIO.GetControlOffset().Y, _maxTextOffset);
            }

            this.CalculateMinimumSize(vars);
            this.CalculatePreferredSize(vars);
        }
Example #9
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]);
            }
        }
Example #10
0
        public override void CalculatePreferredSize(LayoutVariables vars)
        {
            LabelCIO       labelCIO  = (LabelCIO)_CIOs[LABEL_INDEX];
            StateLinkedCIO stateCIO1 = (StateLinkedCIO)_CIOs[COMPONENT1_INDEX];
            StateLinkedCIO stateCIO2 = (StateLinkedCIO)_CIOs[COMPONENT2_INDEX];

            int prefWidth = 0, prefHeight = 0;

            PreferredSize lblSize = new PreferredSize(0, 0);

            if (labelCIO != null)
            {
                labelCIO.UseMinimumLabel();
                lblSize = labelCIO.GetPreferredSize();
            }

            PreferredSize cio1Size = stateCIO1.GetPreferredSize();
            PreferredSize cio2Size = stateCIO2.GetPreferredSize();

            if (lblSize.Height == PreferredSize.INFINITE ||
                cio1Size.Height == PreferredSize.INFINITE ||
                cio2Size.Height == PreferredSize.INFINITE)
            {
                prefHeight = PreferredSize.INFINITE;
            }

            if (lblSize.Width == PreferredSize.INFINITE ||
                cio1Size.Width == PreferredSize.INFINITE ||
                cio2Size.Width == PreferredSize.INFINITE)
            {
                prefWidth = PreferredSize.INFINITE;
            }


            if (_parent.IsVertical())
            {
                if (prefHeight != PreferredSize.INFINITE)
                {
                    prefHeight = lblSize.Height + cio1Size.Height +
                                 cio2Size.Height + 2 * vars.RowPadding;
                }

                if (prefWidth != PreferredSize.INFINITE)
                {
                    prefWidth = Math.Max(lblSize.Width,
                                         Math.Max(cio1Size.Width, cio2Size.Width));
                }
            }
            else
            {
                if (prefHeight != PreferredSize.INFINITE)
                {
                    prefHeight = Math.Max(cio1Size.Height, cio2Size.Height);
                }

                if (prefWidth != PreferredSize.INFINITE)
                {
                    prefWidth =
                        (int)Math.Ceiling((cio1Size.Width + cio2Size.Width + 2 * vars.RowPadding) / (1.0 - vars.OneColLabelPcnt));
                }
            }

            _prefSize = new PUC.Layout.PreferredSize(prefWidth, prefHeight);
        }