示例#1
0
        void DownloadAllCovers()
        {
            if (Games == null)
            {
                return;
            }
            int i = 0;

            foreach (NesMiniApplication game in Games)
            {
                SetStatus(Resources.GooglingFor + " " + game.Name);
                string[] urls = null;
                for (int tries = 0; tries < 5; tries++)
                {
                    if (urls == null)
                    {
                        try
                        {
                            urls = ImageGooglerForm.GetImageUrls(game);
                            break;
                        }
                        catch (Exception ex)
                        {
                            SetStatus(Resources.Error + ": " + ex.Message);
                            Thread.Sleep(1500);
                            continue;
                        }
                    }
                }
                if (urls != null && urls.Length == 0)
                {
                    SetStatus(Resources.NotFound + " " + game.Name);
                }
                for (int tries = 0; urls != null && tries < 5 && tries < urls.Length; tries++)
                {
                    try
                    {
                        var cover = ImageGooglerForm.DownloadImage(urls[tries]);
                        game.Image = cover;
                        break;
                    }
                    catch (Exception ex)
                    {
                        SetStatus(Resources.Error + ": " + ex.Message);
                        Thread.Sleep(1500);
                        continue;
                    }
                }
                SetProgress(++i, Games.Count);
                Thread.Sleep(500); // not so fast, Google don't like it
            }
        }
示例#2
0
        private void buttonGoogle_Click(object sender, EventArgs e)
        {
            var selected = checkedListBoxGames.SelectedItem;

            if (selected == null || !(selected is NesGame))
            {
                return;
            }
            var game    = (selected as NesGame);
            var googler = new ImageGooglerForm(game.Name + " nes box art");

            if (googler.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                game.SetImage(googler.Result);
                ShowSelected();
            }
        }