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

            SeasonNumbers.Clear();
            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;
            }
        }
        public void Init(int animeID, string animeName, EpisodeType aniEpType, int aniEpNumber, int tvDBID, int tvSeason, int tvEpNumber, string tvSeriesName,
                         AniDB_AnimeVM 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 <AniDB_EpisodeVM>();
            List <JMMClient.JMMServerBinary.Contract_AniDB_Episode> contracts = JMMServerVM.Instance.clientBinaryHTTP.GetAniDBEpisodesForAnime(AnimeID);

            foreach (JMMClient.JMMServerBinary.Contract_AniDB_Episode contract in contracts)
            {
                AniDBEpisodes.Add(new AniDB_EpisodeVM(contract));
                if (contract.EpisodeType == (int)EpisodeType.Special)
                {
                    hasSpecials = true;
                }
            }

            cboEpisodeType.Items.Clear();
            cboEpisodeType.Items.Add("Episodes");
            if (hasSpecials)
            {
                cboEpisodeType.Items.Add("Specials");
            }

            cboEpisodeType.SelectionChanged += new SelectionChangedEventHandler(cboEpisodeType_SelectionChanged);

            if (aniEpType == EpisodeType.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
                {
                    JMMServerVM.Instance.clientBinaryHTTP.UpdateTvDBData(tvDBID);
                    TvDetails = new TvDBDetails(tvDBID);
                    seasons   = TvDetails.DictTvDBSeasons.Keys.ToList();
                    //seasons = JMMServerVM.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);
            }
        }