Exemple #1
0
        public Reccomendation()
        {
            BookInfo.fromrec = true;
            if (agepreference != null)
            {
                age.SelectedItem = agepreferenceUP;
            }

            if (racepreference != null)
            {
                race.SelectedItem = racepreferenceUP;     //Checks on load if the pickers have been reset
            }

            if (genderpreference != null)
            {
                gender.SelectedItem = genderpreferenceUP;
            }
            carouselView.ItemsSource = bookcovers;



            if (prodevice)
            {
                homeicon.Scale   = .2;
                homeicon.Margin  = new Thickness(-70, -200, 0, 0);
                arrowimage.Scale = .4;
                //Go further negative for Y increase
            }

            else if (!prodevice)
            {
                BookTitle.Margin    = new Thickness(110, 380, 0, 0);
                AuthorName.Margin   = new Thickness(105, 190, 0, 0);
                carouselView.Margin = new Thickness(20, -70, 0, 0);

                carouselView.Scale = 3.25;
            }

            if (moreinfo)
            {
                ReadMore.Clicked += OnButtonClicked;
                moreinfo          = false;
            }

            if (clickhome)
            {
                homeicon.Clicked += BacktoHome;
                clickhome         = false;
            }

            if (!assignedlists)
            {
                racetypes.Add("Any race");
                racetypes.Add("Black characters");
                racetypes.Add("Asian characters");
                racetypes.Add("Latino characters");
                racetypes.Add("Native American characters");

                agetypes.Add("Any age");
                agetypes.Add("Children's books");
                agetypes.Add("Young Adult books");
                agetypes.Add("Adult books");


                genders.Add("Any gender");
                genders.Add("Male Leads");
                genders.Add("Female Leads");

                assignedlists = true;
            }



            bookcovers.CollectionChanged += booksretrieved;



            age.ItemsSource = agetypes;

            race.ItemsSource = racetypes;

            gender.ItemsSource = genders;


            race.SelectedIndexChanged += (sender, args) =>
            {
                QueryDatabase.anyrace = false;

                racepreference   = race.Items[race.SelectedIndex];
                racepreferenceUP = racepreference;
                racepreference   = parsepreference(racepreference);
                if (racepreference.Equals("Any"))
                {
                    QueryDatabase.anyrace = true;
                }
                checkiffilled();
            };
            age.SelectedIndexChanged += (sender, args) =>
            {
                QueryDatabase.anyage = false;
                agepreference        = age.Items[age.SelectedIndex];
                agepreferenceUP      = agepreference;
                agepreference        = parsepreference(agepreference);
                if (agepreference.Equals("Any"))
                {
                    QueryDatabase.anyage = true;
                }
                checkiffilled();
            };

            gender.SelectedIndexChanged += (sender, args) =>
            {
                QueryDatabase.anygender = false;
                genderpreference        = gender.Items[gender.SelectedIndex];
                genderpreferenceUP      = genderpreference;
                genderpreference        = parsepreference(genderpreference);
                if (genderpreference.Equals("Any"))
                {
                    QueryDatabase.anygender = true;
                }
                checkiffilled();
            };



            carouselView.ItemSwiped += (sender, args) =>
            {
                if (bookswiped % maxbooks == 0)
                {
                    QueryDatabase.calldatabase();
                }

                bookswiped++;
            };

            carouselView.ItemDisappearing += (sender, args) =>
            {
                if (bookcovers.Count > 0)
                {
                    disappearingbook = (BookCover)carouselView.SelectedItem;
                    booktitle        = disappearingbook.thisbook.booktitle;
                    authorname       = disappearingbook.thisbook.authorname;

                    titlelength  = booktitle.Length;
                    authorlength = authorname.Length;

                    SetTitleLength();
                    GetTitleSize();

                    BookTitle.Text  = booktitle;
                    AuthorName.Text = authorname;
                }
            };



            // Accomodate iPhone status bar.
            // this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            this.Content = new StackLayout
            {
                BackgroundColor = Color.AliceBlue, //Default is Alice Blue
                Orientation     = StackOrientation.Vertical,

                Margin  = new Thickness(0),
                Spacing = -170, //Go positively to increase spacing

                Children =
                {
                    age,
                    race,
                    gender,

                    generatebooks,
                    homeicon,
                    BookTitle,
                    AuthorName,
                    carouselView,
                    ReadMore,
                    arrowimage,
                }
            };
        }
        public SavedPage()
        {
            BookInfo.fromrec = false;

            Label Saved = new Label
            {
                Text              = "My Books",
                FontSize          = Device.GetNamedSize(NamedSize.Title, typeof(Label)),
                TextColor         = Color.Blue,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Margin            = new Thickness(0, 60, 0, 0)
            };

            Label NoBooks = new Label
            {
                Text              = "No books saved!",
                FontSize          = Device.GetNamedSize(NamedSize.Title, typeof(Label)),
                TextColor         = Color.Blue,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Margin            = new Thickness(0, 60, 0, 0)
            };
            Label booktitle = new Label
            {
                Text      = "",
                FontSize  = Device.GetNamedSize(NamedSize.Title, typeof(Label)),
                TextColor = Color.DarkBlue,
                Margin    = new Thickness(125, 100, 0, 0),
            };

            Label author = new Label
            {
                Margin    = new Thickness(125, 20, 0, 0),
                Text      = "",
                FontSize  = Device.GetNamedSize(NamedSize.Title, typeof(Label)),
                TextColor = Color.DarkSlateBlue,
            };


            ImageButton backarrow = new ImageButton
            {
                Source = ImageSource.FromFile("FlippedArrow.png"),
                Scale  = 0.2,
                Margin = new Thickness(-275, -105, 0, 0),
            };

            CarouselView savedbookimages = new CarouselView
            {
                Scale  = 4,
                Margin = new Thickness(20, 40, 0, 0)
            };

            Button ReadMore = new Button
            {
                Margin            = new Thickness(55, 0, 60, 20),
                Text              = "Read More",
                Font              = Font.SystemFontOfSize(NamedSize.Title),
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor   = Color.LightBlue,
                TextColor         = Color.Black,
                IsVisible         = false,
            };

            ReadMore.Clicked += OnButtonClicked;


            savedbookimages.ItemsSource = savedBooks;



            backarrow.Clicked += backarrow_Clicked;

            if (!Reccomendation.prodevice)
            {
                savedbookimages.Scale = 4;
            }

            else if (Reccomendation.prodevice)
            {
                ReadMore.Margin        = new Thickness(30, 40, 60, 20);
                savedbookimages.Margin = new Thickness(20, 90, 0, 0);
                booktitle.Margin       = new Thickness(110, 100, 0, 0);
                author.Margin          = new Thickness(105, 20, 0, 0);
                backarrow.Scale        = .4;
                backarrow.Margin       = new Thickness(-265, -95, 0, 0);
            }

            if (savedBooks.Count > 0)
            {
                NoBooks.Text       = "";
                ReadMore.IsVisible = true;
            }

            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    Saved,
                    backarrow,
                    savedbookimages,
                    NoBooks,
                    booktitle,
                    author,
                    ReadMore,
                }
            };

            savedbookimages.ItemDisappearing += (sender, args) =>
            {
                if (savedBooks.Count > 0)
                {
                    disappearingbook = (BookCover)savedbookimages.SelectedItem;
                    booktitle.Text   = disappearingbook.thisbook.booktitle;
                    author.Text      = disappearingbook.thisbook.authorname;
                }
            };
        }
        public BookInfo(BookCover passedbookcover)
        {
            bookcover = passedbookcover;

            string summary = bookcover.thisbook.summary;

            bookimage.Source = bookcover.imagesource;


            string booktextone = "";

            string booktextwo = "";

            string booktextthree = "";

            string booktexfour = "";

            int textheight = summary.Length;

            for (int i = 0; i < SavedPage.savedBooks.Count; i++)
            {
                if (SavedPage.savedBooks[i].thisbook.booktitle.Equals(bookcover.thisbook.booktitle))
                {
                    bookcover = SavedPage.savedBooks[i];
                }
            }
            if (SavedPage.savedBooks.Contains(bookcover))
            {
                savelabel.Text      = "Saved";
                savelabel.TextColor = Color.Gray;
                savebox.IsChecked   = true;
            }



            if (summary.Length >= 1000)
            {
                int currentindex = 0;
                int maxlength    = (summary.Length);
                booktextone   = summary.Substring(0, (maxlength / 4));
                booktextwo    = summary.Substring(booktextone.Length, (maxlength / 4));
                currentindex += (booktextwo.Length + booktextone.Length);
                booktextthree = summary.Substring(currentindex, (maxlength / 4));
                currentindex += booktextthree.Length;
                booktexfour   = summary.Substring(currentindex, maxlength / 4);


                if (!booktexfour.EndsWith(".") && !booktexfour.EndsWith("?"))
                {
                    booktexfour += ".";
                }
            }



            else
            {
                booktextone = summary;
                if (!booktextone.EndsWith("."))
                {
                    booktextone += ".";
                }
            }


            Label booksummary = new Label
            {
                Text = summary,

                Font = Font.SystemFontOfSize(NamedSize.Default),
                HorizontalOptions = LayoutOptions.Center,
                Margin            = new Thickness(0, -20, 0, 0),
            };



            ImageButton backbutton = new ImageButton
            {
                Source = ImageSource.FromFile("FlippedArrow.png"),
                Scale  = .2,
                Margin = new Thickness(-250, -350, 0, 0),
            };

            backbutton.Clicked += BackToReccomended;
            Label Synopsis = new Label
            {
                Text              = "Synopsis",
                Margin            = new Thickness(0, -150, 0, 0),
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                FontAttributes    = FontAttributes.Bold,
                TextColor         = Color.Black,
                Font              = Font.SystemFontOfSize(NamedSize.Title),
            };

            if (Reccomendation.prodevice)
            {
                Synopsis.Margin   = new Thickness(0, -125, 0, 0);
                savelabel.Margin  = new Thickness(100, 346, 0, 0);
                savebox.Margin    = new Thickness(265, -45, 0, 0);
                backbutton.Margin = new Thickness(-270, -300, 0, 0);
                backbutton.Scale  = .4;
            }

            if (!Reccomendation.prodevice)
            {
                bookimage.Scale = 2.7;
            }



            textheight              = setheight(textheight);
            savebox.CheckedChanged += OnChecked;



            ScrollView scrollView = new ScrollView
            {
                Content = new StackLayout
                {
                    HeightRequest = textheight,
                    Children      =
                    {
                        bookimage,

                        backbutton,
                        Synopsis,
                        savelabel,
                        savebox,
                        new Label {
                            Text = booktextone,Margin              = new Thickness(20, 10, 0, 0)
                        },
                        new Label {
                            Text = booktextwo,Margin              = new Thickness(20, 20, 0, 0)
                        },
                        new Label {
                            Text = booktextthree,Margin              = new Thickness(20, 30, 0, 0)
                        },
                        new Label {
                            Text = booktexfour,Margin              = new Thickness(20, 40, 0, 0)
                        },
                    }
                }
            };


            this.Content = new StackLayout
            {
                Children =
                {
                    scrollView,
                }
            };
        }