public List <Mushroom> Identify(Mushroom m) { List <Mushroom> results = new List <Mushroom>(); if (!(m.CapColor == null && m.Underside == null && m.UndersideColor == null && m.Veil == null)) { string query = "SELECT * FROM Mushrooms WHERE"; if (m.CapColor != null) { query += " CapColor LIKE '%" + m.CapColor + "%' AND"; } if (m.Underside != null) { query += " Underside = '" + m.Underside + "' AND"; } if (m.UndersideColor != null) { query += " UndersideColor LIKE '%" + m.UndersideColor + "%' AND"; } if (m.Veil != null) { query += " Veil = '" + m.Veil + "' AND"; } query += " HasStem = " + m.HasStem + " AND"; query += " HasScales = " + m.HasScales + " AND"; query = query.Substring(0, query.Length - 3); results = myDB.Query <Mushroom>(query); } return(results); }
public FieldGuidePage(SQLiteHandler sq) { this.Title = "Field Guide"; List <Mushroom> allMushrooms = sq.GetMushroomTable(); List <Mushroom> mushrooms = new List <Mushroom>(); foreach (Mushroom m in allMushrooms) { if (m.FieldGuide) { mushrooms.Add(m); } } mushrooms.Sort((p, q) => p.LatinName.CompareTo(q.LatinName)); ListView mushroomList = new ListView(); mushroomList.ItemsSource = mushrooms; mushroomList.VerticalOptions = LayoutOptions.Start; mushroomList.ItemTemplate = new DataTemplate(typeof(MushroomViewCell)); //mushroomList.BackgroundColor = Color.Azure; mushroomList.RowHeight = 100; //mushroomList.IsGroupingEnabled = true; //mushroomList.GroupHeaderTemplate = new DataTemplate(typeof(GroupLabel)); mushroomList.ItemTapped += async(sender, e) => { Mushroom m = mushrooms[e.ItemIndex]; await Navigation.PushAsync(new NavigationPage(new DetailPage(m))); }; StackLayout sl = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(10, 10, 10, 10), HeightRequest = 300, Children = { new Frame { BorderColor = Color.DarkRed, CornerRadius = 5, Padding = 8, Content = new StackLayout { Children = { mushroomList } } } } }; this.BackgroundColor = Color.Beige; Content = sl; }
public void AddNewMushroom(FoundMushroom fm) { Mushroom m = fm.mushroom; m.CommonName = "Unknown"; m.ImageName = "Unknown"; fm.CommonName = "Unknown"; var maxPk = myDB.Table <Mushroom>().OrderByDescending(c => c.ID).FirstOrDefault(); m.ID = (maxPk == null ? 1 : maxPk.ID + 1); int what = myDB.Insert(m); fm.MushroomID = m.ID; var maxPk2 = myDB.Table <FoundMushroom>().OrderByDescending(c => c.ID).FirstOrDefault(); fm.ID = (maxPk2 == null ? 1 : maxPk2.ID + 1); myDB.Insert(fm); }
public IdentifyResultsPage(Mushroom m, SQLiteHandler sq) { int selected = -1; Mushroom selectedMushroom = new Mushroom(); List <Mushroom> resultsList = sq.Identify(m); ListView mushroomList = new ListView(); mushroomList.VerticalOptions = LayoutOptions.FillAndExpand; mushroomList.ItemsSource = resultsList; mushroomList.VerticalOptions = LayoutOptions.Start; mushroomList.ItemTemplate = new DataTemplate(typeof(MushroomViewCell)); mushroomList.RowHeight = 130; //mushroomList.IsGroupingEnabled = true; //mushroomList.GroupHeaderTemplate = new DataTemplate(typeof(GroupLabel)); mushroomList.ItemTapped += (sender, e) => { selected = 0; selectedMushroom = resultsList[e.ItemIndex]; }; Button viewDetails = new Button { Text = "View Details", HorizontalOptions = LayoutOptions.FillAndExpand }; viewDetails.Clicked += async(sender, args) => { if (selected == -1) { await DisplayAlert("", "Please select a mushroom to view.", "OK"); } else { await Navigation.PushAsync(new DetailPage(selectedMushroom)); } }; Button setIDButton = new Button { Text = "Save as Selected", HorizontalOptions = LayoutOptions.FillAndExpand }; setIDButton.Clicked += async(sender, args) => { if (selected == -1) { await DisplayAlert("", "Please choose a mushroom from the list that matches your specimen.", "OK"); } else { var confirmed = await DisplayAlert("Confirm Identity", "Please confirm that you want to set the identity of your mushroom to \"" + selectedMushroom.CommonName + "\" (" + selectedMushroom.LatinName + ")", "Confirm", "Cancel"); if (confirmed) { Location gps = await Geolocation.GetLocationAsync(); string fmgps = "Lat " + gps.Latitude.ToString() + " Long " + gps.Longitude.ToString(); FoundMushroom fm = new FoundMushroom(fmgps, DateTime.Now, selectedMushroom.ID, true); fm.mushroom = selectedMushroom; await Navigation.PushAsync(new PersonalizeMushroomPage(sq, fm)); } } }; if (resultsList.Count == 0) { setIDButton.IsEnabled = false; viewDetails.IsEnabled = false; } Label instructions = new Label { Text = "No matching mushroom? Click here to save as unidentified (You can edit it later).", FontSize = 20, VerticalOptions = LayoutOptions.EndAndExpand }; Button saveUnIDButton = new Button { Text = "Save Unidentified Mushroom", HorizontalOptions = LayoutOptions.FillAndExpand }; saveUnIDButton.Clicked += async(sender, args) => { Location gps = await Geolocation.GetLocationAsync(); string fmgps = "Lat " + gps.Latitude.ToString() + " Long " + gps.Longitude.ToString(); FoundMushroom fm = new FoundMushroom(fmgps, DateTime.Now, m.ID, false); fm.mushroom = m; await Navigation.PushAsync(new PersonalizeMushroomPage(sq, fm)); }; StackLayout buttons = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { viewDetails, setIDButton, } }; StackLayout saveUNID = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical, BackgroundColor = Color.AliceBlue, Children = { instructions, saveUnIDButton } }; StackLayout sl1 = new StackLayout { BackgroundColor = Color.AliceBlue, Children = { mushroomList, buttons, } }; StackLayout sl2 = new StackLayout { Padding = new Thickness(10, 5, 10, 5), Orientation = StackOrientation.Vertical, Children = { sl1, saveUNID } }; Frame frame = new Frame { BorderColor = Color.DarkRed, CornerRadius = 5, Padding = 8, Content = sl2 }; Padding = new Thickness(10, 5, 10, 5); this.BackgroundColor = Color.Beige; Content = frame; }
public DetailPage(Mushroom m) { string capString = ""; string undersideString = ""; string[] str = m.CapColor.Split(','); foreach (string s in str) { capString += (s + ", "); } capString = capString.Substring(0, capString.Length - 2); str = m.UndersideColor.Split(','); foreach (string s in str) { undersideString += (s + ", "); } undersideString = undersideString.Substring(0, undersideString.Length - 2); Label Details = new Label { Text = "Here is more information listed for you...", FontAttributes = FontAttributes.Bold, FontSize = 30 }; //set to labels user input + image to showcase object Label capColor = new Label { Text = "Cap color: " + capString }; Label undersideColor = new Label { Text = "Underside color: " + undersideString }; Label stem = new Label { }; if (m.HasStem) { stem.Text = "Stem: Present"; } else { stem.Text = "Stem: Not present"; } Label scales = new Label { }; if (m.HasStem) { scales.Text = "Scales: Not present"; } else { scales.Text = "Scales: present"; } Label veil = new Label { Text = "Veil remnant type: " + m.Veil }; Label CommonName = new Label { Text = "Common Name: " + m.CommonName }; Label LatinName = new Label { Text = "Latin Name: " + m.LatinName }; Label Edibility = new Label { Text = "Edibility: " + m.Edibility }; Label Underside = new Label { Text = "Underside Type: " + m.Underside }; Image picture = new Image { Source = m.ImageName, Aspect = Aspect.AspectFit, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Fill }; //Not sure if I need both the code above and below since both are creating lables for the attributes from the object //Grid grid1 = new Grid(); //grid1.RowDefinitions.Add(new RowDefinition { Height = new GridLength(2, GridUnitType.Star) }); //grid1.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); //grid1.RowDefinitions.Add(new RowDefinition { Height = new GridLength(3, GridUnitType.Star) }); //grid1.RowDefinitions.Add(new RowDefinition { Height = new GridLength(4, GridUnitType.Star) }); //grid1.RowDefinitions.Add(new RowDefinition { Height = new GridLength(5, GridUnitType.Star) }); //grid1.RowDefinitions.Add(new RowDefinition { Height = new GridLength(6, GridUnitType.Star) }); //grid1.RowDefinitions.Add(new RowDefinition { Height = new GridLength(7, GridUnitType.Star) }); //grid1.RowDefinitions.Add(new RowDefinition { Height = new GridLength(8, GridUnitType.Star) }); //grid1.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(200) }); // grid1.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); //grid1.Children.Add(new Label { Text = m.UndersideColor }, 1, ); //grid1.Children.Add(new Label { Text = m.Underside }, 1, 0); //grid1.Children.Add(new Label { Text = m.HasStem }, 1, 1); //grid1.Children.Add(new Label { Text = m.HasScales }, 0, 0); //grid1.Children.Add(new Label { Text = m.HasScales }, 0, 1); //grid1.Children.Add(new Label { Text = m.CapColor }, 1, 0); //grid1.Children.Add(new Label { Text = m.ImageName }, 1, 1); Frame Frame1 = new Frame { Content = CommonName, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red, }; Frame Frame2 = new Frame { Content = LatinName, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red, }; Frame Frame3 = new Frame { Content = capColor, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red, }; Frame Frame4 = new Frame { Content = Underside, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red, }; Frame Frame5 = new Frame { Content = undersideColor, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Frame Frame6 = new Frame { Content = veil, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Frame Frame7 = new Frame { Content = stem, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Frame Frame8 = new Frame { Content = scales, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Frame Frame9 = new Frame { Content = Edibility, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Frame Frame10 = new Frame { Content = picture, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; ScrollView sv = new ScrollView { Content = new StackLayout { Padding = new Thickness(10, 5, 10, 5), Children = { Frame10, Frame1, Frame2, Frame3, Frame4, Frame5, Frame6, Frame7, Frame8, Frame9, } } }; this.Content = sv; this.BackgroundColor = Color.Beige; }
public IdentifyPage(SQLiteHandler sq) { //Get list of colors from database List <Mushroom> fg = sq.GetMushroomTable(); List <string> capColors = new List <string>(); List <string> undersideColors = new List <string>(); foreach (Mushroom m in fg) { if (m.FieldGuide) { string[] ccs = m.CapColor.Split(','); string[] ucs = m.UndersideColor.Split(','); foreach (string s in ccs) { capColors.Add(s); } foreach (string s in ucs) { undersideColors.Add(s); } } } capColors = capColors.Distinct().ToList(); capColors.Sort(); undersideColors = undersideColors.Distinct().ToList(); undersideColors.Sort(); //directions label placed inside a frame Frame welcomeInfo = new Frame { BorderColor = Color.DarkRed, CornerRadius = 5, Padding = 8, Content = new StackLayout { Children = { new Label { Text = "Welcome!", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), FontAttributes = FontAttributes.Bold, FontFamily = "Courier", }, new BoxView { Color = Color.Black, HeightRequest = 2, HorizontalOptions = LayoutOptions.Fill }, new Label { Text = "Please enter the following information below to help classify your mushroom. Click save when finished to view results." } } } }; //user controls //switch for yes or no for stem Label switchLabel1 = new Label { Text = "Does the mushroom have a stem?" }; Switch stemSwitch = new Switch { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.CenterAndExpand, OnColor = Color.Green, }; stemSwitch.Toggled += (sender, e) => { // eventValue.Text = String.Format("Switch is now {0}", e.Value); // pageValue.Text = gills.IsToggled.ToString(); }; // picker for cap color Picker capColor = new Picker { Title = "Pick a cap color", VerticalOptions = LayoutOptions.CenterAndExpand }; foreach (string c in capColors) { capColor.Items.Add(c); } Label label3 = new Label { Text = " " }; capColor.SelectedIndexChanged += (sender, args) => { label3.Text = capColor.Items[capColor.SelectedIndex]; }; //Picker for underside type Picker undersideType = new Picker { Title = "What type of underside does the mushroom have?", VerticalOptions = LayoutOptions.CenterAndExpand, }; var undersideOptions = new List <string> { "Gills", "Pores", "Teeth", "(No underside)" }; foreach (string c in undersideOptions) { undersideType.Items.Add(c); } undersideType.SelectedIndexChanged += (sender, args) => { label3.Text = undersideType.Items[undersideType.SelectedIndex]; }; // picker for underside color Picker undersideColor = new Picker { Title = "What color is the underside?", VerticalOptions = LayoutOptions.CenterAndExpand }; foreach (string c in undersideColors) { undersideColor.Items.Add(c); } undersideColor.SelectedIndexChanged += (sender, args) => { label3.Text = undersideColor.Items[undersideColor.SelectedIndex]; }; //picker for veil Picker veilRemnant = new Picker { Title = "What type of veil remnant does the mushroom have?", VerticalOptions = LayoutOptions.CenterAndExpand }; var options2 = new List <string> { "Universal", "Ring", "None" }; foreach (string optionName in options2) { veilRemnant.Items.Add(optionName); } veilRemnant.SelectedIndexChanged += (sender, args) => { label3.Text = veilRemnant.Items[veilRemnant.SelectedIndex]; }; //switch for yes or no for scales Label switchLabel2 = new Label { Text = "Does it have scales?" }; Switch scalesSwitch = new Switch { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.CenterAndExpand, OnColor = Color.Green, }; scalesSwitch.Toggled += (sender, e) => { // eventValue.Text = String.Format("Switch is now {0}", e.Value); // pageValue.Text = scales.IsToggled.ToString(); }; //save button Button saveButton = new Button { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Text = "Submit", TextColor = Color.Red, FontAttributes = FontAttributes.Bold }; saveButton.Clicked += async(sender, e) => { //await DisplayAlert("Submit?", "Press OK to submit", "OK"); Mushroom m = new Mushroom(); if (capColor.SelectedItem != null) { m.CapColor = capColor.SelectedItem.ToString(); } if (undersideType.SelectedItem != null) { m.Underside = undersideType.SelectedItem.ToString(); } if (veilRemnant.SelectedItem != null) { m.Veil = veilRemnant.SelectedItem.ToString(); } if (undersideColor.SelectedItem != null) { m.UndersideColor = undersideColor.SelectedItem.ToString(); } m.HasStem = stemSwitch.IsToggled; m.HasScales = scalesSwitch.IsToggled; await Navigation.PushAsync(new IdentifyResultsPage(m, sq)); //Get all user inputs and save them in a new Mushroom object. //Pass object to new IdentifyResultsPage() }; StackLayout stackLayout1 = new StackLayout { Padding = new Thickness(10, 5, 10, 5), Children = { welcomeInfo, // eventValue, // pageValue, switchLabel1, stemSwitch, capColor, undersideType, undersideColor, veilRemnant, //label3, switchLabel2, scalesSwitch, saveButton, } }; //background color this.BackgroundColor = Color.Beige; this.Content = stackLayout1; }
public SearchDetailPage(SQLiteHandler sq, Mushroom m) { string capString = ""; string undersideString = ""; string[] str = m.CapColor.Split(','); foreach (string s in str) { capString += (s + ", "); } capString = capString.Substring(0, capString.Length - 2); str = m.UndersideColor.Split(','); foreach (string s in str) { undersideString += (s + ", "); } undersideString = undersideString.Substring(0, undersideString.Length - 2); Label Details = new Label { Text = "Here is more information listed for you...", FontAttributes = FontAttributes.Bold, FontSize = 30 }; //set to labels user input + image to showcase object Label capColor = new Label { Text = "Cap color: " + capString }; Label undersideColor = new Label { Text = "Underside color: " + undersideString }; Label stem = new Label { }; if (m.HasStem) { stem.Text = "Stem: Present"; } else { stem.Text = "Stem: Not present"; } Label scales = new Label { }; if (m.HasStem) { scales.Text = "Scales: Not present"; } else { scales.Text = "Scales: present"; } Label veil = new Label { Text = "Veil remnant type: " + m.Veil }; Label CommonName = new Label { Text = "Common Name: " + m.CommonName }; Label LatinName = new Label { Text = "Latin Name: " + m.LatinName }; Label Edibility = new Label { Text = "Edibility: " + m.Edibility }; Label Underside = new Label { Text = "Underside Type: " + m.Underside }; Image picture = new Image { Source = m.ImageName, Aspect = Aspect.AspectFit, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Fill }; Frame Frame1 = new Frame { Content = CommonName, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red, }; Frame Frame2 = new Frame { Content = LatinName, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red, }; Frame Frame3 = new Frame { Content = capColor, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red, }; Frame Frame4 = new Frame { Content = Underside, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red, }; Frame Frame5 = new Frame { Content = undersideColor, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Frame Frame6 = new Frame { Content = veil, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Frame Frame7 = new Frame { Content = stem, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Frame Frame8 = new Frame { Content = scales, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Frame Frame9 = new Frame { Content = Edibility, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Frame Frame10 = new Frame { Content = picture, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red }; Label confirmLabel = new Label { Text = "Is this your mushroom?", FontSize = 20 }; Button yesButton = new Button { Text = "Yes", }; yesButton.Clicked += async(sender, args) => { Location gps = await Geolocation.GetLocationAsync(); string fmgps = "Lat " + gps.Latitude.ToString() + " Long " + gps.Longitude.ToString(); FoundMushroom fm = new FoundMushroom(fmgps, DateTime.Now, m.ID, true); fm.mushroom = m; await Navigation.PushAsync(new PersonalizeMushroomPage(sq, fm)); }; Button noButton = new Button { Text = "No", }; noButton.Clicked += async(sender, args) => { await Navigation.PopAsync(); }; StackLayout s2 = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { yesButton, noButton } }; ScrollView sv = new ScrollView { Content = new StackLayout { Padding = new Thickness(10, 5, 10, 5), Children = { confirmLabel, s2, Frame10, Frame1, Frame2, Frame3, Frame4, Frame5, Frame6, Frame7, Frame8, Frame9, } } }; this.Content = sv; this.BackgroundColor = Color.Beige; }