private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) { ItemsViewer ParentForm = (ItemsViewer)this.Parent.Parent.Parent; ItemsTree itemsTree = (ItemsTree)ParentForm.Controls.Find("itemsTree1", true).GetValue(0); if (e.Button == MouseButtons.Left) { ListView lv = (ListView)sender; int idx = lv.SelectedIndices[0]; if (idx < 0 || idx > lv.Items.Count - 1) { return; } if (lv.Items[0].Text == "[...]") { if (idx == 0) { LoadDirectory((string)lv.Items[0].Name); } else { idx -= 1; items[idx].OnClick(lv, LoadDirectory); } } else { items[idx].OnClick(lv, LoadDirectory); } } }
private void fileSystemWatcher1_Deleted(object sender, FileSystemEventArgs e) { ItemsTree itemsTree = (ItemsTree)ParentForm.Controls.Find("itemsTree1", true).GetValue(0); itemsTree.Remove(e.FullPath); this.ReloadItems(); }
public void LoadDirectory(string Path) { //Kiem tra su thay doi ve cac item trong duong dan ItemsViewer ParentForm = (ItemsViewer)this.Parent.Parent.Parent; if (Path != "") { fileSystemWatcher1.Path = Path.Substring(0, 3); if (new DirectoryInfo(Path).Exists == false) { //LoadDirectory( Path.Substring(0, 3)); ParentForm.history.CancelNextAdd(); ParentForm.history.CancelFowardClear(); string tempPath = Path.Split(new string[] { "\\" }, StringSplitOptions.None)[0] + "\\"; for (int i = 1; i < Path.Split(new string[] { "\\" }, StringSplitOptions.None).Length - 2; i++) { tempPath += ParentForm.StrCurrentPath.Split(new string[] { "\\" }, StringSplitOptions.None)[i] + "\\"; } LoadDirectory(tempPath); return; } } ItemsTree itemsTree = (ItemsTree)ParentForm.Controls.Find("itemsTree1", true).GetValue(0); listView1.Items.Clear(); PopulateItems(listView1, Path); ParentForm.history.InsertDirectoryToListBack(ParentForm.StrCurrentPath); ParentForm.SelectDriveFromDirectory(Path); itemsTree.SelectNodeFormDirectory(Path); ParentForm.StrCurrentPath = Path; ParentForm.SetAddressLabel(Path); selectedItems.Clear(); UpdateItemsCount(); }
private void fileSystemWatcher1_Created(object sender, FileSystemEventArgs e) { try { if (File.GetAttributes(e.FullPath).HasFlag(FileAttributes.Directory)) { ItemsTree itemsTree = (ItemsTree)Parent.Parent.Parent.Controls[0].Controls[0].Controls.Find("itemsTree1", true).GetValue(0); itemsTree.CreatedNode(e.FullPath); } this.ReloadItems(); } catch { } }
private void fileSystemWatcher1_Renamed(object sender, RenamedEventArgs e) { ItemsTree itemsTree = (ItemsTree)ParentForm.Controls.Find("itemsTree1", true).GetValue(0); itemsTree.Renamed(e.OldFullPath, e.FullPath, e.OldName, e.Name); //if (((UserControl1)this.Parent.Parent.Parent).StrCurrentPath != "") //{ // if (new DirectoryInfo(((UserControl1)this.Parent.Parent.Parent).StrCurrentPath).Exists == true) // this.ReloadItems(); // else // this.LoadDirectory(((UserControl1)this.Parent.Parent.Parent).StrCurrentPath.Substring(0, 3)); //} this.ReloadItems(); }