void workerFiles_DoWork(object sender, DoWorkEventArgs e) { try { RankingRefreshOptions opt = e.Argument as RankingRefreshOptions; List <VM_AnimeRating> rawRatings = VM_ShokoServer.Instance.ShokoServices.GetAnimeRatings( (int)opt.CollectionState, (int)opt.WatchedState, (int)opt.VotedState, VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList <VM_AnimeRating>(); List <VM_AnimeRating> ratings = new List <VM_AnimeRating>(); foreach (VM_AnimeRating rating in rawRatings) { ratings.Add(rating); } e.Result = ratings; /*AllAnime = VM_MainListHelper.Instance.AllAnimeDetailedDictionary.Values.ToList(); * * List<AnimeRanking> rankings = new List<AnimeRanking>(); * * int i = 0; * foreach (AniDB_AnimeDetailedVM anime in AllAnime) * { * i++; * AnimeRanking ranking = new AnimeRanking() * { * AnimeName = anime.AniDB_Anime.MainTitle, * Ranking = 1, * Rating = String.Format("{0:0.00}", anime.AniDB_Anime.AniDBRating), * UserRating = anime.UserRating, * Year = anime.AniDB_Anime.BeginYear, * AnimeDetailed = anime * }; * AllRankings.Add(ranking); * //if (i == 50) break; * }*/ } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void RefreshData() { if (workerFiles.IsBusy) { return; } ShowAnimeDetails = false; IsLoading = true; btnRefresh.IsEnabled = false; AllRankings.Clear(); StatusMessage = Shoko.Commons.Properties.Resources.Loading; RankingRefreshOptions opt = new RankingRefreshOptions() { CollectionState = (RatingCollectionState)cboCollection.SelectedIndex, WatchedState = (RatingWatchedState)cboWatched.SelectedIndex, VotedState = (RatingVotedState)cboVoted.SelectedIndex }; workerFiles.RunWorkerAsync(opt); }