public LibraryService(Store.LibraryModel Library) { try { this.Library = Library; this.Notify = new Notify.NotifyVM("General"); this.Store = DependencyService.Get <Store.ILibraryStore>(); if (!this.Store.LibraryFiles.ContainsKey(ComicsShelf.Store.enLibraryFilesGroup.Libraries)) { this.Store.LibraryFiles.Add(ComicsShelf.Store.enLibraryFilesGroup.Libraries, new List <ComicFiles.ComicFileVM>()); } if (!this.Store.LibraryFiles.ContainsKey(ComicsShelf.Store.enLibraryFilesGroup.RecentFiles)) { this.Store.LibraryFiles.Add(ComicsShelf.Store.enLibraryFilesGroup.RecentFiles, new List <ComicFiles.ComicFileVM>()); } if (!this.Store.LibraryFiles.ContainsKey(ComicsShelf.Store.enLibraryFilesGroup.ReadingFiles)) { this.Store.LibraryFiles.Add(ComicsShelf.Store.enLibraryFilesGroup.ReadingFiles, new List <ComicFiles.ComicFileVM>()); } if (!System.IO.Directory.Exists(Helpers.Constants.CoversCachePath)) { System.IO.Directory.CreateDirectory(Helpers.Constants.CoversCachePath); } if (!System.IO.Directory.Exists(Helpers.Constants.FilesCachePath)) { System.IO.Directory.CreateDirectory(Helpers.Constants.FilesCachePath); } } catch { } }
private static string[] GetNotifyKeys(Store.LibraryModel library) { return(new string[] { $"{NotifyKey}.General", $"{NotifyKey}.{library.ID}" }); }
public void Send(Store.LibraryModel library, bool isRunning) { this.IsRunning = isRunning; foreach (var notifyKey in GetNotifyKeys(library)) { Send(notifyKey, this); } }
public void Send(Store.LibraryModel library, string details, double progress) { this.Details = details; this.Progress = progress; this.IsRunning = true; foreach (var notifyKey in GetNotifyKeys(library)) { Send(notifyKey, this); } }
public void Send(Store.LibraryModel library, string text) { this.Text = text; this.Details = string.Empty; this.Progress = 0; this.IsRunning = true; foreach (var notifyKey in GetNotifyKeys(library)) { Send(notifyKey, this); } }
public LibraryVM(Store.LibraryModel library) { this.Library = library; this.Title = library.Description; this.Notify = new Notify.NotifyVM(library.ID); this.ComicFolders = new ObservableList <ComicFolderVM>(); this.OpenCommand = new Command(async(item) => await this.Open(item as ComicFileVM)); this.RemoveCommand = new Command(async() => await this.Remove()); this.OnRefreshingList(DependencyService.Get <Store.ILibraryStore>().GetLibraryFiles(this.Library)); Messaging.Subscribe <List <ComicFileVM> >("OnRefreshingList", this.Library.ID, this.OnRefreshingList); Messaging.Subscribe <ComicFileVM>("OnRefreshingItem", this.Library.ID, this.OnRefreshingItem); }
internal static void RefreshLibrary(Store.LibraryModel library) { Task.Run(async() => { using (var service = new LibraryService(library)) { if (!await service.RefreshLibrary()) { await Task.Delay(15 * 1000); RefreshLibrary(library); } } }); }
public SplashVM(ComicFileVM file) { this.CurrentFile = file; this.Store = DependencyService.Get <ComicsShelf.Store.ILibraryStore>(); this.Library = this.Store.GetLibrary(file.ComicFile.LibraryKey); this.FolderFiles = this.Store.LibraryFiles[ComicsShelf.Store.enLibraryFilesGroup.Libraries] .Where(x => x.ComicFile.LibraryKey == file.ComicFile.LibraryKey && x.ComicFile.FolderPath == file.ComicFile.FolderPath && x.ComicFile.Available == true) .OrderByDescending(x => x.ComicFile.FilePath) .ToList(); this.ItemSelectedCommand = new Command(async(item) => await this.ItemSelected(item)); this.ItemOpenCommand = new Command(async() => await this.ItemOpen()); this.ClearCacheCommand = new Command(async() => await this.ClearCache()); }