コード例 #1
0
ファイル: NameChooser.cs プロジェクト: stufkan/Maraton
 private void btnPreview_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     WebClient web = new WebClient();
     id = results.First(x => x.Title == lbResults.SelectedItem.ToString().CutToLast(' ', CutDirection.Right, true)).Id;
     IMDBBuffer buffer = new IMDBBuffer();
     MainPage page = buffer.ReadMain(id);
     if (page.PosterURL.Succes == false)
         Properties.Resources.no_photo.Save("temp");
     else web.DownloadFile(page.PosterURL.Data.Address, "temp");
     ImagePreview preview = new ImagePreview("temp");
     Cursor.Current = Cursors.Default;
     preview.ShowDialog();
 }
コード例 #2
0
ファイル: SeriesManager.cs プロジェクト: stufkan/Maraton
        private string getPicture(string title)
        {
            if (title == string.Empty)
                return string.Empty;

            Cursor.Current = Cursors.WaitCursor;

            MainPage page;
            IMDBBuffer buffer = new IMDBBuffer();
            var searchResults = buffer.SearchTitle(title).Results;
            if (searchResults != null && searchResults.Count() != 0)
            {
                var parsed = searchResults.Where(x => x.Type == MediaType.TVSeries);
                if (parsed.Count() > 1)
                {
                    NameChooser result = new NameChooser(parsed);

                    if (result.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        page = buffer.ReadMain(result.Id);
                    }
                    else page = null;
                }

                else if (parsed.Count() == 1)
                {
                    page = buffer.ReadMain(parsed.First().Id);
                }
                else
                {
                    EditSearch edit = new EditSearch(title);
                    if (edit.ShowDialog() == DialogResult.OK)
                        return getPicture(edit.EditedTitle);
                    else return string.Empty;
                }

                if (!Directory.Exists("Posters"))
                    Directory.CreateDirectory("Posters");

                if (page != null && page.PosterURL.Succes != false)
                {
                    WebClient web = new WebClient();
                    web.DownloadFile(page.PosterURL.Data.Address, SeriesManager.PosterPath + title);
                }
                else Properties.Resources.no_photo.Save(SeriesManager.PosterPath + title);
                Cursor.Current = Cursors.Default;
            }
            else
            {
                EditSearch edit = new EditSearch(title);
                if (edit.ShowDialog() == DialogResult.OK)
                    return getPicture(edit.EditedTitle);
                else return string.Empty;
            }
            return title;
        }