protected override void OnAppearing ()
		{
			base.OnAppearing ();

			var r = (Restaurant)BindingContext;

			Xamarin.Insights.Track("View", new Dictionary<string, string> {
				{"Id", r.Number.ToString()},
				{"Name", r.Name},
//				{"Number", "0123456789112345678921234567893123456789412345678951234567896123456789712345678981234567899123456789a123456789b123456789c123456789d123456789e123456789f123456789"},
//				{"0123456789112345678921234567893123456789412345678951234567896123456789712345678981234567899123456789a123456789b123456789c123456789d123456789e123456789f123456789", "Number"},
//				{"0123456789112345678921234567893123456789412345678951234567896123456789712345678981234567899123456789a123456789b123456789c123456789d123456789e123456789f123456789", "0123456789112345678921234567893123456789412345678951234567896123456789712345678981234567899123456789a123456789b123456789c123456789d123456789e123456789f123456789"},
//				{"Japanese", "レストラン–料理店–飲食店"},
//				{"Korean", "레스토랑–레스토랑–요정"},
//				{"Hebrew", "מסעדה"},
//				{"ChineseT","餐廳–飯店"},
//				{"ChineseS","餐厅–酒家"},
			});

			Title = r.Name;

			var template = new RestaurantInfo () { Model = r };
			var page = template.GenerateString ();

			var html = new HtmlWebViewSource {Html = page};
			if (Device.OS != TargetPlatform.iOS) {
				// iOS bug means we're using a custom renderer for now, Android and WP need to implement IBaseUrl
				html.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();
			}
			webView.Source = html;

			if (Device.OS == TargetPlatform.iOS) {
				DependencyService.Get<IUserActivity> ().Start (r);
			}
		}
Пример #2
1
        protected override void OnAppearing()
        {
            //fill-in info
            var htmlSource = new HtmlWebViewSource ()
            {
                Html = ViewModel.HtmlText
            };
            this.webView.Source = htmlSource;

            this.webView.Navigating += (s, e) =>
            {
                if (e.Url.StartsWith("http"))
                {
                    try
                    {
                        var uri = new Uri(e.Url);
                        Device.OpenUri(uri);
                    }
                    catch (Exception)
                    {
                    }

                    e.Cancel = true;
                }
            };

            this.Title = ViewModel.Title;
        }
		public PartsOfSpeechPage (RogetCategory cat)
		{
			NavigationPage.SetHasNavigationBar (this, true);

			web = new WebView {
				WidthRequest = 400,
				HeightRequest = 800
			}; // want this to just always go full-screen...

			var htmlSource = new HtmlWebViewSource ();
			htmlSource.Html = FormatText(cat.PartsOfSpeech);
			web.Source = htmlSource;

			// test PopToRootAsync bugfix in 1.2.2-pre2
			var b = new Button { Text = "Main Menu" };
			b.Clicked += async (sender, e) => {
				await Navigation.PopToRootAsync();
			};

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.StartAndExpand,
				Children = {b, web}
			};

		}
Пример #4
0
        public LocalHtml(PContent content, String userPath)
        {
            //var browser = new WebView();
            //String imagePfadContent = "SMK.zeug.PContent.p";
            String source = (DependencyService.Get<ISaveAndLoad>().PathCombine(
                        (DependencyService.Get<ISaveAndLoad>().PathCombine(
                            DependencyService.Get<ISaveAndLoad>().Getpath(userPath), "p" + content.content_ID.ToString())), content.files[0]));
            var browser = new BaseUrlWebView(); // temporarily use this so we can custom-render in iOS

            var htmlSource = new HtmlWebViewSource();

            if (DependencyService.Get<ISaveAndLoad>().FileExistExact(source))
            {
                htmlSource.Html = DependencyService.Get<ISaveAndLoad>().LoadText(source);
            }

            if (Device.OS != TargetPlatform.iOS)
            {
                // the BaseUrlWebViewRenderer does this for iOS, until bug is fixed
                htmlSource.BaseUrl = (DependencyService.Get<ISaveAndLoad>().PathCombine(
                            DependencyService.Get<ISaveAndLoad>().Getpath(userPath), "p" + content.content_ID.ToString()));
            }

            browser.Source = htmlSource;

            Content = browser;
        }
Пример #5
0
 void OnQuoteResponse(object obj)
 {
     _dependencies = obj as ViewQuoteDependencies;
     File = new HtmlWebViewSource();
     File.Html = new DocumentGenerator().ExecuteAsync(_dependencies);
     Quote = _dependencies.Quote;
 }
		public LocalHtmlBaseUrl ()
		{
			var browser = new BaseUrlWebView (); // temporarily use this so we can custom-render in iOS

			var htmlSource = new HtmlWebViewSource ();

			htmlSource.Html = @"<html>
<head>
<link rel=""stylesheet"" href=""default.css"">
</head>
<body>
<h1>Xamarin.Forms</h1>
<p>The CSS and image are loaded from local files!</p>
<img src='Images/XamarinLogo.png'/>
<p><a href=""local.html"">next page</a></p>
</body>
</html>";

			if (Device.OS != TargetPlatform.iOS) {
				// the BaseUrlWebViewRenderer does this for iOS, until bug is fixed
				htmlSource.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();
			}

			browser.Source = htmlSource;

			Content = browser;
		}
Пример #7
0
        public GuidePageView()
        {
            this.BackgroundColor = Color.Black;

            var layout = new StackLayout{ Padding = new Thickness (5, 10) };
            this.Title = "Help Page";
            layout.Children.Add (new Label {
                Text = "This will contain some helpful information.",
                FontSize = 30,
                TextColor = Color.White
            });

            var browser = new WebView ();
            var htmlSource = new HtmlWebViewSource ();
            htmlSource.Html = @"<iframe width=""300"" height=""200"" src=""https://www.youtube.com/embed/Y7bxlR-MxxM"" frameborder=""0"" allowfullscreen></iframe>";
            browser.Source = htmlSource;
            browser.HeightRequest = 215.0;
            browser.WidthRequest = 320.0;

            layout.Children.Add (browser);
            layout.Children.Add (
                new Button () {Text = "I'm ready to start",
                    Command = new Command (() => this.Navigation.PushAsync (new MainListViews ()))
                });
            this.Content = layout;
        }
Пример #8
0
		public Schedules (string title)
		{
			ToolbarItem itemPrint = new ToolbarItem {
				Text = "Printable web version",
				Order = ToolbarItemOrder.Secondary,

			};
			ToolbarItems.Add(itemPrint);
			var browser = new BaseUrlWebView (); // temporarily use this so we can custom-render in iOS
			Title=title;
			var htmlSource = new HtmlWebViewSource ();
			htmlSource.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();
			string filename = "";
			if (title == "Table of study schedules")
				filename = "schedule1.html";
			else if (title == "勉強スケジュールの比較")
				filename = "schedule2.html";
			else if (title == "100-minute lessons")
				filename = "schedule6.html";
			else if (title == "90-minute lessons")
				filename = "schedule5.html";
			else if (title == "80-minute lessons")
				filename = "schedule4.html";
			else if (title == "60-minute lessons")
				filename = "schedule3.html";
			
			if (Device.OS != TargetPlatform.iOS) {
				browser.Source = htmlSource.BaseUrl+filename;
			}
			else
			{	      
				browser.Source = htmlSource.BaseUrl + "/" + filename;
			}
			Content = browser;
		}
 public HtmlInstructionsViewModel(TKRoute route)
 {
     this.Instructions = new HtmlWebViewSource();
     this.Instructions.Html = @"<html><body>";
     foreach (var s in route.Steps)
     {
         this.Instructions.Html += string.Format("<b>{0}km:</b> {1}<br /><hr />", s.Distance / 1000, s.Instructions);
     }
     this.Instructions.Html += @"</body></html>";
 }
Пример #10
0
 public ArticleViewModel()
 {
   Title = "";
   ArticleTitle = "";
   AuthorString = "";
   Expand = "";
   WvSource = new HtmlWebViewSource();
   NoSubId = new HtmlWebViewSource();
   ArticleInfoVisible = true;
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var html = new HtmlWebViewSource();

            if (value != null)
            {
                html.Html = value.ToString();
            }

            return html;
        }
Пример #12
0
		HtmlWebViewSource LoadHTMLFileFromResource ()
		{
			var source = new HtmlWebViewSource ();

			// Load the HTML file embedded as a resource in the PCL
			var assembly = typeof(WebViewPage).GetTypeInfo ().Assembly;
			var stream = assembly.GetManifestResourceStream ("CallJavaScript.index.html");
			using (var reader = new StreamReader (stream)) {
				source.Html = reader.ReadToEnd ();
			}
			return source;
		}
        public DonkyWebView()
        {
            this.PropertyChanged += (s, e) =>
                {
                    if (e.PropertyName.Equals(DonkyWebView.HtmlStringProperty.PropertyName))
                    {
                        var htmlSource = new HtmlWebViewSource();
                        htmlSource.Html = HtmlString;

                        this.Source = htmlSource;
                    }
                };
        }
Пример #14
0
        private async void LoadResume() {
            this.IsBusy = true;

            var mth = new ResumePreview();
            var html = await ApiClient.Execute(mth);

            this.Data = new HtmlWebViewSource() {
                Html = html
            };

            this.NotifyOfPropertyChange(() => this.Data);

            this.IsBusy = false;
        }
Пример #15
0
        public WebviewGenerated()
        {
            var webView = new WebView
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            // let's have some table data
            var dataList = new Dictionary<string, string>
            {
                { "Name", "Henry Crunn" },
                { "Address", "2, The Spon, Neesden" },
                { "Favourite food", "Spinach" },
                { "Favourite person", "Minnie Bannister" },
                { "Would like to live", "In a pineapple, under the sea" },
                { "Listens to","The sound of my pulse" }
            };

            // generate the table

            var tableData = new StringBuilder();
            tableData.Append("<table>");
            foreach (var info in dataList)
                tableData.Append(string.Format("<tr><td width=\"25%\">{0}</td><td width=\"75%\">{1}</td></tr>", info.Key, info.Value));
            tableData.Append("</table>");

            // create the web page - remember for this to work, the Base URL must be implemented on all
            // platforms included

            var htmlPageSource = new HtmlWebViewSource();
            var url = DependencyService.Get<IWebUrl>().GetBaseUrl();
            htmlPageSource.BaseUrl = url;
            htmlPageSource.Html = @"<html><head>
                    <title>Test webview</title>
                    <link rel=""stylesheet"" href=""myCSS.css"">
                        </head>
                        <body>
            <h1 div id=""mainTitle"">It's all about Henry</h1>
            <p>Henry Crunn is a mild mannered octagenarian who still has many of his own teeth. We interviewed him in the
            middle of East Acton High Street and asked him some questions. His replies are quite inciteful</p>" +
            tableData.ToString() +
            "<br /><p>Henry Crunn, thank you</p> <img src=\"Images/henrycrunn.png\" /> </body></html>";

            // add this to the webview
            webView.Source = htmlPageSource;

            Content = webView;
        }
Пример #16
0
		public GCO ()
		{
			var browser = new BaseUrlWebView (); // temporarily use this so we can custom-render in iOS
			Title="Gojūon Collation Order";
			var htmlSource = new HtmlWebViewSource ();
			htmlSource.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();
			if (Device.OS != TargetPlatform.iOS) {
				browser.Source = htmlSource.BaseUrl+"GCO.html";
			}
			else
			{	      
				browser.Source = htmlSource.BaseUrl+"/GCO.html";
			}
			Content = browser;
		}
Пример #17
0
		public Intro ()
		{
			var browser = new BaseUrlWebView (); // temporarily use this so we can custom-render in iOS

			Title = "Japanese Phonetic Writing";
			var htmlSource = new HtmlWebViewSource ();
			htmlSource.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();
			if (Device.OS != TargetPlatform.iOS) {
				browser.Source = htmlSource.BaseUrl+"Introduction.html";
			}
			else
			{	      
				browser.Source = htmlSource.BaseUrl+"/Introduction.html";
			}
			Content = browser;
		}
Пример #18
0
		public Terms ()
		{
			var browser = new BaseUrlWebView ();
			Title = "Terms of Use";
			this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
			var htmlSource = new HtmlWebViewSource ();
			htmlSource.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();
			if (Device.OS != TargetPlatform.iOS) {
				browser.Source = htmlSource.BaseUrl+"EULA-Google.htm";
			}
			else
			{	      
				browser.Source = htmlSource.BaseUrl+"/EULA-Apple.htm";
			}
			Content = browser;
		}
Пример #19
0
		public WallChart ()
		{
			this.Title = "Wall Chart";

			var browser = new BaseUrlWebView (); // temporarily use this so we can custom-render in iOS

			var htmlSource = new HtmlWebViewSource ();
			htmlSource.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();
			if (Device.OS != TargetPlatform.iOS) {
				browser.Source = htmlSource.BaseUrl+"wallchart.html";
			}
			else
			{	      
				browser.Source = htmlSource.BaseUrl+"/wallchart.html";
			}
			Content = browser;
		}
Пример #20
0
	public LocalHtml ()
	{
		var browser = new WebView();

		var htmlSource = new HtmlWebViewSource ();

		htmlSource.Html = @"<html><body>
<h1>Xamarin.Forms</h1>
<p>Welcome to WebView.</p>
</body>
</html>";
		
		
		browser.Source = htmlSource;

		Content = browser;
	}
Пример #21
0
        public ResultPage(WorklightResult result)
            : base()
        {
            BackgroundColor = Color.XamarinLightGray.ToFormsColor ();

            var htmlSource = new HtmlWebViewSource ();
            htmlSource.Html = (String.IsNullOrWhiteSpace(result.Response)) ? result.Message : result.Response;

            var webView = new WebView()
            {
                Source = htmlSource,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            Content = webView;
        }
		protected override void OnAppearing ()
		{
			base.OnAppearing ();

			var r = (Restaurant)BindingContext;

			Title = r.Name;

			var template = new RestaurantInfo () { Model = r };
			var page = template.GenerateString ();

			var html = new HtmlWebViewSource {Html = page};
			if (Device.OS != TargetPlatform.iOS) {
				// iOS bug means we're using a custom renderer for now, Android and WP need to implement IBaseUrl
				html.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();
			}
			webView.Source = html;
		}
Пример #23
0
        public ItemPage(Item selectedItem)
        {
            InitializeComponent();        

            // We set the BindingContext in code because it's parameterized with the tapped item.            
            // Note: it's possible, of course, to skip the view model and just set the binding context
            // to the item. However, we're leaving the viewmodel here to allow for later extension.             
            ItemViewModel viewModel = new ItemViewModel(selectedItem);
            this.BindingContext = viewModel;

            // Create and initialize the webview that displays the HTML body. Note that the 
            // selectedItem object will not have the body; we have to use the item in the viewModel
            // because that's what contains the full data.
            WebView wv = new WebView();

            // Force links in the webview to open in a browser; alternately, we could get the back
            // button command and navigate back in the webview, but this seems simpler and avoids
            // complications with rendering random web pages in the webview.
            wv.Navigating += (Object sender, WebNavigatingEventArgs e) =>
                {
                    if (navigateToBrowser)
                    {
                        Device.OpenUri(new System.Uri(e.Url));
                        e.Cancel = true;
                    }

                    navigateToBrowser = true;
                };

            HtmlWebViewSource source = new HtmlWebViewSource();            
            source.Html = viewModel.Body;
            wv.Source = source;
            
            this.WebviewFrame.Content = wv;

            // Make the provider label tappable to open the original post
            this.ProviderLabel.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command (() =>
                {
                    Device.OpenUri(new System.Uri(viewModel.Url));
                })
            });
        }
		public PartsOfSpeechPage (RogetCategory cat)
		{
			NavigationPage.SetHasNavigationBar (this, true);

			var web = new WebView {
				WidthRequest = 400,
				HeightRequest = 800
			}; // want this to just always go full-screen...

			var htmlSource = new HtmlWebViewSource ();
			htmlSource.Html = FormatText(cat.PartsOfSpeech);
			web.Source = htmlSource;

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.StartAndExpand,
				Children = {web}
			};

		}
Пример #25
0
        public WebView vid = new WebView(); // Holds the layout for this page.

        #endregion Fields

        #region Constructors

        //
        public VideoPage(string pageTitle, string vidURL)
        {
            //sets the background color based on settings
            if (Helpers.Settings.ContrastSetting == true)
            {
                BackgroundColor = Colors.contrastBg;
            }
            else
            {
                BackgroundColor = Colors.background;
            }

            Title					= pageTitle;
            url						= vidURL;
            var htmlSource			= new HtmlWebViewSource();                      // Create variable for holding page as a html string.
            htmlSource.Html			= @create_html(url);                            // Compile html string for page.
            vid.Source				= htmlSource;                                   // Set the source for this page (the page as a html stirng).

            Content = vid;                                      // Set the created html string to be the content of the page.
        }
Пример #26
0
        public LocalHtml2(PContent content, String userPath)
        {
            //Pfad setzen
            String source = (DependencyService.Get<ISaveAndLoad>().PathCombine(
                        (DependencyService.Get<ISaveAndLoad>().PathCombine(
                            DependencyService.Get<ISaveAndLoad>().Getpath(userPath), "p" + content.content_ID.ToString())), content.files[0]));
            //browser und viewsource initalisieren
            var browser = new WebView();
            var htmlSource = new HtmlWebViewSource();
            // fals Datei vorhanden einlesen
            if (DependencyService.Get<ISaveAndLoad>().FileExistExact(source))
            {
                htmlSource.Html = DependencyService.Get<ISaveAndLoad>().LoadText(source);
            }
            //BaseUrl setzen um auf andere Dateien referenzieren zu können(Css, javascript oder html)
            htmlSource.BaseUrl = (DependencyService.Get<ISaveAndLoad>().PathCombine(
                            DependencyService.Get<ISaveAndLoad>().Getpath(userPath), "p" + content.content_ID.ToString()));

            browser.Source = htmlSource;
            Content = browser;
        }
Пример #27
0
        protected override async void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();

            this.AdjustBookmarkedState();

            var content = ((DetailsViewModel) this.BindingContext).Article.HtmlContent;
            var html = (string) Converters.StringToHtml.Convert(content, null, null, null);
            var htmlWebViewSource = new HtmlWebViewSource
            {
                Html = html
            };

            this.webView = new WebView {Source = htmlWebViewSource};
            this.webView.VerticalOptions = LayoutOptions.FillAndExpand;
            this.webView.HorizontalOptions = LayoutOptions.Fill;

            this.ContentLayout.Children.Add(this.webView);

            await Task.Delay(2000);
        }
Пример #28
0
		public SkillVideoPage (Skill skill)
		{
			this.Icon = "Video.png";
			this.Title = "Video";

			if (skill.videos.Count > 0) {


				HtmlWebViewSource src = new HtmlWebViewSource {
					Html = String.Format("<!DOCTYPE html><html><body><iframe width=\"100%\" height=\"500px\" src=\"https://www.youtube.com/embed/{0}\" frameborder=\"0\" allowfullscreen></iframe>", skill.videos[0].youtube_id)
				};

				var videoWebview = new WebView {
					Source = src
				};

				Content = videoWebview;
			} else {
				Content = new Label{ Text = "No video for this skill" };
			}
		}
Пример #29
0
        private static void OnSourceHtmlStringPropertyChanged(BindableObject bindable, string oldvalue, string newvalue)
        {
            BaseUrlWebView webView = bindable as BaseUrlWebView;
            if (webView == null)
                return;

            if (newvalue.StartsWith("http"))
            {
                webView.Source = new UrlWebViewSource() {Url = newvalue};
            }
            else
            {
                var htmlSource = new HtmlWebViewSource();
                // do not set the BaseUrl on iOS because of the bug
                if (Device.OS != TargetPlatform.iOS)
                {
                    // the BaseUrlWebViewRenderer does this for iOS, until bug is fixed
                    htmlSource.BaseUrl = DependencyService.Get<IBaseUrl>().Get();
                }
                htmlSource.Html = newvalue;
                webView.Source = htmlSource;
            }
        }
        void OnButtonClicked(object sender, EventArgs e)
        {
            Assembly assembly = typeof(App).GetTypeInfo().Assembly;
            // Creating a new document.
            WordDocument document = new WordDocument();
            Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.WordtoHTML.doc");
            //Open the Word document to convert
            document.Open(inputStream, FormatType.Doc);
            //Export the Word document to HTML file
            MemoryStream stream = new MemoryStream();
            HTMLExport htmlExport = new HTMLExport();
            htmlExport.SaveAsXhtml(document, stream);
            document.Close();

            if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
                Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("WordtoHTML.html", "application/html", stream);
            else
                Xamarin.Forms.DependencyService.Get<ISave>().Save("WordtoHTML.html", "application/html", stream);
            if (!(Device.Idiom != TargetIdiom.Phone && Device.OS == TargetPlatform.Windows))
            {
                //Set the stream to start position to read the content as string
                stream.Position = 0;
                StreamReader reader = new StreamReader(stream);
                string htmlString = reader.ReadToEnd();

                //Set the HtmlWebViewSource to the html string
                HtmlWebViewSource html = new HtmlWebViewSource();
                html.Html = htmlString;

                //Create the web view control to view the web page
                WebView view = new WebView();
                view.Source = html;
                ContentPage webpage = new ContentPage();
                webpage.Content = view;
                this.ContentView.Navigation.PushAsync(webpage);
            }
        }