public void ShowFolder(DossierFolderInfo folder, int depth = 0, GroupMode mode = GroupMode.None) { this.BeginUpdate(); this.Items.Clear(); this.Groups.Clear(); InitGroups(mode); this.Items.Add(GetFolderItem(folder, mode, true)); List <ListViewItem> sort = new List <ListViewItem>(); foreach (DossierFileInfo file in folder.Files) { sort.Add(GetFileItem(file, mode)); } int recurse = (depth == -1 ? int.MaxValue : depth); if (recurse > 0) { foreach (DossierFolderInfo sub in folder.Folders) { this.Items.Add(GetFolderItem(sub, mode)); sort.AddRange(GetFileItems(sub, recurse - 1, mode)); } } this.Items.AddRange(sort.OrderBy(i => i.Text).ToArray()); this.EndUpdate(); }
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(); }
protected List <ListViewItem> GetFileItems(DossierFolderInfo folder, int recurse, GroupMode mode) { List <ListViewItem> items = new List <ListViewItem>(); foreach (DossierFileInfo file in folder.Files) { items.Add(GetFileItem(file, mode)); } if (recurse > 1) { foreach (DossierFolderInfo sub in folder.Folders) { items.AddRange(GetFileItems(sub, recurse - 1, mode)); } } return(items); }
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); }
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); }
private void tree_AfterSelect(object sender, TreeViewEventArgs e) { _folder = (DossierFolderInfo)tree.SelectedNode.Tag; RefreshView(); }