Exemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();
            AppHelper.MainForm = this;
            _list = JsonConvert.DeserializeObject <List <Menus> >(File.ReadAllText("MenuConfig.json")); //加载菜单列表
            MenuApi menuApi  = new MenuApi();
            var     response = menuApi.GetMenuByUser(AppHelper.UserId);

            if (response.Code == 1 && response.DataCount > 0)
            {
                _menus = JsonConvert.DeserializeObject <List <Menus> >(response.Data.ToString());
            }
            InitMenu();
            tvMenu.AfterSelect += tvMenu_AfterSelect;
        }
Exemplo n.º 2
0
        private void Init()
        {
            MenuApi menuApi  = new MenuApi();
            var     response = menuApi.GetMenuByUser(AppHelper.UserId);

            if (response.Code == 1 && response.DataCount > 0)
            {
                List <Menus> menuList = JsonConvert.DeserializeObject <List <Menus> >(response.Data?.ToString());
                tvMenus.Nodes.Clear();
                tvMenus.CheckBoxes = true;
                TreeNode rootNode = new TreeNode("系统菜单");
                rootNode.Name = "0";
                tvMenus.Nodes.Add(rootNode);
                CreateTreeNode(menuList, rootNode, 0);
                tvMenus.ExpandAll();
            }
        }