Beispiel #1
0
        public static ControlUI getControl(string typeName)
        {
            ControlUI newControl = null;
            int       len        = typeName.Length;

            switch (len)
            {
            case 4:
            {
                if (typeName == "Edit")
                {
                    newControl = new EditUI();
                }
                else if (typeName == "List")
                {
                    newControl = new ListUI();
                }
                else if (typeName == "Text")
                {
                    newControl = new TextUI();
                }

                break;
            }

            case 5:
            {
                if (typeName == "Combo")
                {
                    newControl = new ComboUI();
                }
                else if (typeName == "Label")
                {
                    newControl = new LabelUI();
                }
                break;
            }

            case 6:
            {
                if (typeName == "Button")
                {
                    newControl = new ButtonUI();
                }
                else if (typeName == "Option")
                {
                    newControl = new OptionUI();
                }
                else if (typeName == "Slider")
                {
                    newControl = new SliderUI();
                }

                break;
            }

            case 7:
            {
                if (typeName == "Control")
                {
                    newControl = new ControlUI();
                }
                else if (typeName == "ActiveX")
                {
                    newControl = new ActiveXUI();
                }
                break;
            }

            case 8:
            {
                if (typeName == "Progress")
                {
                    newControl = new ProgressUI();
                }
                break;
            }

            case 9:
            {
                if (typeName == "Container")
                {
                    newControl = new ContainerUI();
                }
                else if (typeName == "TabLayout")
                {
                    newControl = new TabLayoutUI();
                }

                break;
            }

            case 10:
            {
                if (typeName == "ListHeader")
                {
                    newControl = new ListHeaderUI();
                }
                else if (typeName == "TileLayout")
                {
                    newControl = new TileLayoutUI();
                }

                break;
            }

            case 12:
            {
                if (typeName == "DialogLayout")
                {
                    newControl = new DialogLayoutUI();
                }
                break;
            }

            case 14:
            {
                if (typeName == "VerticalLayout")
                {
                    newControl = new VerticalLayoutUI();
                }
                else if (typeName == "ListHeaderItem")
                {
                    newControl = new ListHeaderItemUI();
                }

                break;
            }

            case 15:
            {
                if (typeName == "ListTextElement")
                {
                    newControl = new ListTextElementUI();
                }
                break;
            }

            case 16:
            {
                if (typeName == "HorizontalLayout")
                {
                    newControl = new HorizontalLayoutUI();
                }
                else if (typeName == "ListLabelElement")
                {
                    newControl = new ListLabelElementUI();
                }

                break;
            }

            case 17:
            {
                if (typeName == "ListExpandElement")
                {
                    newControl = new ListExpandElementUI();
                }
                break;
            }

            case 20:
            {
                if (typeName == "ListContainerElement")
                {
                    newControl = new ListContainerElementUI();
                }
                break;
            }
            }

            return(newControl);
        }
Beispiel #2
0
        public void init(ComboUI pOwner)
        {
            mOwner          = pOwner;
            mVerticalLayout = null;
            mOldSel         = mOwner.getCurSel();

            // 使用显示器坐标显示组合控件窗口
            Size      szDrop  = mOwner.getDropBoxSize();
            Rectangle rcOwner = pOwner.getPos();
            Rectangle rc      = rcOwner;

            rc.Y      = rc.Bottom;
            rc.Height = szDrop.Height;

            if (szDrop.Width > 0)
            {
                rc.Width = rc.Left + szDrop.Width - rc.X;
            }

            Size szAvailable = new Size(rc.Right - rc.Left, rc.Bottom - rc.Top);
            int  cyFixed     = 0;

            for (int it = 0; it < pOwner.getCount(); it++)
            {
                ControlUI pControl = (ControlUI)pOwner.getItemAt(it);
                if (!pControl.isVisible())
                {
                    continue;
                }
                Size sz = pControl.estimateSize(szAvailable);
                cyFixed += sz.Height;
            }
            cyFixed  += 4; // CVerticalLayoutUI 默认的Inset 调整
            rc.Height = Math.Min(cyFixed, szDrop.Height);


            rc = mOwner.getManager().getPaintWindow().RectangleToScreen(rc);

            Rectangle rcMonitor = Screen.PrimaryScreen.Bounds;
            Rectangle rcWork    = Screen.PrimaryScreen.WorkingArea;

            rcWork.Offset(-rcWork.Left, -rcWork.Top);
            if (rc.Bottom > rcWork.Bottom)
            {
                rc.X     = rcOwner.X;
                rc.Width = rcOwner.Right - rc.X;
                if (szDrop.Width > 0)
                {
                    rc.Width = szDrop.Width;
                }
                rc.Y      = rcOwner.Y - Math.Min(cyFixed, szDrop.Height);
                rc.Height = rcOwner.Top - rc.Y;
                rc        = mOwner.getManager().getPaintWindow().RectangleToScreen(rc);
            }
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.ShowInTaskbar   = false;
            mRectClient          = rc;

            this.StartPosition = FormStartPosition.Manual;
            this.ClientSize    = new Size(rc.Width, rc.Height);
            this.Location      = new Point(rc.Left, rc.Top);
            this.TopMost       = true;

            this.Show();
        }