void checkiffilled() { if (racepreference != null && agepreference != null && genderpreference != null) { if (bookcovers.Count == 0) { Device.GetNamedSize(NamedSize.Title, typeof(Label)); generatebooks.Text = "Grabbing books..."; } else { generatebooks.Text = ""; } if (bookcovers.Count > 0) { bookcovers.Clear(); QueryDatabase.booksindexed = 0; } QueryDatabase.calldatabase(); //If all of the pickers are filled, call the database. } }
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, } }; }