Beispiel #1
0
        /// <summary>
        /// Initialise the form
        /// </summary>
        /// <param name="_userId"></param>
        public void InitialiseForm(String _userId, ICacheProvider _provider)
        {
            //m_tvdbHandler = new Tvdb(new BinaryCacheProvider(@"cachefile.bin"), Resources.API_KEY);new XmlCacheProvider("XmlCache")

            m_tvdbHandler = new TvdbHandler(_provider, Resources.API_KEY);
            m_tvdbHandler.InitCache();

            List <TvdbLanguage> m_languages = m_tvdbHandler.Languages;

            foreach (TvdbLanguage l in m_languages)
            {
                if (l.Abbriviation.Equals("en"))
                {
                    m_currentLanguage = l;
                }
                cbLanguage.Items.Add(l);
            }
            lblCurrentLanguage.Text = "[" + m_currentLanguage.ToString() + "]";

            //enable/disable community features
            if (_userId != null)
            {
                TvdbUser user = new TvdbUser("user", _userId);
                m_tvdbHandler.UserInfo = user;
                List <TvdbSeries> favList = null;
                try
                {
                    user.UserPreferredLanguage = m_tvdbHandler.GetPreferredLanguage();
                    favList = m_tvdbHandler.GetUserFavorites(user.UserPreferredLanguage);
                }
                catch (TvdbInvalidApiKeyException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                catch (TvdbNotAvailableException ex)
                {
                    MessageBox.Show(ex.Message);
                }

                if (favList != null)
                {
                    foreach (TvdbSeries s in favList)
                    {
                        if (s != null)
                        {
                            cbUserFavourites.Items.Add(s);
                        }
                    }
                }
            }
            else
            {
                cbUserFavourites.Text    = "No userinfo set";
                cbUserFavourites.Enabled = false;
            }

            cmdAddRemoveFavorites.Enabled = false;
            cmdSendSeriesRating.Enabled   = false;
            raterSeriesYourRating.Enabled = false;
        }