private void copyToToolStripMenuItem_Click(object sender, EventArgs e) { OverwriteDialog.Reset(); RenameProfileElement pe = (sender as ToolStripMenuItem).Tag as RenameProfileElement; bool useTranslit = (sender as ToolStripMenuItem).Text.StartsWith(Properties.Resources.TranslitMenuText); if (pe != null) { folderBrowserDialog.SelectedPath = Properties.Settings.Default.DefaultCopyToPath; if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { InProgress = true; Properties.Settings.Default.DefaultCopyToPath = folderBrowserDialog.SelectedPath; Properties.Settings.Default.Save(); foreach (ListViewItem item in filesView.CheckedItems) { FB2File fc = item.Tag as FB2File; string oldName = fc.FileInformation.FullName; try { var processed = fc.CopyTo(folderBrowserDialog.SelectedPath, pe, useTranslit); if (!processed.Skipped) { LoadedFileIDs.Remove(oldName); if (!LoadedFileIDs.ContainsKey(fc.FileInformation.FullName)) { LoadedFileIDs.Add(fc.FileInformation.FullName, string.Empty); } AddMessageRN(String.Format(Properties.Resources.CopyFileSuccess, oldName, fc.FileInformation.FullName)); } else { AddErrorRN(String.Format(Properties.Resources.CopyFileSkipped, oldName, processed.NewFullName)); } } catch (Exception ex) { AddErrorRN(String.Format(Properties.Resources.CopyFileError, oldName, ex.Message)); } UpdateItem(item); if (CheckCancel()) { break; } } InProgress = false; } } }
private void renameToToolStripMenuItem_Click(object sender, EventArgs e) { OverwriteDialog.Reset(); RenameProfileElement pe = (sender as ToolStripMenuItem).Tag as RenameProfileElement; bool useTranslit = (sender as ToolStripMenuItem).Text.StartsWith(Properties.Resources.TranslitMenuText); if (pe != null) { if (MessageBox.Show(String.Format(Properties.Resources.ConfirmationRename, SelectedCount, pe.Name), Properties.Resources.ConfirmationCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { InProgress = true; foreach (ListViewItem item in filesView.CheckedItems) { FB2File fc = item.Tag as FB2File; string oldName = fc.FileInformation.Name; string oldFullName = fc.FileInformation.FullName; try { var processed = fc.RenameTo(pe, useTranslit); if (!processed.Skipped) { LoadedFileIDs.Remove(oldFullName); if (!LoadedFileIDs.ContainsKey(fc.FileInformation.FullName)) { LoadedFileIDs.Add(fc.FileInformation.FullName, string.Empty); } AddMessageRN(String.Format(Properties.Resources.RenameFileSuccess, oldName, fc.FileInformation.Name)); } else { AddErrorRN(String.Format(Properties.Resources.RenameFileSkip, oldName, processed.NewFullName)); } } catch (Exception ex) { AddErrorRN(String.Format(Properties.Resources.RenameFileError, fc.FileInformation.FullName, ex.Message)); } UpdateItem(item); if (CheckCancel()) { break; } } InProgress = false; } } }