Beispiel #1
0
 protected override async void PreLoadAll(int start)
 {
     base.PreLoadAll(start);
     this.Title = hitomi.name + " 0/" + (hitomi.files.Length - 1);
     for (int i = start; i < hitomi.files.Length; i++)
     {
         this.Title = hitomi.name + " " + i + "/" + (hitomi.files.Length - 1);
         if (images == null || images.Length < hitomi.files.Length)
         {
             images = new BitmapImage[hitomi.files.Length];
         }
         if (images[i] == null)
         {
             BitmapImage   image = null;
             Task <byte[]> task  = null;
             for (int m = 0; m < 10 && image == null; m++)
             {
                 task = ImageProcessor.ProcessAsync(hitomi.files[i].url);
                 try { image = (await task).ToImage(); } catch { }
             }
             if (image == null && task.IsFaulted)
             {
                 MessageBox.Show($"{i + 1}번 이미지를 불러오는데 실패했습니다.\nexcept.log 에 정보가 기록됩니다.\n{hitomi.files[i].url}\n{task.Exception.InnerException.Message}");
                 System.Reflection.MethodBase current = System.Reflection.MethodBase.GetCurrentMethod();
                 task.Exception.InnerException.WriteExcept(sourceName: current.FullName());
                 return;
             }
             else
             {
                 image.Freeze();
                 images[i] = image;
             }
         }
     }
 }
Beispiel #2
0
        protected override async void SetImage(Hitomi.HFile file)
        {
            base.SetImage(file);
            int copypage = page;

            if (images == null || images.Length < hitomi.files.Length)
            {
                images = new BitmapImage[hitomi.files.Length];
            }
            if (images[copypage] == null)
            {
                BitmapImage   image = null;
                Task <byte[]> task  = null;
                for (int m = 0; m < 10 && image == null; m++)
                {
                    task = ImageProcessor.ProcessAsync(file.url);
                    try { image = (await task).ToImage(); } catch { }
                }
                if (image == null && task.IsFaulted)
                {
                    MessageBox.Show($"{copypage + 1}번 이미지를 불러오는데 실패했습니다.\nlatest.log 에 정보가 기록됩니다.\n{file.url}\n{task.Exception.InnerException.ToString()}");
                    System.Reflection.MethodBase current = System.Reflection.MethodBase.GetCurrentMethod();
                    task.Exception.InnerException.WriteExcept(sourceName: current.FullName());
                }
                else
                {
                    image.Freeze();
                    if (images.Length == hitomi.files.Length)
                    {
                        images[copypage] = image;
                    }
                }
            }
            if (copypage == page && images.Length == hitomi.files.Length)
            {
                if (file.url.EndsWith(".gif"))
                {
                    WpfAnimatedGif.ImageBehavior.SetAnimatedSource(image, images[page]);
                }
                else
                {
                    WpfAnimatedGif.ImageBehavior.SetAnimatedSource(image, null);
                    image.Source = images[page];
                }
                ClearMemory();
            }
        }
Beispiel #3
0
        protected override async void PreLoad()
        {
            base.PreLoad();
            if (page + 1 >= hiyobi.files.Length)
            {
                return;
            }
            int loadpage = page + 1;

            if (images == null || images.Length < hiyobi.files.Length)
            {
                images = new BitmapImage[hiyobi.files.Length];
            }
            if (images[loadpage] != null)
            {
                return;
            }
            Hitomi.HFile  file  = hiyobi.files[loadpage];
            BitmapImage   image = null;
            Task <byte[]> task  = null;

            for (int m = 0; m < 10 && image == null; m++)
            {
                task = ImageProcessor.ProcessAsync(file.url);
                try { image = (await task).ToImage(); } catch { }
            }
            if (image == null && task.IsFaulted)
            {
                MessageBox.Show($"{loadpage + 1}번 이미지를 불러오는데 실패했습니다.\nlatest.log 에 정보가 기록됩니다.\n{file.url}\n{task.Exception.InnerException.ToString()}");
                System.Reflection.MethodBase current = System.Reflection.MethodBase.GetCurrentMethod();
                task.Exception.InnerException.WriteExcept(sourceName: current.FullName());
            }
            else
            {
                image.Freeze();
                if (images.Length == hiyobi.files.Length)
                {
                    images[loadpage] = image;
                }
            }
        }