Example #1
0
        /// <summary>
        /// Creates an ePub file at the location specified by parameters
        /// </summary>
        /// <param name="parameters">BookPath and epubOutputPath should be set.</param>
        /// <param name="control">The epub code needs a control that goes back to the main thread, in order to run some tasks that need to be on the main thread</param>
        public static void CreateEpubArtifact(CreateArtifactsParameters parameters, Control control)
        {
            if (String.IsNullOrEmpty(parameters.EpubOutputPath))
            {
                return;
            }

            string directoryName = Path.GetDirectoryName(parameters.EpubOutputPath);

            Directory.CreateDirectory(directoryName);                   // Ensures that the directory exists

            BookServer      bookServer  = _projectContext.BookServer;
            BookThumbNailer thumbNailer = _projectContext.ThumbNailer;
            var             maker       = new EpubMaker(thumbNailer, bookServer);

            maker.ControlForInvoke = control;

            maker.Book            = _book;
            maker.Unpaginated     = true;         // so far they all are
            maker.OneAudioPerPage = true;         // default used in EpubApi
            // Enhance: maybe we want book to have image descriptions on page? use reader font sizes?

            // Make the epub
            maker.SaveEpub(parameters.EpubOutputPath, new NullWebSocketProgress());
        }
        public void UpdateAndSave(EpubPublishUiSettings newSettings, string path, bool force, WebSocketProgress progress = null)
        {
            bool succeeded;

            do
            {
                lock (this)
                {
                    succeeded = UpdatePreview(newSettings, force, progress);
                    if (succeeded)
                    {
                        EpubMaker.SaveEpub(path, _progress);
                        _webSocketServer.SendString(kWebsocketContext, kWebsocketEventId_epubReady, _previewSrc);
                    }
                }
            } while (!succeeded && !EpubMaker.AbortRequested);             // try until we get a complete epub, not interrupted by user changing something.
        }