private void button_refreshMasterDir_Click(object sender, EventArgs e) { Program.hbase.Render(); HDir old_selected_dir = masterdir_treeView1.SelectedNode?.Tag as HDir; TreeNode old_selected_node = null; this.SuspendLayout(); masterdir_treeView1.Nodes.Clear(); void fill(TreeNode node, HDir dir) { node.Tag = dir; foreach (HDir d in dir.dirs) { TreeNode n = new TreeNode(d.name); n.Tag = d; if (d == old_selected_dir) { old_selected_node = n; } node.Nodes.Add(n); fill(n, d); } } TreeNode rootnode = new TreeNode(@"\"); masterdir_treeView1.Nodes.Add(rootnode); fill(rootnode, Program.hbase.root); masterdir_treeView1.SelectedNode = (old_selected_node is null) ? rootnode : old_selected_node; UpdateMasterFileBox((old_selected_dir is null) ? Program.hbase.root : old_selected_dir); this.ResumeLayout(); }
internal void Render() { HDir hd_map = GetMasterRoot(); SnapDir sd = GetSnapshotRoot(); sd.RenderTo(hd_map); }
private void UpdateMasterFileBox(HDir dir) { this.SuspendLayout(); masterdir_listView1.Items.Clear(); foreach (HFile f in dir.files) { masterdir_listView1.Items.Add(f.name).Tag = f; } this.ResumeLayout(); }
public HDir SpawnSubdir(string name) { HDir newbie = new HDir(name) { parent = this, fullpath = this.fullpath + "\\" + name }; this.dirs.Add(newbie); return(newbie); }
internal void RenderTo(HDir hd) { foreach (SnapFile sf in files) { HFile hf = hd.GetFile(sf.name, true); hf.AddInstance(sf); } foreach (SnapDir subsd in dirs) { HDir subhd = hd.GetPath(subsd.name, true); subhd.AddScanned(subsd); subsd.RenderTo(subhd); } if (files.Count + dirs.Count > 0) { hd.AddScanned(this); } }
/** * <summary>Find <i>path</i> in a given folder. Note: search for "%:\FOO\BAR\BLAH" from anywhere, but preferably from Program.masterdir - but search for "BAR\BLAH" from inside "FOO".</summary> */ internal HDir GetPath(string path, bool allow_creation = false) { while (path.Substring(path.Length - 1) == "\\") { path = path.Substring(0, path.Length - 1); } string[] path_tokens = path.Split("\\".ToCharArray(), 2); string first_token = path_tokens[0]; if (first_token == "%:") { if (name != "%:") // this would be a request for the hydra root { return(Program.hbase.root.GetPath(path, allow_creation)); } if (path_tokens.Length == 1) { return(this); } // chop the %\ off the start and go from there. path_tokens = path_tokens[1].Split("\\".ToCharArray(), 2); first_token = path_tokens[0]; } HDir dir = this.FindHDir(first_token, allow_creation); if (dir == null) { throw new HDirNotFoundException(first_token, this.fullpath, path); } if (path_tokens.Length > 1) { string remainder = path_tokens[1]; return(dir.GetPath(remainder, allow_creation)); } else { return(dir); } }