Esempio n. 1
0
        private void SetFirstPage()
        {
            var page = PageFacade.FindByBookIdTop1(NewBook.ID);

            page.Image = ImageFacade.FindBy(page.ImageID);

            NewBook.FirstPage = page;
            s_logger.Debug($"Set FirstPage : {page.Image}");

            Load.BookLoading.GenerateThumbnailIf(NewBook);
        }
Esempio n. 2
0
 internal static void SetImageToPage(PageViewModel page)
 {
     page.Image = ImageFacade.FindBy(page.ImageID);
 }
Esempio n. 3
0
 private object LoadBitmap(string path)
 {
     try
     {
         Guid guid;
         if (Guid.TryParse(path, out guid))
         {
             var image = ImageFacade.FindBy(guid);
             if (!image.IsDecrypted)
             {
                 image.DecryptImage();
             }
             var bitmap = OnmemoryImageManager.Instance.PullAsWriteableBitmap(guid);
             return(bitmap);
         }
         else
         {
             using (Mat mat = new Mat(path, ImreadModes.Unchanged))
             {
                 if (mat.Rows == 0 || mat.Cols == 0)
                 {
                     var fileInfo = new FileInfo(path);
                     if (fileInfo.Length == 0)
                     {
                         s_logger.Error($"File is broken:{path}");
                         return(null);
                     }
                     if (Path.GetExtension(path) == ".gif")
                     {
                         return(null);
                     }
                     Thread.Sleep(100);
                     s_logger.Error($"Retry to load bitmap:{path}");
                     return(LoadBitmap(path));
                 }
                 return(ToWriteableBitmap(mat));
             }
         }
     }
     catch (OutOfMemoryException e)
     {
         s_logger.Error(e);
         GC.WaitForPendingFinalizers();
         GC.Collect();
         return(null);
     }
     catch (COMException e)
     {
         s_logger.Error(e);
         GC.WaitForPendingFinalizers();
         GC.Collect();
         return(null);
     }
     catch (OpenCVException e)
     {
         s_logger.Error(e);
         GC.WaitForPendingFinalizers();
         GC.Collect();
         return(null);
     }
     catch (FileNotFoundException e)
     {
         s_logger.Error(e);
         GC.WaitForPendingFinalizers();
         GC.Collect();
         return(LoadBitmap($"{Configuration.ApplicationConfiguration.ExecutingDirectory}\\{Specifications.LOCK_ICON_FILE}"));
     }
 }