private async void SourceButton_Click(object sender, EventArgs e) { chapterDataTextBox.Text = "00:00:00.000 Title"; newNameTextBox.Text = ""; OpenFileDialog openFileDialog1 = new() { InitialDirectory = @"V:\", Title = "Browse Video Files", CheckFileExists = true, CheckPathExists = true, DefaultExt = "mp4", Filter = "mp4 video files (*.mp4)|*.mp4|All files (*.*)|*.*", FilterIndex = 1, RestoreDirectory = true, ReadOnlyChecked = true, ShowReadOnly = true }; if (openFileDialog1.ShowDialog() == DialogResult.OK) { var filepath = openFileDialog1.FileName; sourceFileTextBox.Text = filepath; var folder = Path.GetDirectoryName(filepath); var filename = Path.GetFileNameWithoutExtension(filepath); if (CurrentDestinationPath == InitialDestinationPath) { CurrentDestinationPath = folder; destinationFolderTextBox.Text = folder; } newNameTextBox.Text = filename; try { SourceAvailable = false; DisableButtons(); var chapterDataTask = DraxHelpers.GetChapterData(filepath); var chapterData = await chapterDataTask; if (!string.IsNullOrWhiteSpace(chapterData)) { chapterDataTextBox.Text = chapterData; } EnableButtons(); SourceAvailable = true; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } } }
private async void SaveButton_Click(object sender, EventArgs e) { var sourcePath = sourceFileTextBox.Text; var chapterData = chapterDataTextBox.Text; try { var task = DraxHelpers.SetChapterData(sourcePath, chapterData); SetChapterDataTasks.Enqueue(task); var result = await task; } catch (Exception ex) { MessageBox.Show(ex.Message); } }