Пример #1
0
        private static void CreateEntities(ILibrary _libraryVM, PageViewModel _page, CoverSegmenting cs, DataOperationUnit dataOpUnit)
        {
            Guid imageID = Guid.NewGuid();
            var  image   = new ImageViewModel(imageID, "cover", cs._masterPath, Configuration.ApplicationConfiguration);

            image.Configuration  = Configuration.ApplicationConfiguration;
            image.ID             = imageID;
            image.UnescapedTitle = "cover";
            if (System.IO.Path.IsPathRooted(cs._masterPath))
            {
                image.RelativeMasterPath = ImageViewModel.MakeRelativeMasterPath(Configuration.ApplicationConfiguration.WorkingDirectory, cs._masterPath);
            }
            else
            {
                image.RelativeMasterPath = cs._masterPath;
            }
            ImageFacade.Insert(image, dataOpUnit);

            var pageID = Guid.NewGuid();
            var page   = new PageViewModel();

            page.Configuration  = Configuration.ApplicationConfiguration;
            page.ID             = pageID;
            page.UnescapedTitle = "cover";
            page.ImageID        = imageID;
            page.BookID         = _page.BookID;
            page.PageIndex      = 1;
            page.Image          = image;
            PageFacade.Insert(page, dataOpUnit);

            var book = _libraryVM.OnStage.Where(b => b.ID.Equals(_page.BookID)).Single();

            book.FirstPage = page;
            if (book.FirstPage.Image.ThumbnailRecorded)
            {
                book.FirstPage.Image.Thumbnail = ThumbnailFacade.FindByImageID(book.FirstPage.ImageID, dataOpUnit);
            }

            if (!book.FirstPage.Image.ThumbnailLoaded || !book.FirstPage.Image.ThumbnailGenerated)
            {
                ThumbnailGenerating.GenerateThumbnail(book.FirstPage.Image, dataOpUnit);
            }

            cs._book = book;
        }
Пример #2
0
        private static void GenerateNewCoverBitmap(PageViewModel _page, CoverSideCandidate CoverLeftSide, CoverSideCandidate CoverRightSide, CoverSegmenting cs, DataOperationUnit dataOpUnit)
        {
            int count = Querying.BookContentsCount(_page.BookID, dataOpUnit);
            var dir   = Path.GetDirectoryName(_page.Image.AbsoluteMasterPath);

            cs._masterPath = $"{dir}\\XC{(count + 1)}.jpg";
            var newBitmap = CopyBitmap(_page, CoverLeftSide, CoverRightSide);

            SaveBitmap(newBitmap, cs._masterPath);
        }