// Add new child. public void addNewChild(VDirs child) { if (child != null) { this.subdirs.Add(child); } }
public MoveFilesToDir(VDirs[] dirs, VDirs selected) { InitializeComponent(); comboBoxMoveToDir.Items.AddRange(dirs); comboBoxMoveToDir.SelectedItem = selected; }
public NewVDir(VDirs[] pathNames, VDirs vds) { InitializeComponent(); comboBoxMainDir.Items.AddRange(pathNames); comboBoxMainDir.SelectedItem = vds; }
public MoveVDirs(VDirs[] dirs, string moveDir) { InitializeComponent(); labelMoveableDir.Text = moveDir; comboBoxMoveInto.Items.AddRange(dirs); }
// Build up the Custom dirs. (children) private TreeNode[] generateCustomVDirsRecursive(VDirs actualPack) { if (actualPack != null) { TreeNode[] tn = new TreeNode[actualPack.Subdirs.Count]; int actIndex = 0; foreach (VDirs actualItem in actualPack.Subdirs) { TreeNode tnsub = new TreeNode(actualItem.Name, generateCustomVDirsRecursive(actualItem)); tnsub.Tag = actualItem; tn[actIndex] = tnsub; actIndex++; } return tn; } return null; }
// Returns a VDir tree from the db. public VDirs getVDirs() { VDirs returnVdir = new VDirs(-1, "root"); SQLiteCommand sqlc = new SQLiteCommand("SELECT * FROM vdirs WHERE parentdir_id IS NULL", dbConnection); SQLiteDataReader sqldr = sqlc.ExecuteReader(); while (sqldr.Read()) { returnVdir.addNewChild(getVDirsById(Convert.ToInt32(sqldr["id"]))); } return returnVdir; }
// Generate tree object in recursive mode. private VDirs recursiveBuildVDirs(ref List<VDirs> treeList, ref List<int> idEnd, int actualId) { int index = idEnd.FindIndex(a => a == actualId); if (treeList.Count == 0 || index > 0) { return null; } else { VDirs tmp = null; VDirs tmp2 = null; foreach (VDirs item in treeList) { if (item.ParentId == actualId) { tmp = new VDirs(item.Id, item.Name, item.ParentId); tmp2 = item; break; } } if (tmp2 != null) { treeList.Remove(tmp2); } if (tmp != null) { VDirs tmp3 = null; do { tmp3 = recursiveBuildVDirs(ref treeList, ref idEnd, tmp.Id); if (tmp3 != null) { tmp.addNewChild(tmp3); } } while (tmp3 != null); } return tmp; } }