Files
BookReader/BookReader/Models/Book.cs
Курнат Андрей e2f50bf57e edit
2026-02-17 20:37:27 +03:00

57 lines
1.5 KiB
C#

using SQLite;
namespace BookReader.Models;
public class Book
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Title { get; set; } = string.Empty;
public string Author { get; set; } = string.Empty;
public string FilePath { get; set; } = string.Empty;
public string FileName { get; set; } = string.Empty;
public string Format { get; set; } = string.Empty; // "epub" or "fb2"
public byte[]? CoverImage { get; set; }
public double ReadingProgress { get; set; } // 0.0 to 1.0
public string? LastCfi { get; set; } // CFI location for epub, or position for fb2
public string? LastChapter { get; set; }
public string? Locations { get; set; }
public DateTime DateAdded { get; set; } = DateTime.UtcNow;
public DateTime LastRead { get; set; } = DateTime.UtcNow;
public int TotalPages { get; set; }
public int CurrentPage { get; set; }
public string? CalibreId { get; set; } // ID from Calibre-Web if downloaded from there
[Ignore]
public ImageSource? CoverImageSource
{
get
{
if (CoverImage != null && CoverImage.Length > 0)
{
return ImageSource.FromStream(() => new MemoryStream(CoverImage));
}
return ImageSource.FromFile("default_cover.png");
}
}
[Ignore]
public string ProgressText => $"{(ReadingProgress * 100):F0}%";
[Ignore]
public double ProgressBarWidth => ReadingProgress * 120; // relative to cover width
}