Exemplo n.º 1
0
        private void FillMenuContents(MenuItemCollection holderMenuItems, ChoiceActionItemCollection actionItems){
            foreach (ChoiceActionItem groupValue in actionItems){
                if (!groupValue.Active){
                    continue;
                }

                if (groupValue.Items.Count == 0){
                    var itemWrapper = new ASPxMenuItemChoiceActionItem(SingleChoiceAction,
                        groupValue);
                    MenuItemToWrapperMap.Add(itemWrapper.CurrentMenuItem, itemWrapper);
                    holderMenuItems.Add(itemWrapper.CurrentMenuItem);
                    ActionItemToMenuItemMap.Add(groupValue, itemWrapper.CurrentMenuItem);
                }
                else{
                    var groupItem = new ASPxMenuGroupChoiceActionItem(SingleChoiceAction,
                        groupValue);
                    GroupWrappers.Add(groupItem);
                    MenuItem group = groupItem.MenuGroup;
                    ActionItemToMenuGroupMap.Add(groupValue, group);
                    holderMenuItems.Add(group);
                    var itemsDisplayStyle = ItemsDisplayStyle.LargeIcons;
                    if (groupValue.Model != null){
                        itemsDisplayStyle = ItemsDisplayStyle.List;
                        if (groupValue.Model is IModelChoiceActionItemChildItemsDisplayStyle){
                            itemsDisplayStyle =
                                ((IModelChoiceActionItemChildItemsDisplayStyle) groupValue.Model).ChildItemsDisplayStyle;
                        }
                    }
                    var args = new CreateCustomGroupControlEventArgs(groupValue);
                    OnCreateCustomGroupControl(args);
                    if (args.Control != null){
                        var customControlItem = new ASPxMenuCustomControlItem(args.Control);
                        customControlItem.InitTemplate();
                        group.Items.Add(customControlItem);
                    }
                    else{
                        switch (itemsDisplayStyle){
                            case ItemsDisplayStyle.LargeIcons:
                            case ItemsDisplayStyle.List:
                                if (groupValue.IsHierarchical()){
                                    FillMenuContents(group.Items, groupValue.Items);
                                }
                                else{
                                    FillMenuGroup(group, groupValue);
                                }
                                break;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void FillMenuContents(MenuItemCollection holderMenuItems, ChoiceActionItemCollection actionItems)
        {
            foreach (ChoiceActionItem groupValue in actionItems)
            {
                if (!groupValue.Active)
                {
                    continue;
                }

                if (groupValue.Items.Count == 0)
                {
                    var itemWrapper = new ASPxMenuItemChoiceActionItem(SingleChoiceAction,
                                                                       groupValue);
                    MenuItemToWrapperMap.Add(itemWrapper.CurrentMenuItem, itemWrapper);
                    holderMenuItems.Add(itemWrapper.CurrentMenuItem);
                    ActionItemToMenuItemMap.Add(groupValue, itemWrapper.CurrentMenuItem);
                }
                else
                {
                    var groupItem = new ASPxMenuGroupChoiceActionItem(SingleChoiceAction,
                                                                      groupValue);
                    GroupWrappers.Add(groupItem);
                    MenuItem group = groupItem.MenuGroup;
                    ActionItemToMenuGroupMap.Add(groupValue, group);
                    holderMenuItems.Add(group);
                    var itemsDisplayStyle = ItemsDisplayStyle.LargeIcons;
                    if (groupValue.Model != null)
                    {
                        itemsDisplayStyle = ItemsDisplayStyle.List;
                        if (groupValue.Model is IModelChoiceActionItemChildItemsDisplayStyle)
                        {
                            itemsDisplayStyle =
                                ((IModelChoiceActionItemChildItemsDisplayStyle)groupValue.Model).ChildItemsDisplayStyle;
                        }
                    }
                    var args = new CreateCustomGroupControlEventArgs(groupValue);
                    OnCreateCustomGroupControl(args);
                    if (args.Control != null)
                    {
                        var customControlItem = new ASPxMenuCustomControlItem(args.Control);
                        customControlItem.InitTemplate();
                        group.Items.Add(customControlItem);
                    }
                    else
                    {
                        switch (itemsDisplayStyle)
                        {
                        case ItemsDisplayStyle.LargeIcons:
                        case ItemsDisplayStyle.List:
                            if (groupValue.IsHierarchical())
                            {
                                FillMenuContents(group.Items, groupValue.Items);
                            }
                            else
                            {
                                FillMenuGroup(group, groupValue);
                            }
                            break;
                        }
                    }
                }
            }
        }