Ejemplo n.º 1
0
        private void RefreshData()
        {
            AnimeSeriesVM ser = this.DataContext as AnimeSeriesVM;

            if (ser == null)
            {
                return;
            }

            ser.RefreshBase();

            UnwatchedEpisodeCount = ser.UnwatchedEpisodeCount;

            UnwatchedEpisodes.Clear();
            Recommendations.Clear();
            Shouts.Clear();

            RefreshUnwatchedEpisodes();
        }
Ejemplo n.º 2
0
        public List <AnimeEpisodeVM> GetAllEpisodes(bool onlyRandom)
        {
            List <AnimeEpisodeVM> allEps = new List <AnimeEpisodeVM>();

            // find the next episode to play
            if (DefaultPlayOrderEnum == PlaylistPlayOrder.Sequential && !onlyRandom)
            {
                foreach (PlaylistItemVM pli in PlaylistObjects)
                {
                    if (pli.ItemType == JMMClient.PlaylistItemType.Episode)
                    {
                        AnimeEpisodeVM epTemp = pli.PlaylistItem as AnimeEpisodeVM;
                        if (CanUseEpisode(this, epTemp))
                        {
                            allEps.Add(epTemp);
                        }
                    }

                    if (pli.ItemType == JMMClient.PlaylistItemType.AnimeSeries)
                    {
                        AnimeSeriesVM ser = pli.PlaylistItem as AnimeSeriesVM;
                        ser.RefreshBase();
                        ser.RefreshEpisodes();

                        List <AnimeEpisodeVM> eps = ser.AllEpisodes;

                        List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>();
                        sortCriteria.Add(new SortPropOrFieldAndDirection("EpisodeType", false, JMMClient.SortType.eInteger));
                        sortCriteria.Add(new SortPropOrFieldAndDirection("EpisodeNumber", false, JMMClient.SortType.eInteger));
                        eps = Sorting.MultiSort <AnimeEpisodeVM>(eps, sortCriteria);

                        foreach (AnimeEpisodeVM epTemp in eps)
                        {
                            if (epTemp.EpisodeTypeEnum == EpisodeType.Episode || epTemp.EpisodeTypeEnum == EpisodeType.Special)
                            {
                                if (CanUseEpisode(this, epTemp))
                                {
                                    allEps.Add(epTemp);
                                }
                            }
                        }
                    }
                }
            }
            else // random
            {
                foreach (PlaylistItemVM pli in PlaylistObjects)
                {
                    if (pli.ItemType == JMMClient.PlaylistItemType.Episode)
                    {
                        AnimeEpisodeVM epTemp = pli.PlaylistItem as AnimeEpisodeVM;
                        if (CanUseEpisode(this, epTemp))
                        {
                            allEps.Add(epTemp);
                        }
                    }

                    if (pli.ItemType == JMMClient.PlaylistItemType.AnimeSeries)
                    {
                        AnimeSeriesVM ser = pli.PlaylistItem as AnimeSeriesVM;
                        ser.RefreshBase();
                        ser.RefreshEpisodes();

                        List <AnimeEpisodeVM> eps = ser.AllEpisodes;

                        foreach (AnimeEpisodeVM epTemp in eps)
                        {
                            if (epTemp.EpisodeTypeEnum == EpisodeType.Episode || epTemp.EpisodeTypeEnum == EpisodeType.Special)
                            {
                                if (CanUseEpisode(this, epTemp))
                                {
                                    allEps.Add(epTemp);
                                }
                            }
                        }
                    }
                }

                allEps.Shuffle();
            }

            return(allEps);
        }
Ejemplo n.º 3
0
        public void SetNextEpisode(bool onlyRandom)
        {
            if (PlaylistObjects.Count == 0)
            {
                return;
            }

            // find the next episode to play
            NextEpisode = null;
            if (DefaultPlayOrderEnum == PlaylistPlayOrder.Sequential && !onlyRandom)
            {
                bool foundEp = false;
                while (!foundEp)
                {
                    foreach (PlaylistItemVM pli in PlaylistObjects)
                    {
                        if (pli.ItemType == JMMClient.PlaylistItemType.Episode)
                        {
                            AnimeEpisodeVM epTemp = pli.PlaylistItem as AnimeEpisodeVM;
                            if (CanUseEpisode(this, epTemp))
                            {
                                NextEpisode = epTemp;
                                foundEp     = true;
                                break;
                            }
                        }

                        if (pli.ItemType == JMMClient.PlaylistItemType.AnimeSeries)
                        {
                            AnimeSeriesVM ser = pli.PlaylistItem as AnimeSeriesVM;
                            ser.RefreshBase();
                            ser.RefreshEpisodes();

                            List <AnimeEpisodeVM> eps = ser.AllEpisodes;

                            List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>();
                            sortCriteria.Add(new SortPropOrFieldAndDirection("EpisodeType", false, JMMClient.SortType.eInteger));
                            sortCriteria.Add(new SortPropOrFieldAndDirection("EpisodeNumber", false, JMMClient.SortType.eInteger));
                            eps = Sorting.MultiSort <AnimeEpisodeVM>(eps, sortCriteria);

                            foreach (AnimeEpisodeVM epTemp in eps)
                            {
                                if (epTemp.EpisodeTypeEnum == EpisodeType.Episode || epTemp.EpisodeTypeEnum == EpisodeType.Special)
                                {
                                    if (CanUseEpisode(this, epTemp))
                                    {
                                        NextEpisode = epTemp;
                                        foundEp     = true;
                                        break;
                                    }
                                }
                            }

                            if (foundEp)
                            {
                                break;
                            }
                        }
                    }
                    break;
                }
            }
            else // random
            {
                // get all the candidate episodes
                List <AnimeEpisodeVM> canidateEps = new List <AnimeEpisodeVM>();

                foreach (PlaylistItemVM pli in PlaylistObjects)
                {
                    if (pli.ItemType == JMMClient.PlaylistItemType.Episode)
                    {
                        AnimeEpisodeVM epTemp = pli.PlaylistItem as AnimeEpisodeVM;
                        if (CanUseEpisode(this, epTemp))
                        {
                            canidateEps.Add(epTemp);
                        }
                    }

                    if (pli.ItemType == JMMClient.PlaylistItemType.AnimeSeries)
                    {
                        AnimeSeriesVM ser = pli.PlaylistItem as AnimeSeriesVM;
                        ser.RefreshBase();
                        ser.RefreshEpisodes();

                        List <AnimeEpisodeVM> eps = ser.AllEpisodes;

                        foreach (AnimeEpisodeVM epTemp in eps)
                        {
                            if (epTemp.EpisodeTypeEnum == EpisodeType.Episode || epTemp.EpisodeTypeEnum == EpisodeType.Special)
                            {
                                if (CanUseEpisode(this, epTemp))
                                {
                                    canidateEps.Add(epTemp);
                                }
                            }
                        }
                    }
                }

                // pick a random object from the play list
                if (canidateEps.Count > 0)
                {
                    NextEpisode = canidateEps[epRandom.Next(0, canidateEps.Count)];
                }
            }

            if (NextEpisode != null)
            {
                NextEpisode.SetTvDBInfo();
                NextEpisode.RefreshAnime();
                AniDB_Anime = NextEpisode.AniDB_Anime;

                if (MainListHelperVM.Instance.AllSeriesDictionary.ContainsKey(NextEpisode.AnimeSeriesID))
                {
                    Series = MainListHelperVM.Instance.AllSeriesDictionary[NextEpisode.AnimeSeriesID];
                }
            }
        }
Ejemplo n.º 4
0
		public void UpdateHeirarchy(AnimeSeriesVM ser)
		{
			try
			{
				// update the attached series
				// refresh the data
				ser.RefreshBase();
				ser.AniDB_Anime.Detail.RefreshBase();

				List<JMMServerBinary.Contract_AnimeGroup> grps = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupsAboveSeries(ser.AnimeSeriesID.Value,
					JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
				foreach (AnimeGroupVM grp in MainListHelperVM.Instance.AllGroups)
				{
					foreach (JMMServerBinary.Contract_AnimeGroup grpContract in grps)
					{
						if (grp.AnimeGroupID.Value == grpContract.AnimeGroupID)
						{
							grp.Populate(grpContract);
							break;
						}
					}

				}
			}
			catch (Exception ex)
			{
				Utils.ShowErrorMessage(ex);
			}
		}