Example #1
0
        private void frmPreview_Load(object sender, EventArgs e)
        {
            PicElement pe = new PicElement(this);

            pe.Article       = new HitomiArticle();
            pe.Article.Magic = id;
            Task.Run(() => HitomiCore.DownloadAndSetImageLink(pe, ImageLinkCallback));
        }
        static public void DownloadAndSetImageLink(PicElement pe, CallBack callback)
        {
            WebClient wc = new WebClient();

            wc.Encoding = Encoding.UTF8;
            wc.DownloadStringCompleted += wc_dasil;
            wc.DownloadStringAsync(new Uri(HitomiDef.HitomiGalleryAddress + pe.Article.Magic + ".js"),
                                   new Tuple <PicElement, CallBack>(pe, callback));
        }
Example #3
0
 private void AddPanel(PicElement pe)
 {
     try
     {
         if (ImagePanel.InvokeRequired)
         {
             Invoke(new Action <PicElement>(AddPanel), new object[] { pe }); return;
         }
         ImagePanel.Controls.Add(pe);
         SortThumbnail();
     } catch
     {
     }
 }
Example #4
0
        private void Notify(string uri, string filename, object obj)
        {
            PicElement pe = new PicElement(this);

            pe.Article       = new HitomiArticle();
            pe.Article.Magic = ((int)obj).ToString();
            pe.Dock          = DockStyle.Bottom;
            pe.SetImageFromAddress(filename, 300, 400, false);

            pe.Font = this.Font;

            AddPanel(pe);
            PBIncrease();
            Application.DoEvents();
        }
Example #5
0
        private void AddPanel()
        {
            int count = 0;

            foreach (var md in metadatas)
            {
                if (!md.Item3.HasValue)
                {
                    continue;
                }
                count++;
                if (count == 100)
                {
                    return;
                }
                string path = Path.Combine(tbPath.Text, md.Item1);

                IPicElement pe;
                pe = new PicElement(this);
                HitomiArticle article = HitomiCommon.MetadataToArticle(md.Item3.Value);

                pe.Article = article;
                pe.Label   = article.Title;

                using (var zip = ZipFile.Open(path, ZipArchiveMode.Read))
                {
                    string tmp = Path.GetTempFileName();
                    zip.Entries[0].ExtractToFile(tmp, true);
                    pe.SetImageFromAddress(tmp, 150, 200);
                }

                pe.Font = this.Font;

                this.Post(() => ImagePanel.Controls.Add(pe as Control));
            }
        }
 static public void DownloadArticle(HitomiArticle ha, string folder, CallBack2 callback, PicElement pe, int v1, int v2)
 {
     Directory.CreateDirectory(folder);
     for (int i = v1; i < v2; i++)
     {
         WebClient wc = new WebClient();
         wc.Headers["Accept-Encoding"] = "application/x-gzip";
         wc.Encoding = Encoding.UTF8;
         wc.DownloadFileCompleted += wc_da;
         if (ha.TagsKor == false)
         {
             wc.DownloadFileAsync(new Uri(HitomiDef.GetDownloadImageAddress(ha.Magic, ha.ImagesLink[i])),
                                  Path.Combine(folder, ha.ImagesLink[i]),
                                  new Tuple <HitomiArticle, int, CallBack2, PicElement>(ha, i, callback, pe));
         }
     }
 }