public void AddFoundMushroom(FoundMushroom fm) { var maxPk = myDB.Table <FoundMushroom>().OrderByDescending(c => c.ID).FirstOrDefault(); fm.ID = (maxPk == null ? 1 : maxPk.ID + 1); myDB.Insert(fm); }
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 FMDetailPage(FoundMushroom fm) { string capString = ""; string undersideString = ""; if (fm.mushroom.CapColor != null) { string[] str = fm.mushroom.CapColor.Split(','); foreach (string s in str) { capString += (s + ", "); } capString = capString.Substring(0, capString.Length - 2); } if (fm.mushroom.UndersideColor != null) { string[] str = fm.mushroom.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 foundDate = new Label { Text = "Found on: " + fm.TimeStamp.ToLongDateString() }; Label location = new Label { Text = "Location: " + fm.GPS }; Label capColor = new Label { Text = "Cap color: " + capString }; Label undersideColor = new Label { Text = "Underside color: " + undersideString }; Label stem = new Label { }; if (fm.mushroom.HasStem) { stem.Text = "Stem: Present"; } else { stem.Text = "Stem: Not present"; } Label scales = new Label { }; if (fm.mushroom.HasStem) { scales.Text = "Scales: Not present"; } else { scales.Text = "Scales: present"; } Label veil = new Label { Text = "Veil remnant type: " + fm.mushroom.Veil }; Label CommonName = new Label { Text = "Common Name: " + fm.mushroom.CommonName }; Label LatinName = new Label { Text = "Latin Name: " + fm.mushroom.LatinName }; Label Edibility = new Label { Text = "Edibility: " + fm.mushroom.Edibility }; Label Underside = new Label { Text = "Underside Type: " + fm.mushroom.Underside }; Image picture = new Image { Source = fm.Photo, Aspect = Aspect.AspectFit, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center }; Label notes = new Label { Text = "Additional notes: " + fm.Notes }; 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 }; Frame Frame11 = new Frame { Content = new StackLayout { Children = { foundDate, location, notes } }, CornerRadius = 10, HasShadow = true, BorderColor = Color.Green }; ScrollView sv = new ScrollView { Content = new StackLayout { Padding = new Thickness(10, 5, 10, 5), Children = { Frame10, Frame11, Frame1, Frame2, Frame3, Frame4, Frame5, Frame6, Frame7, Frame8, Frame9, } } }; this.Content = sv; this.BackgroundColor = Color.Beige; }
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 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; }