示例#1
0
 /// <summary>
 /// 添加子菜单项
 /// </summary>
 /// <param name="item">菜单项</param>
 public void addItem(FCMenuItem item)
 {
     item.ParentItem = this;
     item.ParentMenu = ParentMenu;
     item.onAddingItem(-1);
     m_items.add(item);
 }
示例#2
0
 /// <summary>
 /// 移除菜单项
 /// </summary>
 /// <param name="item">菜单项</param>
 public void removeItem(FCMenuItem item)
 {
     if (m_dropDownMenu != null)
     {
         m_dropDownMenu.removeItem(item);
     }
 }
示例#3
0
 /// <summary>
 /// 插入项
 /// </summary>
 /// <param name="index">索引</param>
 /// <param name="item">菜单项</param>
 public void insertItem(int index, FCMenuItem item)
 {
     item.ParentItem = this;
     item.ParentMenu = ParentMenu;
     item.onAddingItem(index);
     m_items.Insert(index, item);
 }
示例#4
0
 /// <summary>
 /// 插入菜单项
 /// </summary>
 /// <param name="index">索引</param>
 /// <param name="item">菜单项</param>
 public void insertItem(int index, FCMenuItem item)
 {
     if (m_dropDownMenu != null)
     {
         m_dropDownMenu.insertItem(index, item);
     }
 }
示例#5
0
 /// <summary>
 /// 添加菜单项
 /// </summary>
 /// <param name="item">菜单项</param>
 public void addItem(FCMenuItem item)
 {
     if (m_dropDownMenu != null)
     {
         m_dropDownMenu.addItem(item);
     }
 }
示例#6
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);
        }
示例#7
0
 /// <summary>
 /// 调用菜单的触摸事件
 /// </summary>
 /// <param name="eventID">事件ID</param>
 /// <param name="item">菜单项</param>
 /// <param name="touchInfo">触摸信息</param>
 protected void callMenuItemTouchEvent(int eventID, FCMenuItem item, FCTouchInfo touchInfo)
 {
     if (m_events != null && m_events.containsKey(eventID))
     {
         ArrayList <object> events = m_events.get(eventID);
         int eventSize             = events.size();
         for (int i = 0; i < eventSize; i++)
         {
             FCMenuItemTouchEvent func = events.get(i) as FCMenuItemTouchEvent;
             if (func != null)
             {
                 func(this, item, touchInfo);
             }
         }
     }
 }
示例#8
0
        /// <summary>
        /// 菜单项的点击方法
        /// </summary>
        /// <param name="sender">调用者</param>
        /// <param name="item">菜单项</param>
        /// <param name="touchInfo">触摸信息</param>
        private void menuItemClick(object sender, FCMenuItem item, FCTouchInfo touchInfo)
        {
            Text = item.Text;
            ArrayList <FCMenuItem> items = getItems();
            int itemSize = items.size();

            for (int i = 0; i < itemSize; i++)
            {
                if (items.get(i) == item)
                {
                    SelectedIndex = i;
                    break;
                }
            }
            SelectionStart = Text.Length;
            invalidate();
        }
示例#9
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();
        }
示例#10
0
 /// <summary>
 /// 菜单点击方法
 /// </summary>
 /// <param name="item">菜单项</param>
 /// <param name="touchInfo">触摸信息</param>
 public virtual void onMenuItemClick(FCMenuItem item, FCTouchInfo touchInfo)
 {
     if (item.getItems().size() == 0)
     {
         callMenuItemTouchEvent(FCEventID.MENUITEMCLICK, item, touchInfo);
         bool close = closeMenus(m_items);
         if (m_popup)
         {
             hide();
         }
         else
         {
             Native.invalidate();
         }
     }
     else
     {
         onMenuItemTouchMove(item, touchInfo);
     }
 }
示例#11
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);
        }
示例#12
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);
        }
示例#13
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);
        }
示例#14
0
 /// <summary>
 /// 移除菜单项
 /// </summary>
 /// <param name="item">菜单项</param>
 public void removeItem(FCMenuItem item)
 {
     item.onRemovingItem();
     m_items.remove(item);
 }
示例#15
0
 /// <summary>
 /// 菜单项点击事件
 /// </summary>
 /// <param name="sender">调用者</param>
 /// <param name="item">菜单项</param>
 /// <param name="touchInfo">触摸信息</param>
 public void callMenuItemClick(object sender, FCMenuItem item, FCTouchInfo touchInfo)
 {
     m_touchInfo = touchInfo;
     callFunction(sender, FCEventID.MENUITEMCLICK);
 }