private void btnQueue_Click(object sender, RoutedEventArgs e) { bool isValid = ValidateInput(); if (isValid) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "MP4 Files | *.mp4"; saveFileDialog.RestoreDirectory = true; if (saveFileDialog.ShowDialog() == true) { SetEnabled(false); DownloadOptions options = new DownloadOptions(); options.UpdateValues(this); options.filename = saveFileDialog.FileName; TaskVodDownload currentDownload = new TaskVodDownload(options); currentDownload.Preview = imgThumbnail.Source; ObservableCollection <ITwitchTask> taskList = ((MainWindow)Window.GetWindow(this)).taskList; taskList.Add(currentDownload); } } else { AppendLog("ERROR: Invalid Crop Inputs"); } }
private async void btnDownload_Click(object sender, RoutedEventArgs e) { bool isValid = ValidateInput(); if (isValid) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "MP4 Files | *.mp4"; saveFileDialog.RestoreDirectory = true; if (saveFileDialog.ShowDialog() == true) { SetEnabled(false); btnGetInfo.IsEnabled = false; DownloadOptions options = new DownloadOptions(); options.UpdateValues(this); options.filename = saveFileDialog.FileName; TaskVodDownload currentDownload = new TaskVodDownload(options); currentDownload.Preview = imgThumbnail.Source; Progress <ProgressReport> uploadProgress = new Progress <ProgressReport>(OnProgressChanged); SetImage("Images/ppOverheat.gif", true); statusMessage.Text = "Downloading"; try { await Task.Run(() => currentDownload.runTask(uploadProgress)); statusMessage.Text = "Done"; SetImage("Images/ppHop.gif", true); } catch (Exception ex) { statusMessage.Text = "ERROR"; SetImage("Images/peepoSad.png", false); AppendLog("ERROR: " + ex.Message); } /* * BackgroundWorker backgroundDownloadManager = new BackgroundWorker(); * backgroundDownloadManager.WorkerReportsProgress = true; * backgroundDownloadManager.DoWork += BackgroundDownloadManager_DoWork; * backgroundDownloadManager.ProgressChanged += BackgroundDownloadManager_ProgressChanged; * backgroundDownloadManager.RunWorkerCompleted += BackgroundDownloadManager_RunWorkerCompleted; */ } } else { AppendLog("ERROR: Invalid Crop Inputs"); } }