Exemplo n.º 1
0
 void AssociatedObject_RequestTreeItems(object sender, TreeGridRequestTreeItemsEventArgs args)
 {
     if (args.ParentItem == null)
     {
         if (viewModel != null)
         {
             //get the root list - get all employees who have no boss
             args.ChildItems = viewModel.EmployeeList.Where(x => x.ReportsTo == -1); //get all employees whose boss's id is -1 (no boss)
         }
         else
         {
             args.ChildItems = (IEnumerable)fileExplorerViewModel.DriveDetails;
         }
     }
     else
     //if ParentItem not null, then set args.ChildList to the child items for the given ParentItem.
     {   //get the children of the parent object
         if (viewModel != null)
         {
             EmployeeInfo emp = args.ParentItem as EmployeeInfo;
             if (emp != null)
             {
                 //get all employees that report to the parent employee
                 args.ChildItems = viewModel.GetReportees(emp.ID);
             }
         }
         else
         {
             FileInfoModel item = args.ParentItem as FileInfoModel;
             args.ChildItems = fileExplorerViewModel.GetChildFolderContent(item);
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileInfoModel"/> class.
        /// </summary>
        /// <param name="path">The path.</param>
        public FileInfoModel Infomodel(string path)
        {
            FileInfoModel model = new FileInfoModel();
            FileInfo      fi    = new FileInfo(path);

            model.FullName  = Path.GetFullPath(path);
            model.ShortName = Path.GetFileNameWithoutExtension(path);
            if (model.ShortName == "")
            {
                model.ShortName = path;
                model.FileType  = "Drive";
                System.IO.DriveInfo di = new System.IO.DriveInfo(path);
                model.TotalSize = (di.TotalSize / 1073741824).ToString();
                var freeSpace = (double.Parse(di.TotalFreeSpace.ToString()) / 1073741824);
                model.TotalFreeSpace     = (Math.Round(freeSpace, 1)).ToString();
                model.PercentofFreeSpace = 100 - ((double.Parse(model.TotalFreeSpace) / double.Parse(model.TotalSize)) * 100);
            }
            else
            {
                if ((fi.Attributes & FileAttributes.Directory) != 0)
                {
                    model.FileType = "Directory";
                }
                else
                {
                    model.Size     = fi.Length.ToString() + "Kb";
                    model.FileType = Path.GetExtension(path);
                }
            }
            model.DateModified = fi.LastWriteTime;
            model.DateAccessed = fi.LastAccessTime;
            model.DateCreated  = fi.CreationTime;
            model.Attributes   = fi.Attributes;
            return(model);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Used to get ChildFolder Content of Particular folder
        /// </summary>
        /// <param name="fileNodeItem"></param>
        /// <returns></returns>
        public List <FileInfoModel> GetChildFolderContent(FileInfoModel fileNodeItem)
        {
            List <FileInfoModel> children = new List <FileInfoModel>();

            string folder = fileNodeItem.FullName;

            try
            {
                FileInfo fi = new FileInfo(folder);
                if ((fi.Attributes & FileAttributes.Directory) != (FileAttributes)0)
                {
                    DirectoryInfo di = new DirectoryInfo(folder);
                    // Skip Recycle Bin, System Volume Information etc.
                    if (di.Parent != null && (di.Attributes & FileAttributes.Hidden) != (FileAttributes)0 ||
                        (int)di.Attributes == -1)
                    {
                        //skip...
                    }
                    else
                    {
                        foreach (string s2 in Directory.GetDirectories(folder))
                        {
                            FileInfo fi2 = new FileInfo(s2);
                            if ((fi2.Attributes & FileAttributes.Hidden) != (FileAttributes)0)
                            {
                                continue;
                            }
                            children.Add(Infomodel(s2));
                        }
                        foreach (string s2 in Directory.GetFiles(folder))
                        {
                            FileInfo fi2 = new FileInfo(s2);
                            if ((fi2.Attributes & FileAttributes.Hidden) != (FileAttributes)0)
                            {
                                continue;
                            }
                            children.Add(Infomodel(s2));
                        }
                    }
                }
            }
            catch { }
            return(children);
        }