示例#1
0
 private void SearchMenu(ModuleTreeItem module, string txt)
 {
     if (module.Children != null)
     {
         module.Children.ForEach(m =>
         {
             SearchMenu(m, txt);
         });
     }
     else
     {
         if (module.Module.Name.Contains(txt))
         {
             _qsModuleTreeItems.Add(new QSModuleTreeItem
             {
                 Icon   = module.Icon,
                 Module = module.Module,
                 Tip    = GetAncestorPath(module.Module) + module.Module.Name
             });
         }
     }
 }
示例#2
0
        /// <summary>
        /// 递归构造菜单树节点
        /// </summary>
        private static ModuleTreeItem ApplyChildrenForModule(SysModule module, List <SysModule> modules)
        {
            ModuleTreeItem treeItem = new ModuleTreeItem();

            treeItem.Module = module;
            var children = modules.FindAll(m => m.ParentCode == module.Code);

            if (children.Count > 0)
            {
                var moduleTreeItems = new List <ModuleTreeItem>();
                children.ForEach(m =>
                {
                    moduleTreeItems.Add(ApplyChildrenForModule(m, modules));
                });
                treeItem.Children = moduleTreeItems;
            }
            //下句在xaml中可用,在后台代码中不能定位,另外需要注意相对路径的深度不要搞错
            //treeItem.Icon = "../Images/Menu/" + SetMenuIcon(treeItem.Module.Name);
            //下句更具通用性,在后台代码和xaml中都可用,且没有相对路径的深度麻烦
            treeItem.Icon = @"pack://application:,,,/HabilimentERP;component/Images/Menu/" + SetMenuIcon(treeItem.Module.Name);
            return(treeItem);
        }