Ejemplo n.º 1
0
            public Image RegisterImage(string url, byte[] imageData = null, bool overwrite = false)
            {
                Image image;

                if (Images.TryGetValue(url, out image) && !overwrite)
                {
                    return(image);
                }
                else
                {
                    image = new Image(url);
                }

                Images[url] = image;

                if (imageData != null)
                {
                    image.Save(imageData);
                }
                else
                {
                    ImageDownloader.Download(image);
                }

                return(image);
            }
Ejemplo n.º 2
0
        private async Task HandleFileDrop(DragEventArgs e)
        {
            if (romsListMain.SelectedIndex > -1 && e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] file_paths = (string[])(e.Data.GetData(DataFormats.FileDrop));

                var file = file_paths[0];

                if (ImageFileValidator.IsValid(file))
                {
                    var selected_rom = (Rom)romsListMain.SelectedObject;

                    Library.SetRomImage(selected_rom, file);

                    romsListMain.RefreshSelectedObjects();
                }
            }
            else if (romsListMain.SelectedIndex > -1 && e.Data.GetDataPresent(DataFormats.Html))
            {
                var selected_rom = (Rom)romsListMain.SelectedObject;

                string data = (string)e.Data.GetData(DataFormats.Html);

                string image_path = HtmlCodeImageUrlExtractor.Extract(data);

                Bitmap image = await ImageDownloader.Download(image_path);

                if (image != null)
                {
                    Library.SetRomImage(selected_rom, image);

                    romsListMain.RefreshSelectedObjects();
                }
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            ImageDownloader _downloader;

            _downloader = new ImageDownloader();
            _downloader.DowloadValueChange += _downloader_DowloadValueChange;
            _downloader.DownloadStarting   += _downloader_DownloadStarting;
            _downloader.DownloadFinish     += _downloader_DownloadFinish;
            _downloader.Download(@"http://url/");

            Console.WriteLine("press any key to exit");
            Console.ReadKey();
        }
Ejemplo n.º 4
0
        private void buttonDownload_Click(object sender, EventArgs e)
        {
            List <Chapter> Chapters = new List <Chapter>();

            foreach (DataGridViewRow rowView in dataGridView1.Rows)
            {
                if ((bool)rowView.Cells[ColumnDownload.Index].Value)
                {
                    Chapter chapter = new Chapter()
                    {
                        Tom             = (string)rowView.Cells[ColumnTom.Index].Value,
                        chapter         = (string)rowView.Cells[ColumnChapter.Index].Value,
                        Name            = (string)rowView.Cells[ColumnName.Index].Value,
                        PrefixToChapter = (string)rowView.Cells[ColumnLink.Index].Value
                    };

                    Chapters.Add(chapter);
                }
            }
            if (Chapters.Count == 0)
            {
                return;
            }

            Chapter.RepeatCheck(Chapters);

            progressBarToms.Maximum = Chapters.Count;
            labelIndicatorTom.Text  = $"{progressBarToms.Value}/{progressBarToms.Maximum}";

            PathDownload = $"D:\\Anime\\Manga\\{Static.ToSafeFileName(labelName.Text)}";

            Directory.CreateDirectory(PathDownload);

            Download(true);

            downloader = new ImageDownloader(Chapters, this, siteObject);
            downloader.Download();
        }