コード例 #1
0
        /// <summary>
        /// Initializes the library. Needs to be called at first.
        /// </summary>
        /// <returns></returns>
        public bool Init()
        {
            ICacheProvider cacheProvider = new XmlCacheProvider(SeriesTvDbMatcher.CACHE_PATH);

            _tvdbHandler = new TvdbHandler(cacheProvider, "9628A4332A8F3487");
            _tvdbHandler.InitCache();
            if (!_tvdbHandler.IsLanguagesCached)
            {
                _tvdbHandler.ReloadLanguages();
            }
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Form is shown (after it's loaded)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Tester_Shown(object sender, EventArgs e)
        {
            if (Resources.API_KEY != null && !Resources.API_KEY.Equals(""))
            {
                try
                {
                    StartScreen screen = new StartScreen();
                    screen.StartPosition = FormStartPosition.Manual;
                    screen.Left          = (this.Left) + (this.Width / 2) - (screen.Width / 2);
                    screen.Top           = (this.Top) + (this.Height / 2) - (screen.Height / 2);
                    DialogResult res = screen.ShowDialog();

                    if (res == DialogResult.OK)
                    {
                        ICacheProvider p = null;
                        if (screen.CacheProvider == typeof(XmlCacheProvider))
                        {
                            p = new XmlCacheProvider(screen.RootFolder);
                        }
                        else if (screen.CacheProvider == typeof(BinaryCacheProvider))
                        {
                            p = new BinaryCacheProvider(screen.RootFolder);
                        }

                        if (screen.UseUserIdentifier)
                        {
                            InitialiseForm(screen.UserIdentifier, p);
                        }
                        else
                        {
                            InitialiseForm(null, p);
                        }
                    }
                    else
                    {//user clicked on exit -> use no userid and no caching
                        InitialiseForm(null, null);
                    }
                }
                catch (TvdbNotAvailableException)
                {
                    MessageBox.Show("Tvdb not available, try again later");
                }
            }
            else
            {
                MessageBox.Show("Please insert your api key into the project's Resources");
                panelSeriesOverview.Enabled = false;
                tabControlTvdb.Enabled      = false;
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes the library. Needs to be called at first.
        /// </summary>
        /// <returns></returns>
        public async Task <bool> InitAsync(string cachePath, bool useHttps)
        {
            ICacheProvider cacheProvider = new XmlCacheProvider(cachePath);

            _tvdbHandler = new TvdbHandler("9628A4332A8F3487", useHttps, cacheProvider);
            _tvdbHandler.InitCache();
            if (!_tvdbHandler.IsLanguagesCached)
            {
                await _tvdbHandler.ReloadLanguagesAsync().ConfigureAwait(false);
            }
            _tvdbHandler.UpdateFinished   += TvdbHandlerOnUpdateFinished;
            _tvdbHandler.UpdateProgressed += TvdbHandlerOnUpdateProgressed;
            SetDefaultLanguage(TvdbLanguage.DefaultLanguage);
            SetCachePath(cachePath);

            _seriesToActorMap = new IdMapper(Path.Combine(cachePath, "SeriesToActorMap.xml"));
            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Form is shown (after it's loaded)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Tester_Shown(object sender, EventArgs e)
        {
            if (Resources.API_KEY != null && !Resources.API_KEY.Equals(""))
            {
                StartScreen screen = new StartScreen();
                screen.StartPosition = FormStartPosition.Manual;
                screen.Left          = (this.Left) + (this.Width / 2) - (screen.Width / 2);
                screen.Top           = (this.Top) + (this.Height / 2) - (screen.Height / 2);
                DialogResult res = screen.ShowDialog();

                ICacheProvider p = null;
                if (screen.CacheProvider == typeof(XmlCacheProvider))
                {
                    p = new XmlCacheProvider(screen.RootFolder);
                }
                else if (screen.CacheProvider == typeof(BinaryCacheProvider))
                {
                    p = new BinaryCacheProvider(screen.RootFolder);
                }

                if (res == DialogResult.Cancel)
                {
                    InitialiseForm(null, p);
                }
                else
                {
                    InitialiseForm(screen.UserIdentifier, p);
                }
            }
            else
            {
                MessageBox.Show("Please insert your api key into the project's Resources");
                panelSeriesOverview.Enabled = false;
                tabControlTvdb.Enabled      = false;
            }
        }