private void EnableBeginGroup(ChoiceActionItemCollection items, IModelNavigationItems itemsModel)
 {
     foreach (ChoiceActionItem item in items)
     {
         IModelNavigationItem itemModel = itemsModel != null ? itemsModel.GetNode(item.Id) as IModelNavigationItem : null;
         item.BeginGroup = itemModel != null ? ((IModelNavigationItemSeparator)itemModel).BeginGroup : false;
         EnableBeginGroup(item.Items, itemModel != null ? itemModel.GetNode("Items") as IModelNavigationItems : null);
     }
 }
Esempio n. 2
0
 public void fillLanguageList(ChoiceActionItemCollection items, string current)
 {
     foreach (ChoiceActionItem item in items)
     {
         this.chooseLanguageBox.Properties.Items.Add(item.Id);
     }
     foreach (string item in this.chooseLanguageBox.Properties.Items)
     {
         if (item == current)
             this.chooseLanguageBox.SelectedItem = item;
     }
     // this.chooseLanguageBox.SelectedItem = from string curItem in (from ComboBoxItemCollection coll in this.chooseLanguageBox.Properties.Items select coll) where curItem == current select curItem;
 }
Esempio n. 3
0
        ChoiceActionItem FindChoiceActionItemByModelPath(ChoiceActionItemCollection items, string path)
        {
            foreach (var ni in items)
            {
                if ((ni.Model as ModelNode).Path == path)
                {
                    return(ni);
                }

                if (ni.Items.Count > 0)
                {
                    var rst = FindChoiceActionItemByModelPath(ni.Items, path);
                    if (rst != null)
                    {
                        return(rst);
                    }
                }
            }
            return(null);
        }
 private void CreateItemsSingleChoiceAction(ChoiceActionItemCollection items, ChoiceActionItemCollection menuItems, string nodeId)
 {
     foreach (ChoiceActionItem current in
         from a in items
         where a.Active && a.Enabled
         select a)
     {
         string text = nodeId + "/" + current.Id;
         ChoiceActionItemMenuItem choiceActionItemMenuItem = new ChoiceActionItemMenuItem(current, base.MenuItemsAction, text);
         menuItems.Add(choiceActionItemMenuItem);
         SingleChoiceAction singleChoiceAction = this.Action as SingleChoiceAction;
         if (singleChoiceAction != null && singleChoiceAction.IsHierarchical())
         {
             this.CreateItemsSingleChoiceAction(current.Items, choiceActionItemMenuItem.Items, text);
         }
     }
 }
Esempio n. 5
0
 Action <IModelCreatableItem> AddItems(ChoiceActionItemCollection choiceActionItemCollection)
 {
     return(creatableItem => choiceActionItemCollection.Add(CreateItem(creatableItem.ModelClass.TypeInfo.Type, creatableItem)));
 }
 public void SetNavigationActionItems(ChoiceActionItemCollection actionItems, SingleChoiceAction action){
     Guard.ArgumentNotNull(action, "action");
     UnsubscribeFromAction();
     ActionItems = actionItems;
     SingleChoiceAction = action;
     BuildControl();
     SubscribeToAction();
 }
        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;
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        ChoiceActionItem FindChoiceActionItemByModelPath(ChoiceActionItemCollection items, string path)
        {
            foreach (var ni in items)
            {
                if ((ni.Model as ModelNode).Path == path)
                {
                    return ni;
                }

                if (ni.Items.Count > 0)
                {
                    var rst = FindChoiceActionItemByModelPath(ni.Items, path);
                    if (rst != null)
                        return rst;
                }
            }
            return null;
        }
        public void GenerateMenuItems(ChoiceActionItemCollection collection)
        {
            Helpers.ContentHelper.ClearMenu();
            var ULText = "";
            var style = @"style=""" + (String.Concat(XAFBootstrapConfiguration.Instance.GetMenuTextColor()) != "" ? "font-size: 11px; color: " + XAFBootstrapConfiguration.Instance.GetMenuTextColor() + "; " : "font-size: 11px; color: #666;") + @"""";

            XafApplication App = (WebApplication.Instance as XafApplication);
            IModelNode NavigationItems = App.Model.GetNode("NavigationItems").GetNode("Items");

            IList<ChoiceActionItem> LeftItems = new List<ChoiceActionItem>();
            IList<ChoiceActionItem> RightItems = new List<ChoiceActionItem>();

            for (int i = 0; i < collection.Count; i++)
            {
                var RootItem = collection[i];
                if (!RootItem.Active || !RootItem.Enabled)
                    continue;

                if (RootItem.Model.GetValue<XAFBootstrapMenuAlign>("MenuAlign") == XAFBootstrapMenuAlign.Right)
                    RightItems.Add(RootItem);
                else
                    LeftItems.Add(RootItem);
            }

            if (XAFBootstrapConfiguration.Instance.Menu == MenuType.Default || XAFBootstrapConfiguration.Instance.Menu == MenuType.xbMegaMenu)
            {
                #region xb menu

                if (LeftItems.Count > 0)
                {
                    var xbMenu = "";
                    foreach (var RootItem in LeftItems)
                        xbMenu += GeneratexbSubMenu(RootItem, true, false, style);
                    foreach (var RootItem in RightItems)
                        xbMenu += GeneratexbSubMenu(RootItem, true, true, style);

                    var Settings = "";
                    var SettingsLi = "";
                    Settings += String.Format(@"
                        <li aria-haspopup=""true"" class=""right"">
                            <a {0} href=""javascript:;"">&nbsp;<span class=""glyphicon glyphicon-cog""></span>&nbsp;</a>
                            <div class=""grid-container4"">
                                <ul>", style);

                    StringBuilder tempRes = new StringBuilder();
                    foreach (XafMenuItem menuItem in Helpers.GetMenuActions(SAC))
                    {
                        String glyphiconString = "glyphicon-star";
                        if (menuItem.ActionProcessor != null && menuItem.ActionProcessor.Action != null && menuItem.ActionProcessor.Action.Model != null && !String.IsNullOrEmpty(menuItem.ActionProcessor.Action.Model.GetValue<String>("Glyphicon")))
                            glyphiconString = menuItem.ActionProcessor.Action.Model.GetValue<String>("Glyphicon");
                        if (!(Helpers.GenerateSingleChoiceAction(ref tempRes, menuItem, true, "", SAC.UniqueID + "_Callback")))
                            SettingsLi += String.Format("<li><a islink=\"true\" class=\"xb-mega-menu-li-a\" href='javascript:;' onclick='$(\".xb-mega-menu.mobile li\").removeClass(\"hover\"); if ($(\"#settingsCollapseButton\").is(\":visible\")) $(\"#settingsCollapseButton\").click();{2}'><span class='glyphicon {4}'></span> {0}</a></li>"
                                , menuItem.Text
                                , menuItem.Name
                                , Helpers.ContentHelper.GetScript(SAC.UniqueID + "_Callback", String.Format("\"Action={0}\"", menuItem.Name)).Replace("'", "\"")
                                , ""
                                , glyphiconString
                                , style);
                        else
                        {
                            var choiceAction = (menuItem.ActionProcessor as MenuActionItemBase).Action as SingleChoiceAction;
                            SettingsLi += String.Format(@"<li class=""dropdown-header"">{0}</li>", choiceAction.Caption);
                            SettingsLi += String.Join("", choiceAction.Items.Select(f =>
                                String.Format("<li><a islink=\"true\" class=\"xb-mega-menu-li-a\" href=\"javascript:;\" onclick='$(\".xb-mega-menu.mobile li\").removeClass(\"hover\"); if ($(\"#settingsCollapseButton\").is(\":visible\")) $(\"#settingsCollapseButton\").click();{2}'><span class=\"glyphicon {1}\"></span> {0}</a></li>"
                                    , f.Caption
                                    , glyphiconString
                                    , Helpers.ContentHelper.GetScript(SAC.UniqueID + "_Callback", String.Format("\"Action={0},{1}\"", menuItem.Name, f.Id)).Replace("'", "\"")
                                    , style
                                )
                            ));
                        }
                    }
                    Settings += SettingsLi;
                    Settings += @"</ul>
                            <div>
                        </li>";

                    xbMenu += Settings;

                    ULText = String.Format(
                    @"<div style='position: relative'>
                        <div class=""hidden-xs hidden-sm"">
                            <ul class=""xb-mega-menu desktop xb-mega-menu-anim-scale xb-mega-menu-response-to-icons"" style=""{2}"">
                            {0}
                            </ul>
                        </div>
                        <div class=""hidden-md hidden-lg"">
                            <ul class=""xb-mega-menu mobile xb-mega-menu-anim-scale xb-mega-menu-response-to-icons"" style=""{2}"">
                                <li aria-haspopup=""true"" class=""right"">
                                    <a href=""javascript:;"">
                                        &nbsp;<span class=""glyphicon glyphicon-th-list"" style=""font-size: 13pt; margin-top: 10px; {3}""></span>&nbsp;
                                    </a>
                                    <div class=""grid-container4"">
                                        <ul style=""{2}"">{1}</ul>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        <div class=""progress loading-progress"" style=""display: none; position: absolute; bottom: 0px; z-index: 1000; width: 100%;"" id=""loadingProgress"">
                            <div class=""progress-bar progress-bar-info progress-bar-striped active"" role=""progressbar"" aria-valuenow=""100"" aria-valuemin=""0"" aria-valuemax=""100"" style=""width: 100%""></div>
                        </div>
                    </div>"
                        , xbMenu
                        , xbMenu
                        , String.Concat(XAFBootstrapConfiguration.Instance.GetMenuBackgroundColor()) != "" ? "background: " + XAFBootstrapConfiguration.Instance.GetMenuBackgroundColor() + ";" : ""
                        , String.Concat(XAFBootstrapConfiguration.Instance.GetMenuTextColor()) != "" ? "color: " + XAFBootstrapConfiguration.Instance.GetMenuTextColor() + ";" : ""
                    );

                }

                xbMegaMenu.EncodeHtml = false;
                xbMegaMenu.Text = ULText;
                #endregion
            }
            else
            {
                #region Bootstrap menu
                if (LeftItems.Count > 0)
                {
                    ULText += "<ul class='nav navbar-nav'>";
                    foreach (var RootItem in LeftItems)
                    {
                        if (RootItem.Items.Count > 0)
                            ULText += String.Format(
                              @"<li class='dropdown'>
                                <a href='javascript:;' class='dropdown-toggle' data-toggle='dropdown'>{2} <span>{0}</span> <span class='caret'></span>
                                </a>
                                <ul class='dropdown-menu' role='menu'>{1}</ul></li>
                               "
                                , RootItem.Caption
                                , GenerateSubMenu(RootItem, true)
                                , String.Concat(RootItem.Model.GetValue<String>("Glyphicon")) != ""
                                     ? FormatGlyphicon(String.Concat(RootItem.Model.GetValue<String>("Glyphicon"))) : ""
                            );
                        else
                            ULText += GetMenuItem(RootItem);
                    }
                    ULText += "</ul>";
                }

                var Settings = "";
                var SettingsLi = "";
                Settings += @"
                        <li class='dropdown hidden-xs' style='position: absolute; right: 10px;'>
                          <a href='#' class='dropdown-toggle' data-toggle='dropdown'><span class='glyphicon glyphicon-cog settings-button'></span></a>
                          <ul class='dropdown-menu' role='menu'>";

                StringBuilder tempRes = new StringBuilder();
                foreach (XafMenuItem menuItem in Helpers.GetMenuActions(SAC))
                {
                    String glyphiconString = "glyphicon-star";
                    if (menuItem.ActionProcessor != null && menuItem.ActionProcessor.Action != null && menuItem.ActionProcessor.Action.Model != null && !String.IsNullOrEmpty(menuItem.ActionProcessor.Action.Model.GetValue<String>("Glyphicon")))
                        glyphiconString = menuItem.ActionProcessor.Action.Model.GetValue<String>("Glyphicon");
                    if (!(Helpers.GenerateSingleChoiceAction(ref tempRes, menuItem, true, "", SAC.UniqueID + "_Callback")))
                        SettingsLi += String.Format("<li><a href='javascript:;' onclick='if ($(\"#settingsCollapseButton\").is(\":visible\")) $(\"#settingsCollapseButton\").click();{2}'><span class='glyphicon {4}'></span> {0}</a></li>"
                            , menuItem.Text
                            , menuItem.Name
                            , Helpers.ContentHelper.GetScript(SAC.UniqueID + "_Callback", String.Format("\"Action={0}\"", menuItem.Name)).Replace("'", "\"")
                            , ""
                            , glyphiconString);
                    else
                    {
                        var choiceAction = (menuItem.ActionProcessor as MenuActionItemBase).Action as SingleChoiceAction;
                        SettingsLi += String.Format(@"<li class=""dropdown-header"">{0}</li>", choiceAction.Caption);
                        SettingsLi += String.Join("", choiceAction.Items.Select(f =>
                            String.Format("<li><a href=\"javascript:;\" onclick='if ($(\"#settingsCollapseButton\").is(\":visible\")) $(\"#settingsCollapseButton\").click();{2}'><span class=\"glyphicon {1}\"></span> {0}</a></li>"
                                , f.Caption
                                , glyphiconString
                                , Helpers.ContentHelper.GetScript(SAC.UniqueID + "_Callback", String.Format("\"Action={0},{1}\"", menuItem.Name, f.Id)).Replace("'", "\""))
                        ));
                    }
                }
                Settings += SettingsLi;
                Settings +=
                      @"</ul>
                      </li>";

                //if (RightItems.Count > 0)
                {
                    ULText += "<ul class='nav navbar-nav navbar-right'>";

                    ULText += Settings;

                    foreach (var RootItem in RightItems)
                    {
                        if (RootItem.Items.Count > 0)
                            ULText += String.Format(
                                @"<li class='dropdown'>
                                <a href='#' class='dropdown-toggle' data-toggle='dropdown'>{0} <span class='caret'></span></a>
                                <ul class='dropdown-menu' role='menu'>{1}</ul></li>"
                                , RootItem.Caption
                                , GenerateSubMenu(RootItem, true)
                                , String.Concat(RootItem.Model.GetValue<String>("Glyphicon")) != ""
                                     ? FormatGlyphicon(String.Concat(RootItem.Model.GetValue<String>("Glyphicon"))) : ""
                            );
                        else
                            ULText += String.Format("<li><a href='#about'>{0}</a></li>", GetMenuItem(RootItem));
                    }
                    ULText += "</ul>";
                }

                TopMenu.EncodeHtml = false;
                TopMenu.Text = String.Format(@"
                    <div class='navbar navbar-default navbar-fixed-top {3}' role='navigation' id='navbar'>
                      <div>
                        <div class='navbar-header'>
                          <button type='button' id='menuCollapseButton' class='navbar-toggle collapsed' data-toggle='collapse' data-target='#mainMenu'>
                            <span class='sr-only'>Toggle navigation</span>
                            <span class='icon-bar'></span>
                            <span class='icon-bar'></span>
                            <span class='icon-bar'></span>
                          </button>
                          <button type='button' id='settingsCollapseButton' class='navbar-toggle collapsed' data-toggle='collapse' data-target='#settingsMenu'>
                            <span class='sr-only'>Toggle navigation</span>
                            <span class='glyphicon glyphicon-cog text-info settings-button'></span>
                          </button>
                          <a class='navbar-brand' href='#'>{1}</a>
                        </div>
                        <div class='navbar-collapse collapse' id='mainMenu'>
                            <div class='container'>
                                {0}
                            </div>
                        </div>
                        <div class='navbar-collapse collapse' id='settingsMenu'>
                            <ul class='nav hidden-sm hidden-md hidden-lg navbar-nav'>
                                {2}
                            </ul>
                        </div>
                      </div>

                      <div class=""progress loading-progress"" style=""display: none"" id=""loadingProgress"">
                        <div class=""progress-bar progress-bar-info progress-bar-striped active"" role=""progressbar"" aria-valuenow=""100"" aria-valuemin=""0"" aria-valuemax=""100"" style=""width: 100%""></div>
                      </div>

                    </div>"
                        , ULText
                        , (File.Exists(MapPath("~/images/logo.png")) ? "<img style='max-height: 30px; max-width: 160px; margin-top: -5px;' src='images/logo.png'>" : App.Model.Title)
                        , SettingsLi
                        , XAFBootstrapConfiguration.Instance != null && XAFBootstrapConfiguration.Instance.InverseNavBar ? "navbar-inverse" : "");
                #endregion
            }
        }
 public ChoiceActionItem FindNode(ChoiceActionItemCollection items, String param)
 {
     var paramValues = param.Split(new String[] { "->" }, StringSplitOptions.RemoveEmptyEntries);
     var item = items.Find(paramValues[0], ChoiceActionItemFindType.NonRecursive, ChoiceActionItemFindTarget.Any);
     if (paramValues.Length > 1)
         return FindNode(item.Items, String.Join("->", paramValues.Skip(1).Take(paramValues.Length - 1)));
     return item;
 }
Esempio n. 11
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;
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        public void GenerateMenuItems(ChoiceActionItemCollection collection)
        {
            Helpers.ContentHelper.ClearMenu();
            var ULText = "";
            var style  = @"style=""" + (String.Concat(XAFBootstrapConfiguration.Instance.GetMenuTextColor()) != "" ? "font-size: 11px; color: " + XAFBootstrapConfiguration.Instance.GetMenuTextColor() + "; " : "font-size: 11px; color: #666;") + @"""";

            XafApplication App             = (WebApplication.Instance as XafApplication);
            IModelNode     NavigationItems = App.Model.GetNode("NavigationItems").GetNode("Items");

            IList <ChoiceActionItem> LeftItems  = new List <ChoiceActionItem>();
            IList <ChoiceActionItem> RightItems = new List <ChoiceActionItem>();

            for (int i = 0; i < collection.Count; i++)
            {
                var RootItem = collection[i];
                if (!RootItem.Active || !RootItem.Enabled)
                {
                    continue;
                }

                if (RootItem.Model.GetValue <XAFBootstrapMenuAlign>("MenuAlign") == XAFBootstrapMenuAlign.Right)
                {
                    RightItems.Add(RootItem);
                }
                else
                {
                    LeftItems.Add(RootItem);
                }
            }

            if (XAFBootstrapConfiguration.Instance.Menu == MenuType.Default || XAFBootstrapConfiguration.Instance.Menu == MenuType.xbMegaMenu)
            {
                #region xb menu

                if (LeftItems.Count > 0)
                {
                    var xbMenu = "";
                    foreach (var RootItem in LeftItems)
                    {
                        xbMenu += GeneratexbSubMenu(RootItem, true, false, style);
                    }
                    foreach (var RootItem in RightItems)
                    {
                        xbMenu += GeneratexbSubMenu(RootItem, true, true, style);
                    }

                    var Settings   = "";
                    var SettingsLi = "";
                    Settings += String.Format(@"
                        <li aria-haspopup=""true"" class=""right"">
					        <a {0} href=""javascript:;"">&nbsp;<span class=""glyphicon glyphicon-cog""></span>&nbsp;</a>
                            <div class=""grid-container4"">                                        
                                <ul>", style);

                    StringBuilder tempRes = new StringBuilder();
                    foreach (XafMenuItem menuItem in Helpers.GetMenuActions(SAC))
                    {
                        String glyphiconString = "glyphicon-star";
                        if (menuItem.ActionProcessor != null && menuItem.ActionProcessor.Action != null && menuItem.ActionProcessor.Action.Model != null && !String.IsNullOrEmpty(menuItem.ActionProcessor.Action.Model.GetValue <String>("Glyphicon")))
                        {
                            glyphiconString = menuItem.ActionProcessor.Action.Model.GetValue <String>("Glyphicon");
                        }
                        if (!(Helpers.GenerateSingleChoiceAction(ref tempRes, menuItem, true, "", SAC.UniqueID + "_Callback")))
                        {
                            SettingsLi += String.Format("<li><a islink=\"true\" class=\"xb-mega-menu-li-a\" href='javascript:;' onclick='$(\".xb-mega-menu.mobile li\").removeClass(\"hover\"); if ($(\"#settingsCollapseButton\").is(\":visible\")) $(\"#settingsCollapseButton\").click();{2}'><span class='glyphicon {4}'></span> {0}</a></li>"
                                                        , menuItem.Text
                                                        , menuItem.Name
                                                        , Helpers.ContentHelper.GetScript(SAC.UniqueID + "_Callback", String.Format("\"Action={0}\"", menuItem.Name)).Replace("'", "\"")
                                                        , ""
                                                        , glyphiconString
                                                        , style);
                        }
                        else
                        {
                            var choiceAction = (menuItem.ActionProcessor as MenuActionItemBase).Action as SingleChoiceAction;
                            SettingsLi += String.Format(@"<li class=""dropdown-header"">{0}</li>", choiceAction.Caption);
                            SettingsLi += String.Join("", choiceAction.Items.Select(f =>
                                                                                    String.Format("<li><a islink=\"true\" class=\"xb-mega-menu-li-a\" href=\"javascript:;\" onclick='$(\".xb-mega-menu.mobile li\").removeClass(\"hover\"); if ($(\"#settingsCollapseButton\").is(\":visible\")) $(\"#settingsCollapseButton\").click();{2}'><span class=\"glyphicon {1}\"></span> {0}</a></li>"
                                                                                                  , f.Caption
                                                                                                  , glyphiconString
                                                                                                  , Helpers.ContentHelper.GetScript(SAC.UniqueID + "_Callback", String.Format("\"Action={0},{1}\"", menuItem.Name, f.Id)).Replace("'", "\"")
                                                                                                  , style
                                                                                                  )
                                                                                    ));
                        }
                    }
                    Settings += SettingsLi;
                    Settings += @"</ul>
                            <div>
                        </li>";

                    xbMenu += Settings;

                    ULText = String.Format(
                        @"<div style='position: relative'>
                        <div class=""hidden-xs hidden-sm"">
                            <ul class=""xb-mega-menu desktop xb-mega-menu-anim-scale xb-mega-menu-response-to-icons"" style=""{2}"">
                            {0}
                            </ul>
                        </div>
                        <div class=""hidden-md hidden-lg"">
                            <ul class=""xb-mega-menu mobile xb-mega-menu-anim-scale xb-mega-menu-response-to-icons"" style=""{2}"">
                                <li aria-haspopup=""true"" class=""right"">
					                <a href=""javascript:;"">
                                        &nbsp;<span class=""glyphicon glyphicon-th-list"" style=""font-size: 13pt; margin-top: 10px; {3}""></span>&nbsp;                                    
                                    </a>
                                    <div class=""grid-container4"">                                        
                                        <ul style=""{2}"">{1}</ul>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        <div class=""progress loading-progress"" style=""display: none; position: absolute; bottom: 0px; z-index: 1000; width: 100%;"" id=""loadingProgress"">
                            <div class=""progress-bar progress-bar-info progress-bar-striped active"" role=""progressbar"" aria-valuenow=""100"" aria-valuemin=""0"" aria-valuemax=""100"" style=""width: 100%""></div>
                        </div>
                    </div>"
                        , xbMenu
                        , xbMenu
                        , String.Concat(XAFBootstrapConfiguration.Instance.GetMenuBackgroundColor()) != "" ? "background: " + XAFBootstrapConfiguration.Instance.GetMenuBackgroundColor() + ";" : ""
                        , String.Concat(XAFBootstrapConfiguration.Instance.GetMenuTextColor()) != "" ? "color: " + XAFBootstrapConfiguration.Instance.GetMenuTextColor() + ";" : ""
                        );
                }

                xbMegaMenu.EncodeHtml = false;
                xbMegaMenu.Text       = ULText;
                #endregion
            }
            else
            {
                #region Bootstrap menu
                if (LeftItems.Count > 0)
                {
                    ULText += "<ul class='nav navbar-nav'>";
                    foreach (var RootItem in LeftItems)
                    {
                        if (RootItem.Items.Count > 0)
                        {
                            ULText += String.Format(
                                @"<li class='dropdown'>
                                <a href='javascript:;' class='dropdown-toggle' data-toggle='dropdown'>{2} <span>{0}</span> <span class='caret'></span>
                                </a>
                                <ul class='dropdown-menu' role='menu'>{1}</ul></li>
                               "
                                , RootItem.Caption
                                , GenerateSubMenu(RootItem, true)
                                , String.Concat(RootItem.Model.GetValue <String>("Glyphicon")) != ""
                                     ? FormatGlyphicon(String.Concat(RootItem.Model.GetValue <String>("Glyphicon"))) : ""
                                );
                        }
                        else
                        {
                            ULText += GetMenuItem(RootItem);
                        }
                    }
                    ULText += "</ul>";
                }

                var Settings   = "";
                var SettingsLi = "";
                Settings += @"
                        <li class='dropdown hidden-xs' style='position: absolute; right: 10px;'>
                          <a href='#' class='dropdown-toggle' data-toggle='dropdown'><span class='glyphicon glyphicon-cog settings-button'></span></a>
                          <ul class='dropdown-menu' role='menu'>";

                StringBuilder tempRes = new StringBuilder();
                foreach (XafMenuItem menuItem in Helpers.GetMenuActions(SAC))
                {
                    String glyphiconString = "glyphicon-star";
                    if (menuItem.ActionProcessor != null && menuItem.ActionProcessor.Action != null && menuItem.ActionProcessor.Action.Model != null && !String.IsNullOrEmpty(menuItem.ActionProcessor.Action.Model.GetValue <String>("Glyphicon")))
                    {
                        glyphiconString = menuItem.ActionProcessor.Action.Model.GetValue <String>("Glyphicon");
                    }
                    if (!(Helpers.GenerateSingleChoiceAction(ref tempRes, menuItem, true, "", SAC.UniqueID + "_Callback")))
                    {
                        SettingsLi += String.Format("<li><a href='javascript:;' onclick='if ($(\"#settingsCollapseButton\").is(\":visible\")) $(\"#settingsCollapseButton\").click();{2}'><span class='glyphicon {4}'></span> {0}</a></li>"
                                                    , menuItem.Text
                                                    , menuItem.Name
                                                    , Helpers.ContentHelper.GetScript(SAC.UniqueID + "_Callback", String.Format("\"Action={0}\"", menuItem.Name)).Replace("'", "\"")
                                                    , ""
                                                    , glyphiconString);
                    }
                    else
                    {
                        var choiceAction = (menuItem.ActionProcessor as MenuActionItemBase).Action as SingleChoiceAction;
                        SettingsLi += String.Format(@"<li class=""dropdown-header"">{0}</li>", choiceAction.Caption);
                        SettingsLi += String.Join("", choiceAction.Items.Select(f =>
                                                                                String.Format("<li><a href=\"javascript:;\" onclick='if ($(\"#settingsCollapseButton\").is(\":visible\")) $(\"#settingsCollapseButton\").click();{2}'><span class=\"glyphicon {1}\"></span> {0}</a></li>"
                                                                                              , f.Caption
                                                                                              , glyphiconString
                                                                                              , Helpers.ContentHelper.GetScript(SAC.UniqueID + "_Callback", String.Format("\"Action={0},{1}\"", menuItem.Name, f.Id)).Replace("'", "\""))
                                                                                ));
                    }
                }
                Settings += SettingsLi;
                Settings +=
                    @"</ul>
                      </li>";


                //if (RightItems.Count > 0)
                {
                    ULText += "<ul class='nav navbar-nav navbar-right'>";

                    ULText += Settings;

                    foreach (var RootItem in RightItems)
                    {
                        if (RootItem.Items.Count > 0)
                        {
                            ULText += String.Format(
                                @"<li class='dropdown'>
                                <a href='#' class='dropdown-toggle' data-toggle='dropdown'>{0} <span class='caret'></span></a>
                                <ul class='dropdown-menu' role='menu'>{1}</ul></li>"
                                , RootItem.Caption
                                , GenerateSubMenu(RootItem, true)
                                , String.Concat(RootItem.Model.GetValue <String>("Glyphicon")) != ""
                                     ? FormatGlyphicon(String.Concat(RootItem.Model.GetValue <String>("Glyphicon"))) : ""
                                );
                        }
                        else
                        {
                            ULText += String.Format("<li><a href='#about'>{0}</a></li>", GetMenuItem(RootItem));
                        }
                    }
                    ULText += "</ul>";
                }

                TopMenu.EncodeHtml = false;
                TopMenu.Text       = String.Format(@"
                    <div class='navbar navbar-default navbar-fixed-top {3}' role='navigation' id='navbar'>
                      <div>
                        <div class='navbar-header'>                        
                          <button type='button' id='menuCollapseButton' class='navbar-toggle collapsed' data-toggle='collapse' data-target='#mainMenu'>
                            <span class='sr-only'>Toggle navigation</span>
                            <span class='icon-bar'></span>
                            <span class='icon-bar'></span>
                            <span class='icon-bar'></span>
                          </button>
                          <button type='button' id='settingsCollapseButton' class='navbar-toggle collapsed' data-toggle='collapse' data-target='#settingsMenu'>
                            <span class='sr-only'>Toggle navigation</span>
                            <span class='glyphicon glyphicon-cog text-info settings-button'></span>
                          </button>                    
                          <a class='navbar-brand' href='#'>{1}</a>
                        </div>                    
                        <div class='navbar-collapse collapse' id='mainMenu'>
                            <div class='container'>
                                {0}
                            </div>
                        </div>
                        <div class='navbar-collapse collapse' id='settingsMenu'>
                            <ul class='nav hidden-sm hidden-md hidden-lg navbar-nav'>
                                {2}
                            </ul>
                        </div>
                      </div>
                    
                      <div class=""progress loading-progress"" style=""display: none"" id=""loadingProgress"">
                        <div class=""progress-bar progress-bar-info progress-bar-striped active"" role=""progressbar"" aria-valuenow=""100"" aria-valuemin=""0"" aria-valuemax=""100"" style=""width: 100%""></div>
                      </div>

                    </div>"
                                                   , ULText
                                                   , (File.Exists(MapPath("~/images/logo.png")) ? "<img style='max-height: 30px; max-width: 160px; margin-top: -5px;' src='images/logo.png'>" : App.Model.Title)
                                                   , SettingsLi
                                                   , XAFBootstrapConfiguration.Instance != null && XAFBootstrapConfiguration.Instance.InverseNavBar ? "navbar-inverse" : "");
                #endregion
            }
        }
Esempio n. 13
0
        public void GenerateMenuItems(ChoiceActionItemCollection collection)
        {
            Helpers.ContentHelper.ClearMenu();
            var ULText = "";

            XafApplication App             = (WebApplication.Instance as XafApplication);
            IModelNode     NavigationItems = App.Model.GetNode("NavigationItems").GetNode("Items");

            IList <ChoiceActionItem> LeftItems  = new List <ChoiceActionItem>();
            IList <ChoiceActionItem> RightItems = new List <ChoiceActionItem>();

            for (int i = 0; i < collection.Count; i++)
            {
                var RootItem = collection[i];
                if (!RootItem.Active || !RootItem.Enabled)
                {
                    continue;
                }
                if (RootItem.Model is IModelMenuAlign)
                {
                    if ((RootItem.Model as IModelMenuAlign).MenuAlign == XAFBootstrapMenuAlign.Right)
                    {
                        RightItems.Add(RootItem);
                    }
                    else
                    {
                        LeftItems.Add(RootItem);
                    }
                }
                else
                {
                    LeftItems.Add(RootItem);
                }
            }

            if (LeftItems.Count > 0)
            {
                ULText += "<ul class='nav navbar-nav'>";
                foreach (var RootItem in LeftItems)
                {
                    if (RootItem.Items.Count > 0)
                    {
                        ULText += String.Format(
                            @"<li class='dropdown'>
                            <a href='javascript:;' class='dropdown-toggle' data-toggle='dropdown'>{2} <span>{0}</span> <span class='caret'></span>
                            </a>
                            <ul class='dropdown-menu' role='menu'>{1}</ul></li>
                           "
                            , RootItem.Caption
                            , GenerateSubMenu(RootItem, true)
                            , RootItem.Model is IModelGlyphicon && String.Concat((RootItem.Model as IModelGlyphicon).Glyphicon) != ""
                                 ? String.Format("<span class='glyphicon glyphicon-{0}'></span> ", (RootItem.Model as IModelGlyphicon).Glyphicon) : ""
                            );
                    }
                    else
                    {
                        ULText += GetMenuItem(RootItem);
                    }
                }
                ULText += "</ul>";
            }

            var Settings   = "";
            var SettingsLi = "";

            Settings += @"
                    <li class='dropdown hidden-xs' style='position: absolute; right: 10px;'>
                      <a href='#' class='dropdown-toggle' data-toggle='dropdown'><span class='glyphicon glyphicon-cog settings-button'></span></a>
                      <ul class='dropdown-menu' role='menu'>";

            StringBuilder tempRes = new StringBuilder();

            foreach (XafMenuItem menuItem in Helpers.GetMenuActions(SAC))
            {
                if (!(Helpers.GenerateSingleChoiceAction(ref tempRes, menuItem, true, "", SAC.UniqueID + "_Callback")))
                {
                    SettingsLi += String.Format("<li><a href='javascript:;' onclick='if ($(\"#settingsCollapseButton\").is(\":visible\")) $(\"#settingsCollapseButton\").click();{2}'><span class='glyphicon glyphicon-star'></span> {0}</a></li>"
                                                , menuItem.Text
                                                , menuItem.Name
                                                , Helpers.ContentHelper.GetScript(SAC.UniqueID + "_Callback", String.Format("\"Action={0}\"", menuItem.Name)).Replace("'", "\""), "");
                }
                else
                {
                    var choiceAction = (menuItem.ActionProcessor as MenuActionItemBase).Action as SingleChoiceAction;
                    SettingsLi += String.Format(@"<li class=""dropdown-header"">{0}</li>", choiceAction.Caption);
                    SettingsLi += String.Join("", choiceAction.Items.Select(f =>
                                                                            String.Format("<li><a href=\"javascript:;\" onclick='if ($(\"#settingsCollapseButton\").is(\":visible\")) $(\"#settingsCollapseButton\").click();{1}'><span class=\"glyphicon glyphicon-star\"></span> {0}</a></li>"
                                                                                          , f.Caption
                                                                                          , Helpers.ContentHelper.GetScript(SAC.UniqueID + "_Callback", String.Format("\"Action={0},{1}\"", menuItem.Name, f.Id)).Replace("'", "\""))
                                                                            ));
                }
            }
            Settings += SettingsLi;
            Settings +=
                @"</ul>
                  </li>";


            //if (RightItems.Count > 0)
            {
                ULText += "<ul class='nav navbar-nav navbar-right'>";

                ULText += Settings;

                foreach (var RootItem in RightItems)
                {
                    if (RootItem is IModelMenuAlign)
                    {
                    }
                    if (RootItem.Items.Count > 0)
                    {
                        ULText += String.Format(
                            @"<li class='dropdown'>
                            <a href='#' class='dropdown-toggle' data-toggle='dropdown'>{0} <span class='caret'></span></a>
                            <ul class='dropdown-menu' role='menu'>{1}</ul></li>"
                            , RootItem.Caption
                            , GenerateSubMenu(RootItem, true)
                            , RootItem.Model is IModelGlyphicon && String.Concat((RootItem.Model as IModelGlyphicon).Glyphicon) != ""
                                 ? String.Format("<span class='glyphicon glyphicon-{0}'></span> ", (RootItem.Model as IModelGlyphicon).Glyphicon) : ""
                            );
                    }
                    else
                    {
                        ULText += String.Format("<li><a href='#about'>{0}</a></li>", GetMenuItem(RootItem));
                    }
                }
                ULText += "</ul>";
            }

            TopMenu.EncodeHtml = false;
            TopMenu.Text       = String.Format(@"
                <div class='navbar navbar-default navbar-fixed-top {3}' role='navigation' id='navbar'>
                  <div class='container'>
                    <div class='navbar-header'>                        
                      <button type='button' id='menuCollapseButton' class='navbar-toggle collapsed' data-toggle='collapse' data-target='#mainMenu'>
                        <span class='sr-only'>Toggle navigation</span>
                        <span class='icon-bar'></span>
                        <span class='icon-bar'></span>
                        <span class='icon-bar'></span>
                      </button>
                      <button type='button' id='settingsCollapseButton' class='navbar-toggle collapsed' data-toggle='collapse' data-target='#settingsMenu'>
                        <span class='sr-only'>Toggle navigation</span>
                        <span class='glyphicon glyphicon-cog text-info settings-button'></span>
                      </button>                    
                      <a class='navbar-brand' href='#'>{1}</a>
                    </div>                    
                    <div class='navbar-collapse collapse' id='mainMenu'>
                        {0}
                    </div>
                    <div class='navbar-collapse collapse' id='settingsMenu'>
                        <ul class='nav hidden-sm hidden-md hidden-lg navbar-nav'>
                            {2}
                        </ul>
                    </div>
                  </div>
                    
                  <div class=""progress loading-progress"" style=""display: none"" id=""loadingProgress"">
                    <div class=""progress-bar progress-bar-info progress-bar-striped active"" role=""progressbar"" aria-valuenow=""100"" aria-valuemin=""0"" aria-valuemax=""100"" style=""width: 100%""></div>
                  </div>

                </div>"
                                               , ULText
                                               , (File.Exists(MapPath("~/images/logo.png")) ? "<img style='max-height: 30px; max-width: 160px; margin-top: -5px;' src='images/logo.png'>" : App.Model.Title)
                                               , SettingsLi
                                               , XAFBootstrapConfiguration.Instance != null && XAFBootstrapConfiguration.Instance.InverseNavBar ? "navbar-inverse" : "");
        }
 private void ClearItems(ChoiceActionItemCollection items)
 {
     if (items == null)
     {
         return;
     }
     ChoiceActionItem[] array = items.ToArray<ChoiceActionItem>();
     for (int i = 0; i < array.Length; i++)
     {
         ChoiceActionItem choiceActionItem = array[i];
         this.ClearItems(choiceActionItem.Items);
         if (choiceActionItem is IDisposable)
         {
             (choiceActionItem as IDisposable).Dispose();
         }
     }
     items.Clear();
 }
 protected void ProcessItemNew(IModelNavigationItem item, ChoiceActionItemCollection choiceActionItems)
 {
     ChoiceActionItem item2;
     if (item.View != null)
     {
         var viewShortcut = new ViewShortcut(item.View.Id, item.ObjectKey);
         var lvcni = item as IListViewCriteriaNavigationItem;
         if (lvcni != null)
         {
             viewShortcut.Add("Criteria", lvcni.Criteria + "");
         }
         item2 = new ChoiceActionItem(item, viewShortcut);
         item2.Active["HasRights"] = this.HasRights(item2, item.Application.Views);
     }
     else
     {
         item2 = new ChoiceActionItem(item)
         {
             ActiveItemsBehavior = ActiveItemsBehavior.RequireActiveItems
         };
     }
     item2.Active["Visible"] = item.Visible;
     choiceActionItems.Add(item2);
     foreach (IModelNavigationItem item3 in item.Items)
     {
         this.ProcessItemNew(item3, item2.Items);
     }
     this.OnNavigationItemCreated(item, item2);
 }