Example #1
0
        private async Task <List <MenuTree> > LoadMenuTreeAsync(string selectedGuid = null)
        {
            var list = await _dbContext.DncMenu.
                       Where(x => x.IsDeleted ==
                             CommonEnum.IsDeleted.No && x.Status == CommonEnum.Status.Normal).
                       ToListAsync();

            var temp = list.Select(x => new MenuTree
            {
                Guid       = x.Guid.ToString(),
                ParentGuid = x.ParentGuid,
                Title      = x.Name
            }).ToList();
            var root = new MenuTree
            {
                Title      = "顶级菜单",
                Guid       = Guid.Empty.ToString(),
                ParentGuid = null
            };

            temp.Insert(0, root);
            var tree = temp.BuildTree(selectedGuid);

            return(tree);
        }
Example #2
0
        // GET: SystemSchema/Role
        public ActionResult Index()
        {
            List <MenuTree> menuTreeList = new List <MenuTree> {
            };
            var menuTree = db.Queryable <Menu>().Where(it => it.Menu_ParentID == null).ToList();

            foreach (var item in menuTree)
            {
                var tree = new MenuTree
                {
                    Menu_ID   = item.Menu_ID,
                    Menu_Name = item.Menu_Name
                };
                var item1 = item;
                tree.Childs =
                    db.Queryable <Menu>().Where(it => it.Menu_ParentID == item1.Menu_ID).Select(it => new MenuTree
                {
                    Menu_ID   = it.Menu_ID,
                    Menu_Name = it.Menu_Name
                }).ToList();
                menuTreeList.Add(tree);
            }
            ViewBag.MenuList = menuTreeList;
            return(View());
        }
Example #3
0
        /// <summary>
        /// 根据数据库查询结果获取对应的菜单树结构
        /// </summary>
        /// <param name="laa">数据库查询权限结果</param>
        /// <returns>前端所需要的菜单数据结构列表</returns>
        public static List <MenuTree> GetMenuTree(List <ActionAll> laa)
        {
            List <MenuTree> lmt = new List <MenuTree>();
            IEnumerable <IGrouping <int, ActionAll> > groupAction = laa.GroupBy(a => a.GroupID);

            foreach (IGrouping <int, ActionAll> group in groupAction)
            {
                MenuTree at = new MenuTree();
                at.children = new List <MenuTree>();
                at.id       = group.Key;
                at.parentID = 0;
                var tmp = group.FirstOrDefault();
                at.iconCls       = tmp.GroupIcon;
                at.iconClsActive = tmp.GroupActiveIcon;
                at.name          = tmp.GroupName;
                at.path          = tmp.GroupURL;
                at.order         = tmp.GroupOrder;
                foreach (ActionAll a in group.OrderBy(g => g.ActionOrder))
                {
                    MenuTree at1 = new MenuTree();
                    at1.id       = a.ActionID;
                    at1.name     = a.ActionName;
                    at1.parentID = a.GroupID;
                    at1.path     = a.ActionURL;
                    at1.iconCls  = a.ActionIcon;
                    at.children.Add(at1);
                }
                lmt.Add(at);
            }
            return(lmt);
        }
Example #4
0
        public void Crawl_Study_Data(string url)
        {
            string html       = Crawl.Instance.CrawlDataFromUrl(url, httpclient);
            var    CourseList = Regex.Matches(html, @"<div class=""info-course(.*?)</div>", RegexOptions.Singleline);

            foreach (var course in CourseList)
            {
                string courseName = Regex.Match(course.ToString(), @"(?=<h2>).*?(?=</h2>)").Value.Replace("<h2>", "");
                string linkCourse = "https://www.howkteam.com" + Regex.Match(course.ToString(), @"'(.*?)'", RegexOptions.Singleline).Value.Replace("'", "");

                MenuTree item = new MenuTree();
                item.Name = courseName;
                item.URL  = linkCourse;

                AddItemIntoTreeViewItem(TreeItems, item);

                string htmlCourse  = Crawl.Instance.CrawlDataFromUrl(linkCourse, httpclient);
                string sideBar     = Regex.Match(htmlCourse, @"<div class=""sidebardetail"">(.*?)</ul>", RegexOptions.Singleline).Value;
                var    listLecture = Regex.Matches(sideBar, @"<a href=""/course(.*?)</a>", RegexOptions.Singleline);
                foreach (var lecture in listLecture)
                {
                    string lectureName = Regex.Match(lecture.ToString(), @">(.*?)</a>", RegexOptions.Singleline).Value.Replace(">", "").Replace("</a", "");
                    string linkLecture = "https://www.howkteam.com" + Regex.Match(lecture.ToString(), @"<a href=""(.*?)"" class", RegexOptions.Singleline).Value.Replace("<a href=\"", "").Replace("\" class", "");

                    MenuTree Subitem = new MenuTree();
                    Subitem.Name = lectureName;
                    Subitem.URL  = linkLecture;
                    AddItemIntoTreeViewItem(item.Items, Subitem);
                }
            }
            treeMain.AddHandler(TreeViewItem.MouseDoubleClickEvent, new MouseButtonEventHandler(MenuItem_MouseDoubleClick));
        }
Example #5
0
        //[Route("GetMenusTreeList")]
        //[AllowAnonymous]
        public async Task <BaseResponse <MenuTree> > GetMenusTreeList(int pid = 0)
        {
            var data        = new BaseResponse <MenuTree>();
            var permissions = await _menuServices.Query(d => d.IsDrop == false);

            var permissionTrees = (from child in permissions
                                   where child.IsDrop == false
                                   orderby child.Id
                                   select new MenuTree
            {
                value = child.Id,
                label = child.Name,
                Pid = child.ParentId,
                order = child.OrderSort,
            }).ToList();
            MenuTree rootRoot = new MenuTree
            {
                value = 0,
                Pid   = 0,
                label = "根节点"
            };

            permissionTrees = permissionTrees.OrderBy(d => d.order).ToList();

            RecursionHelper.LoopToAppendChildren(permissionTrees, rootRoot, pid);
            data.Data = rootRoot;
            data.Msg  = "获取成功";
            return(data);
        }
Example #6
0
        private MenuTree getNode(RoleMapDto item, List <RoleMapDto> col3)
        {
            Object metaobj = new
            {
                title   = item.menu_title,
                icon    = item.menu_icon,
                noCache = true
            };
            MenuTree node = new MenuTree()
            {
                id        = item.map_id,
                name      = item.menu_title,
                path      = item.menu_jump,
                pid       = item.menu_pid,
                meta      = metaobj,
                component = item.menu_pid == "0" ? "Layout" : string.Format("system/{0}/index", item.menu_jump)
            };
            List <RoleMapDto> childs = col3.Where(t => t.menu_pid == item.map_id).ToList();

            if (childs.Count() > 0)
            {
                List <MenuTree> children = new List <MenuTree>();
                foreach (var childitem in childs)
                {
                    MenuTree childnode = getNode(childitem, col3);
                    if (children.Where(t => t.id == childnode.id).Count() == 0)
                    {
                        children.Add(childnode);
                    }
                }
                node.children = children;
            }
            return(node);
        }
        private void Init()
        {
            ResponseModel response = rbacService_.GetRoles();

            if (response.Code == 1 && response.DataCount >= 1)
            {
                List <Menus> menus_ = serializer_.Deserialize <List <Menus> >(serializer_.Serialize(response.Data));
                foreach (Menus menu in menus_.Where(p => p.ParentId == 0))
                {
                    MenuTree.Nodes.Add(menu.MenuName);
                }
                foreach (Menus menu in menus_.Where(p => p.ParentId > 0))
                {
                    TreeNode targetNode = MenuTree.Nodes[menu.ParentName];
                    targetNode.Nodes.Add(menu.MenuName);
                }
                MenuTree.ExpandAll();
            }
            else
            {
                MessageBox.Show(response.Message);
            }
            response = menuService_.GetMenu(AppManager.GetInstance().User.user_id.SafeParse());
            if (response.Code == 1 && response.DataCount >= 1)
            {
                currentUserMenus_ = serializer_.Deserialize <List <Menus> >(serializer_.Serialize(response.Data));
            }
            else
            {
                MessageBox.Show("权限验证失败,当前登录账户无权限");
            }
        }
Example #8
0
        private IEnumerable <MenuTree> GetMenuTree2(int parentId, IEnumerable <Menu> list)
        {
            var children = list.Where(m => m.PARENTID == parentId);

            if (children != null)
            {
                List <MenuTree> menus = new List <MenuTree>();
                children = children.OrderBy(m => m.SORTID).ToList();
                foreach (var m in children)
                {
                    if (!m.DISPLAY)
                    {
                        continue;
                    }
                    var tree = new MenuTree(m);
                    var ms   = GetMenuTree2(m.ID, list);
                    if (ms != null && ms.Count() > 0)
                    {
                        tree.children = ms;
                    }
                    menus.Add(tree);
                }
                return(menus);
            }
            else
            {
                return(null);
            }
        }
        public MenuTreeModel MakeTreeModel(MenuTree root, string lang)
        {
            const string strConnection = "Data Source=LEONARDO-SQL;Initial Catalog=Utenti;Persist Security Info=True;User ID=www_rw;Password=farelt$k3j@aer24!fasf4234654;MultipleActiveResultSets=True;Application Name=menutester";

            List <MenuTree> result;

            using (var context = new MyDbContext(strConnection))
            {
                result = context.Set <MenuTree>().Include(tree => tree.Languages)
                         .Where(tree => tree.Root.IdMenu == root.IdMenu && tree.Root.IdLevel == root.IdLevel
                                &&
                                tree.Origins.Any(
                                    origin =>
                                    origin.IdCompany == 1 || origin.IdMacroGroup == 21 || origin.IdGroup == 927 ||
                                    origin.IdUser == 1547)
                                ).ToList();
            }

            return(new MenuTreeModel
            {
                IdMenu = root.IdMenu,
                IdLevel = root.IdLevel,
                LevelDescription = root.LevelDescription,
                Link = root.Link,
                MenuDescription =
                    (root.Languages.FirstOrDefault(n => n.Language == lang)
                     ?? new MenuLanguage {
                    Description = "nothing"
                }).Description,
                Subtrees = result.Select(tree => this.MakeTreeModel(tree, lang)).ToList()
            });
        }
Example #10
0
        internal static void ShowMenu(MenuTree menuTree, CentrifugeMenu parentMenu, int pageIndex)
        {
            if (menuTree.GetItems().Count is 0)
            {
                ShowUnavailableMessage();
                return;
            }

            foreach (var component in parentMenu.PanelObject_.GetComponents <CentrifugeMenu>())
            {
                component.Destroy();
            }

            var menu = GameAPI.Instance.gameObject.AddComponent <CentrifugeMenu>();

            menu.MenuTree = menuTree;

            menu.CurrentPageIndex             = pageIndex;
            menu.MenuPanel                    = MenuPanel.Create(menu.PanelObject_, true, true, false, true, true, true);
            menu.MenuPanel.backgroundOpacity_ = 0.75f;

            menu.MenuPanel.onIsTopChanged_ += (isTop) =>
            {
                if (isTop)
                {
                    menu.ResetAnimations();
                }
                else
                {
                    if (G.Sys.MenuPanelManager_.panelStack_.Contains(menu.MenuPanel))
                    {
                        menu.SwitchPage(menu.CurrentPageIndex, false, true);
                    }
                    else
                    {
                        menu.SwitchPage(0, false, true);
                    }
                }
            };

            menu.MenuPanel.onPanelPop_ += () =>
            {
                if (!G.Sys.MenuPanelManager_.panelStack_.Contains(menu.MenuPanel))
                {
                    menu.SwitchPage(0, false, true);
                    parentMenu.PanelObject_.SetActive(true);

                    if (menu.MenuTree != MenuTree)
                    {
                        menu.PanelObject_.Destroy();
                    }

                    menu.Destroy();
                }
            };

            parentMenu.PanelObject_.SetActive(false);

            menu.MenuPanel.Push();
        }
Example #11
0
        private void CreateSettingsMenu()
        {
            MenuTree settingsMenu = new MenuTree("menu.mod.scenedumper", "Scene Dumper Settings")
            {
                new InputPrompt(MenuDisplayMode.Both, "setting:keybind_dumper_basic", "BASIC DUMP KEY BIND")
                .WithDefaultValue(() => Config.DumpSceneBasic)
                .WithSubmitAction((x) => Config.DumpSceneBasic = x)
                .WithTitle("ENTER KEY BINDING")
                .WithDescription("Set the keyboard shortcut used to make a basic dump."),

                new InputPrompt(MenuDisplayMode.Both, "setting:keybind_dumper_detailed", "DETAILED DUMP KEY BIND")
                .WithDefaultValue(() => Config.DumpSceneDetailed)
                .WithSubmitAction((x) => Config.DumpSceneDetailed = x)
                .WithTitle("ENTER KEY BINDING")
                .WithDescription("Set the keyboard shortcut used to make a detailed dump."),

                new ActionButton(MenuDisplayMode.Both, "setting:open_dumps_folder", "OPEN DUMPS FOLDER")
                .WhenClicked(() =>
                {
                    DirectoryInfo data = new DirectoryInfo(FileSystem.VirtualFileSystemRoot);

                    if (!data.Exists)
                    {
                        data.Create();
                    }

                    Process.Start(new ProcessStartInfo(data.FullName));
                })
                .WithDescription("Opens the folder containing dump logs.")
            };

            Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "SCENE DUMPER", "Settings for the Scene Dumper mod.");
        }
Example #12
0
        private List <MenuTree> RecursionMenuButton(List <RoleMenuButtonList> data, List <DistinctMenu> menuData, Guid menuId, Guid roleId)
        {
            var list      = new List <MenuTree>();
            var childMenu = menuData.Where(d => d.ParentId == menuId);

            foreach (var menu in childMenu)
            {
                var buttonList = new List <ButtonTree>();
                var menuButton = new MenuTree();
                var attributes = new MenuButtonAttributes();
                menuButton.Id           = menu.Id;
                menuButton.Title        = menu.Name;
                attributes.MenuButtonId = null;
                menuButton.Attributes   = attributes;
                var buttonTree = data.Where(d => d.MenuId == menu.Id && d.ButtonId.HasValue);
                if (buttonTree.Any())
                {
                    foreach (var button in buttonTree)
                    {
                        var buttons         = new ButtonTree();
                        var buttonAttribute = new MenuButtonAttributes();
                        buttons.Id                   = roleId;
                        buttons.Title                = button.ButtonName;
                        buttons.Checked              = button.Checked;
                        buttons.Attributes           = buttonAttribute;
                        buttonAttribute.MenuButtonId = button.MenuButtonId;
                        buttonList.Add(buttons);
                    }
                }
                menuButton.Children = buttonList;
                list.Add(menuButton);
            }
            return(list);
        }
        private void CreateSettingsMenu()
        {
            var settingsMenu = new MenuTree("menu.mod.heat", "Heat Display Settings")
            {
                new InputPrompt(MenuDisplayMode.Both, "setting:toggle_hotkey", "SET TOGGLE HOTKEY")
                .WithTitle("SET TOGGLE HOTKEY")
                .WithDefaultValue(() => Config.ToggleHotkey)
                .WithSubmitAction(x => Config.ToggleHotkey = x),

                new ListBox <DisplayMode>(MenuDisplayMode.Both, "setting:display_mode", "DISPLAY MODE")
                .WithEntries(MapEnumToListBox <DisplayMode>())
                .WithGetter(() => Config.DisplayMode)
                .WithSetter((x) => Config.DisplayMode = x),

                new ListBox <ActivationMode>(MenuDisplayMode.Both, "setting:activation_mode", "ACTIVATION MODE")
                .WithEntries(MapEnumToListBox <ActivationMode>())
                .WithGetter(() => Config.ActivationMode)
                .WithSetter((x) => Config.ActivationMode = x),

                new FloatSlider(MenuDisplayMode.Both, "setting:warning_threshold", "WARNING THRESHOLD")
                .LimitedByRange(0.0f, 1.0f)
                .WithGetter(() => Config.WarningTreshold)
                .WithSetter((x) => Config.WarningTreshold = x)
            };

            Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "HEAT DISPLAY", "Configure the Heat mod.");
        }
Example #14
0
        private static bool CanVisible(MenuTree tree)
        {
            var result = false;

            if (tree == null)
            {
                result = false;
            }
            else
            {
                if (!tree.IsParent)
                {
                    result = tree.IsVisible;
                }
                else if (tree.IsParent && tree.IsVisible == false)
                {
                    result = false;
                }
                else
                {
                    foreach (var leaf in listMenuTrees.Where(l => l.ParentID == tree.ID))
                    {
                        if (CanVisible(leaf))
                        {
                            result = true;
                            break;
                        }
                    }
                }
            }

            return(result);
        }
        private void CreateSettingsMenu()
        {
            MenuTree settingsMenu = new MenuTree("menu.mod.trackmusic", "Track Music Settings")
            {
                new IntegerSlider(MenuDisplayMode.Both, "setting:max_music_download_size", "MAXIMUM DOWNLOAD SIZE (MB)")
                .WithGetter(() => (int)Config.MaxMusicDownloadSizeMB)
                .WithSetter((x) => Config.MaxMusicDownloadSizeMB = x)
                .LimitedByRange(10, 150)
                .WithDefaultValue(30)
                .WithDescription("Set the maximum file size to download for online music downloading."),

                new IntegerSlider(MenuDisplayMode.Both, "setting:max_music_download_time", "MAXIMUM DOWNLOAD TIME (SECS)")
                .WithGetter(() => (int)Config.MaxMusicDownloadTimeSeconds)
                .WithSetter((x) => Config.MaxMusicDownloadTimeSeconds = x)
                .LimitedByRange(5, 60)
                .WithDefaultValue(15)
                .WithDescription("Set the amount of time after which the music download times out (gets canceled)."),

                new IntegerSlider(MenuDisplayMode.Both, "setting:max_level_load_time", "MAXIMUM LOAD TIME (SECS)")
                .WithGetter(() => (int)Config.MaxMusicLevelLoadTimeSeconds)
                .WithSetter((x) => Config.MaxMusicLevelLoadTimeSeconds = x)
                .LimitedByRange(5, 60)
                .WithDefaultValue(20)
                .WithDescription("Set the amount of time after which the level loads whether the music download is complete or not."),
            };

            Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "TRACK MUSIC", "Settings for the Track Music mod.");
        }
        private void DisplayMenu()
        {
            MenuTree currentTree = MenuTree.GetItems(MenuSystem.GetCurrentDisplayMode());

            if (currentTree.Any())
            {
                for (int i = CurrentPageIndex * MaxEntriesPerPage; i < (CurrentPageIndex * MaxEntriesPerPage) + MaxEntriesPerPage; i++)
                {
                    if (i < currentTree.Count)
                    {
                        currentTree[i]?.Tweak(this);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Create(InternalResources.Strings.MenuSystem.UnavailableMenuError, InternalResources.Strings.MenuSystem.UnavailableMenuErrorTitle)
                .SetButtons(MessageButtons.Ok)
                .OnConfirm(() => PanelManager.TopPanel_.onPanelPop_ += () => MenuPanel.Pop())
                .Show();
            }
        }
Example #17
0
        public ActionResult MenuIndex()
        {
            MenuTree        mt           = new MenuTree();
            List <MenuTree> listmenuTree = mt.GetTreeData();
            List <MenuTree> menuTree     = mt.GetMenuTree(listmenuTree);

            return(View(menuTree));
        }
Example #18
0
 private void RegisterChildForSearch(MenuTree <T> node)
 {
     ElementsIndex.Add(node);
     if (Parent != null)
     {
         Parent.RegisterChildForSearch(node);
     }
 }
Example #19
0
        private void CreateSettingsMenu()
        {
            MenuTree settingsMenu = new MenuTree("menu.gsl.distance", InternalResources.Strings.Settings.Gsl.MenuTitle);

            settingsMenu.CheckBox(MenuDisplayMode.Both, "setting:show_version_info", InternalResources.Strings.Settings.Gsl.ShowVersionInfo, () => Config.ShowVersionInfo, (value) => Config.ShowVersionInfo = value, InternalResources.Strings.Settings.Gsl.ShowVersionInfoDescription);

            MenuSystem.MenuTree.SubmenuButton(MenuDisplayMode.Both, "navigate:menu.gsl.distance", InternalResources.Strings.Settings.Gsl.MenuTitle.ToUpper(), settingsMenu, InternalResources.Strings.Settings.Gsl.MenuDescription);
        }
Example #20
0
        //public ActionResult Index()
        //{
        //    ObjectData objtemp = new ObjectData();
        //    List<ObjectData> listobjnullsite = objtemp.GetObjects(); //load all the available uploaded list which has site id as null
        //    //List<ObjectData> menuTree = objtemp.GetMenuTree(listobjnullsite, listobjnullsite.FirstOrDefault().ObjType, listobjnullsite.FirstOrDefault().ObjSubType);
        //    List<ObjectData> menuTree = objtemp.GetMenuTree(listobjnullsite, "OT1");
        //    return View(menuTree);
        //}

        public JsonResult Test()
        {
            MenuTree        mt           = new MenuTree();
            List <MenuTree> listmenuTree = mt.GetTreeData();
            List <MenuTree> menuTree     = mt.GetMenuTree(listmenuTree);

            //List<MenuTree> menuTree = mt.GetMenuTree(listmenuTree, listmenuTree.FirstOrDefault().ObjType);
            return(Json(menuTree, JsonRequestBehavior.AllowGet));
        }
Example #21
0
        public PartialViewResult BottomMenu()
        {
            //replace by repo by another repo. IE categories

            MenuTree myparent = new MenuTree(myrepo);



            return(PartialView("BottomFlexMenu", myparent));
        }
Example #22
0
        public ActionResult GetMenuByRole()
        {
            //select rm.menuId from Employee e inner join RoleMenu rm on e.roleId=rm.roleId
            RoleMenuBLL rm       = new RoleMenuBLL();
            int         roleId   = ((Employee)Session["employee"]).roleId;
            RoleMenu    roleMenu = rm.GetEntityById(roleId);
            string      menuJson = "";

            if (roleMenu != null && roleMenu.menuId != null && !roleMenu.Equals(""))
            {
                string[] menuIds = roleMenu.menuId.Split(',');
                int[]    ids     = new int[menuIds.Count()];//当前用户所属角色所有的菜单id
                for (int i = 0; i < menuIds.Count(); i++)
                {
                    ids[i] = Convert.ToInt32(menuIds[i]);
                }
                MenuBLL         rmBll    = new MenuBLL();
                List <Menu>     menuList = rmBll.GetEntitys(t => ids.Contains(t.Id), true, t => t.sort).ToList();
                List <MenuTree> list     = new List <MenuTree>();
                foreach (Menu menu in menuList)
                {
                    if (menu.parent == 0)
                    {
                        MenuTree mtree = new MenuTree();
                        mtree.text       = menu.text;
                        mtree.Id         = menu.Id;
                        mtree.leaf       = menu.leaf;
                        mtree.view       = menu.view;
                        mtree.sort       = menu.sort;
                        mtree.parent     = menu.parent;
                        mtree.expanded   = menu.expanded;
                        mtree.iconCls    = menu.iconCls;
                        mtree.controller = menu.controller;
                        mtree.xtypes     = menu.xtypes;
                        List <Menu> _clist = new List <Menu>();
                        foreach (Menu _menu in menuList)
                        {
                            if (_menu.parent == menu.Id)
                            {
                                _clist.Add(new Menu {
                                    text = _menu.text, Id = _menu.Id, leaf = _menu.leaf, iconCls = _menu.iconCls, view = _menu.view, sort = _menu.sort, parent = _menu.parent, controller = _menu.controller, xtypes = _menu.xtypes
                                });
                            }
                        }
                        mtree.children = _clist;
                        list.Add(mtree);
                    }
                }
                menuJson  = Common.Common.JsonSerialize(list);
                menuJson  = "{checked:false,children:" + menuJson;
                menuJson += "}";
            }

            return(Content(menuJson));
        }
Example #23
0
 private void CreateTreeAsync(string [] menu, int index)
 {
     if (MenuTree.InvokeRequired)
     {
         MenuTree.Invoke(new Action <string[], int>(CreateTreeAsync), menu, index);
     }
     else
     {
         CreateTree(menu, index);
     }
 }
Example #24
0
        private List <UIElement> CreateMainPowerStrip()
        {
            MenuTree <OpenMainSubCategory> mainCategory = _mainCategory;

            mainCategory.Buttons.Clear();
            List <UIElement> list = new List <UIElement>();
            CreativePowerUIElementRequestInfo creativePowerUIElementRequestInfo = default(CreativePowerUIElementRequestInfo);

            creativePowerUIElementRequestInfo.PreferredButtonWidth  = 40;
            creativePowerUIElementRequestInfo.PreferredButtonHeight = 40;
            CreativePowerUIElementRequestInfo request           = creativePowerUIElementRequestInfo;
            GroupOptionButton <int>           groupOptionButton = CreativePowersHelper.CreateCategoryButton(request, 1, 0);

            groupOptionButton.Append(CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.ItemDuplication));
            groupOptionButton.OnClick  += MainCategoryButtonClick;
            groupOptionButton.OnUpdate += itemsWindowButton_OnUpdate;
            mainCategory.Buttons.Add(1, groupOptionButton);
            list.Add(groupOptionButton);
            GroupOptionButton <int> groupOptionButton2 = CreativePowersHelper.CreateCategoryButton(request, 2, 0);

            groupOptionButton2.Append(CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.ItemResearch));
            groupOptionButton2.OnClick  += MainCategoryButtonClick;
            groupOptionButton2.OnUpdate += researchWindowButton_OnUpdate;
            mainCategory.Buttons.Add(2, groupOptionButton2);
            list.Add(groupOptionButton2);
            GroupOptionButton <int> groupOptionButton3 = CreativePowersHelper.CreateCategoryButton(request, 3, 0);

            groupOptionButton3.Append(CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.TimeCategory));
            groupOptionButton3.OnClick  += MainCategoryButtonClick;
            groupOptionButton3.OnUpdate += timeCategoryButton_OnUpdate;
            mainCategory.Buttons.Add(3, groupOptionButton3);
            list.Add(groupOptionButton3);
            GroupOptionButton <int> groupOptionButton4 = CreativePowersHelper.CreateCategoryButton(request, 4, 0);

            groupOptionButton4.Append(CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.WeatherCategory));
            groupOptionButton4.OnClick  += MainCategoryButtonClick;
            groupOptionButton4.OnUpdate += weatherCategoryButton_OnUpdate;
            mainCategory.Buttons.Add(4, groupOptionButton4);
            list.Add(groupOptionButton4);
            GroupOptionButton <int> groupOptionButton5 = CreativePowersHelper.CreateCategoryButton(request, 6, 0);

            groupOptionButton5.Append(CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.PersonalCategory));
            groupOptionButton5.OnClick  += MainCategoryButtonClick;
            groupOptionButton5.OnUpdate += personalCategoryButton_OnUpdate;
            mainCategory.Buttons.Add(6, groupOptionButton5);
            list.Add(groupOptionButton5);
            CreativePowerManager.Instance.GetPower <CreativePowers.StopBiomeSpreadPower>().ProvidePowerButtons(request, list);
            GroupOptionButton <int> groupOptionButton6 = CreateSubcategoryButton <CreativePowers.DifficultySliderPower>(ref request, 1, "strip 1", 5, 0, mainCategory.Buttons, mainCategory.Sliders);

            groupOptionButton6.OnClick += MainCategoryButtonClick;
            list.Add(groupOptionButton6);
            return(list);
        }
        private void CreateSettingsMenu()
        {
            MenuTree settingsMenu = new MenuTree("menu.mod.customcar", "Custom Cars Settings")
            {
                new CheckBox(MenuDisplayMode.Both, "setting:use_trumpet_horn", "USE TRUMPET HORN")
                .WithGetter(() => Config.UseTrumpetHorn)
                .WithSetter((x) => Config.UseTrumpetHorn = x)
                .WithDescription("Custom car models will use the encryptor horn (the \"doot\" trumpet).")
            };

            Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "CUSTOM CARS", "Settings for the Custom Cars mod.");
        }
        public void Initialize(IManager manager, string ipcIdentifier)
        {
            PrivateSettings = new Settings("AdditionalSettings");
            var enableConsole = PrivateSettings.GetOrCreate("EnableConsole", true);

            if (!enableConsole)
            {
                ConsoleTricks.HideConsoleWindow();
            }

            var tree = new MenuTree("Spectrum.InGameSettings", "Spectrum Manager Settings")
            {
                new CheckBox(MenuDisplayMode.Both, "Spectrum.InGameSettings.NetworkDebugging", "Network debugging")
                .WithDefaultValue(manager.GetConfig <bool>("NetworkDebugging"))
                .WithGetter(() => manager.GetConfig <bool>("NetworkDebugging"))
                .WithSetter((value) => manager.SetConfig("NetworkDebugging", value))
                .WithDescription("Toggles JSON packet logging in the development console."),

                new CheckBox(MenuDisplayMode.Both, "Spectrum.InGameSettings.ManagerEnabled", "Enable Spectrum mods")
                .WithDefaultValue(manager.GetConfig <bool>("Enabled"))
                .WithGetter(() => manager.GetConfig <bool>("Enabled"))
                .WithSetter((value) => manager.SetConfig("Enabled", value))
                .WithDescription("Toggles manager functionality.\n[00D483]Will be applied next time you boot Distance.[-]"),

                new CheckBox(MenuDisplayMode.Both, "Spectrum.InGameSettings.LogToConsole", "Console event logging")
                .WithDefaultValue(manager.GetConfig <bool>("LogToConsole"))
                .WithGetter(() => manager.GetConfig <bool>("LogToConsole"))
                .WithSetter((value) => manager.SetConfig("LogToConsole", value))
                .WithDescription("Toggles Manager echoing its logs to development console."),

                new CheckBox(MenuDisplayMode.Both, "Spectrum.InGameSettings.EnableConsole", "Enable development console")
                .WithDefaultValue(enableConsole)
                .WithGetter(() => PrivateSettings.GetItem <bool>("EnableConsole"))
                .WithSetter((value) =>
                {
                    PrivateSettings["EnableConsole"] = value;

                    if (value)
                    {
                        ConsoleTricks.ShowConsoleWindow();
                    }
                    else
                    {
                        ConsoleTricks.HideConsoleWindow();
                    }

                    PrivateSettings.Save();
                })
                .WithDescription("Toggles development console.\nUseful for debugging plugin issues.")
            };

            manager.Menus.AddMenu(MenuDisplayMode.Both, tree, "Change Spectrum Manager settings");
        }
Example #27
0
 private void ToggleCategory <TEnum>(MenuTree <TEnum> tree, int option, TEnum defaultOption) where TEnum : struct, IConvertible
 {
     if (tree.CurrentOption == option)
     {
         option = defaultOption.ToInt32(null);
     }
     tree.CurrentOption = option;
     foreach (GroupOptionButton <int> value in tree.Buttons.Values)
     {
         value.SetCurrentOption(option);
     }
 }
Example #28
0
        public ActionResult Authorize(int id)
        {
            RoleAuthorizeModel model = new RoleAuthorizeModel
            {
                Role            = SysRole.SingleOrDefault(id),
                Funcs           = SysFunction.Fetch(Sql.Builder),
                Trees           = MenuTree.Fetch(Sql.Builder),
                SelectedFuncIds = SysPower.Fetch("where master_id=@0 and master_type=@1", id, MasterType.Role.ToString()).Select(power => power.FunctionID)
            };

            return(View(model));
        }
        private void CreateSettingsMenu()
        {
            MenuTree settingsMenu = new MenuTree("menu.mod.customwheelhologram", "Wheel Hologram Settings")
            {
                new ActionButton(MenuDisplayMode.Both, "setting:select_image", "SELECT IMAGE")
                .WhenClicked(() =>
                {
                    var dlgOpen = new System.Windows.Forms.OpenFileDialog
                    {
                        Filter = "Image file (*.png, *.jpg, *.jpeg *.bmp)|*.png;*.jpg;*.jpeg;*.bmp|All Files (*.*)|*.*",
                        SupportMultiDottedExtensions = true,
                        RestoreDirectory             = true,
                        Title           = "Select an image file",
                        CheckFileExists = true,
                        CheckPathExists = true
                    };

                    if (dlgOpen.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        FileInfo image = new FileInfo(dlgOpen.FileName);

                        if (image.Exists)
                        {
                            Config.FileName = Path.GetFileName(image.CopyTo(Path.Combine(FileSystem.VirtualFileSystemRoot, Path.GetFileName(image.FullName)), true).FullName);
                            Config.Enabled  = true;
                        }
                    }
                })
                .WithDescription("Select the image file displayed on the wheel hologram."),

                new ActionButton(MenuDisplayMode.Both, "setting:reset_image", "RESET IMAGE")
                .WhenClicked(() =>
                {
                    MessageBox.Create("Are you sure you want to reset the hologram to its default image?", "RESET WHEEL IMAGE")
                    .SetButtons(MessageButtons.YesNo)
                    .OnConfirm(() =>
                    {
                        Config.Enabled  = false;
                        Config.FileName = string.Empty;

                        if (WheelImage.Exists)
                        {
                            WheelImage.Delete();
                        }
                    })
                    .Show();
                })
                .WithDescription("Resets the wheel hologram to the game's default.")
            };

            Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "CUSTOM WHEEL HOLOGRAM", "Change settings of the Custom Wheel Hologram mod and customize your vehicle's wheel image (works only with vanilla cars).");
        }
Example #30
0
    public MenuTree <T> AddChild(T child)
    {
        MenuTree <T> childNode = new MenuTree <T>(child)
        {
            Parent = this
        };

        this.Children.Add(childNode);

        this.RegisterChildForSearch(childNode);

        return(childNode);
    }
Example #31
0
        public ActionResult GetAllMenu()
        {
            MenuBLL mbll = new MenuBLL();
            List<Menu> menuList = mbll.GetEntitys(t => t.sort);
            string menuJson = "";
            List<MenuTree> list = new List<MenuTree>();
            foreach (Menu menu in menuList)
            {
                if (menu.parent == 0)
                {
                    MenuTree mtree = new MenuTree();
                    mtree.text = menu.text;
                    mtree.Id = menu.Id;
                    mtree.leaf = menu.leaf;
                    mtree.view = menu.view;
                    mtree.sort = menu.sort;
                    mtree.parent = menu.parent;
                    mtree.expanded = menu.expanded;
                    mtree.iconCls = menu.iconCls;
                    mtree.controller = menu.controller;
                    mtree.xtypes = menu.xtypes;
                    List<Menu> _clist = new List<Menu>();
                    foreach (Menu _menu in menuList)
                    {
                        if (_menu.parent == menu.Id)
                        {
                            _clist.Add(new Menu { text = _menu.text, Id = _menu.Id, leaf = _menu.leaf, iconCls = _menu.iconCls, view = _menu.view,sort=_menu.sort,parent=_menu.parent,controller=_menu.controller,xtypes=_menu.xtypes });
                        }
                    }
                    mtree.children = _clist;
                    list.Add(mtree);
                }
            }
            menuJson = Common.Common.JsonSerialize(list);
            menuJson = "{text:'',children:" + menuJson;
            menuJson += "}";

            return Content(Common.Common.JsonSerialize(list));
        }
Example #32
0
        public ActionResult GetMenuByRole()
        {
            //select rm.menuId from Employee e inner join RoleMenu rm on e.roleId=rm.roleId
            RoleMenuBLL rm = new RoleMenuBLL();
            int roleId = ((Employee)Session["employee"]).roleId;
            RoleMenu roleMenu = rm.GetEntityById(roleId);
            string menuJson = "";
            if (roleMenu != null && roleMenu.menuId != null && !roleMenu.Equals(""))
            {
                string[] menuIds = roleMenu.menuId.Split(',');
                int[] ids = new int[menuIds.Count()];//当前用户所属角色所有的菜单id
                for (int i = 0; i < menuIds.Count(); i++)
                {
                    ids[i] = Convert.ToInt32(menuIds[i]);
                }
                MenuBLL rmBll = new MenuBLL();
                List<Menu> menuList = rmBll.GetEntitys(t => ids.Contains(t.Id),true,t=>t.sort).ToList();
                List<MenuTree> list = new List<MenuTree>();
                foreach (Menu menu in menuList)
                {
                    if (menu.parent == 0)
                    {
                        MenuTree mtree = new MenuTree();
                        mtree.text = menu.text;
                        mtree.Id = menu.Id;
                        mtree.leaf = menu.leaf;
                        mtree.view = menu.view;
                        mtree.sort = menu.sort;
                        mtree.parent = menu.parent;
                        mtree.expanded = menu.expanded;
                        mtree.iconCls = menu.iconCls;
                        mtree.controller = menu.controller;
                        mtree.xtypes = menu.xtypes;
                        List<Menu> _clist = new List<Menu>();
                        foreach (Menu _menu in menuList)
                        {
                            if (_menu.parent == menu.Id)
                            {
                                _clist.Add(new Menu { text = _menu.text, Id = _menu.Id, leaf = _menu.leaf, iconCls = _menu.iconCls, view = _menu.view, sort = _menu.sort, parent = _menu.parent, controller = _menu.controller, xtypes = _menu.xtypes });
                            }
                        }
                        mtree.children = _clist;
                        list.Add(mtree);
                    }
                }
                menuJson = Common.Common.JsonSerialize(list);
                menuJson = "{checked:false,children:" + menuJson;
                menuJson += "}";
            }

            return Content(menuJson);
        }