Ejemplo n.º 1
0
 /// <summary>
 /// 销毁方法
 /// </summary>
 public override void delete()
 {
     if (!IsDeleted)
     {
         if (m_calendar != null)
         {
             if (m_selectedTimeChangedEvent != null)
             {
                 m_calendar.removeEvent(m_selectedTimeChangedEvent, FCEventID.SELECTEDTIMECHANGED);
                 m_selectedTimeChangedEvent = null;
             }
         }
         if (m_dropDownButton != null)
         {
             if (m_dropDownButtonTouchDownEvent != null)
             {
                 m_dropDownButton.removeEvent(m_dropDownButtonTouchDownEvent, FCEventID.TOUCHDOWN);
                 m_dropDownButtonTouchDownEvent = null;
             }
         }
         if (m_dropDownMenu != null)
         {
             Native.removeControl(m_dropDownMenu);
             m_dropDownMenu.delete();
             m_dropDownMenu = null;
         }
     }
     base.delete();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 自动适应位置和大小
        /// </summary>
        /// <param name="menu">菜单</param>
        protected void adjust(FCMenu menu)
        {
            FCNative native = Native;

            if (AutoSize)
            {
                int contentHeight = menu.getContentHeight();
                int maximumHeight = MaximumSize.cy;
                menu.Height = Math.Min(contentHeight, maximumHeight);
            }
            FCPoint mPoint = menu.Location;
            FCSize  mSize  = menu.Size;
            FCSize  nSize  = native.DisplaySize;

            if (mPoint.x < 0)
            {
                mPoint.x = 0;
            }
            if (mPoint.y < 0)
            {
                mPoint.y = 0;
            }
            if (mPoint.x + mSize.cx > nSize.cx)
            {
                mPoint.x = nSize.cx - mSize.cx;
            }
            if (mPoint.y + mSize.cy > nSize.cy)
            {
                mPoint.y = nSize.cy - mSize.cy;
            }
            menu.Location = mPoint;
            menu.update();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 移除项方法
        /// </summary>
        public virtual void onRemovingItem()
        {
            FCMenu dropDownMenu = null;

            if (m_parentItem != null)
            {
                dropDownMenu = m_parentItem.DropDownMenu;
            }
            else
            {
                dropDownMenu = m_parentMenu;
            }
            if (dropDownMenu != null)
            {
                if (m_items != null && m_items.size() > 0)
                {
                    int itemSize = m_items.size();
                    for (int i = 0; i < itemSize; i++)
                    {
                        m_items.get(i).onRemovingItem();
                    }
                }
                dropDownMenu.removeControl(this);
            }
            if (m_dropDownMenu != null)
            {
                m_parentMenu.Native.removeControl(m_dropDownMenu);
                m_dropDownMenu.delete();
                m_dropDownMenu = null;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 下拉菜单显示方法
        /// </summary>
        public virtual void onDropDownOpening()
        {
            //创建下拉菜单及日历
            if (m_dropDownMenu == null)
            {
                FCHost host = Native.Host;
                m_dropDownMenu = host.createInternalControl(this, "dropdownmenu") as FCMenu;
                Native.addControl(m_dropDownMenu);
                if (m_calendar == null)
                {
                    m_calendar = CreateCalendar();
                    m_dropDownMenu.addControl(m_calendar);
                    m_calendar.Size = m_dropDownMenu.Size;
                    m_calendar.addEvent(m_selectedTimeChangedEvent, FCEventID.SELECTEDTIMECHANGED);
                }
            }
            if (m_calendar != null && !m_showTime)
            {
                m_calendar.TimeDiv.Height = 0;
            }
            m_dropDownMenu.Native = Native;
            FCPoint nativePoint = pointToNative(new FCPoint(0, Height));

            m_dropDownMenu.Location = nativePoint;
            m_dropDownMenu.Visible  = true;
            if (m_calendar != null)
            {
                m_calendar.Mode = FCCalendarMode.Day;
            }
            m_dropDownMenu.bringToFront();
            m_dropDownMenu.invalidate();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 创建菜单项
        /// </summary>
        /// <param name="node">节点</param>
        /// <param name="menu">菜单</param>
        /// <param name="parentItem">父节点</param>
        protected override void createMenuItem(XmlNode node, FCMenu menu, FCMenuItem parentItem)
        {
            FCMenuItem item = new FCMenuItem();

            item.Native = Native;
            item.Font   = new FCFont("微软雅黑", 12, false, false, false);
            setAttributesBefore(node, item);
            if (parentItem != null)
            {
                parentItem.addItem(item);
            }
            else
            {
                menu.addItem(item);
            }
            if (node.ChildNodes != null && node.ChildNodes.Count > 0)
            {
                foreach (XmlNode subNode in node.ChildNodes)
                {
                    createMenuItem(subNode, menu, item);
                }
            }
            setAttributesAfter(node, item);
            onAddControl(item, node);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 创建菜单
        /// </summary>
        /// <returns>布局控件</returns>
        public virtual FCMenu createDropDownMenu()
        {
            FCMenu menu = new FCMenu();

            menu.Popup          = true;
            menu.ShowHScrollBar = true;
            menu.ShowVScrollBar = true;
            return(menu);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 显示右键菜单
        /// </summary>
        /// <param name="var">变量</param>
        /// <returns>状态</returns>
        private double SHOWRIGHTMENU(CVariable var)
        {
            DesignerScript designerScript = m_xml.Script as DesignerScript;
            FCNative       native         = m_xml.Native;
            FCView         control        = m_xml.findControl(designerScript.getSender());
            int            clientX        = native.clientX(control);
            int            clientY        = native.clientY(control);
            FCMenu         menu           = m_xml.getMenu(m_indicator.getText(var.m_parameters[0]));

            menu.Location = new FCPoint(clientX, clientY + control.Height);
            menu.Visible  = true;
            menu.Focused  = true;
            menu.bringToFront();
            native.invalidate();
            return(0);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 菜单触摸移动方法
        /// </summary>
        /// <param name="item">菜单项</param>
        /// <param name="touchInfo">触摸信息</param>
        public virtual void onMenuItemTouchMove(FCMenuItem item, FCTouchInfo touchInfo)
        {
            FCNative native = Native;
            ArrayList <FCMenuItem> items      = null;
            FCMenuItem             parentItem = item.ParentItem;

            if (parentItem != null)
            {
                items = parentItem.getItems();
            }
            else
            {
                items = m_items;
            }
            //关闭其他表格
            bool close = closeMenus(items);

            if (item.getItems().size() > 0)
            {
                FCMenu dropDownMenu = item.DropDownMenu;
                //获取位置和大小
                if (dropDownMenu != null)
                {
                    dropDownMenu.Native = native;
                    FCLayoutStyle layoutStyle = LayoutStyle;
                    FCPoint       location    = new FCPoint(native.clientX(item) + item.Width, native.clientY(item));
                    if (layoutStyle == FCLayoutStyle.LeftToRight || layoutStyle == FCLayoutStyle.RightToLeft)
                    {
                        location.x = native.clientX(item);
                        location.y = native.clientY(item) + item.Height;
                    }
                    //设置弹出位置
                    dropDownMenu.Opacity  = Opacity;
                    dropDownMenu.Location = location;
                    dropDownMenu.bringToFront();
                    dropDownMenu.focus();
                    dropDownMenu.show();
                    adjust(dropDownMenu);
                }
            }
            native.invalidate();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 添加项
        /// </summary>
        /// <param name="index">行索引</param>
        public virtual void onAddingItem(int index)
        {
            FCMenu dropDownMenu = null;

            if (m_parentItem != null)
            {
                dropDownMenu = m_parentItem.DropDownMenu;
                if (dropDownMenu == null)
                {
                    dropDownMenu              = m_parentMenu.createDropDownMenu();
                    dropDownMenu.Visible      = false;
                    m_parentItem.DropDownMenu = dropDownMenu;
                    dropDownMenu.ParentItem   = m_parentItem;
                    m_parentMenu.Native.addControl(dropDownMenu);
                }
            }
            else
            {
                dropDownMenu = m_parentMenu;
            }
            if (dropDownMenu != null)
            {
                if (index != -1)
                {
                    //插入行
                    dropDownMenu.insertControl(index, this);
                }
                else
                {
                    //添加行
                    dropDownMenu.addControl(this);
                }
                //添加子节点
                int itemSize = m_items.size();
                for (int i = 0; i < itemSize; i++)
                {
                    m_items.get(i).onAddingItem(-1);
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 关闭网格控件
        /// </summary>
        /// <param name="items">菜单集合</param>
        /// <returns>是否关闭成功</returns>
        protected bool closeMenus(ArrayList <FCMenuItem> items)
        {
            int  itemSize = items.size();
            bool close    = false;

            for (int i = 0; i < itemSize; i++)
            {
                FCMenuItem             item     = items.get(i);
                ArrayList <FCMenuItem> subItems = item.getItems();
                if (closeMenus(subItems))
                {
                    close = true;
                }
                FCMenu dropDownMenu = item.DropDownMenu;
                if (dropDownMenu != null && dropDownMenu.Visible)
                {
                    dropDownMenu.hide();
                    close = true;
                }
            }
            return(close);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 检查图层是否具有焦点
        /// </summary>
        /// <param name="items">控件集合</param>
        /// <returns>是否有焦点</returns>
        protected bool checkDivFocused(ArrayList <FCMenuItem> items)
        {
            int itemSize = items.size();

            for (int i = 0; i < items.size(); i++)
            {
                FCMenuItem item         = items.get(i);
                FCMenu     dropDownMenu = item.DropDownMenu;
                if (dropDownMenu != null)
                {
                    if (checkFocused(dropDownMenu))
                    {
                        return(true);
                    }
                }
                ArrayList <FCMenuItem> subItems = item.getItems();
                bool focused = checkDivFocused(subItems);
                if (focused)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 创建菜单项
        /// </summary>
        /// <param name="node">节点</param>
        /// <param name="menu">菜单</param>
        /// <param name="parentItem">父项</param>
        protected virtual void createMenuItem(XmlNode node, FCMenu menu, FCMenuItem parentItem)
        {
            FCMenuItem item = new FCMenuItem();

            item.Native = m_native;
            setAttributesBefore(node, item);
            if (parentItem != null)
            {
                parentItem.addItem(item);
            }
            else
            {
                menu.addItem(item);
            }
            if (node.ChildNodes != null && node.ChildNodes.Count > 0)
            {
                foreach (XmlNode subNode in node.ChildNodes)
                {
                    createMenuItem(subNode, menu, item);
                }
            }
            setAttributesAfter(node, item);
            onAddControl(item, node);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 创建子属性
        /// </summary>
        /// <param name="node">节点</param>
        /// <param name="control">控件</param>
        public virtual void createSubProperty(XmlNode node, FCView control)
        {
            String name        = node.Name.ToLower();
            String controlType = null;

            if (control != null)
            {
                controlType = control.getControlType();
            }
            if (name == "bands")
            {
                if (control is FCBandedGrid)
                {
                    createBandedGridColumns(node, control);
                }
            }
            else if (name == "columns")
            {
                if (control is FCGrid)
                {
                    createGridColumns(node, control);
                }
            }
            //下拉项
            else if (name == "item" || name == "option")
            {
                //下拉列表
                if (control is FCComboBox)
                {
                    FCComboBox comboBox = control as FCComboBox;
                    if (comboBox != null)
                    {
                        createMenuItem(node, comboBox.DropDownMenu, null);
                    }
                }
                //菜单
                else if (control is FCMenu)
                {
                    FCMenu menu = control as FCMenu;
                    if (menu != null)
                    {
                        createMenuItem(node, menu, null);
                    }
                }
            }
            //树节点
            else if (name == "nodes")
            {
                if (control is FCTree)
                {
                    createTreeNodes(node, control);
                }
            }
            //行
            else if (name == "rows")
            {
                if (control is FCGrid)
                {
                    createGridRows(node, control);
                }
            }
            //多页夹
            else if (name == "tabpage")
            {
                if (control is FCTabControl)
                {
                    createTabPage(node, control);
                }
            }
            else if (name == "tr")
            {
                if (control is FCGrid)
                {
                    FCGrid grid = control as FCGrid;
                    if (grid.m_columns.size() == 0)
                    {
                        createGridColumns(node, control);
                    }
                    else
                    {
                        createGridRow(node, control);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 创建内部控件
        /// </summary>
        /// <param name="parent">父控件</param>
        /// <param name="clsid">控件标识</param>
        /// <returns>内部控件</returns>
        public override FCView createInternalControl(FCView parent, String clsid)
        {
            //日历控件
            FCCalendar calendar = parent as FCCalendar;

            if (calendar != null)
            {
                if (clsid == "datetitle")
                {
                    return(new DateTitle(calendar));
                }
                else if (clsid == "headdiv")
                {
                    HeadDiv headDiv = new HeadDiv(calendar);
                    headDiv.Width = parent.Width;
                    headDiv.Dock  = FCDockStyle.Top;
                    return(headDiv);
                }
                else if (clsid == "lastbutton")
                {
                    return(new ArrowButton(calendar));
                }
                else if (clsid == "nextbutton")
                {
                    ArrowButton nextBtn = new ArrowButton(calendar);
                    nextBtn.ToLast = false;
                    return(nextBtn);
                }
            }
            //分割层
            FCSplitLayoutDiv splitLayoutDiv = parent as FCSplitLayoutDiv;

            if (splitLayoutDiv != null)
            {
                if (clsid == "splitter")
                {
                    FCButton splitter = new FCButton();
                    splitter.BackColor   = FCColor.Border;
                    splitter.BorderColor = FCColor.Border;
                    splitter.Size        = new FCSize(5, 5);
                    return(splitter);
                }
            }
            //滚动条
            FCScrollBar scrollBar = parent as FCScrollBar;

            if (scrollBar != null)
            {
                scrollBar.BorderColor = FCColor.None;
                scrollBar.BackColor   = FCColor.None;
                if (clsid == "addbutton")
                {
                    RibbonButton addButton = new RibbonButton();
                    addButton.Size = new FCSize(10, 10);
                    if (scrollBar is FCHScrollBar)
                    {
                        addButton.ArrowType = 2;
                    }
                    else if (scrollBar is FCVScrollBar)
                    {
                        addButton.ArrowType = 4;
                    }
                    return(addButton);
                }
                else if (clsid == "backbutton")
                {
                    FCButton backButton = new FCButton();
                    backButton.BorderColor = FCColor.None;
                    backButton.BackColor   = FCColor.None;
                    return(backButton);
                }
                else if (clsid == "scrollbutton")
                {
                    RibbonButton scrollButton = new RibbonButton();
                    scrollButton.AllowDrag = true;
                    if (scrollBar is FCVScrollBar)
                    {
                        scrollButton.Angle = 0;
                    }
                    return(scrollButton);
                }
                else if (clsid == "reducebutton")
                {
                    RibbonButton reduceButton = new RibbonButton();
                    reduceButton.Size = new FCSize(10, 10);
                    if (scrollBar is FCHScrollBar)
                    {
                        reduceButton.ArrowType = 1;
                    }
                    else if (scrollBar is FCVScrollBar)
                    {
                        reduceButton.ArrowType = 3;
                    }
                    return(reduceButton);
                }
            }
            //页夹
            FCTabPage tabPage = parent as FCTabPage;

            if (tabPage != null)
            {
                if (clsid == "headerbutton")
                {
                    RibbonButton button = new RibbonButton();
                    button.AllowDrag = true;
                    FCSize size = new FCSize(100, 20);
                    button.Size = size;
                    return(button);
                }
            }
            //下拉列表
            FCComboBox comboBox = parent as FCComboBox;

            if (comboBox != null)
            {
                if (clsid == "dropdownbutton")
                {
                    RibbonButton dropDownButton = new RibbonButton();
                    dropDownButton.ArrowType     = 4;
                    dropDownButton.DisplayOffset = false;
                    int     width    = comboBox.Width;
                    int     height   = comboBox.Height;
                    FCPoint location = new FCPoint(width - 20, 0);
                    dropDownButton.Location = location;
                    FCSize size = new FCSize(20, height);
                    dropDownButton.Size = size;
                    return(dropDownButton);
                }
                else if (clsid == "dropdownmenu")
                {
                    FCComboBoxMenu comboBoxMenu = new FCComboBoxMenu();
                    comboBoxMenu.ComboBox = comboBox;
                    comboBoxMenu.Popup    = true;
                    FCSize size = new FCSize(100, 200);
                    comboBoxMenu.Size = size;
                    return(comboBoxMenu);
                }
            }
            //日期选择
            FCDateTimePicker datePicker = parent as FCDateTimePicker;

            if (datePicker != null)
            {
                if (clsid == "dropdownbutton")
                {
                    RibbonButton dropDownButton = new RibbonButton();
                    dropDownButton.ArrowType     = 4;
                    dropDownButton.DisplayOffset = false;
                    int     width    = datePicker.Width;
                    int     height   = datePicker.Height;
                    FCPoint location = new FCPoint(width - 16, 0);
                    dropDownButton.Location = location;
                    FCSize size = new FCSize(16, height);
                    dropDownButton.Size = size;
                    return(dropDownButton);
                }
                else if (clsid == "dropdownmenu")
                {
                    FCMenu dropDownMenu = new FCMenu();
                    dropDownMenu.Padding = new FCPadding(1);
                    dropDownMenu.Popup   = true;
                    FCSize size = new FCSize(200, 200);
                    dropDownMenu.Size = size;
                    return(dropDownMenu);
                }
            }
            //数字选择
            FCSpin spin = parent as FCSpin;

            if (spin != null)
            {
                if (clsid == "downbutton")
                {
                    RibbonButton downButton = new RibbonButton();
                    downButton.DisplayOffset = false;
                    downButton.ArrowType     = 4;
                    FCSize size = new FCSize(16, 16);
                    downButton.Size = size;
                    return(downButton);
                }
                else if (clsid == "upbutton")
                {
                    RibbonButton upButton = new RibbonButton();
                    upButton.DisplayOffset = false;
                    upButton.ArrowType     = 3;
                    FCSize size = new FCSize(16, 16);
                    upButton.Size = size;
                    return(upButton);
                }
            }
            //容器层
            FCDiv div = parent as FCDiv;

            if (div != null)
            {
                if (clsid == "hscrollbar")
                {
                    FCHScrollBar hScrollBar = new FCHScrollBar();
                    hScrollBar.Visible = false;
                    hScrollBar.Size    = new FCSize(10, 10);
                    return(hScrollBar);
                }
                else if (clsid == "vscrollbar")
                {
                    FCVScrollBar vScrollBar = new FCVScrollBar();
                    vScrollBar.Visible = false;
                    vScrollBar.Size    = new FCSize(10, 10);
                    return(vScrollBar);
                }
            }
            //表格
            FCGrid grid = parent as FCGrid;

            if (grid != null)
            {
                if (clsid == "edittextbox")
                {
                    return(new FCTextBox());
                }
            }
            return(base.createInternalControl(parent, clsid));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 重绘前景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪矩形</param>
        public override void onPaintForeground(FCPaint paint, FCRect clipRect)
        {
            int width = Width, height = Height;

            if (width > 0 && height > 0)
            {
                int    right     = width;
                int    midY      = height / 2;
                String text      = Text;
                int    tRight    = 0;
                long   textColor = getPaintingTextColor();
                if (text != null && text.Length > 0)
                {
                    FCFont font  = Font;
                    FCSize tSize = paint.textSize(text, font);
                    FCRect tRect = new FCRect();
                    tRect.left   = 10;
                    tRect.top    = midY - tSize.cy / 2 + 2;
                    tRect.right  = tRect.left + tSize.cx;
                    tRect.bottom = tRect.top + tSize.cy;
                    paint.drawText(text, textColor, font, tRect);
                    tRight = tRect.right + 4;
                }
                //绘制选中
                if (m_checked)
                {
                    FCRect eRect = new FCRect(tRight, height / 2 - 4, tRight + 8, height / 2 + 4);
                    paint.fillEllipse(textColor, eRect);
                }
                //画子菜单的提示箭头
                if (m_items.size() > 0)
                {
                    FCPoint point1 = new FCPoint(), point2 = new FCPoint(), point3 = new FCPoint();
                    FCMenu  menu = m_parentMenu;
                    if (m_parentItem != null)
                    {
                        menu = m_parentItem.DropDownMenu;
                    }
                    FCLayoutStyle layoutStyle = menu.LayoutStyle;
                    //横向
                    if (layoutStyle == FCLayoutStyle.LeftToRight || layoutStyle == FCLayoutStyle.RightToLeft)
                    {
                        point1.x = right - 25;
                        point1.y = midY - 2;
                        point2.x = right - 14;
                        point2.y = midY - 2;
                        point3.x = right - 20;
                        point3.y = midY + 4;
                    }
                    //纵向
                    else
                    {
                        point1.x = right - 15;
                        point1.y = midY;
                        point2.x = right - 25;
                        point2.y = midY - 5;
                        point3.x = right - 25;
                        point3.y = midY + 5;
                    }
                    FCPoint[] points = new FCPoint[] { point1, point2, point3 };
                    paint.fillPolygon(textColor, points);
                }
            }
        }