Exemplo n.º 1
0
 private void AddMenu(TreeMenuNode parent, IList <JToken> menus)
 {
     try
     {
         if (parent == null)
         {
             string  menuStr = File.ReadAllText(Path.Combine(Application.StartupPath, @"../../mainMenu/mainMenu.txt"));
             JObject menuObj = JObject.Parse(menuStr);
             menus = menuObj["menus"].Children().ToList();
         }
         foreach (JToken ret in menus)
         {
             if (ret["children"] != null)
             {
                 IList <JToken> subMenus = ret["children"].Children().ToList();
                 MainMenuTag    menuTag  = JsonConvert.DeserializeObject <MainMenuTag>(ret.ToString());
                 menuTag.Type = MenuType.Folder;
                 TreeMenuNode newNode = new TreeMenuNode(menuTag.Name, MenuType.Folder);
                 newNode.Tag = menuTag;
                 if (parent == null)
                 {
                     mainMenu.Nodes.Add(newNode);
                 }
                 else
                 {
                     parent.Nodes.Add(newNode);
                 }
                 AddMenu(newNode, subMenus);
             }
             else
             {
                 MainMenuTag menuTag = JsonConvert.DeserializeObject <MainMenuTag>(ret.ToString());
                 menuTag.Type = MenuType.Leaf;
                 TreeMenuNode newNode = new TreeMenuNode(menuTag.Name, MenuType.Leaf);
                 newNode.Tag = menuTag;
                 if (parent == null)
                 {
                     mainMenu.Nodes.Add(newNode);
                 }
                 else
                 {
                     parent.Nodes.Add(newNode);
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 2
0
        private void mainMenu_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeMenuNode node = (TreeMenuNode)e.Node;
            MainMenuTag  tag  = (MainMenuTag)node.Tag;

            switch (tag.ID)
            {
            case MenuID.Setup_Country:
                frmCountry cty = new frmCountry(BOIDEnum.Country);
                cty.MdiParent = this.MdiParent;
                cty.Show();
                break;

            case MenuID.Setup_Market:
                frmMarketList mkt = new frmMarketList();
                mkt.MdiParent = this.MdiParent;
                mkt.Show();
                break;

            case MenuID.Setup_Texture:
                frmTexture txt = new frmTexture(BOIDEnum.Texture);
                txt.MdiParent = this.MdiParent;
                txt.Show();
                break;

            case MenuID.Setup_ProductGroup:
                frmProductGroup frmProGrp = new frmProductGroup();
                frmProGrp.MdiParent = this.MdiParent;
                frmProGrp.Show();
                break;

            case MenuID.Setup_KeyWord:
                frmKeyWrod frmkw = new frmKeyWrod();
                frmkw.MdiParent = this.MdiParent;
                frmkw.Show();
                break;

            case MenuID.Setup_KeyWordList:
                frmKeyWordList frmKwl = new frmKeyWordList();
                frmKwl.MdiParent = this.MdiParent;
                frmKwl.Show();
                break;

            case MenuID.Setup_SearchPlatform:
                break;

            case MenuID.BP_MD:
                frmBP bpmd = new frmBP(BOIDEnum.BP);
                bpmd.MdiParent = this.MdiParent;
                bpmd.Show();
                break;

            case MenuID.BP_List:
                frmBpList bpList = new frmBpList();
                bpList.MdiParent = this.MdiParent;
                bpList.Show();
                break;

            case MenuID.PR_MD:
                frmProduct frmPro = new frmProduct(BOIDEnum.Product);
                frmPro.MdiParent = this.MdiParent;
                frmPro.Show();
                break;

            case MenuID.PR_MDList:
                frmProductList frmProList = new frmProductList();
                frmProList.MdiParent = this.MdiParent;
                frmProList.Show();
                break;

            default: break;
            }
        }