コード例 #1
0
ファイル: Root.master.cs プロジェクト: hassyfit/ApexRepo
        protected void LoadMenu(XmlElement PpItemNode, DevExpress.Web.MenuItemCollection MpTarget)
        {
            // In case of error - enable everything
            bool   bPermitted = true;
            string sItemFlags = PpItemNode.GetAttribute("Roles");

            if (User != null && sItemFlags.Length > 0)
            {
                int nItemFlags = Convert.ToInt32(sItemFlags, 16);
                if ((nItemFlags & MpUser.RoleBits) == 0)
                {
                    bPermitted = false;
                }
            }

            if (bPermitted)
            {
                DevExpress.Web.MenuItem pItem = new DevExpress.Web.MenuItem();

                String sName = PpItemNode.GetAttribute("Name");
                if (sName.Length > 0)
                {
                    pItem.Name = sName;
                }

                if (PpItemNode.GetAttribute("ClientEnabled") == "true")
                {
                    pItem.ClientEnabled = true;
                }

                pItem.Text        = PpItemNode.GetAttribute("Text");
                pItem.NavigateUrl = PpItemNode.GetAttribute("NavigateUrl");

                MpTarget.Add(pItem);

                // Recurse to load child nodes
                foreach (XmlElement pChild in PpItemNode.SelectNodes("Items/MenuItem"))
                {
                    LoadMenu(pChild, pItem.Items);
                }
            }
            else
            {
                CheckPageSpoof(PpItemNode);
            }
        }
コード例 #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;
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void FillMenuContents(DevExpress.Web.MenuItemCollection holderMenuItems, ChoiceActionItemCollection actionItems)
        {
            foreach (ChoiceActionItem groupValue in actionItems)
            {
                if (!groupValue.Active)
                {
                    continue;
                }

                if (groupValue.Items.Count == 0)
                {
                    ASPxMenuItemChoiceActionItem itemWrapper = new ASPxMenuItemChoiceActionItem(SingleChoiceAction,
                                                                                                groupValue);
                    MenuItemToWrapperMap.Add(itemWrapper.CurrentMenuItem, itemWrapper);
                    holderMenuItems.Add(itemWrapper.CurrentMenuItem);
                    ActionItemToMenuItemMap.Add(groupValue, itemWrapper.CurrentMenuItem);
                }
                else
                {
                    ASPxMenuGroupChoiceActionItem groupItem = new ASPxMenuGroupChoiceActionItem(SingleChoiceAction,
                                                                                                groupValue);
                    GroupWrappers.Add(groupItem);
                    DevExpress.Web.MenuItem group = groupItem.MenuGroup;
                    ActionItemToMenuGroupMap.Add(groupValue, group);
                    holderMenuItems.Add(group);
                    ItemsDisplayStyle itemsDisplayStyle = ItemsDisplayStyle.LargeIcons;
                    if (groupValue.Model != null)
                    {
                        itemsDisplayStyle = ItemsDisplayStyle.List;
                        if (groupValue.Model is IModelChoiceActionItemChildItemsDisplayStyle)
                        {
                            itemsDisplayStyle =
                                ((IModelChoiceActionItemChildItemsDisplayStyle)groupValue.Model).ChildItemsDisplayStyle;
                        }
                    }
                    CreateCustomGroupControlEventArgs 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;
                        }
                    }
                }
            }
        }