示例#1
0
 public virtual void OnMenuItemEventCommandClick(WebMenuItem menuItem, WebTreeNode node)
 {
     if (menuItem != null && menuItem.Command != null)
     {
         menuItem.Command.OnClick();
     }
 }
示例#2
0
 /// <summary> Fires the <see cref="MenuBase.WxeFunctionCommandClick"/> event. </summary>
 protected virtual void OnWxeFunctionCommandClick(WebMenuItem item)
 {
     if (WxeFunctionCommandClick != null)
     {
         WebMenuItemClickEventArgs e = new WebMenuItemClickEventArgs(item);
         WxeFunctionCommandClick(this, e);
     }
 }
示例#3
0
        /// <summary> Implements interface <see cref="IPostBackEventHandler"/>. </summary>
        /// <param name="eventArgument"> &lt;index&gt; </param>
        void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
        {
            ArgumentUtility.CheckNotNullOrEmpty("eventArgument", eventArgument);

            //  First part: index
            int index;

            try
            {
                if (eventArgument.Length == 0)
                {
                    throw new FormatException();
                }
                index = int.Parse(eventArgument);
            }
            catch (FormatException)
            {
                throw new ArgumentException("First part of argument 'eventArgument' must be an integer. Expected format: '<index>'.");
            }

            if (index >= _menuItems.Count)
            {
                throw new ArgumentOutOfRangeException(
                          eventArgument,
                          "Index of argument 'eventargument' was out of the range of valid values. Index must be less than the number of displayed menu items.'");
            }

            WebMenuItem item = _menuItems[index];

            if (item.Command == null)
            {
                throw new ArgumentOutOfRangeException(
                          eventArgument, "The DropDownMenu '" + ID + "' does not have a command associated with menu item " + index + ".");
            }

            switch (item.Command.Type)
            {
            case CommandType.Event:
            {
                OnEventCommandClick(item);
                break;
            }

            case CommandType.WxeFunction:
            {
                OnWxeFunctionCommandClick(item);
                break;
            }

            default:
            {
                break;
            }
            }
        }
示例#4
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            for (int i = 0; i < MenuItems.Count; i++)
            {
                WebMenuItem menuItem = MenuItems[i];
                if (menuItem.Command != null)
                {
                    menuItem.Command.RegisterForSynchronousPostBackOnDemand(
                        this, i.ToString(), string.Format("ListMenu '{0}', MenuItem '{1}'", ID, menuItem.ItemID));
                }
            }
        }
示例#5
0
 public virtual void OnMenuItemWxeFunctionCommandClick(WebMenuItem menuItem, WebTreeNode node)
 {
     if (menuItem != null && menuItem.Command != null)
     {
         Command command = menuItem.Command;
         Page    page    = node.TreeView.Page;
         if (page is IWxePage)
         {
             command.ExecuteWxeFunction((IWxePage)page, null);
         }
         //else
         //  command.ExecuteWxeFunction (Page, null, new NameValueCollection (0));
     }
 }
示例#6
0
        /// <summary> Fires the <see cref="MenuBase.EventCommandClick"/> event. </summary>
        protected virtual void OnEventCommandClick(WebMenuItem item)
        {
            ArgumentUtility.CheckNotNull("item", item);

            if (item.Command != null)
            {
                item.Command.OnClick();
            }

            if (EventCommandClick != null)
            {
                WebMenuItemClickEventArgs e = new WebMenuItemClickEventArgs(item);
                EventCommandClick(this, e);
            }
        }
        /// <summary> Sorts the <paramref name="menuItems"/> by their categories." </summary>
        /// <param name="menuItems"> Must not be <see langword="null"/> or contain items that are <see langword="null"/>. </param>
        /// <param name="generateSeparators"> <see langword="true"/> to generate a separator before starting a new category. </param>
        /// <returns> The <paramref name="menuItems"/>, sorted by their categories. </returns>
        public static WebMenuItem[] GroupMenuItems(WebMenuItem[] menuItems, bool generateSeparators)
        {
            ArgumentUtility.CheckNotNullOrItemsNull("menuItems", menuItems);

            //  <string category, ArrayList menuItems>
            NameObjectCollection groupedMenuItems = new NameObjectCollection();
            ArrayList            categories       = new ArrayList();

            for (int i = 0; i < menuItems.Length; i++)
            {
                WebMenuItem menuItem = menuItems[i];

                string    category = menuItem.Category ?? string.Empty;
                ArrayList menuItemsForCategory;
                if (groupedMenuItems.Contains(category))
                {
                    menuItemsForCategory = (ArrayList)groupedMenuItems[category];
                }
                else
                {
                    menuItemsForCategory = new ArrayList();
                    groupedMenuItems.Add(category, menuItemsForCategory);
                    categories.Add(category);
                }
                menuItemsForCategory.Add(menuItem);
            }

            ArrayList arrayList = new ArrayList();
            bool      isFirst   = true;

            for (int i = 0; i < categories.Count; i++)
            {
                string category = (string)categories[i];
                if (generateSeparators)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        arrayList.Add(WebMenuItem.GetSeparator());
                    }
                }
                arrayList.AddRange((ArrayList)groupedMenuItems[category]);
            }
            return((WebMenuItem[])arrayList.ToArray(typeof(WebMenuItem)));
        }
 /// <summary> Initializes an instance. </summary>
 public WebMenuItemClickEventArgs(WebMenuItem item)
 {
     ArgumentUtility.CheckNotNull("item", item);
     _item = item;
 }