示例#1
0
        //public void AddOrUpdate<T>(this IBarrel barrel, string key, T value, TimeSpan timeSpan)
        //{
        //    if (barrel.Exists(key))
        //        barrel.Empty(key);
        //    barrel.Add<T>(key, value, timeSpan);
        //}

        public EpubBook ExtractEpubFromId(string assetId)
        {
            var asset    = Barrel.Current.Get <EpubAsset>(assetId);
            var epubBook = EpubReader.ReadBook(asset.Path);

            var tempFolder = BookEnvironment.GetTempLocalPathForEpub();

            ExtractAllFilesFromEpub(epubBook, tempFolder);

            return(epubBook);
        }
示例#2
0
        async void Button_Clicked(System.Object sender, System.EventArgs e)
        {
            var fileData = await CrossFilePicker.Current.PickFile();

            if (fileData == null)
            {
                return; // user canceled file picking
            }
            epubBook = EpubReader.ReadBook(fileData.FilePath);
            //SaveImages();
            Item.Text = epubBook.Title;

            try
            {
                var coverFileName = "";
                if (Device.RuntimePlatform == "UWP")
                {
                    coverFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "tempCover.jpg");
                }
                else
                {
                    coverFileName = Path.Combine(baseUrl, "tempCover.jpg");
                }
                File.WriteAllBytes(coverFileName, epubBook.CoverImage ?? epubBook.Content.Images.FirstOrDefault().Value.Content);
                this.CoverImage.Source = coverFileName;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            this.OnPropertyChanged("Item");

            //SaveHtmlCssFiles();
            contentService.ExtractAllFilesFromEpub(epubBook, BookEnvironment.GetTempLocalPathForEpub());

            renderHtml();
        }