public void AddFileFileListView(string newFile, FileInfo file) { ViewList mydata = new ViewList(); mydata.FillFile(file); ListViewItem item = AddFoldresListView(new DirectoryInfo(file.FullName), mydata); this.LVInfo.Items.Add(item); if (newFile != null) { if (file.FullName == newFile) { item.IsSelected = true; } } }
/// <summary> /// method for add item dir ListView /// </summary> /// <param name="newFile"></param> /// <param name="dir"></param> public void AddDirectoryFillListView(string newFile, DirectoryInfo dir) { ViewList mydata = new ViewList(); mydata.FillDirectory(dir, dir.Name, @"pack://application:,,,/Resources/icons8-folder-invoices-16.png"); ListViewItem item = AddFoldresListView(new DirectoryInfo(dir.FullName), mydata); this.LVInfo.Items.Add(item); this.TestSelected(item, dir); if (newFile != null) { if (dir.FullName == newFile) { item.IsSelected = true; } } }
/// <summary> /// method for add search dir /// </summary> /// <param name="dir"></param> private void AddSearchDir(DirectoryInfo dir) { this.Dispatcher.Invoke(new Action(() => { ListViewItem item = null; if (this.indexView == 1) { item = AddListViewListFolder <DirectoryInfo>(dir, @"pack://*****:*****@"pack://application:,,,/Resources\icons8-folder-invoices-16.png"); item = AddFoldresListView(new DirectoryInfo(dir.FullName), mydata); } this.LVInfo.Items.Insert(0, item); this.lstSearchDir.Add((DirectoryInfo)item.Tag); this.countElement++; this.lbElemet.Content = string.Format("Elements: {0}", this.countElement.ToString()); })); }
/// <summary> /// method for active seclected root TreeView /// </summary> /// <param name="root"></param> private void SelectedTreeView(TreeViewItem root) { this.LVInfo.IsEnabled = true; this.search.IsEnabled = true; this.btnFile.IsEnabled = true; try { if (root.IsSelected) { this.btnFile.IsEnabled = false; this.search.IsEnabled = false; this.MenuDelete.Visibility = Visibility.Collapsed; this.MenuCriate.Visibility = Visibility.Collapsed; this.MenuRename.Visibility = Visibility.Collapsed; this.LVInfo.Items.Clear(); foreach (var info in this.specFolders.GetSpecFoldersMyComp) { ListViewItem item = null; string Name = info.Path.Remove(0, info.Path.LastIndexOf('\\') + 1); if (this.indexView == 0) { ViewList mydata = new ViewList(); mydata.FillDirectory(new DirectoryInfo(info.Path), Name, info.PathImage); item = this.AddFoldresListView(new DirectoryInfo(info.Path), mydata); } else if (this.indexView == 1) { item = this.AddListViewListFolder <DirectoryInfo>(new DirectoryInfo(info.Path), info.PathImage, Name); } else if (this.indexView == 2) { } this.LVInfo.Items.Add(item); this.TestSelected(item, new DirectoryInfo(info.Path)); } foreach (var drive in DriveInfo.GetDrives()) { ListViewItem item = null; if (this.indexView == 0) { ViewList mydata = new ViewList(); mydata.FillDrive(drive, @"pack://*****:*****@"pack://application:,,,/Resources/icons8-hdd-16.png", drive.Name); } this.LVInfo.Items.Add(item); this.TestSelected(item, new DirectoryInfo(drive.Name)); } this.MenuCopy.Visibility = Visibility.Collapsed; } else { this.TVRoot_SelectedItemChanged(); this.MenuCriate.Visibility = Visibility.Visible; this.MenuRename.Visibility = Visibility.Visible; } } catch (Exception ex) { } }