示例#1
0
        //TODO Little guide for Micah
        /// <summary>
        /// You can pass any IItem here.
        /// SelectionMenuItem will invoke it's action when clicked
        /// Anything else will do no action when clicked
        /// </summary>
        /// <param name="item"></param>
        /// <param name="category"></param>
        public void AddItem(IItem item, SelectionMenuCategory category = null)
        {
            var foundCategory = category == null ? null : Items.FirstOrDefault(s => s == category) as SelectionMenuCategory;

            if (foundCategory != null)
            {
                foundCategory.Add(item);
            }
            else
            {
                Items.Add(item);
            }
        }
示例#2
0
        public SelectionMenuCategory CreateCategoryIfNotExist(params string[] path)
        {
            if (path.Length < 1)
            {
                throw new Exception("Path must have at least one value");
            }
            List <IItem>          items        = Items;
            SelectionMenuCategory pathMenuItem = null;

            foreach (var pathItem in path)
            {
                pathMenuItem = items.OfType <SelectionMenuCategory>().FirstOrDefault(p => p.Title == pathItem);
                if (pathMenuItem == null)
                {
                    pathMenuItem = new SelectionMenuCategory()
                    {
                        Title = pathItem,
                    };
                    items.Add(pathMenuItem);
                }
                items = pathMenuItem.ChildItems;
            }
            return(pathMenuItem);
        }