public DisclaimerPage(SQLiteHandler sq) { Label welcomeLabel = new Label { Text = "Hello, and welcome to Mushroom Hunter, an app for identifying and saving the mushrooms you find!", FontSize = 20, HorizontalTextAlignment = TextAlignment.Center }; Button startButton = new Button { Text = "Start Hunting!", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, TextColor = Color.Red, FontAttributes = FontAttributes.Bold }; StackLayout sl = new StackLayout { VerticalOptions = LayoutOptions.Center, Padding = new Thickness(10, 5, 10, 5), HeightRequest = 300, Children = { new Frame { BorderColor = Color.DarkRed, CornerRadius = 5, Padding = 8, Content = new StackLayout { Children = { welcomeLabel, startButton, new Label { Text = "*Please always exercise caution when digesting mushrooms. Do not ingest unless 100% positive what the mushroom is", FontAttributes = FontAttributes.Italic, FontSize = 10, HorizontalTextAlignment = TextAlignment.Center } } } } } }; startButton.Clicked += async(sender, e) => { //Navigation.InsertPageBefore(new TabbedPages(sq), this); //await Navigation.PopAsync(); await Navigation.PushAsync(new TabbedPages(sq)); }; this.BackgroundColor = Color.Beige; Content = sl; }
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 SavedMushrooms(SQLiteHandler sq) { this.Title = "My Mushrooms"; List <FoundMushroom> fmList = sq.GetFoundMushroomTable(); fmList.Sort((p, q) => p.TimeStamp.CompareTo(q.TimeStamp)); fmList.Reverse(); ListView mushroomList = new ListView(); mushroomList.VerticalOptions = LayoutOptions.FillAndExpand; mushroomList.ItemsSource = fmList; mushroomList.VerticalOptions = LayoutOptions.Start; mushroomList.ItemTemplate = new DataTemplate(typeof(FMViewCell)); mushroomList.RowHeight = 100; //mushroomList.IsGroupingEnabled = true; //mushroomList.GroupHeaderTemplate = new DataTemplate(typeof(GroupLabel)); Label noMushrooms = new Label { Text = "You don't have any saved mushrooms." }; if (fmList.Count == 0) { noMushrooms.IsVisible = true; } else { noMushrooms.IsVisible = false; } mushroomList.ItemTapped += async(sender, e) => { int index = e.ItemIndex; await Navigation.PushAsync(new FMDetailPage(fmList[index])); }; Frame frame = new Frame { BorderColor = Color.DarkRed, CornerRadius = 5, Padding = 8, Content = new StackLayout { Children = { noMushrooms, mushroomList } } }; Padding = new Thickness(10, 10, 10, 10); this.BackgroundColor = Color.BurlyWood; Content = frame; }
public App() { InitializeComponent(); InitializeComponent(); SQLiteHandler sq = new SQLiteHandler(); sq.CreateDB(); MainPage = new NavigationPage(new DisclaimerPage(sq)); }
public TabbedPages(SQLiteHandler sq) { Page homePage = new HomePage(sq); homePage.Title = "Add a Mushroom"; Page fieldGuide = new FieldGuidePage(sq); fieldGuide.Title = "Field Guide"; Page myMushrooms = new SavedMushrooms(sq); myMushrooms.Title = "My Mushrooms"; Children.Add(homePage); Children.Add(fieldGuide); Children.Add(myMushrooms); }
public Mushroom(SQLiteHandler dbHandler, string commonName, string latinName, bool hasStem, string underside, string undersideColor, string veil, string capColor, bool fieldGuide, bool hasScales, string edibility) { CommonName = commonName; LatinName = latinName; HasStem = hasStem; Underside = underside; UndersideColor = undersideColor; CapColor = capColor; FieldGuide = fieldGuide; HasScales = hasScales; Edibility = edibility; Veil = veil; string[] latins = latinName.Split(' '); ImageName = latins[0] + "_" + latins[1]; }
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 PersonalizeMushroomPage(SQLiteHandler sq, FoundMushroom fm) { Label label = new Label { Text = "Additional Details", FontSize = 30, HorizontalOptions = LayoutOptions.Center }; Button takePhoto = new Button { Text = "Add Photo" }; Entry notesEntry = new Entry { Placeholder = "Additional Notes" }; takePhoto.Clicked += async(sender, args) => { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await DisplayAlert("No Camera", ":( No camera available.", "OK"); return; } Plugin.Media.Abstractions.StoreCameraMediaOptions Options = new Plugin.Media.Abstractions.StoreCameraMediaOptions() { CompressionQuality = 50 }; var photo = await CrossMedia.Current.TakePhotoAsync(Options); string name = fm.CommonName + fm.TimeStamp.Ticks; fm.Photo = DependencyService.Get <IFileService>().SavePicture(name, photo.GetStream(), "imagesFolder"); }; Button saveButton = new Button { Text = "Save" }; saveButton.Clicked += async(sender, args) => { if (fm.Photo == null) { fm.Photo = "empty"; } fm.Notes = notesEntry.Text; if (fm.Identified) { sq.AddFoundMushroom(fm); await DisplayAlert("", "Mushroom saved as \"" + fm.mushroom.CommonName + "\" (" + fm.mushroom.LatinName + ")\n\n" + "Date: " + fm.TimeStamp.ToShortDateString() + "\n\n" + "Location: " + fm.GPS, "OK"); } else { sq.AddNewMushroom(fm); await DisplayAlert("", "Mushroom saved as \"Unknown\" \n\n" + "Date: " + fm.TimeStamp.ToShortDateString() + "\n\n" + "Location: " + fm.GPS, "OK"); } await Navigation.PushAsync(new TabbedPages(sq)); }; Frame Frame1 = new Frame { Content = new StackLayout { Children = { notesEntry, takePhoto, } }, CornerRadius = 10, HasShadow = true, BorderColor = Color.Red, }; StackLayout sl = new StackLayout { Children = { label, Frame1, saveButton } }; BackgroundColor = Color.Beige; Padding = new Thickness(20); Content = sl; }
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 HomePage(SQLiteHandler sq) { this.Title = "Add a Mushroom"; List <Mushroom> ms = sq.GetMushroomTable(); List <string> names = new List <string>(); foreach (Mushroom m in ms) { if (m.FieldGuide) { names.Add(m.CommonName); names.Add(m.LatinName); } } SfAutoComplete mushroomEntry = new SfAutoComplete(); mushroomEntry.AutoCompleteSource = names; mushroomEntry.SuggestionMode = SuggestionMode.Contains; mushroomEntry.DropDownCornerRadius = 5; mushroomEntry.DropDownBackgroundColor = Color.AntiqueWhite; mushroomEntry.Watermark = "Search Here"; Label questionLabel = new Label { Text = "Do you already know what your mushroom is? If so, type the name into the search bar below..", FontSize = 20 }; Button submitButton = new Button { Text = "Submit", TextColor = Color.Red, }; submitButton.Clicked += async(sender, args) => { string query = mushroomEntry.Text.ToLower(); if (validateInput(query)) { List <Mushroom> match = sq.GetMushroom(query); if (match.Count == 1) { mushroomEntry.Text = ""; await Navigation.PushAsync(new SearchDetailPage(sq, match[0])); } else { await DisplayAlert("", "Mushroom Hunter does not have a mushroom matching this name.", "OK"); } } }; Label instr2 = new Label { Text = "Not sure what kind of mushroom you have? Select \"Identify\" to find out. ", FontSize = 20 }; Button button1 = new Button { Text = "Identify", TextColor = Color.Red, }; button1.Clicked += async(sender, e) => { await Navigation.PushAsync(new IdentifyPage(sq)); }; Button button2 = new Button { Text = "Go to Field Guide page" }; button2.Clicked += async(sender, e) => { await Navigation.PushAsync(new FieldGuidePage(sq)); }; StackLayout sl1 = new StackLayout { VerticalOptions = LayoutOptions.Center, Padding = new Thickness(10, 5, 10, 5), Children = { questionLabel, mushroomEntry, submitButton } }; StackLayout sl2 = new StackLayout { VerticalOptions = LayoutOptions.Center, Padding = new Thickness(10, 5, 10, 5), Children = { instr2, button1 } }; Frame frame1 = new Frame { BorderColor = Color.DarkRed, CornerRadius = 10, Padding = 8, Content = sl1 }; Frame frame2 = new Frame { BorderColor = Color.DarkRed, CornerRadius = 10, Padding = 8, Content = sl2 }; Grid grid = new Grid { BackgroundColor = Color.Beige, RowDefinitions = { new RowDefinition { Height = new GridLength(8, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(8, GridUnitType.Star) } }, ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Auto } } }; grid.Children.Add(frame1, 0, 0); grid.Children.Add(frame2, 0, 2); StackLayout sl3 = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Children = { grid } }; Padding = new Thickness(30, 55); BackgroundColor = Color.Beige; Content = grid; }
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; }