public TransparentWebView ConstructHTMLContent(WildFlower plant) { browser = new TransparentWebView(); var htmlSource = new HtmlWebViewSource(); string html = ""; /* * html += "<!DOCTYPE html><html lang='en' xmlns='http://www.w3.org/1999/xhtml'><head><meta charset = 'utf-8' /><title>Plant Info Page</title></head><body>"; * html += "<style>body, a { color: white; font-size: 0.9em; } .section_header { font-weight: bold; border-bottom: 1px solid white; margin: 10px 0; } .embedded_table { width: 100%; margin-left: 10px; } .iconImg { height: 40px; }</style>"; * * html += "<div class='section_header'>HABITAT & ECOLOGY</div>" + plant.habitat; * * html += "<div class='section_header'>COMMENTS</div>" + plant.comments; * * html += "<div class='section_header'>WETLAND TYPES</div>" + ReconstructWetlandTypes(plant.ecologicalsystems); * * html += "<div class='section_header'>ANIMAL USE</div>" + plant.animaluse.Replace("resources/images/animals/", ""); * * html += "</body></html>"; * * htmlSource.Html = html; * browser.Source = htmlSource; */ return(browser); }
public async Task UpdatePlantAsync(WildFlower plant) { try { await connAsync.UpdateAsync(plant); } catch (Exception ex) { StatusMessage = string.Format("Failed to update {0}. Error: {1}", plant, ex.Message); } }
public WildFlowerEcologyPage(WildFlower plant) { System.GC.Collect(); // Turn off navigation bar and initialize pageContainer NavigationPage.SetHasNavigationBar(this, false); AbsoluteLayout pageContainer = ConstructPageContainer(); // Initialize grid for inner container Grid innerContainer = new Grid { Padding = new Thickness(0, Device.OnPlatform(10, 0, 0), 0, 0) }; innerContainer.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); // Add header to inner container Grid navigationBar = ConstructNavigationBarMain(plant.genusSpeciesWeber); innerContainer.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) }); innerContainer.Children.Add(navigationBar, 0, 0); ScrollView contentScrollView = new ScrollView { BackgroundColor = Color.FromHex("88000000"), Padding = new Thickness(20, 5, 20, 5), Margin = new Thickness(0, 0, 0, 0) }; TransparentWebView browser = ConstructHTMLContent(plant); //browser.Navigating += ToWetlandType; contentScrollView.Content = browser; innerContainer.RowDefinitions.Add(new RowDefinition { }); innerContainer.Children.Add(contentScrollView, 0, 1); //var wetlandTypes = ConstructWetlandTypes(plant.ecologicalsystems); //innerContainer.RowDefinitions.Add(new RowDefinition { }); //innerContainer.Children.Add(wetlandTypes, 0, 2); // Add inner container to page container and set as page content pageContainer.Children.Add(innerContainer, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All); Content = pageContainer; base.OnAppearing(); System.GC.Collect(); }
public async Task AddOrUpdatePlantAsync(WildFlower plant) { try { if (string.IsNullOrEmpty(plant.commonName1)) { throw new Exception("Valid plant required"); } await connAsync.RunInTransactionAsync((SQLite.Net.SQLiteConnection tran) => { tran.InsertOrReplaceWithChildren(plant); }); // await connAsync.InsertOrReplaceAllWithChildrenAsync(plant); } catch (Exception ex) { StatusMessage = string.Format("Failed to add {0}. Error: {1}", plant, ex.Message); } }
public WildFlowerDetailPage(WildFlower plant, bool streaming) { GC.Collect(); NavigationPage.SetHasNavigationBar(this, false); var helpers = new ViewHelpers(); Children.Add(new WildFlowerImagesPage(plant, streaming) { Title = "IMAGES", Icon = "images.png" }); Children.Add(new WildFlowerInfoPage(plant) { Title = "INFO", Icon = "info.png" }); Children.Add(new WildFlowerEcologyPage(plant) { Title = "ECOLOGY", Icon = "ecology.png" }); Children.Add(new WildFlowerRangePage(plant, streaming) { Title = "RANGE", Icon = "range.png" }); BarBackgroundColor = Color.Black; BarTextColor = Color.White; BackgroundColor = Color.Black; if (selectedTabSetting != null) { SelectedItem = Children[Convert.ToInt32(selectedTabSetting.valueint)]; } else { SelectedItem = Children[0]; } this.CurrentPageChanged += RememberPageChange; System.GC.Collect(); }
public WildFlowerImagesPage(WildFlower plant, bool streaming) { System.GC.Collect(); // Turn off navigation bar and initialize pageContainer NavigationPage.SetHasNavigationBar(this, false); AbsoluteLayout pageContainer = ConstructPageContainer(); // Initialize grid for inner container Grid innerContainer = new Grid { Padding = new Thickness(0, Device.OnPlatform(10, 0, 0), 0, 0) }; innerContainer.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); // Add header to inner container Grid navigationBar = ConstructNavigationBarMain(plant.genusSpeciesWeber); innerContainer.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) }); innerContainer.Children.Add(navigationBar, 0, 0); CarouselViewControl carouselControl = new CarouselViewControl(); try { carouselControl.ItemsSource = plant.Images; } catch (NullReferenceException e) { carouselControl.ItemsSource = null; } carouselControl.ShowIndicators = true; DataTemplate imageTemplate = new DataTemplate(() => { Grid cell = new Grid { BackgroundColor = Color.FromHex("88000000") }; cell.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); cell.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); // Add image var image = new ZoomImage { Margin = new Thickness(10, 0, 10, 0) }; string imageBinding = streaming ? "ImagePathStreamed" : "ImagePathDownloaded"; var cachedImage = new CachedImage() { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, WidthRequest = 300, HeightRequest = 300, Aspect = Aspect.AspectFill, Margin = new Thickness(10, 0, 10, 0), CacheDuration = System.TimeSpan.FromDays(30), DownsampleToViewSize = true, RetryCount = 0, RetryDelay = 250, TransparencyEnabled = false, LoadingPlaceholder = "loading.png", ErrorPlaceholder = "error.png", }; image.SetBinding(Image.SourceProperty, new Binding(imageBinding)); cachedImage.SetBinding(CachedImage.SourceProperty, new Binding(imageBinding)); cell.Children.Add(image, 0, 0); return(cell); }); carouselControl.ItemTemplate = imageTemplate; carouselControl.Position = 0; carouselControl.InterPageSpacing = 10; carouselControl.Orientation = CarouselViewOrientation.Horizontal; innerContainer.RowDefinitions.Add(new RowDefinition { }); innerContainer.Children.Add(carouselControl, 0, 1); // Add inner container to page container and set as page content pageContainer.Children.Add(innerContainer, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All); Content = pageContainer; System.GC.Collect(); }
// return a specificWildFlower given an id public WildFlower GetWildFlowerByAltId(int Id) { WildFlower plant = conn.Table <WildFlower>().Where(p => p.id.Equals(Id)).FirstOrDefault(); return(conn.GetWithChildren <WildFlower>(plant.plant_id)); }
public TransparentWebView ConstructHTMLContent(WildFlower plant) { var browser = new TransparentWebView(); var htmlSource = new HtmlWebViewSource(); string html = ""; /* * html += "<!DOCTYPE html><html lang='en' xmlns='http://www.w3.org/1999/xhtml'><head><meta charset = 'utf-8' /><title>Plant Info Page</title></head><body>"; * html += "<style>body { color: white; font-size: 0.9em; } .section_header { font-weight: bold; border-bottom: 1px solid white; margin: 10px 0; } .embedded_table { width: 100%; margin-left: 10px; }</style>"; * * html += "<div class='section_header'>NOMENCLATURE</div>"; * html += "<strong>Scientific Name: </strong>" + plant.scinameauthor + "<br/>"; * html += "<strong>Family: </strong>" + plant.family + "<br/>"; * html += "<strong>Common Name: </strong>" + plant.commonname + "<br/>"; * html += "<strong>Synonyms: </strong>" + plant.synonyms + "<br/>"; * html += "<strong>USDA Plants Symbol: </strong>" + plant.plantscode + "<br/>"; * html += "<strong>ITIS TSN: </strong>" + plant.itiscode + "<br/>"; * * html += "<div class='section_header'>CONSERVATION STATUS</div>"; * html += "<strong>Federal Status: </strong>" + plant.federalstatus + "<br/>"; * html += "<strong>Global Rank: </strong>" + plant.grank + "<br/>"; * html += "<strong>State Ranks</strong><br/>"; * html += "<table class='embedded_table'><tbody>"; * html += "<tr><td><strong>CO: </strong>" + plant.cosrank + "</td><td><strong>MT: </strong>" + plant.mtsrank + "</td></tr>"; * html += "<tr><td><strong>WY: </strong>" + plant.wysrank + "</td><td><strong>ND: </strong>" + plant.ndsrank + "</td></tr>"; * html += "<tr><td><strong>UT: </strong>" + plant.utsrank + "</td></tr>"; * html += "</tbody></table>"; * * html += "<div class='section_header'>BIOLOGY</div>"; * html += "<strong>C-Value: </strong>" + plant.cvalue + "<br/>"; * html += "<strong>Duration: </strong>" + plant.duration + "<br/>"; * html += "<strong>Native Status: </strong>" + plant.nativity + "<br/>"; * html += "<strong>Wetland Indicator Status</strong><br/>"; * html += "<table class='embedded_table'><tbody>"; * html += "<tr><td><strong>AW: </strong>" + plant.awwetcode + "</td></tr>"; * html += "<tr><td><strong>WM: </strong>" + plant.wmvcwetcode + "</td></tr>"; * html += "<tr><td><strong>GP: </strong>" + plant.gpwetcode + "</td></tr>"; * html += "</tbody></table>"; * * html += "<div class='section_header'>KEY CHARACTERISTICS</div>"; * * html += "<ul>"; * if (plant.keychar1 != null && plant.keychar1 != "") { html += "<li>" + plant.keychar1 + "</li>"; }; * if (plant.keychar2 != null && plant.keychar2 != "") { html += "<li>" + plant.keychar2 + "</li>"; }; * if (plant.keychar3 != null && plant.keychar3 != "") { html += "<li>" + plant.keychar3 + "</li>"; }; * if (plant.keychar4 != null && plant.keychar4 != "") { html += "<li>" + plant.keychar4 + "</li>"; }; * if (plant.keychar5 != null && plant.keychar5 != "") { html += "<li>" + plant.keychar5 + "</li>"; }; * if (plant.keychar6 != null && plant.keychar6 != "") { html += "<li>" + plant.keychar6 + "</li>"; }; * html += "</ul>"; * * html += "<div class='section_header'>REFERENCES</div>"; * * html += "<ul>"; * foreach (WildFlowerReference reference in plant.References) * { * html += "<li>" + reference.fullcitation + "</li>"; * } * html += "</ul>"; * * html += "</body></html>"; * * htmlSource.Html = html; * browser.Source = htmlSource;*/ return(browser); }
public WildFlowerRangePage(WildFlower plant, bool streaming) { System.GC.Collect(); // Turn off navigation bar and initialize pageContainer NavigationPage.SetHasNavigationBar(this, false); AbsoluteLayout pageContainer = ConstructPageContainer(); // Initialize grid for inner container Grid innerContainer = new Grid { Padding = new Thickness(0, Device.OnPlatform(10, 0, 0), 0, 0) }; innerContainer.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); // Add header to inner container Grid navigationBar = ConstructNavigationBarMain(plant.genusSpeciesWeber); innerContainer.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) }); innerContainer.Children.Add(navigationBar, 0, 0); ScrollView contentScrollView = new ScrollView { BackgroundColor = Color.FromHex("88000000"), Padding = new Thickness(0, 20, 0, 20), Margin = new Thickness(0, 0, 0, 0) }; StackLayout contentContainer = new StackLayout(); Image rangeImage = new Image { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, WidthRequest = 600, HeightRequest = 300, Aspect = Aspect.AspectFit, Margin = new Thickness(10, 0, 10, 0), }; rangeImage.BindingContext = plant; string imageBinding = streaming ? "RangePathStreamed" : "RangePathDownloaded"; rangeImage.SetBinding(Image.SourceProperty, new Binding(imageBinding)); contentContainer.Children.Add(rangeImage); /* Image mapKey = new Image * { * HorizontalOptions = LayoutOptions.Center, * VerticalOptions = LayoutOptions.Center, * WidthRequest = 600, * HeightRequest = 300, * Aspect = Aspect.AspectFit, * Margin = new Thickness(10, 0, 10, 0), * }; * * mapKey.Source = ImageSource.FromResource("WoodyPlants.Resources.Images.WoodyMapKey.png"); * * contentContainer.Children.Add(mapKey);*/ contentScrollView.Content = contentContainer; innerContainer.RowDefinitions.Add(new RowDefinition { }); innerContainer.Children.Add(contentScrollView, 0, 1); // Add inner container to page container and set as page content pageContainer.Children.Add(innerContainer, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All); Content = pageContainer; System.GC.Collect(); }