Ejemplo n.º 1
0
        public static MenuItemDefinition GetOrCreatePlugInsRootMenu(this MenuDefinition menu, string url, string icon, string plugInMenuName = "PlugIns", string fixedDisplayName = null, string requiredPermission = null)
        {
            if (plugInMenuName.IsNullOrWhiteSpace())
            {
                plugInMenuName = "PlugIns";
            }

            if (fixedDisplayName.IsNullOrWhiteSpace())
            {
                fixedDisplayName = "PlugIns";
            }

            var plugInRoot = menu.Items.FirstOrDefault(i => i.Name == plugInMenuName);

            if (plugInRoot == null)
            {
                plugInRoot = new MenuItemDefinition(
                    plugInMenuName,
                    new FixedLocalizableString(fixedDisplayName),
                    url: url,
                    icon: icon,
                    requiredPermissionName: requiredPermission
                    );

                menu.AddItem(plugInRoot);
            }

            return(plugInRoot);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new <see cref="UserMenu"/> object from given <see cref="MenuDefinition"/>.
 /// 构造函数
 /// <param name="menuDefinition">菜单定义</param>
 /// <param name="localizationContext">本地化上下文</param>
 /// </summary>
 internal UserMenu(MenuDefinition menuDefinition, ILocalizationContext localizationContext)
 {
     Name = menuDefinition.Name;
     DisplayName = menuDefinition.DisplayName.Localize(localizationContext);
     CustomData = menuDefinition.CustomData;
     Items = new List<UserMenuItem>();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new <see cref="UserMenu"/> object from given <see cref="MenuDefinition"/>.
 /// </summary>
 internal UserMenu(MenuDefinition menuDefinition)
 {
     Name        = menuDefinition.Name;
     DisplayName = menuDefinition.DisplayName.Localize();
     CustomData  = menuDefinition.CustomData;
     Items       = new List <UserMenuItem>();
 }
Ejemplo n.º 4
0
        public override void SetNavigation(INavigationProviderContext context)
        {
            var frontEndMenu = new MenuDefinition(MenuName, new FixedLocalizableString("Frontend menu"));
            context.Manager.Menus[MenuName] = frontEndMenu;

            frontEndMenu

                //HOME
                .AddItem(new MenuItemDefinition(
                   DefaultAppConst.Pages.Frontend.Home,
                    L("HomePage"),
                    url: ""
                    )

                //ABOUT
                ).AddItem(new MenuItemDefinition(
                    DefaultAppConst.Pages.Frontend.About,
                    L("AboutUs"),
                    url: "About"
                    )

                //MULTI-LEVEL MENU (JUST FOR EXAMPLE)
                //).AddItem(new MenuItemDefinition(
                //    "MultiLevelMenu",
                //    new FixedLocalizableString("Multi level menu")
                //    ).AddItem(new MenuItemDefinition(
                //        "MultiLevelMenu.1",
                //        new FixedLocalizableString("Sub menu item 1")
                //        )
                //    ).AddItem(new MenuItemDefinition(
                //        "MultiLevelMenu.2",
                //        new FixedLocalizableString("Sub menu item 2")
                //        ).AddItem(new MenuItemDefinition(
                //            "MultiLevelMenu.2.1",
                //            new FixedLocalizableString("Sub menu item 2.1")
                //            )
                //        ).AddItem(new MenuItemDefinition(
                //            "MultiLevelMenu.2.2",
                //            new FixedLocalizableString("Sub menu item 2.2")
                //            )
                //        ).AddItem(new MenuItemDefinition(
                //            "MultiLevelMenu.2.3",
                //            new FixedLocalizableString("Sub menu item 2.3")
                //            ).AddItem(new MenuItemDefinition(
                //                "MultiLevelMenu.2.3.1",
                //                new FixedLocalizableString("ASP.NET Boilerplate"),
                //                url: "http://aspnetboilerplate.com"
                //                )
                //            ).AddItem(new MenuItemDefinition(
                //                "MultiLevelMenu.2.3.2",
                //                new FixedLocalizableString("jtable.org"),
                //                url: "http://jtable.org"
                //                )
                //            )
                //        )
                //    )
                );
        }
Ejemplo n.º 5
0
        public void SetMenu(MenuDefinition mainMenu, IEnumerable<MenuDto> menues)
        {
            foreach (var menu in menues)
            {
                var menuitem = new MenuItemDefinition(
                    menu.Name,
                    new LocalizableString(menu.DisplayName, IdentityConsts.LocalizationSourceName),
                    url: menu.Url,
                    icon: menu.Icon
                    );
                mainMenu.AddItem(menuitem);

                if (menu.Items.Count > 0)
                {
                    SetMenu(menuitem, menu.Items);
                }
            }
        }
        public override void SetNavigation(INavigationProviderContext context)
        {
            /* 设置菜单 */
            var frontEndMenu = new MenuDefinition(MenuName, new FixedLocalizableString("Frontend menu"));
            context.Manager.Menus[MenuName] = frontEndMenu;

            frontEndMenu
                .AddItem(new MenuItemDefinition(
                    PageNames.Frontend.Home, //首页
                    L("HomePages"),
                    url: ""
                    ))
                .AddItem(new MenuItemDefinition(
                    PageNames.Frontend.About, //关于我们
                    L("AboutUs"),
                    url: "About"
                    ));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a new <see cref="UserMenu"/> object from given <see cref="MenuDefinition"/>.
 /// </summary>
 internal UserMenu(MenuDefinition menuDefinition)
 {
     Name = menuDefinition.Name;
     DisplayName = menuDefinition.DisplayName.Localize();
     Items = new List<UserMenuItem>();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new <see cref="UserMenu"/> object from given <see cref="MenuDefinition"/>.
 /// </summary>
 public UserMenu(MenuDefinition menuDefinition)
 {
     Name        = menuDefinition.Name;
     DisplayName = menuDefinition.DisplayName.Localize();
     Items       = new List <UserMenuItem>();
 }