private void OnLoaded(object sender, RoutedEventArgs e) { var tempData = TempDataSaver.Load(); if (tempData is null) { tempData = new TempData { LatestDownloadPath = DownloadDirectoryTextBox.Text, LatestDownloadUri = EpisodeUrlTextBox.Text }; TempDataSaver.Save(tempData); } DownloadDirectoryTextBox.Text = tempData.LatestDownloadPath; EpisodeUrlTextBox.Text = tempData.LatestDownloadUri; }
private void CheckEpisodesButton_OnClick(object sender, RoutedEventArgs e) { LoadingBar.Visibility = Visibility.Visible; var episodeUrl = EpisodeUrlTextBox.Text; if (!Uri.TryCreate(episodeUrl, UriKind.Absolute, out var uri)) { MessageBox.Show("Episode link is invalid.", "Error", MessageBoxButton.OK); return; } var downloadDirectory = DownloadDirectoryTextBox.Text; if (string.IsNullOrWhiteSpace(downloadDirectory)) { MessageBox.Show("Download directory is invalid.", "Error", MessageBoxButton.OK); return; } var tempData = new TempData { LatestDownloadPath = DownloadDirectoryTextBox.Text, LatestDownloadUri = EpisodeUrlTextBox.Text }; TempDataSaver.Save(tempData); var factory = new DownloaderFactory(); var downloaderConfig = new DownloaderConfig { ShouldDownloadFillers = DownloadFillersCheckbox.IsChecked.Value, Checkpoint = new JsonCheckpoint(), DownloadDirectory = downloadDirectory, }; var downloader = factory.GetDownloaderForSite(uri, downloaderConfig); if (downloader == null) { MessageBox.Show($"Site:\n {uri} not supported yet.", "Site not supported", MessageBoxButton.OK, MessageBoxImage.Error); return; } LoadingBar.Visibility = Visibility.Collapsed; this.Content = new DownloadUserControl(downloader); }