private void reloadToolStripMenuItem_Click(object sender, EventArgs e) { if (filesView.FocusedItem != null) { FB2File fc = filesView.FocusedItem.Tag as FB2File; fc.Reload(); UpdateItem(filesView.FocusedItem); } }
private void windows1251ToolStripMenuItem_Click(object sender, EventArgs e) { Encoding enc = (sender as ToolStripMenuItem).Tag as Encoding; if (MessageBox.Show(String.Format(Properties.Resources.ConfirmationRecode, SelectedCount, enc.EncodingName), 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; if (fc.BookEncoding == enc.EncodingName) { string message = String.Format(Properties.Resources.ProgressEncodingAlreadyEncoded, fc.FileInformation.Name, enc.EncodingName); AddMessageRN(message); } else { string olfFileSize = fc.BookSizeText; string message = String.Format(Properties.Resources.ProgressEncoding, fc.FileInformation.Name, enc.EncodingName); AddMessage(message); try { fc.EncodeTo(enc); AddMessageRN(String.Format(Properties.Resources.ProgressFileSizeChange, olfFileSize, fc.BookSizeText)); } catch (Exception ex) { message = String.Format(Properties.Resources.ProgressEncodingError, fc.FileInformation.Name, ex.Message); AddErrorRN(message); fc.Reload(); } UpdateItem(item); } if (CheckCancel()) { break; } } UpdateStatus(); InProgress = false; } }
private void ExecuteCommand(ListViewItem item, CommandElement command) { string commandString = String.Empty; try { FB2File fc = item.Tag as FB2File; if (!String.IsNullOrEmpty(command.OnlyWithExtension)) { if (!fc.FileInformation.FullName.ToLowerInvariant().EndsWith(command.OnlyWithExtension.ToLowerInvariant())) { AddMessageRN(String.Format(Properties.Resources.ExecuteCommandWrongExtension, fc.FileInformation.FullName, command.OnlyWithExtension)); return; } } ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = command.CreateNoWindow; startInfo.FileName = command.FileName; startInfo.UseShellExecute = false; commandString = String.Format(command.Arguments, fc.FileInformation.FullName); startInfo.Arguments = commandString; AddMessageRN(String.Format(Properties.Resources.ExecuteCommand, command.FileName, commandString)); using (Process exeProcess = Process.Start(startInfo)) { if (command.WaitAndReload) { exeProcess.WaitForExit(); fc.Reload(); UpdateItem(item); } } } catch (Exception ex) { AddMessageRN(String.Format(Properties.Resources.ExecuteCommandError, command.FileName, ex.Message)); } }