private void PopulateSeasons(VM_CrossRef_AniDB_TvDBV2 xref)
        {
            cboSeason.SelectionChanged -= new SelectionChangedEventHandler(cboSeason_SelectionChanged);


            cboSeason.Items.Clear();
            TvDetails = null;
            if (Anime.TvSummary.TvDetails.ContainsKey(xref.TvDBID))
            {
                TvDetails = Anime.TvSummary.TvDetails[xref.TvDBID];
            }

            if (TvDetails == null)
            {
                return;
            }

            foreach (int season in TvDetails.DictTvDBSeasons.Keys)
            {
                cboSeason.Items.Add(season);
            }

            cboSeason.SelectionChanged += new SelectionChangedEventHandler(cboSeason_SelectionChanged);

            if (cboSeason.Items.Count > 0)
            {
                cboSeason.SelectedIndex = 0;
            }
        }
Beispiel #2
0
        public void Init(int animeID, string animeName, enEpisodeType aniEpType, int aniEpNumber, int tvDBID, int tvSeason, int tvEpNumber, string tvSeriesName,
                         VM_AniDB_Anime anime, int?crossRef_AniDB_TvDBV2ID)
        {
            Anime                   = anime;
            AnimeID                 = animeID;
            AnimeName               = animeName;
            AnimeEpisodeType        = (int)aniEpType;
            AnimeEpisodeNumber      = aniEpNumber;
            TvDBID                  = tvDBID;
            TvDBSeason              = tvSeason;
            TvDBEpisodeNumber       = tvEpNumber;
            TvDBSeriesName          = tvSeriesName;
            CrossRef_AniDB_TvDBV2ID = crossRef_AniDB_TvDBV2ID;

            AnimeURL = string.Format(Constants.URLS.AniDB_Series, AnimeID);
            TvDBURL  = string.Format(Constants.URLS.TvDB_Series, TvDBID);

            bool hasSpecials = false;

            AniDBEpisodes = new List <VM_AniDB_Episode>();
            foreach (VM_AniDB_Episode contract in VM_ShokoServer.Instance.ShokoServices.GetAniDBEpisodesForAnime(AnimeID).Cast <VM_AniDB_Episode>())
            {
                AniDBEpisodes.Add(contract);
                if (contract.EpisodeType == (int)enEpisodeType.Special)
                {
                    hasSpecials = true;
                }
            }

            cboEpisodeType.Items.Clear();
            cboEpisodeType.Items.Add(Shoko.Commons.Properties.Resources.Anime_Episodes);
            if (hasSpecials)
            {
                cboEpisodeType.Items.Add(Shoko.Commons.Properties.Resources.Anime_Specials);
            }

            cboEpisodeType.SelectionChanged += new SelectionChangedEventHandler(cboEpisodeType_SelectionChanged);

            if (aniEpType == enEpisodeType.Episode)
            {
                cboEpisodeType.SelectedIndex = 0;
            }
            else
            {
                cboEpisodeType.SelectedIndex = 1;
            }



            // get the seasons

            try
            {
                cboSeasonNumber.Items.Clear();

                List <int> seasons = null;
                if (anime.TvSummary.TvDetails.ContainsKey(tvDBID))
                {
                    TvDetails = anime.TvSummary.TvDetails[tvDBID];
                    seasons   = anime.TvSummary.TvDetails[tvDBID].DictTvDBSeasons.Keys.ToList();
                }
                else
                {
                    VM_ShokoServer.Instance.ShokoServices.UpdateTvDBData(tvDBID);
                    TvDetails = new VM_TvDBDetails(tvDBID);
                    seasons   = TvDetails.DictTvDBSeasons.Keys.ToList();
                    //seasons = VM_ShokoServer.Instance.clientBinaryHTTP.GetSeasonNumbersForSeries(tvDBID);
                }

                int i   = 0;
                int idx = 0;
                foreach (int season in seasons)
                {
                    cboSeasonNumber.Items.Add(season.ToString());
                    if (season == tvSeason)
                    {
                        idx = i;
                    }
                    i++;
                }

                cboSeasonNumber.SelectionChanged  += new SelectionChangedEventHandler(cboSeasonNumber_SelectionChanged);
                cboEpisodeNumber.SelectionChanged += new SelectionChangedEventHandler(cboEpisodeNumber_SelectionChanged);

                cboSeasonNumber.SelectedIndex = idx;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }