/// <summary> /// Handles the Click event of the searchButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void SearchButtonOnClick(object sender, RoutedEventArgs e) { if (!_loaded || _sidx == database.SelectedIndex) { return; } database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = false; Guide guide; switch (database.SelectedIndex) { case 1: guide = new TVRage(); break; case 2: guide = new TVDB(); break; case 3: guide = new TVcom(); break; case 4: guide = new EPisodeWorld(); break; case 5: guide = new IMDb(); break; case 6: guide = new AniDB(); break; case 7: guide = new AnimeNewsNetwork(); break; case 9: guide = new EPGuides(); break; case 10: guide = new EPGuides(); break; default: database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true; return; } new ShowGuideTaskDialog().Search(guide, nameTextBox.Text, (language.SelectedItem as StackPanel).Tag as string, (id, title, lang) => { if (id == null) { Dispatcher.Invoke((Action)(() => { switch (Database.TVShows[_id].Source) { case "TVRage": database.SelectedIndex = 1; break; case "TVDB": database.SelectedIndex = 2; break; case "TVcom": database.SelectedIndex = 3; break; case "EPisodeWorld": database.SelectedIndex = 4; break; case "IMDb": database.SelectedIndex = 5; break; case "AniDB": database.SelectedIndex = 6; break; case "AnimeNewsNetwork": database.SelectedIndex = 7; break; case "EPGuides": database.SelectedIndex = 10; break; } database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true; })); TaskDialog.Show(new TaskDialogOptions { MainIcon = VistaTaskDialogIcon.Error, Title = "Not found", MainInstruction = _show, Content = "The currently set show title was not found on the selected guide.\r\nYour selection will be reverted. Try editing the official title.", CustomButtons = new[] { "OK" } }); } else { _newSource = guide.GetType().Name; _newSID = id; _newLang = lang; _change = _upReq = true; Dispatcher.Invoke((Action)(() => { nameTextBox.Text = title; _sidx = database.SelectedIndex; database.IsEnabled = language.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true; })); TaskDialog.Show(new TaskDialogOptions { MainIcon = VistaTaskDialogIcon.Information, Title = "Modified", MainInstruction = _show, Content = "The guide was successfully changed!\r\nAn update will be initiated to this TV show after you click Save.", CustomButtons = new[] { "OK" } }); } }); }
/// <summary> /// Handles the OnSelectionChanged event of the database control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void DatabaseOnSelectionChanged(object sender, RoutedEventArgs e) { if (!_loaded || _sidx == database.SelectedIndex) { return; } Guide guide; switch (database.SelectedIndex) { case 1: guide = new TVRage(); break; case 2: guide = new TVDB(); break; case 3: guide = new TVcom(); break; case 4: guide = new EPisodeWorld(); break; case 5: guide = new IMDb(); break; case 6: guide = new AniDB(); break; case 7: guide = new AnimeNewsNetwork(); break; case 9: guide = new EPGuides(); break; case 10: guide = new EPGuides(); break; default: return; } new ShowGuideTaskDialog().Search(guide, nameTextBox.Text, (language.SelectedItem as StackPanel).Tag as string, (id, title, lang) => { if (id == null) { Dispatcher.Invoke((Action)(() => { switch (Database.TVShows[_id].Source) { case "TVRage": database.SelectedIndex = 1; break; case "TVDB": database.SelectedIndex = 2; break; case "TVcom": database.SelectedIndex = 3; break; case "EPisodeWorld": database.SelectedIndex = 4; break; case "IMDb": database.SelectedIndex = 5; break; case "AniDB": database.SelectedIndex = 6; break; case "AnimeNewsNetwork": database.SelectedIndex = 7; break; case "EPGuides": database.SelectedIndex = 10; break; } })); } else { Database.TVShows[_id].Source = guide.GetType().Name; Database.TVShows[_id].SourceID = id; Database.TVShows[_id].Title = title; Database.TVShows[_id].Language = lang; _upReq = true; Dispatcher.Invoke((Action)(() => { nameTextBox.Text = title; _sidx = database.SelectedIndex; })); } }); }