private void fillMenu(List <SystemProgram> allPrograms, SystemProgram program)
 {
     string[] childIdList = program.Children.Select(x => x.RecordId).ToArray();
     program.Children.AddRange(allPrograms.Where(x => x.ParentId == program.RecordId && !childIdList.Contains(x.RecordId)));
     foreach (SystemProgram child in program.Children)
     {
         fillMenu(allPrograms, child);
     }
 }
Beispiel #2
0
        public override void Assign(BaseProgram other)
        {
            base.Assign(other);
            if (!(other is SystemProgram))
            {
                return;
            }

            SystemProgram program = other as SystemProgram;

            this.ProgramPrivilegeId = program.Privielges.Where(x => x.PrivilegeCode == ProgramPrivilege.PRIVILEGE_RUN).Single().RecordId;

            this.Children = new ProgramWithPrivilgeViewModel[program.Children.Count];
            this.DataType = "app.model.admin.SystemMenuTreeModel";

            for (int i = 0; i < this.Children.Length; i++)
            {
                ProgramWithPrivilgeViewModel childMenu = new ProgramWithPrivilgeViewModel();
                SystemProgram childProgram             = program.Children[i];
                childMenu.Assign(childProgram);
                this.Children[i] = childMenu;
            }

            if (this.Children.Length == 0)
            {
                this.Children = (from item in program.Privielges
                                 where item.PrivilegeCode != ProgramPrivilege.PRIVILEGE_RUN
                                 select new
                {
                    item.RecordId,
                    item.ProgramId,
                    item.PrivilegeCode,
                    item.PrivilegeName,
                    Checked = false,
                    DataType = "app.model.admin.ProgramPrivilegeModel"
                }).ToArray();
            }

            if (this.Children.Length > 0)
            {
                this.Expanded = true;
            }
        }
Beispiel #3
0
        public static IEnumerable <SystemProgram> GetStartMenu()
        {
            var userstartmenu   = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
            var commonstartmenu = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu);

            var user   = Directory.GetFiles(userstartmenu, "*.lnk", SearchOption.AllDirectories);
            var common = Directory.GetFiles(commonstartmenu, "*.lnk", SearchOption.AllDirectories);

            var programs = new List <SystemProgram>(user.Length + common.Length);

            foreach (var item in common)
            {
                var program = new SystemProgram
                {
                    Name = Path.GetFileNameWithoutExtension(item),
                    Path = item,
                    Icon = ExeIconExtractor.GetIcon(item)
                };
                programs.Add(program);
            }

            return(programs.OrderBy(p => p.Name));
        }
Beispiel #4
0
 public ProgramWithPrivilgeViewModel(SystemProgram program)
 {
     this.Assign(program);
 }