private void CommandBinding_BookmarkAnime(object sender, ExecutedRoutedEventArgs e) { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) return; try { if (obj.GetType() == typeof(RecommendationVM)) { RecommendationVM rec = obj as RecommendationVM; if (rec == null) return; BookmarkedAnimeVM bookmark = new BookmarkedAnimeVM(); bookmark.AnimeID = rec.RecommendedAnimeID; bookmark.Downloading = 0; bookmark.Notes = ""; bookmark.Priority = 1; if (bookmark.Save()) MainListHelperVM.Instance.RefreshBookmarkedAnime(); } if (obj.GetType() == typeof(MissingEpisodeVM)) { MissingEpisodeVM rec = obj as MissingEpisodeVM; if (rec == null) return; BookmarkedAnimeVM bookmark = new BookmarkedAnimeVM(); bookmark.AnimeID = rec.AnimeID; bookmark.Downloading = 0; bookmark.Notes = ""; bookmark.Priority = 1; if (bookmark.Save()) MainListHelperVM.Instance.RefreshBookmarkedAnime(); } if (obj.GetType() == typeof(AniDB_AnimeVM)) { AniDB_AnimeVM rec = obj as AniDB_AnimeVM; if (rec == null) return; BookmarkedAnimeVM bookmark = new BookmarkedAnimeVM(); bookmark.AnimeID = rec.AnimeID; bookmark.Downloading = 0; bookmark.Notes = ""; bookmark.Priority = 1; if (bookmark.Save()) MainListHelperVM.Instance.RefreshBookmarkedAnime(); } if (obj.GetType() == typeof(AniDB_Anime_SimilarVM)) { AniDB_Anime_SimilarVM sim = (AniDB_Anime_SimilarVM)obj; BookmarkedAnimeVM bookmark = new BookmarkedAnimeVM(); bookmark.AnimeID = sim.SimilarAnimeID; bookmark.Downloading = 0; bookmark.Notes = ""; bookmark.Priority = 1; if (bookmark.Save()) MainListHelperVM.Instance.RefreshBookmarkedAnime(); } if (obj.GetType() == typeof(AniDB_Anime_RelationVM)) { AniDB_Anime_RelationVM rel = (AniDB_Anime_RelationVM)obj; BookmarkedAnimeVM bookmark = new BookmarkedAnimeVM(); bookmark.AnimeID = rel.RelatedAnimeID; bookmark.Downloading = 0; bookmark.Notes = ""; bookmark.Priority = 1; if (bookmark.Save()) MainListHelperVM.Instance.RefreshBookmarkedAnime(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void RefreshBookmarkedAnime() { try { // set this to null so that it will be refreshed the next time it is needed List<JMMServerBinary.Contract_BookmarkedAnime> baRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllBookmarkedAnime(); //if (baRaw.Count == 0) return; System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate() { BookmarkedAnime.Clear(); // must series before groups the binding is based on the groups, and will refresh when that is changed foreach (JMMServerBinary.Contract_BookmarkedAnime contract in baRaw) { BookmarkedAnimeVM ba = new BookmarkedAnimeVM(contract); if (ba.DownloadingBool && BookmarkFilter_Downloading) BookmarkedAnime.Add(ba); if (ba.NotDownloadingBool && BookmarkFilter_NotDownloading) BookmarkedAnime.Add(ba); } ViewBookmarkedAnime.Refresh(); }); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }