public override void Add(SimpleActionItem item)
        {
            var menu = new IconMenuItem(item.Caption, item.SmallImage, (sender, e) => item.OnClick(e))
            {Name = item.Key, Enabled = item.Enabled, Visible = item.Visible,};
            item.PropertyChanged += SimpleActionItem_PropertyChanged;

            EnsureNonNullRoot(item);

            MenuItem root;
            if (item.MenuContainerKey == null)
            {
                root = !mainmenu.MenuItems.ContainsKey(item.RootKey)
                    ? mainmenu.MenuItems[mainmenu.MenuItems.Add(new MenuItem(item.RootKey) {Name = item.RootKey})]
                    : mainmenu.MenuItems.Find(item.RootKey, true)[0];
            }
            else
            {
                root = mainmenu.MenuItems.Find(item.MenuContainerKey, true)[0];
            }

            root.MenuItems.Add(menu);
        }
Example #2
0
        /// <summary>
        /// Recursive add method to handle nesting of menu items.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="mi"></param>
        private static void AddMenuItem(Menu.MenuItemCollection parent, SymbologyMenuItem mi)
        {
            MenuItem m;

            if (mi.Icon != null)
            {
                m = new IconMenuItem(mi.Name, mi.Icon, mi.ClickHandler);
            }
            else if (mi.Image != null)
            {
                m = new IconMenuItem(mi.Name, mi.Image, mi.ClickHandler);
            }
            else
            {
                m = new IconMenuItem(mi.Name, mi.ClickHandler);
            }

            parent.Add(m);
            foreach (SymbologyMenuItem child in mi.MenuItems)
            {
                AddMenuItem(m.MenuItems, child);
            }
        }
Example #3
0
        /// <summary>
        /// Recursive add method to handle nesting of menu items.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="mi"></param>
        private static void AddMenuItem(Menu.MenuItemCollection parent, SymbologyMenuItem mi)
        {
            MenuItem m;
            if (mi.Icon != null)
            {
                m = new IconMenuItem(mi.Name, mi.Icon, mi.ClickHandler);
            }
            else if (mi.Image != null)
            {
                m = new IconMenuItem(mi.Name, mi.Image, mi.ClickHandler);
            }
            else
            {
                m = new IconMenuItem(mi.Name, mi.ClickHandler);
            }

            parent.Add(m);
            foreach (SymbologyMenuItem child in mi.MenuItems)
            {
                AddMenuItem(m.MenuItems, child);
            }
        }