Added events to retrieve cover art upon request using PictureStorage.
This commit is contained in:
parent
2955e8b464
commit
3af84af2e2
3 changed files with 56 additions and 13 deletions
|
|
@ -267,6 +267,23 @@ namespace LibationWinForms.BookLiberation
|
|||
void updateRemainingTime(object _, TimeSpan remaining) => decryptDialog.UpdateRemainingTime(remaining);
|
||||
|
||||
void decryptCompleted(object _, string __) => decryptDialog.Close();
|
||||
|
||||
void requestCoverArt(object _, Action<byte[]> setArt)
|
||||
{
|
||||
var picDef = new FileManager.PictureDefinition(libraryBook.Book.PictureId, FileManager.PictureSize._500x500);
|
||||
(bool isDefault, byte[] picture) = FileManager.PictureStorage.GetPicture(picDef);
|
||||
|
||||
if (isDefault)
|
||||
{
|
||||
void pictureCached(object _, string pictureId) => onPictureCached(libraryBook, pictureId, setArt, pictureCached);
|
||||
FileManager.PictureStorage.PictureCached += pictureCached;
|
||||
}
|
||||
else
|
||||
setArt(picture);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region subscribe new form to model's events
|
||||
|
|
@ -278,6 +295,7 @@ namespace LibationWinForms.BookLiberation
|
|||
decryptBook.CoverImageFilepathDiscovered += coverImageFilepathDiscovered;
|
||||
decryptBook.UpdateProgress += updateProgress;
|
||||
decryptBook.UpdateRemainingTime += updateRemainingTime;
|
||||
decryptBook.RequestCoverArt += requestCoverArt;
|
||||
|
||||
decryptBook.DecryptCompleted += decryptCompleted;
|
||||
#endregion
|
||||
|
|
@ -294,13 +312,25 @@ namespace LibationWinForms.BookLiberation
|
|||
decryptBook.CoverImageFilepathDiscovered -= coverImageFilepathDiscovered;
|
||||
decryptBook.UpdateProgress -= updateProgress;
|
||||
decryptBook.UpdateRemainingTime -= updateRemainingTime;
|
||||
decryptBook.RequestCoverArt -= requestCoverArt;
|
||||
|
||||
decryptBook.DecryptCompleted -= decryptCompleted;
|
||||
decryptBook.Cancel();
|
||||
};
|
||||
#endregion
|
||||
}
|
||||
private static void onPictureCached(LibraryBook libraryBook, string picId, Action<byte[]> setArt, EventHandler<string> pictureCacheDelegate)
|
||||
{
|
||||
if (picId == libraryBook.Book.PictureId)
|
||||
{
|
||||
FileManager.PictureStorage.PictureCached -= pictureCacheDelegate;
|
||||
|
||||
var picDef = new FileManager.PictureDefinition(libraryBook.Book.PictureId, FileManager.PictureSize._500x500);
|
||||
(_, byte[] picture) = FileManager.PictureStorage.GetPicture(picDef);
|
||||
|
||||
setArt(picture);
|
||||
}
|
||||
}
|
||||
private static (AutomatedBackupsForm, LogMe) attachToBackupsForm(IDownloadableProcessable downloadable)
|
||||
{
|
||||
#region create form and logger
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue