Esempio n. 1
0
        private void AddMetadataToPanel(int i, string file_name)
        {
            string tmp = Path.GetTempFileName();

            using (var zip = ZipFile.Open(file_name, ZipArchiveMode.Read))
            {
                if (!zip.Entries[0].Name.EndsWith(".json"))
                {
                    zip.Entries[0].ExtractToFile(tmp, true);
                }
                else
                {
                    zip.Entries[1].ExtractToFile(tmp, true);
                }
            }

            Image img;

            using (FileStream fs = new FileStream(tmp, FileMode.Open, FileAccess.Read, FileShare.None, 4096, FileOptions.DeleteOnClose))
            {
                img = Image.FromStream(fs);
                //img = img.GetThumbnailImage(img.Width, img.Height, () => false, (IntPtr)null);
            }
            info[i] = new InfoWrapper(img.Clone() as Image);

            PictureBox[] pbs = { pb1, pb2, pb3, pb4, pb5 };
            pbs[i].MouseEnter += info[i].Picture_MouseEnter;
            pbs[i].MouseMove  += info[i].Picture_MouseMove;
            pbs[i].MouseLeave += info[i].Picture_MouseLeave;

            if (pbs[i].InvokeRequired)
            {
                pbs[i].Invoke(new Action(() => { pbs[i].Image = img; }));
            }
            else
            {
                pbs[i].Image = img;
            }

            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            GC.WaitForPendingFinalizers();
        }
Esempio n. 2
0
        private void AddMetadataToPanel(int i, string id)
        {
            string thumbnail = GetThumbnailAddress(id);

            string    temp = Path.GetTempFileName();
            WebClient wc   = new WebClient();

            wc.Headers["Accept-Encoding"] = "application/x-gzip";
            wc.Encoding = Encoding.UTF8;
            wc.DownloadFile(new Uri(HitomiDef.HitomiThumbnail + thumbnail), temp);

            Image img;

            using (FileStream fs = new FileStream(temp, FileMode.Open, FileAccess.Read, FileShare.None, 4096, FileOptions.DeleteOnClose))
            {
                img = Image.FromStream(fs);
            }
            if (closed)
            {
                img.Dispose();
                LogEssential.Instance.PushLog(() => $"Unexpected Disposed! {HitomiDef.HitomiThumbnail + thumbnail} {temp} {i} {id}");
                return;
            }
            info[i] = new InfoWrapper(img.Clone() as Image);

            PictureBox[] pbs = { pb1, pb2, pb3, pb4, pb5 };
            pbs[i].MouseEnter += info[i].Picture_MouseEnter;
            pbs[i].MouseMove  += info[i].Picture_MouseMove;
            pbs[i].MouseLeave += info[i].Picture_MouseLeave;

            if (pbs[i].InvokeRequired)
            {
                pbs[i].Invoke(new Action(() => { pbs[i].Image = img; }));
            }
            else
            {
                pbs[i].Image = img;
            }

            LogEssential.Instance.PushLog(() => $"Load successful! {HitomiDef.HitomiThumbnail + thumbnail} {temp} {i} {id}");
        }