Exemple #1
0
        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;
             * });*/
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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();
     }
 }
Exemple #5
0
        protected void OnRemoveClicked(object sender)
        {
            if (Publisher == null)
            {
                return;
            }
            Catalogue catalogue = Catalogue.GetCatalogue();

            catalogue.RemovePublisher(Publisher);
            Navigation.PopAsync();
        }
Exemple #6
0
 public void RenameAuthor(object sender)
 {
     try
     {
         Catalogue.GetCatalogue().RenameAuthor(Author, NewTitle);
     }
     catch (FormatException)
     {
         NewTitle = Author.FullName;
         OnPropertyChanged(NewTitle);
     }
 }
Exemple #7
0
 public void RenameBook(object sender)
 {
     try
     {
         Catalogue.GetCatalogue().RenameBook(Book, NewTitle);
     }
     catch (FormatException)
     {
         NewTitle = Book.Title;
         OnPropertyChanged(NewTitle);
     }
 }
Exemple #8
0
 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();
     }
 }
Exemple #10
0
 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();
     }
 }
Exemple #11
0
 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;
 }
Exemple #12
0
        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);
        }
Exemple #13
0
        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);
        }
Exemple #14
0
        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));
            }
        }
Exemple #15
0
        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;
        }
Exemple #16
0
        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);
        }
Exemple #17
0
        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);
        }
Exemple #18
0
        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);
        }
Exemple #19
0
 protected override void OnSleep()
 {
     // Handle when your app sleeps
     Catalogue.GetCatalogue().Save();
     UserSettings.Current.Save();
 }