public void ToggleWatchedStatus(bool watched, bool promptForRating) { bool currentStatus = Watched; if (currentStatus == watched) { return; } CL_Response <CL_AnimeEpisode_User> response = VM_ShokoServer.Instance.ShokoServices.ToggleWatchedStatusOnEpisode(AnimeEpisodeID, watched, VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (!string.IsNullOrEmpty(response.ErrorMessage)) { BaseConfig.MyAnimeLog.Write("Error in ToggleWatchedStatus: " + response.ErrorMessage); return; } if (promptForRating && BaseConfig.Settings.DisplayRatingDialogOnCompletion) { VM_AnimeSeries_User ser = (VM_AnimeSeries_User)VM_ShokoServer.Instance.ShokoServices.GetSeries(response.Result.AnimeSeriesID, VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (ser != null) { Utils.PromptToRateSeriesOnCompletion(ser); } } }
public void Save() { CL_Response <Playlist> resp = VM_ShokoServer.Instance.ShokoServices.SavePlaylist(this); if (!string.IsNullOrEmpty(resp.ErrorMessage)) { Utils.ShowErrorMessage(resp.ErrorMessage); } }
protected override void OnShowContextMenu() { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) { return; } if (currentitem.TVTag.GetType() == typeof(VM_Recommendation)) { VM_Recommendation rec = currentitem.TVTag as VM_Recommendation; if (rec != null) { ContextMenu cmenu = new ContextMenu(rec.Recommended_DisplayName); cmenu.AddAction(Translation.DontShowThisAnime, () => { int recType = 1; VM_ShokoServer.Instance.ShokoServices.IgnoreAnime(rec.RecommendedAnimeID, recType, VM_ShokoServer.Instance.CurrentUser.JMMUserID); LoadData(); }); cmenu.AddAction(Translation.BookmarkThisAnime, () => { VM_BookmarkedAnime bookmark = new VM_BookmarkedAnime(); bookmark.AnimeID = rec.RecommendedAnimeID; bookmark.Downloading = 0; bookmark.Notes = ""; bookmark.Priority = 1; if (bookmark.Save()) { Utils.DialogMsg(Translation.Sucess, Translation.BookmarkCreated); } }); cmenu.AddAction(Translation.CreateSeriesForAnime, () => { CL_Response <CL_AnimeSeries_User> resp = VM_ShokoServer.Instance.ShokoServices.CreateSeriesFromAnime( rec.RecommendedAnimeID, null, VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (string.IsNullOrEmpty(resp.ErrorMessage)) { Utils.DialogMsg(Translation.Sucess, Translation.SeriesCreated); } else { Utils.DialogMsg(Translation.Error, resp.ErrorMessage); } }); cmenu.Show(); } } }
public bool Save() { CL_Response <CL_BookmarkedAnime> resp = VM_ShokoServer.Instance.ShokoServices.SaveBookmarkedAnime(this); if (!string.IsNullOrEmpty(resp.ErrorMessage)) { Utils.ShowErrorMessage(resp.ErrorMessage); return(false); } Populate(resp.Result); return(true); }
private void CommandBinding_ToggleWatchedStatus(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } Cursor = Cursors.Wait; IsEnabled = false; bool newStatus = false; try { if (obj.GetType() == typeof(VM_VideoDetailed)) { VM_VideoDetailed vid = obj as VM_VideoDetailed; newStatus = !vid.Watched; VM_ShokoServer.Instance.ShokoServices.ToggleWatchedStatusOnVideo(vid.VideoLocalID, newStatus, VM_ShokoServer.Instance.CurrentUser.JMMUserID); VM_MainListHelper.Instance.UpdateHeirarchy(vid); } if (obj.GetType() == typeof(VM_AnimeEpisode_User)) { VM_AnimeEpisode_User ep = obj as VM_AnimeEpisode_User; newStatus = !ep.Watched; CL_Response <CL_AnimeEpisode_User> response = VM_ShokoServer.Instance.ShokoServices.ToggleWatchedStatusOnEpisode(ep.AnimeEpisodeID, newStatus, VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (!string.IsNullOrEmpty(response.ErrorMessage)) { MessageBox.Show(response.ErrorMessage, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } VM_MainListHelper.Instance.UpdateHeirarchy((VM_AnimeEpisode_User)response.Result); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { Cursor = Cursors.Arrow; IsEnabled = true; } }
public static VM_Playlist CreatePlaylist(Window owner) { try { Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(AppSettings.Culture); DialogText dlg = new DialogText(); dlg.Init(Shoko.Commons.Properties.Resources.Playlist_Name + " ", ""); dlg.Owner = owner; bool?res = dlg.ShowDialog(); if (res.HasValue && res.Value) { if (string.IsNullOrEmpty(dlg.EnteredText)) { Utils.ShowErrorMessage(Shoko.Commons.Properties.Resources.Playlist_NameBlank); return(null); } Playlist pl = new Playlist { DefaultPlayOrder = (int)PlaylistPlayOrder.Sequential, PlaylistItems = "", PlaylistName = dlg.EnteredText, PlayUnwatched = 1, PlayWatched = 0 }; CL_Response <Playlist> resp = VM_ShokoServer.Instance.ShokoServices.SavePlaylist(pl); if (!string.IsNullOrEmpty(resp.ErrorMessage)) { Utils.ShowErrorMessage(resp.ErrorMessage); return(null); } // refresh data Instance.RefreshData(); return((VM_Playlist)resp.Result); } return(null); } catch (Exception ex) { Utils.ShowErrorMessage(ex); return(null); } }
protected override void OnShowContextMenu() { try { ContextMenu cmenu = new ContextMenu(Translation.Calendar); cmenu.AddAction(Translation.BookmarkThisAnime, () => { VM_AniDB_Anime anime3; if ((anime3 = m_Facade.SelectedListItem.TVTag as VM_AniDB_Anime) != null) { VM_BookmarkedAnime bookmark = new VM_BookmarkedAnime(); bookmark.AnimeID = anime3.AnimeID; bookmark.Downloading = 0; bookmark.Notes = string.Empty; bookmark.Priority = 1; if (bookmark.Save()) { Utils.DialogMsg(Translation.Sucess, Translation.BookmarkCreated); } } }); cmenu.AddAction(Translation.CreateSeriesForAnime, () => { VM_AniDB_Anime anime4; if ((anime4 = m_Facade.SelectedListItem.TVTag as VM_AniDB_Anime) != null) { CL_Response <CL_AnimeSeries_User> resp = VM_ShokoServer.Instance.ShokoServices.CreateSeriesFromAnime( anime4.AnimeID, null, VM_ShokoServer.Instance.CurrentUser.JMMUserID, false); if (string.IsNullOrEmpty(resp.ErrorMessage)) { Utils.DialogMsg(Translation.Sucess, Translation.SeriesCreated); } else { Utils.DialogMsg(Translation.Error, resp.ErrorMessage); } } }); cmenu.Show(); } catch (Exception ex) { BaseConfig.MyAnimeLog.Write("Error in menu: {0}", ex); } }
public bool Save() { try { CL_Response <CL_AnimeSeries_User> response = VM_ShokoServer.Instance.ShokoServices.SaveSeries(ToContract(), VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (!string.IsNullOrEmpty(response.ErrorMessage)) { return(false); } Populate((VM_AnimeSeries_User)response.Result); return(true); } catch (Exception ex) { BaseConfig.MyAnimeLog.Write(ex.ToString()); return(false); } }
public bool Save() { try { CL_Response <CL_AnimeSeries_User> response = VM_ShokoServer.Instance.ShokoServices.SaveSeries(ToSaveRequest(), VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (!string.IsNullOrEmpty(response.ErrorMessage)) { MessageBox.Show(response.ErrorMessage); return(false); } Populate((VM_AnimeSeries_User)response.Result); return(true); } catch (Exception ex) { Utils.ShowErrorMessage(ex); return(false); } }
void postCommentWorker_DoWork(object sender, DoWorkEventArgs e) { VM_Trakt_CommentPost comment = e.Argument as VM_Trakt_CommentPost; string msg = ""; try { CL_Response <bool> resp = VM_ShokoServer.Instance.ShokoServices.PostTraktCommentShow(comment.TraktID, comment.CommentText, comment.Spoiler); msg = resp.ErrorMessage; } catch (Exception ex) { e.Result = ex.Message; return; } e.Result = msg; }
public bool Save() { try { CL_Response <ImportFolder> response = VM_ShokoServer.Instance.ShokoServices.SaveImportFolder(this.ToContract()); if (!string.IsNullOrEmpty(response.ErrorMessage)) { MessageBox.Show(response.ErrorMessage); return(false); } FolderMappings.Instance.MapFolder(response.Result.ImportFolderID, LocalPathTemp); return(true); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(false); }
void btnAddCustomTag_Click(object sender, RoutedEventArgs e) { try { Cursor = Cursors.Wait; string res = ""; if (string.IsNullOrWhiteSpace(txtTagName.Text)) { MessageBox.Show(Shoko.Commons.Properties.Resources.CustomTag_EnterName, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); txtTagName.Focus(); return; } VM_CustomTag contract = new VM_CustomTag(); contract.TagName = txtTagName.Text.Trim(); contract.TagDescription = txtTagDescription.Text.Trim(); CL_Response <CustomTag> resp = VM_ShokoServer.Instance.ShokoServices.SaveCustomTag(contract); if (!string.IsNullOrEmpty(resp.ErrorMessage)) { MessageBox.Show(res, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else { VM_ShokoServer.Instance.AllCustomTags.Add((VM_CustomTag)resp.Result); VM_ShokoServer.Instance.ViewCustomTagsAll.Refresh(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { Cursor = Cursors.Arrow; } }
public bool Save() { try { CL_Response <CL_AnimeGroup_User> response = VM_ShokoServer.Instance.ShokoServices.SaveGroup(ToRequest(), VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (!string.IsNullOrEmpty(response.ErrorMessage)) { MessageBox.Show(response.ErrorMessage); return(false); } Populate((VM_AnimeGroup_User)response.Result); VM_MainListHelper.Instance.AllGroupsDictionary[AnimeGroupID] = this; PopulateSerieInfo(VM_MainListHelper.Instance.AllGroupsDictionary, VM_MainListHelper.Instance.AllSeriesDictionary); return(true); } catch (Exception ex) { Utils.ShowErrorMessage(ex); return(false); } }
public bool Save() { try { CL_Response <RenameScript> response = VM_ShokoServer.Instance.ShokoServices.SaveRenameScript(this); if (!string.IsNullOrEmpty(response.ErrorMessage)) { Utils.ShowErrorMessage(response.ErrorMessage); return(false); } else { Populate(response.Result); return(true); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); return(false); } }
void btnNewScript_Click(object sender, RoutedEventArgs e) { try { DialogText dlg = new DialogText(); dlg.Init(Shoko.Commons.Properties.Resources.Rename_EnterScriptName, ""); dlg.Owner = Window.GetWindow(this); bool?res = dlg.ShowDialog(); if (res.HasValue && res.Value) { if (string.IsNullOrEmpty(dlg.EnteredText)) { Utils.ShowErrorMessage(Shoko.Commons.Properties.Resources.Rename_BlankScript); return; } RenameScript script = new RenameScript(); script.IsEnabledOnImport = 0; script.Script = ""; script.ScriptName = dlg.EnteredText; script.RenamerType = "Legacy"; CL_Response <RenameScript> resp = VM_ShokoServer.Instance.ShokoServices.SaveRenameScript(script); if (!string.IsNullOrEmpty(resp.ErrorMessage)) { Utils.ShowErrorMessage(resp.ErrorMessage); return; } defaultScriptID = resp.Result.RenameScriptID; // refresh data RefreshScripts(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public bool Save() { try { CL_Response <CL_GroupFilter> response = VM_ShokoServer.Instance.ShokoServices.SaveGroupFilter(this); if (!string.IsNullOrEmpty(response.ErrorMessage)) { MessageBox.Show(response.ErrorMessage); return(false); } else { Populate(response.Result); } return(true); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(false); }
/// <summary> /// This event bubbles up from PlayEpisodeControl /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CommandBinding_ToggleWatchedStatus(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } Cursor = Cursors.Wait; try { Window parentWindow = Window.GetWindow(this); VM_AnimeSeries_User serTemp = null; bool newStatus = false; if (obj.GetType() == typeof(VM_VideoDetailed)) { VM_VideoDetailed vid = obj as VM_VideoDetailed; newStatus = !vid.Watched; VM_ShokoServer.Instance.ShokoServices.ToggleWatchedStatusOnVideo(vid.VideoLocalID, newStatus, VM_ShokoServer.Instance.CurrentUser.JMMUserID); VM_MainListHelper.Instance.UpdateHeirarchy(vid); serTemp = VM_MainListHelper.Instance.GetSeriesForVideo(vid.VideoLocalID); } if (obj.GetType() == typeof(VM_AnimeEpisode_User)) { VM_AnimeEpisode_User ep = obj as VM_AnimeEpisode_User; newStatus = !ep.Watched; CL_Response <CL_AnimeEpisode_User> response = VM_ShokoServer.Instance.ShokoServices.ToggleWatchedStatusOnEpisode(ep.AnimeEpisodeID, newStatus, VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (!string.IsNullOrEmpty(response.ErrorMessage)) { MessageBox.Show(response.ErrorMessage, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } VM_MainListHelper.Instance.UpdateHeirarchy((VM_AnimeEpisode_User)response.Result); serTemp = VM_MainListHelper.Instance.GetSeriesForEpisode(ep); } if (obj.GetType() == typeof(VM_PlaylistItem)) { VM_PlaylistItem pli = obj as VM_PlaylistItem; VM_AnimeEpisode_User ep = pli.PlaylistItem as VM_AnimeEpisode_User; newStatus = !ep.Watched; CL_Response <CL_AnimeEpisode_User> response = VM_ShokoServer.Instance.ShokoServices.ToggleWatchedStatusOnEpisode(ep.AnimeEpisodeID, newStatus, VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (!string.IsNullOrEmpty(response.ErrorMessage)) { MessageBox.Show(response.ErrorMessage, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } VM_MainListHelper.Instance.UpdateHeirarchy((VM_AnimeEpisode_User)response.Result); serTemp = VM_MainListHelper.Instance.GetSeriesForEpisode(ep); } VM_Playlist pl = DataContext as VM_Playlist; if (pl == null) { return; } pl.PopulatePlaylistObjects(); ShowNextEpisode(); if (newStatus == true && serTemp != null) { Utils.PromptToRateSeries(serTemp, parentWindow); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { Cursor = Cursors.Arrow; } }
void btnSave_Click(object sender, RoutedEventArgs e) { try { // An import folder cannot be both the drop source and the drop destination if (chkDropDestination.IsChecked.HasValue && chkDropSource.IsChecked.HasValue && chkDropDestination.IsChecked.Value && chkDropSource.IsChecked.Value) { MessageBox.Show(Shoko.Commons.Properties.Resources.ImportFolders_SameFolder, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } // The import folder location cannot be blank. Enter a valid path on OMM Server if (string.IsNullOrEmpty(txtImportFolderLocation.Text)) { MessageBox.Show(Shoko.Commons.Properties.Resources.ImportFolders_BlankImport, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); txtImportFolderLocation.Focus(); return; } ImportFolder contract = new ImportFolder(); contract.ImportFolderID = importFldr.ImportFolderID; contract.ImportFolderType = (int)(importFldr.CloudID.HasValue ? ImportFolderType.Cloud : ImportFolderType.HDD); contract.ImportFolderName = "NA"; contract.ImportFolderLocation = txtImportFolderLocation.Text.Trim(); contract.IsDropDestination = chkDropDestination.IsChecked.Value ? 1 : 0; contract.IsDropSource = chkDropSource.IsChecked.Value ? 1 : 0; contract.IsWatched = chkIsWatched.IsChecked.Value ? 1 : 0; if (comboProvider.SelectedIndex == 0) { contract.CloudID = null; } else { contract.CloudID = ((SVR_CloudAccount)comboProvider.SelectedItem).CloudID; } ShokoServiceImplementation imp = new ShokoServiceImplementation(); CL_Response <ImportFolder> response = imp.SaveImportFolder(contract); if (!string.IsNullOrEmpty(response.ErrorMessage)) { MessageBox.Show(response.ErrorMessage, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } importFldr = null; ServerInfo.Instance.RefreshImportFolders(); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } this.DialogResult = true; this.Close(); }
void btnConfirm_Click(object sender, RoutedEventArgs e) { //VM_AnimeGroup_User grp = null; int animeID = 0; int?groupID = null; try { if (IsAnimeNotSelected) { MessageBox.Show(Shoko.Commons.Properties.Resources.NewSeries_SelectAnime, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); txtAnimeSearch.Focus(); return; } if (IsExistingGroup) { if (lbGroups.SelectedItem == null) { MessageBox.Show(Shoko.Commons.Properties.Resources.MSG_ERR_GroupSelectionRequired, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); lbGroups.Focus(); return; } else { VM_AnimeGroup_User grp = lbGroups.SelectedItem as VM_AnimeGroup_User; groupID = grp.AnimeGroupID; } } if (IsNewGroup) { if (txtGroupName.Text.Trim().Length == 0) { MessageBox.Show(Shoko.Commons.Properties.Resources.MSG_ERR_GroupNameRequired, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); txtGroupName.Focus(); return; } } if (SelectedAnime != null) { animeID = SelectedAnime.AnimeID; } Cursor = Cursors.Wait; if (IsNewGroup) { VM_AnimeGroup_User grp = new VM_AnimeGroup_User(); grp.GroupName = txtGroupName.Text.Trim(); grp.SortName = txtGroupName.Text.Trim(); grp.AnimeGroupParentID = null; grp.Description = ""; grp.IsFave = 0; grp.IsManuallyNamed = 0; grp.OverrideDescription = 0; if (grp.Validate()) { grp.IsReadOnly = true; grp.IsBeingEdited = false; if (grp.Save()) { VM_MainListHelper.Instance.ViewGroups.Refresh(); groupID = grp.AnimeGroupID; } } } CL_Response <CL_AnimeSeries_User> response = VM_ShokoServer.Instance.ShokoServices.CreateSeriesFromAnime(animeID, groupID, VM_ShokoServer.Instance.CurrentUser.JMMUserID); if (response.ErrorMessage.Length > 0) { Cursor = Cursors.Arrow; MessageBox.Show(response.ErrorMessage, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } VM_MainListHelper.Instance.AllSeriesDictionary[response.Result.AnimeSeriesID] = (VM_AnimeSeries_User)response.Result; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { Cursor = Cursors.Arrow; } DialogResult = true; Close(); }