private async void btnConvert_Click(object sender, EventArgs e) { if (!Directory.Exists(Settings.OutputDirectory)) { btnSaveTo_Click(sender, e); } if (!Directory.Exists(Settings.OutputDirectory)) { return; } btnAbort.Enabled = true; btnConvert.Enabled = false; this.AcceptButton = btnAbort; panelTop.Enabled = false; var progress = new Progress <ProgressMessage> (_progress.Update); var callback = new InteractionCallback <InteractionMessage, bool?> (_interactionHandler.Interact); foreach (var lvi in listViewAaxFiles.SelectedItems) { (lvi as ListViewItem).ImageIndex = 0; } var fileitems = _fileItems .Where(x => listViewAaxFiles.SelectedItems .Contains(x.ListViewItem)) .Select(x => x.FileItem) .OrderBy(x => x.BookTitle) .ToList(); var cursor = this.Cursor; this.Cursor = Cursors.AppStarting; _progress.Reset(); _cts = new CancellationTokenSource(); Log(1, this, () => $"#files={fileitems.Count}"); try { await _converter.ConvertAsync(fileitems, _cts.Token, progress, callback); } catch (OperationCanceledException) { } if (_closing) { return; } _cts.Dispose(); _cts = null; this.Cursor = cursor; var converted = fileitems.Where(x => x.Converted); var lvis = _fileItems.Where(x => converted.Contains(x.FileItem)).Select(x => x.ListViewItem); foreach (var lvi in lvis) { lvi.ImageIndex = 1; } this.AcceptButton = null; panelTop.Enabled = true; btnAbort.Enabled = false; listViewAaxFiles.Select(); int cnt = converted.Count(); bool fullSuccess = cnt == fileitems.Count; Log(1, this, () => $"#files={fileitems.Count}, #conv={cnt}"); MessageBoxIcon mbIcon; string intro; if (cnt == 0) { intro = R.MsgAborted; mbIcon = MessageBoxIcon.Stop; } else if (cnt != fileitems.Count) { intro = R.MsgSomeDone; mbIcon = MessageBoxIcon.Warning; } else { intro = R.MsgAllDone; mbIcon = MessageBoxIcon.Information; } MsgBox.Show(this, $"{intro}. {converted.Count()} {(cnt == 1 ? R.file : R.files)} {R.MsgConverted}.", this.Text, MessageBoxButtons.OK, mbIcon); _progress.Reset(); if (fullSuccess) { autoplay(); } }