Ejemplo n.º 1
0
        public static Image GetImage(string pictureId, PictureSize size)
        {
            var def = new PictureDefinition(pictureId, size);

            if (!cache.ContainsKey(def))
            {
                (var isDefault, var bytes) = PictureStorage.GetPicture(def);

                var image = ImageReader.ToImage(bytes);
                if (isDefault)
                {
                    return(image);
                }
                cache[def] = image;
            }
            return(cache[def]);
        }
Ejemplo n.º 2
0
        public override void Processable_Begin(object sender, LibraryBook libraryBook)
        {
            base.Processable_Begin(sender, libraryBook);

            GetCoverArtDelegate = () => PictureStorage.GetPictureSynchronously(
                new PictureDefinition(
                    libraryBook.Book.PictureId,
                    PictureSize._500x500));

            //Set default values from library
            AudioDecodable_TitleDiscovered(sender, libraryBook.Book.Title);
            AudioDecodable_AuthorsDiscovered(sender, string.Join(", ", libraryBook.Book.Authors));
            AudioDecodable_NarratorsDiscovered(sender, string.Join(", ", libraryBook.Book.NarratorNames));
            AudioDecodable_CoverImageDiscovered(sender,
                                                PictureStorage.GetPicture(
                                                    new PictureDefinition(
                                                        libraryBook.Book.PictureId,
                                                        PictureSize._80x80)).bytes);
        }
Ejemplo n.º 3
0
        // 1st draft: lazily cribbed from GridEntry.ctor()
        private void initDetails()
        {
            this.Text = Book.Title;

            (_, var picture)   = PictureStorage.GetPicture(new PictureDefinition(Book.PictureId, PictureSize._80x80));
            this.coverPb.Image = Dinah.Core.Drawing.ImageReader.ToImage(picture);

            var t = @$ "
Title: {Book.Title}
Author(s): {Book.AuthorNames}
Narrator(s): {Book.NarratorNames}
Length: {(Book.LengthInMinutes == 0 ? " " : $" { Book.LengthInMinutes / 60 } hr {
                Book.LengthInMinutes % 60
            } min ")}
Category: {string.Join(" > ", Book.CategoriesNames)}
Purchase Date: {_libraryBook.DateAdded.ToString(" d ")}
".Trim();

            if (!string.IsNullOrWhiteSpace(Book.SeriesNames))
            {
                t += $"\r\nSeries: {Book.SeriesNames}";
            }

            var bookRating = Book.Rating?.ToStarString();

            if (!string.IsNullOrWhiteSpace(bookRating))
            {
                t += $"\r\nBook Rating:\r\n{bookRating}";
            }

            var myRating = Book.UserDefinedItem.Rating?.ToStarString();

            if (!string.IsNullOrWhiteSpace(myRating))
            {
                t += $"\r\nMy Rating:\r\n{myRating}";
            }

            this.detailsTb.Text = t;
        }