Beispiel #1
0
 private void barbtnMnuItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     var nd = this.treeCtl1.FocusedNode;
     var pnd = nd.ParentNode == null ? nd : nd.ParentNode;
     var md = new MenuData
     {
         IsUsing = true,
         MenuGrpName = pnd.GetValue(0).ToString(),
         MenuItem = null
     };
     var md2 = new MenuData
     {
         IsUsing = true,
         MenuGrpName = pnd.GetValue(0).ToString(),
         MenuItem = new MenuItemData
         {
             IsUsing = true,
             MenuName = "新建菜单项",
             MenuClsName = string.Empty,
             MenuAsmName = string.Empty
         }
     };
     var tnd = pnd.Nodes.Add(new object[] { "新建菜单项", md2 });
     tnd.Tag = md2;
     this.treeCtl1.FocusedNode = tnd;
 }
Beispiel #2
0
 private void barbtnMnuGrp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
     var md = new MenuData {
         IsUsing = true,
         MenuGrpName = "新建菜单组",
         MenuItems = null
     };
     var nd = this.treeCtl1.Nodes.Add(new object[] { "新建菜单组", md });
     nd.Tag = md;
     this.treeCtl1.FocusedNode = nd;
 }
Beispiel #3
0
 private void btnCtl1_Click(object sender, EventArgs e)
 {
     var md = new MenuData {
         IsUsing = checkCtl1.Checked,
         MenuGrpName = "新建菜单组",
         MenuItem = null
     };
     var nd = this.treeCtl1.Nodes.Add(new object[] { "新建菜单组", md });
     nd.Tag = md;
     this.treeCtl1.FocusedNode = nd;
 }
Beispiel #4
0
 private void btnCtl2_Click(object sender, EventArgs e)
 {
     var nd = this.treeCtl1.FocusedNode;
     var pnd = nd.ParentNode == null ? nd : nd.ParentNode;
     var md2 = new MenuData {
         IsUsing = checkCtl1.Checked,
         MenuGrpName = pnd.GetValue(0).ToString(),
         MenuItem = new MenuItemData {
             IsUsing = checkCtl1.Checked,
             MenuName = "新建菜单项",
             MenuClsName = string.Empty,
             MenuAsmName = string.Empty
         }
     };
     var tnd = pnd.Nodes.Add(new object[] { "新建菜单项", md2 });
     tnd.Tag = md2;
     this.treeCtl1.FocusedNode = tnd;
 }
Beispiel #5
0
        private void LoadMenu()
        {
            this.navMenu.Groups.Clear();
            t_menu mnu;
            using (var db = new Database()) {
                mnu = db.FirstOrDefault<t_menu>("select * from t_menu");
                if (null == mnu || string.IsNullOrEmpty(mnu.MenuXml))
                    return;
            }
            XDocument xdoc = XDocument.Parse(mnu.MenuXml);
            foreach (XElement item in xdoc.Element("Menus").Elements()) {
                var md = new MenuData {
                    IsUsing = true,
                    MenuGrpName = item.Attribute("Name").Value,
                    MenuItem = null
                };
                //var td = treeCtl1.Nodes.Add(new object[] { item.Attribute("Name").Value, md });
                var gp = this.navMenu.Groups.Add();
                gp.Caption = item.Attribute("Name").Value;
                gp.Tag = md;
                CanAddMenuGrp(gp);
                foreach (XElement xd in item.Elements()) {
                    var mi = new MenuData {
                        IsUsing = true,
                        MenuGrpName = md.MenuGrpName,
                        MenuItem = new MenuItemData {
                            MenuAsmName = xd.Attribute("AsmName").Value,
                            MenuClsName = xd.Attribute("ClsName").Value,
                            MenuName = xd.Attribute("Name").Value,
                            IsUsing = string.Compare(true.ToString(), xd.Attribute("IsUsing").Value) == 0
                        }
                    };
                    var lnk = new DevExpress.XtraNavBar.NavBarItem(mi.MenuItem.MenuName);
                    gp.ItemLinks.Add(lnk);
                    lnk.Visible = CanAddLink(mi);
                    lnk.Tag = mi;
                }
            }

            //navMenu.Groups;
        }
Beispiel #6
0
 private bool CanAddLink(MenuData lnkmd)
 {
     if ("admin".EqualIgnorCase(CurUser))
         return true;
     if (MCD == null)
         return false;
     return MCD.Where(k => k.ClsName == lnkmd.MenuItem.MenuClsName && k.ModName == lnkmd.MenuItem.MenuAsmName
         && k.IsEnabled).Count() > 0;
 }
Beispiel #7
0
        private void LoadNewMenu(List<UltraDbEntity.T_ERP_MenuNew> newmenus)
        {
            var mns = newmenus.Select(k => new MenuData {
                IsUsing = k.IsUsing,
                MenuGrpName = k.MenuGrpName,
                MenuItem = new MenuItemData {
                    MenuAsmName = k.MenuAsmName,
                    MenuName = k.MenuName,
                    MenuClsName = k.MenuClsName,
                    IsUsing = k.IsUsing
                }
            }).ToList();

            var grpname = string.Empty;
            TreeListNode td = null;
            mns.ForEach(smd => {
                if (string.IsNullOrEmpty(grpname) || !grpname.Equals(smd.MenuGrpName)) {
                    grpname = smd.MenuGrpName;
                    var md = new MenuData {
                        IsUsing = true,
                        MenuGrpName = smd.MenuGrpName,
                        MenuItem = null
                    };
                    td = treeCtl1.Nodes.Add(new object[] { md.MenuGrpName, md });
                }
                var tsd = td.Nodes.Add(new object[] {
                        smd.MenuItem.MenuName,smd
                    });
                tsd.Tag = smd;
            });
        }
Beispiel #8
0
 private void ExtractMenu(string xml)
 {
     if (string.IsNullOrEmpty(xml)) return;
     XDocument xdoc = XDocument.Parse(xml);
     foreach (XElement item in xdoc.Element("Menus").Elements()) {
         var md = new MenuData {
             IsUsing = true,
             MenuGrpName = item.Attribute("Name").Value,
             MenuItem = null
         };
         var td = treeCtl1.Nodes.Add(new object[] { item.Attribute("Name").Value, md });
         td.Tag = md;
         foreach (XElement xd in item.Elements()) {
             var mi = new MenuData {
                 IsUsing = string.Compare(xd.Attribute("IsUsing").Value, "true", true) == 0,
                 MenuGrpName = md.MenuGrpName,
                 MenuItem = new MenuItemData {
                     MenuAsmName = xd.Attribute("AsmName").Value,
                     MenuClsName = xd.Attribute("ClsName").Value,
                     MenuName = xd.Attribute("Name").Value,
                     IsUsing = string.Compare(true.ToString(), xd.Attribute("IsUsing").Value) == 0
                 }
             };
             var tsd = td.Nodes.Add(new object[] {
                 mi.MenuItem.MenuName,mi
             });
             tsd.Tag = mi;
         }
     }
 }