protected async void OnPickCoverClicked(object sender) { if (!CrossMedia.Current.IsPickPhotoSupported) { await UserDialogs.Instance.AlertAsync(Localization.NoPermission, Localization.PhotosNotSupport, Localization.Ok); return; } var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions { PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium, }); if (file == null) { return; } Catalogue.GetCatalogue().AddFileForDeleting(Book.Cover); Book.Cover = file.Path; /*image.Source = ImageSource.FromStream(() => * { * var stream = file.GetStream(); * file.Dispose(); * return stream; * });*/ }
protected void OnAddPublisherClicked(object sender) { Catalogue catalogue = Catalogue.GetCatalogue(); var config = new ActionSheetConfig(); config.SetTitle(Localization.AddPublisher); config.SetDestructive(Localization.NewPublisher, async() => { OnRemovePublisherClicked(null); await Navigation.PushModalAsync(new AddPublisherPage(Book, true)); }); config.SetCancel(Localization.Cancel); foreach (var publisher in catalogue.PublishersList) { if (Book.Publisher != publisher) { config.Add(publisher.Name, () => { OnRemovePublisherClicked(null); publisher.AddBook(Book); Book.Publisher = publisher; }); } } UserDialogs.Instance.ActionSheet(config); }
protected void OnRemoveClicked(object sender) { if (Book == null) { return; } Catalogue catalogue = Catalogue.GetCatalogue(); catalogue.RemoveBook(Book); Navigation.PopAsync(); }
protected override void OnAppearing() { if (Catalogue.GetCatalogue().FindPublisher(((PublisherViewModel)BindingContext).Publisher.Name) != ((PublisherViewModel)BindingContext).Publisher) { Navigation.PopAsync(); } else { base.OnAppearing(); } }
protected void OnRemoveClicked(object sender) { if (Publisher == null) { return; } Catalogue catalogue = Catalogue.GetCatalogue(); catalogue.RemovePublisher(Publisher); Navigation.PopAsync(); }
public void RenameAuthor(object sender) { try { Catalogue.GetCatalogue().RenameAuthor(Author, NewTitle); } catch (FormatException) { NewTitle = Author.FullName; OnPropertyChanged(NewTitle); } }
public void RenameBook(object sender) { try { Catalogue.GetCatalogue().RenameBook(Book, NewTitle); } catch (FormatException) { NewTitle = Book.Title; OnPropertyChanged(NewTitle); } }
public void RenamePublisher(object sender) { try { Catalogue.GetCatalogue().RenamePublisher(Publisher, NewTitle); } catch (FormatException) { NewTitle = Publisher.Name; OnPropertyChanged(NewTitle); } }
protected override void OnAppearing() { if (Catalogue.GetCatalogue().FindAuthor(((AuthorViewModel)BindingContext).Author.FullName) != ((AuthorViewModel)BindingContext).Author) { Navigation.PopAsync(); } else { image.Opacity = 0; image.FadeTo(1, 2000, Easing.Linear); base.OnAppearing(); } }
protected override void OnAppearing() { if (Catalogue.GetCatalogue().FindBook(((BookViewModel)BindingContext).Book.Title) != ((BookViewModel)BindingContext).Book) { Navigation.PopAsync(); } else { image.RotationY = 360; image.RotateYTo(0, 1500, Easing.SpringIn); base.OnAppearing(); } }
protected void OnRemovePublisherClicked(object sender) { if (Book.Publisher == null) { return; } Book.Publisher.RemoveBook(Book); if (Book.Publisher.IsEmpty()) { Catalogue.GetCatalogue().RemovePublisher(Book.Publisher); } Book.Publisher = null; }
public void OnRemoveBookClicked(Book sender) { if (sender == null) { return; } var catalogue = Catalogue.GetCatalogue(); var book = catalogue.FindBook(((Book)sender).Title); if (book == null) { return; } catalogue.RemoveBook(book); }
protected void OnRemoveBookClicked(object sender) { var config = new ActionSheetConfig(); config.SetTitle(Localization.BookToRemove); config.SetCancel(Localization.Cancel); foreach (var book in Publisher) { config.Add(book.Title, () => { Catalogue.GetCatalogue().RemoveBook(book); }); } UserDialogs.Instance.ActionSheet(config); }
protected async void OnAuthorsNamesClicked(object sender) { var action = await UserDialogs.Instance.ActionSheetAsync(Localization.Authors, Localization.Cancel, null, null, Book.AuthorsToStringArray()); Book.AuthorsToStringArray(); if (action == Localization.Cancel) { return; } Catalogue catalogue = Catalogue.GetCatalogue(); var selectedAuthor = catalogue.FindAuthor(action); if (selectedAuthor != null) { await Navigation.PushAsync(new AuthorPage(selectedAuthor)); } }
protected async void OnPickPhotoClicked(object sender) { if (!CrossMedia.Current.IsPickPhotoSupported) { await UserDialogs.Instance.AlertAsync(Localization.NoPermission, Localization.PhotosNotSupport, Localization.Ok); return; } var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions { PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium, }); if (file == null) { return; } Catalogue.GetCatalogue().AddFileForDeleting(Author.Photo); Author.Photo = file.Path; }
protected void OnRemoveAuthorClicked(object sender) { var config = new ActionSheetConfig(); config.SetTitle(Localization.AuthorToRemove); config.SetCancel(Localization.Cancel); foreach (var author in Book) { config.Add(author.FullName, () => { Book.RemoveAuthor(author); author.RemoveBook(Book); if (author.IsEmpty()) { Catalogue.GetCatalogue().RemoveAuthor(author); } }); } UserDialogs.Instance.ActionSheet(config); }
protected void OnAddAuthorClicked(object sender) { Catalogue catalogue = Catalogue.GetCatalogue(); var config = new ActionSheetConfig(); config.SetTitle(Localization.AddAuthor); config.SetDestructive(Localization.NewAuthor, async() => { await Navigation.PushModalAsync(new AddAuthorPage(Book, true)); }); config.SetCancel(Localization.Cancel); foreach (var author in catalogue.AuthorsList) { if (!Book.ContainsAuthor(author)) { config.Add(author.FullName, () => { author.AddBook(Book); Book.AddAuthor(author); }); } } UserDialogs.Instance.ActionSheet(config); }
protected void OnAddBookClicked(object sender) { Catalogue catalogue = Catalogue.GetCatalogue(); var config = new ActionSheetConfig(); config.SetTitle(Localization.AddBook); config.SetDestructive(Localization.NewBook, async() => { await App.Current.MainPage.Navigation.PushModalAsync(new AddBookPage(Publisher, true)); }); config.SetCancel(Localization.Cancel); foreach (var book in catalogue.BooksList) { if (book.Publisher == null && !Publisher.ContainsBook(book)) { config.Add(book.Title, () => { book.Publisher = Publisher; Publisher.AddBook(book); }); } } UserDialogs.Instance.ActionSheet(config); }
protected override void OnSleep() { // Handle when your app sleeps Catalogue.GetCatalogue().Save(); UserSettings.Current.Save(); }