private void btnAddMany_Click(object sender, EventArgs e) { foreach (ListViewItem item in this.listViewFilePick.Items) { ListViewHelper.AddItem(this.listViewSelectedItems, ObjectType.File, Path.Combine(this.fullPath, item.Text)); } }
private void btnAddSingle_Click(object sender, EventArgs e) { if (this.listViewFilePick.SelectedItems.Count > 0) // selected files { foreach (ListViewItem item in this.listViewFilePick.SelectedItems) { ListViewHelper.AddItem(this.listViewSelectedItems, ObjectType.File, Path.Combine(this.fullPath, item.Text)); } } else // selected directory if (this.fullPath != Path.GetPathRoot(this.fullPath)) { ListViewHelper.AddItem(this.listViewSelectedItems, ObjectType.Directory, this.fullPath); } }
private void btnAddTree_Click(object sender, EventArgs e) { if (this.treeViewFolderPick.SelectedNode == null) { return; } DirectoryInfo dirInfo = new DirectoryInfo(this.fullPath); FileInfo[] filesInfo = dirInfo.GetFiles("*.*", SearchOption.AllDirectories); foreach (var fileInfo in filesInfo) { ListViewHelper.AddItem(this.listViewSelectedItems, ObjectType.File, fileInfo.FullName); } }
/// <summary> /// Previews changes on selected files according to the selected settings. /// </summary> private void PreviewWork() { try { var renameSettings = this.BuildRenameSettings(); var renameEngine = new RenameEngine(renameSettings); // get NamingRequest items var listViewItems = ListViewHelper.GetCollectionItems(this.listViewSelectedItems.Items); var namingRequests = listViewItems.Select(a => new NamingRequest((ObjectType)a.Tag, a.Text)).ToList(); // send the files/directories to calculate rename changes var namingResults = renameEngine.Preview(namingRequests); // refresh UI foreach (var namingResult in namingResults) { ListViewHelper.AddItem(this.listViewPreview, namingResult.ObjectType, namingResult.OldName, namingResult.NewName); } } catch (Exception ex) { this.statusStripLabelPreview.Text = ex.Message; } }