Example #1
0
        public void BuildTreeView(DossierRootInfo root)
        {
            _root   = root;
            _folder = (DossierFolderInfo)root;

            tree.BeginUpdate();
            tree.Nodes.Clear();

            TreeNode start = new TreeNode();

            start.Tag        = root;
            start.Text       = root.Name;
            start.ImageIndex = 0;
            if (root.ReportRecursive.GrandTotal.TotalSize > Dossier.GetUnitBytes(SizeDisplayUnits.GB))
            {
                start.Text += " @ " + Dossier.BytesDisplayText(root.ReportRecursive.GrandTotal.TotalSize, SizeDisplayUnits.GB);
            }
            tree.Nodes.Add(start);

            BuildTreeNode(start.Nodes, root.Folders);

            tree.SelectedNode = start;

            tree.EndUpdate();
        }
Example #2
0
        private void background_DoWork(object sender, DoWorkEventArgs e)
        {
            DateTime start = DateTime.Now;
            string   type  = e.Argument.ToString().ToLowerInvariant();

            switch (type)
            {
            case "loaddirectory":
                string query = txtQuery.Text.Trim();
                background.ReportProgress(0, "Open: " + query);
                _results = DossierStream.Dir(query, _events);
                background.ReportProgress(2, "Count: " + _results.Count().ToString());
                if (_results.Count() > 0)
                {
                    DossierRootInfo root = (DossierRootInfo)_results[0];
                    background.ReportProgress(3, "Size: " + Dossier.BytesDisplayText(root.ReportRecursive.GrandTotal.TotalSize));
                }
                break;

            case "createmd5":
            case "verifymd5":
                background.ReportProgress(0, "Start: " + _root.FullPath);
                IEnumerable <DossierFileInfo> all = _root.GetAllFiles().OrderBy(f => f.FullPath);
                int total = all.Count();

                background.ReportProgress(0, "Total: " + total.ToString());
                int count = 0;
                foreach (DossierFileInfo file in all)
                {
                    background.ReportProgress(100 * count / total, "Hash: " + file.FullPath + " @ " + Dossier.BytesDisplayText(file.Size));
                    Guid hash = Dossier.CalculateMd5(file.FullPath);
                    if (type == "createmd5")
                    {
                        file.Hash = hash;
                    }
                    else if (file.Hash != hash)
                    {
                        background.ReportProgress(100 * count / total, "CORRUPT: " + file.FullPath);
                        break;
                    }
                    file.IsVerified = file.Hash == hash;
                    count++;
                }
                break;
            }

            DateTime stop = DateTime.Now;
            TimeSpan time = new TimeSpan(stop.Ticks - start.Ticks);

            background.ReportProgress(100, String.Format("DONE: {0}:{1:00}", time.Minutes, time.Seconds));
        }
Example #3
0
 public void BuildTreeNode(TreeNodeCollection nodes, List <DossierFolderInfo> folders)
 {
     if (folders == null)
     {
         return;
     }
     foreach (DossierFolderInfo folder in folders)
     {
         TreeNode node = new TreeNode();
         node.Tag        = folder;
         node.Text       = folder.Name;
         node.ImageIndex = 1;
         if (folder.ReportRecursive.GrandTotal.TotalSize > Dossier.GetUnitBytes(SizeDisplayUnits.GB))
         {
             node.Text += " @ " + Dossier.BytesDisplayText(folder.ReportRecursive.GrandTotal.TotalSize, SizeDisplayUnits.GB);
         }
         nodes.Add(node);
         BuildTreeNode(node.Nodes, folder.Folders);
     }
 }
Example #4
0
        protected ListViewItem GetFolderItem(DossierFolderInfo folder, GroupMode mode, bool root = false)
        {
            ListViewItem item = new ListViewItem();

            item.Text = root ? folder.FullPath : folder.Name;
            item.Tag  = folder;

            if (this.View == View.Details)
            {
                item.SubItems.Add("Folder");
                item.SubItems.Add(Dossier.BytesDisplayText(root ? folder.ReportRecursive.GrandTotal.TotalSize : folder.Report.GrandTotal.TotalSize));
            }

            if (mode == GroupMode.Type || mode == GroupMode.Folder)
            {
                item.Group = GetGroup("Folders");
            }

            item.ImageKey  = root ? "open" : "closed";
            item.ForeColor = Color.White;
            item.BackColor = root ? Color.Black : Color.Gray;
            return(item);
        }
Example #5
0
        protected ListViewItem GetFileItem(DossierFileInfo file, GroupMode mode)
        {
            ListViewItem item = new ListViewItem();

            item.Text = file.Name;
            item.Tag  = file;

            if (file.IsSystem)
            {
                item.ForeColor = Color.Red;
            }
            else if (file.IsHidden)
            {
                item.ForeColor = Color.DarkGray;
            }
            else if (file.IsEncrypted)
            {
                item.ForeColor = Color.Green;
            }
            else if (file.IsCompressed)
            {
                item.ForeColor = Color.Blue;
            }

            if (file.IsVerified)
            {
                item.BackColor = Color.Honeydew;
            }
            else if (file.Hash != Guid.Empty)
            {
                item.BackColor = Color.LemonChiffon;
            }

            item.ImageKey = file.Type.ToString();

            if (this.View == View.Details)
            {
                item.SubItems.Add(file.Type.ToString());
                item.SubItems.Add(Dossier.BytesDisplayText(file.Size));
                item.SubItems.Add(file.DisplayDate);
            }

            if (mode == GroupMode.Folder)
            {
                DossierFolderInfo root = (DossierFolderInfo)this.Items[0].Tag;
                int length             = file.Parent.FullPath.Length;
                if (length > root.FullPath.Length)
                {
                    length = root.FullPath.Length + 1;
                }
                item.Group = this.GetGroup(file.Parent.FullPath.Substring(length));
            }
            else if (mode == GroupMode.Type)
            {
                if (file.Type == DossierTypes.Text)
                {
                    item.Group = this.GetGroup(DossierTypes.Text.ToString());
                }
                else if (file.Type == DossierTypes.Audio)
                {
                    item.Group = this.GetGroup(DossierTypes.Audio.ToString());
                }
                else if (file.Type == DossierTypes.Image)
                {
                    item.Group = this.GetGroup(DossierTypes.Image.ToString());
                }
                else if (file.Type == DossierTypes.Video)
                {
                    item.Group = this.GetGroup(DossierTypes.Video.ToString());
                }
                else
                {
                    item.Group = this.GetGroup(DossierTypes.File.ToString());
                }
            }
            else
            {
                item.Group = null;
            }

            return(item);
        }
Example #6
0
        private void RefreshReport(ListBox list, DossierReport report)
        {
            list.BeginUpdate();
            list.Items.Clear();
            long totalCount = 0;
            long totalSize  = 0;

            foreach (DossierReportInfo info in report.GetTypeSummaryReport())
            {
                list.Items.Add(String.Format("{0:###,###,##0}\t{1}\t{2}", info.TotalCount, info.Extension, Dossier.BytesDisplayText(info.TotalSize)));
                totalCount += info.TotalCount;
                totalSize  += info.TotalSize;
            }
            list.EndUpdate();
        }