Exemple #1
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;
              }
        }
Exemple #2
0
        private void InitTvdblibHandler()
        {
            ICacheProvider provider;
              if (cbCacheType.SelectedIndex == 0 || cbCacheType.SelectedIndex == -1)
              {
            provider = new XmlCacheProvider(txtCacheLocation.Text);
              }
              else
              {
            provider = new BinaryCacheProvider(txtCacheLocation.Text);
              }

              lbCacheSnapshots.Items.Clear();
              foreach (String f in Directory.GetFiles(Directory.GetCurrentDirectory(), "Rev_*.zip"))
              {
            FileInfo file = new FileInfo(f);
            CacheRevision rev = CacheRevision.CreateFromFile(file);

            if (rev != null)
            {
              lbCacheSnapshots.Items.Add(rev);
            }
              }

              m_tvdbHandler = new TvdbHandler(provider, File.ReadAllText("api_key.txt"));
              // m_tvdbHandler.UserInfo = new TvdbLib.Data.TvdbUser("DieBagger", txtUserId.Text);
              m_tvdbHandler.InitCache();
              txtLastUpdated.Text = m_tvdbHandler.GetLastUpdate().ToString();

              List<int> cached = m_tvdbHandler.GetCachedSeries();
              lvCachedSeries.Items.Clear();
              cached.ForEach(delegate(int s)
              {
            ListViewItem item = new ListViewItem(s.ToString());
            item.SubItems.Add("");
            item.Tag = s;
            lvCachedSeries.Items.Add(item);
              });
              m_tvdbDownloader = new TvdbDownloader(File.ReadAllText("api_key.txt"));
              m_tvdbHandler.UpdateFinished += new TvdbHandler.UpdateFinishedDelegate(m_tvdbHandler_UpdateFinished);
        }