Ejemplo n.º 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;
             * });*/
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        protected void OnRemoveClicked(object sender)
        {
            if (Book == null)
            {
                return;
            }
            Catalogue catalogue = Catalogue.GetCatalogue();

            catalogue.RemoveBook(Book);
            Navigation.PopAsync();
        }
Ejemplo n.º 4
0
 protected override void OnAppearing()
 {
     if (Catalogue.GetCatalogue().FindPublisher(((PublisherViewModel)BindingContext).Publisher.Name) != ((PublisherViewModel)BindingContext).Publisher)
     {
         Navigation.PopAsync();
     }
     else
     {
         base.OnAppearing();
     }
 }
Ejemplo n.º 5
0
        protected void OnRemoveClicked(object sender)
        {
            if (Publisher == null)
            {
                return;
            }
            Catalogue catalogue = Catalogue.GetCatalogue();

            catalogue.RemovePublisher(Publisher);
            Navigation.PopAsync();
        }
Ejemplo n.º 6
0
 public void RenameAuthor(object sender)
 {
     try
     {
         Catalogue.GetCatalogue().RenameAuthor(Author, NewTitle);
     }
     catch (FormatException)
     {
         NewTitle = Author.FullName;
         OnPropertyChanged(NewTitle);
     }
 }
Ejemplo n.º 7
0
 public void RenameBook(object sender)
 {
     try
     {
         Catalogue.GetCatalogue().RenameBook(Book, NewTitle);
     }
     catch (FormatException)
     {
         NewTitle = Book.Title;
         OnPropertyChanged(NewTitle);
     }
 }
Ejemplo n.º 8
0
 public void RenamePublisher(object sender)
 {
     try
     {
         Catalogue.GetCatalogue().RenamePublisher(Publisher, NewTitle);
     }
     catch (FormatException)
     {
         NewTitle = Publisher.Name;
         OnPropertyChanged(NewTitle);
     }
 }
Ejemplo n.º 9
0
 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();
     }
 }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 19
0
 protected override void OnSleep()
 {
     // Handle when your app sleeps
     Catalogue.GetCatalogue().Save();
     UserSettings.Current.Save();
 }