コード例 #1
0
        public WebView HTMLProcessor(string location)
        {
            // Generate WebView container
            var browser = new TransparentWebView();
            //var pdfBrowser = new CustomWebView { Uri = location, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand };
            string htmlText;

            // Get file locally unless the location is a web address
            if (location.Contains("http"))
            {
                htmlText       = location;
                browser.Source = htmlText;
            }
            else if (!location.Contains(".pdf"))
            {
                // Get file from PCL--in order for HTML files to be automatically pulled from the PCL, they need to be in a Views/HTML folder
                var    assembly = typeof(HTMLPage).GetTypeInfo().Assembly;
                Stream stream   = assembly.GetManifestResourceStream("WildFlowers.Views.HTML." + location);
                htmlText = "";
                using (var reader = new System.IO.StreamReader(stream)) { htmlText = reader.ReadToEnd(); }
                var htmlSource = new HtmlWebViewSource();
                htmlSource.Html = htmlText;
                browser.Source  = htmlSource;
            }
            return(browser);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.WebView> e)
        {
            base.OnElementChanged(e);

            _xwebView = e.NewElement as TransparentWebView;
            _webView  = Control;

            if (e.OldElement == null)
            {
                _webView.SetWebViewClient(new TransparentWebViewClient());
            }

            // Setting the background as transparent
            this.Control.SetBackgroundColor(Android.Graphics.Color.Transparent);
        }
コード例 #5
0
        public WoodyPlantInfoPage(WoodyPlant plant, ObservableCollection <WoodyPlant> plants)
        {
            // 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 = ConstructPlantNavigationBar(plant.commonName, plant, plants);

            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);

            contentScrollView.Content = browser;
            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;
        }
コード例 #6
0
        public TransparentWebView ConstructHTMLContent(WoodyPlant 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{ color: white; font-size: 0.9em; padding-bottom: 200px; padding-top: 50px; } 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>";

            if ((plant.frequency != null && plant.frequency.Length != 0) || (plant.lifeZone != null && plant.lifeZone.Length != 0) || (plant.habitat != null && plant.habitat.Length != 0) || (plant.endemicLocation != null && plant.endemicLocation.Length != 0))
            {
                html += "<div class='section_header'>ECOSYSTEM</div>";
                if (plant.frequency != null && plant.frequency.Length != 0)
                {
                    html += "<strong>Frequency: </strong>" + plant.frequency + "<br/>";
                }
                if (plant.lifeZone != null && plant.lifeZone.Length != 0)
                {
                    html += "<strong>Life Zone: </strong>" + plant.lifeZone + "<br/>";
                }
                if (plant.habitat != null && plant.habitat.Length != 0)
                {
                    html += "<strong>Habitat: </strong>" + plant.habitat + "<br/>";
                }
                if (plant.endemicLocation != null && plant.endemicLocation.Length != 0)
                {
                    html += "<strong>Endemic Location: </strong>" + plant.endemicLocation + "<br/>";
                }
            }

            if ((plant.edibility != null && plant.edibility.Length != 0) || (plant.toxicity != null && plant.toxicity.Length != 0) || (plant.fiber != null && plant.fiber.Length != 0) || (plant.otherUses != null && plant.otherUses.Length != 0))
            {
                html += "<div class='section_header'>HUMAN CONNECTIONS</div>";
                if (plant.edibility != null && plant.edibility.Length != 0)
                {
                    html += "<strong>Edibility: </strong>" + plant.edibility + "<br/>";
                }
                if (plant.toxicity != null && plant.toxicity.Length != 0)
                {
                    html += "<strong>Toxicity: </strong>" + plant.toxicity + "<br/>";
                }
                if (plant.fiber != null && plant.fiber.Length != 0)
                {
                    html += "<strong>Fiber/Dye: </strong>" + plant.fiber + "<br/>";
                }
                if (plant.otherUses != null && plant.otherUses.Length != 0)
                {
                    html += "<strong>Other Uses: </strong>" + plant.otherUses + "<br/>";
                }
            }

            if ((plant.alien != null && plant.alien.Length != 0) || (plant.weedManagement != null && plant.weedManagement.Length != 0))
            {
                html += "<div class='section_header'>Origin</div>";
                if (plant.alien != null && plant.alien.Length != 0)
                {
                    html += plant.alien + "<br/>";
                }
                if (plant.weedManagement != null && plant.weedManagement.Length != 0)
                {
                    html += "<strong>Weed Management: </strong>" + plant.weedManagement + "<br/>";
                }
            }

            if ((plant.landscapingUse != null && plant.landscapingUse.Length != 0) || (plant.matureHeight != null && plant.matureHeight.Length != 0) || (plant.matureSpread != null && plant.matureSpread.Length != 0) || (plant.siteRequirements != null && plant.siteRequirements.Length != 0) || (plant.soilRequirements != null && plant.soilRequirements.Length != 0) || (plant.moistureRequirements != null && plant.moistureRequirements.Length != 0) || (plant.cultivar != null && plant.cultivar.Length != 0) || (plant.availability != null && plant.availability.Length != 0))
            {
                html += "<div class='section_header'>LANDSCAPING</div>";
                if (plant.landscapingUse != null && plant.landscapingUse.Length != 0)
                {
                    html += "<strong>Landscaping Use: </strong>" + plant.landscapingUse + "<br/>";
                }
                if (plant.matureHeight != null && plant.matureHeight.Length != 0)
                {
                    html += "<strong>Mature Height: </strong>" + plant.matureHeight + "<br/>";
                }
                if (plant.matureSpread != null && plant.matureSpread.Length != 0)
                {
                    html += "<strong>Mature Spread: </strong>" + plant.matureSpread + "<br/>";
                }
                if (plant.siteRequirements != null && plant.siteRequirements.Length != 0)
                {
                    html += "<strong>Site Requirements: </strong>" + plant.siteRequirements + "<br/>";
                }
                if (plant.soilRequirements != null && plant.soilRequirements.Length != 0)
                {
                    html += "<strong>Soil Requirements: </strong>" + plant.soilRequirements + "<br/>";
                }
                if (plant.moistureRequirements != null && plant.moistureRequirements.Length != 0)
                {
                    html += "<strong>Moisture Requirements: </strong>" + plant.moistureRequirements + "<br/>";
                }
                if (plant.cultivar != null && plant.cultivar.Length != 0)
                {
                    html += "<strong>Cultivar: </strong>" + plant.cultivar + "<br/>";
                }
                if (plant.availability != null && plant.availability.Length != 0)
                {
                    html += "<strong>Availability: </strong>" + plant.availability + "<br/>";
                }
            }

            if ((plant.ecologicalRelationships != null && plant.ecologicalRelationships.Length != 0) || (plant.scientificNameMeaning != null && plant.scientificNameMeaning.Length != 0) || (plant.derivation != null && plant.derivation.Length != 0) || (plant.comments != null && plant.comments.Length != 0))
            {
                html += "<div class='section_header'>NOTES</div>";
                if (plant.ecologicalRelationships != null && plant.ecologicalRelationships.Length != 0)
                {
                    html += "<strong>Ecological Relationships: </strong>" + plant.ecologicalRelationships + "<br/>";
                }
                if (plant.scientificNameMeaning != null && plant.scientificNameMeaning.Length != 0)
                {
                    html += "<strong>Scientific Name Meaning: </strong>" + plant.scientificNameMeaning + "<br/>";
                }
                if (plant.derivation != null && plant.derivation.Length != 0)
                {
                    html += "<strong>Derivation: </strong>" + plant.derivation + "<br/>";
                }
                if (plant.comments != null && plant.comments.Length != 0)
                {
                    html += "<strong>Comments: </strong>" + plant.comments + "<br/>";
                }
            }
            html += "</body></html>";

            htmlSource.Html = html;
            browser.Source  = htmlSource;

            return(browser);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public TransparentWebView ConstructHTMLContent(WoodyPlant 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; padding-bottom: 200px; padding-top: 50px; } .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'>NAME</div>";
            if (plant.commonName != null && plant.commonName.Length != 0)
            {
                html += "<strong>Common Name: </strong>" + plant.commonName + "<br/>";
            }
            if (plant.scientificNameWeber != null && plant.scientificNameWeber.Length != 0)
            {
                html += "<strong>Scientific Name: </strong>" + plant.scientificNameWeber + "<br/>";
            }
            if (plant.scientificNameOther != null && plant.scientificNameOther.Length != 0)
            {
                html += "<strong>Synonyms: </strong>" + plant.scientificNameOther + "<br/>";
            }
            if (plant.family != null && plant.family.Length != 0)
            {
                html += "<strong>Family: </strong>" + plant.family + "<br/>";
            }
            if (plant.keyCharacteristics != null && plant.keyCharacteristics.Length != 0)
            {
                html += "<div class='section_header'>KEY CHARACTERISTICS</div>";
                html += plant.keyCharacteristics;
            }

            if (plant.flowerDescription != null && plant.flowerDescription.Length != 0)
            {
                html += "<div class='section_header'>FLOWER</div>";
                html += plant.flowerDescription;
            }

            if (plant.seasonOfBloom != null && plant.seasonOfBloom.Length != 0)
            {
                html += "<div class='section_header'>SEASON OF BLOOM</div>";
                html += plant.seasonOfBloom;
            }

            if (plant.fruitDescription != null && plant.fruitDescription.Length != 0)
            {
                html += "<div class='section_header'>FRUIT/CONE DESCRIPTION</div>";
                html += plant.fruitDescription;
            }

            string leafDescrip = "";

            if (plant.leafType != null && plant.leafType.Length != 0)
            {
                leafDescrip += "<b>Leaf Type: </b>";
                leafDescrip += plant.leafType;
                leafDescrip += "</br>";
            }
            if (plant.leafArrangement != null && plant.leafArrangement.Length != 0)
            {
                leafDescrip += "<b>Leaf Arrangement: </b>";
                leafDescrip += plant.leafArrangement;
            }

            if (!leafDescrip.Equals(""))
            {
                html += "<div class='section_header'>LEAF DESCRIPTION</div>";
                html += leafDescrip;
            }

            if (plant.barkDescription != null && plant.barkDescription.Length != 0)
            {
                html += "<div class='section_header'>BARK/STEM DESCRIPTION</div>";
                html += plant.barkDescription;
            }

            html += "</body></html>";

            htmlSource.Html = html;
            browser.Source  = htmlSource;
            return(browser);
        }