Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public bool onMessageHandle(int uMsg, ref object wParam, ref object lParam, ref int lRes)
        {
            if (uMsg == (int)WindowMessage.WM_CREATE)
            {
                Form frm = this;
                mManager.init(ref frm);
                // 给下拉列表子控件树重新设置父容器以及资源管理器,在组合框窗口关闭后需要还原该子树控件的父容器以及资源管理器
                mVerticalLayout = new VerticalLayoutUI();
                mManager.useParentResource(mOwner.getManager());
                mVerticalLayout.setManager(mManager, null);
                string pDefaultAttributes = mOwner.getManager().getDefaultAttributeList("VerticalLayout");
                if (pDefaultAttributes != "")
                {
                    mVerticalLayout.applyAttributeList(pDefaultAttributes);
                }
                mVerticalLayout.setInset(new Rectangle(2, 2, 0, 0));
                mVerticalLayout.setBackColor(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
                mVerticalLayout.setBorderColor(Color.FromArgb(0xFF, 0x85, 0xE4, 0xFF));
                mVerticalLayout.setBorderSize(2);
                mVerticalLayout.setAutoDestroy(false);
                mVerticalLayout.enableScrollBar();
                mVerticalLayout.applyAttributeList(mOwner.getDropBoxAttributeList());
                for (int i = 0; i < mOwner.getCount(); i++)
                {
                    mVerticalLayout.add((ControlUI)mOwner.getItemAt(i));
                }
                ControlUI rootNode = (ControlUI)mVerticalLayout;
                mManager.attachDialog(ref rootNode);

                this.ClientSize = new Size(mRectClient.Width, mRectClient.Height);

                return(true);
            }
            else if (uMsg == (int)WindowMessage.WM_SIZE)
            {
                this.ClientSize = new Size(mRectClient.Width, mRectClient.Height);

                return(true);
            }
            else if (uMsg == (int)WindowMessage.WM_ERASEBKGND)
            {
                lRes = 1;

                return(true);
            }

            else if (uMsg == (int)WindowMessage.WM_CLOSE)
            {
                mOwner.setManager(mOwner.getManager(), mOwner.getParent());
                mOwner.setPos(mOwner.getPos());
                mOwner.setFocus();
            }
            else if (uMsg == (int)WindowMessage.WM_LBUTTONUP)
            {
                Point pt = Control.MousePosition;
                pt = mManager.getPaintWindow().PointToClient(pt);
                ControlUI pControl = mManager.findControl(ref pt);
                if (pControl != null && pControl.getClass() != "ScrollbarUI")
                {
                    PaintManagerUI.PostMessage(this.Handle, (int)WindowMessage.WM_KILLFOCUS, 0, 0);
                }
            }

            else if (uMsg == (int)WindowMessage.WM_KEYDOWN)
            {
                IntPtr ptr = (IntPtr)wParam;
                int    c   = (int)ptr;
                char   cc  = (char)int.Parse(c.ToString());
                switch ((Keys)cc)
                {
                case Keys.Escape:
                    mOwner.selectItem(mOldSel);
                    ensureVisible(mOldSel);
                    PaintManagerUI.PostMessage(this.Handle, (int)WindowMessage.WM_KILLFOCUS, 0, 0);

                    break;

                case Keys.Return:
                    PaintManagerUI.PostMessage(this.Handle, (int)WindowMessage.WM_KILLFOCUS, 0, 0);
                    break;

                default:
                    TEventUI newEvent = new TEventUI();
                    newEvent.mType = (int)EVENTTYPE_UI.UIEVENT_KEYDOWN;
                    newEvent.mKey  = cc;
                    mOwner.eventProc(ref newEvent);
                    ensureVisible(mOwner.getCurSel());
                    return(true);
                }
            }
            else if (uMsg == (int)WindowMessage.WM_MOUSEWHEEL)
            {
                IntPtr ptr = (IntPtr)wParam;
                int    c   = (int)ptr;

                int      zDelta   = (int)(short)HIWORD(c);
                TEventUI newEvent = new TEventUI();
                newEvent.mType      = (int)EVENTTYPE_UI.UIEVENT_SCROLLWHEEL;
                newEvent.mWParam    = makeLong(zDelta < 0 ? (int)ScrollBarCommands.SB_LINEDOWN : (int)ScrollBarCommands.SB_LINEUP, 0);
                newEvent.mLParam    = lParam;
                newEvent.mTimestamp = PaintManagerUI.GetTickCount();
                mOwner.eventProc(ref newEvent);
                ensureVisible(mOwner.getCurSel());
                return(true);
            }
            else if (uMsg == (int)WindowMessage.WM_KILLFOCUS)
            {
                close();
            }

            if (mManager != null && mManager.messageHandler((uint)uMsg, ref wParam, ref lParam, ref lRes))
            {
                return(true);
            }

            return(false);
        }