コード例 #1
4
		private async void Init()
		{
			//load the article detail
			_viewModel = new ArticleDetailViewModel ();

			await _viewModel.InitData (_articleId);

			var webView = new WebView { 
				Source = new HtmlWebViewSource { Html = _viewModel.Article.ArticleText},
				VerticalOptions = LayoutOptions.FillAndExpand
			};

			var image = new Image {Source = _viewModel.Article.ImageUrl };

			this.Content = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				Padding = new Thickness (
					left: 10, 
					right: 10, 
					bottom: 10, 
					top: Device.OnPlatform (iOS: 20, Android: 0, WinPhone: 0)),
				Children = { 
					image,
					webView 
				}
			};
		}
		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}
			};

		}
コード例 #3
1
        public LinkedInLoginPage(LinkedInConnection connection)//string key, string secret, string scope, string redirectURL)
        {
            this.Title = "LinkedInLoginPage";

            this._Connection = connection;
            this._Browser = new WebView();

           // LinkedInConnection connection = new LinkedInConnection(key, secret, scope, redirectURL);
            this._Connection.SignIn(this._Browser);
            Label lbl = new Label() { Text = "Connecting..." };
            lbl.SetBinding(Label.IsVisibleProperty, "IsVisible", BindingMode.OneWay, new BooleanInverterConverter());
            lbl.BindingContext = this._Browser;

            this._BaseLayout = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
            };

            this._BaseLayout.Children.Add(lbl);
            this._BaseLayout.Children.Add(this._Browser);

            this._Browser.IsVisible = false;


            Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);  // Accomodate iPhone status bar.
            Content = this._BaseLayout;

        }
コード例 #4
0
        public TitleIXPage()
        {
            // Set Page Title
            Title = "Title IX Rights";

            var source = new UrlWebViewSource ();
            source.Url = "http://knowyourix.org/title-ix/title-ix-the-basics/";
            var webView = new WebView {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Source = source
            };
            webView.Navigating += (object sender, WebNavigatingEventArgs e) => {
                System.Diagnostics.Debug.WriteLine("Loading");
            };
            webView.Navigated += (object sender, WebNavigatedEventArgs e) => {
                System.Diagnostics.Debug.WriteLine("Done");
            };

            Content = new ContentView {
                Content = new StackLayout {
                    Children = {
                        webView
                    }
                }
            };
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: mrmandrake/maoui-samples
        public static Maoui.Element CreateElement()
        {
            var panel = new StackLayout();

            var titleLabel = new Xamarin.Forms.Label
            {
                Text           = "WebView",
                FontSize       = 24,
                FontAttributes = FontAttributes.Bold
            };

            panel.Children.Add(titleLabel);

            Xamarin.Forms.WebView webview = new Xamarin.Forms.WebView
            {
                Source = "http://www.xamarin.com"
            };
            panel.Children.Add(webview);

            var page = new ContentPage
            {
                Content = panel
            };

            return(page.GetMaouiElement());
        }
コード例 #6
0
		public AboutPage ()
		{
			NavigationPage.SetHasNavigationBar (this, true);
			Title = "About Evolve";

			// embedded HTML page
//			var source = new HtmlWebViewSource ();
//			source.BaseUrl = "About.html";
//			source.Html = "About.html";

			// a URL is easier
			var source = new UrlWebViewSource ();
			source.Url = "http://xamarin.com/evolve/2013";

			var web = new WebView {
				WidthRequest = 300,
				HeightRequest = 400
			};
			web.Source = source;

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.StartAndExpand,
				Children = {
					web,
				}
			};
		}
コード例 #7
0
        public WebViewDemoPage()
        {
            Label header = new Label
            {
                Text = "WebView",
                Font = Font.BoldSystemFontOfSize(50),
                HorizontalOptions = LayoutOptions.Center
            };

            WebView webView = new WebView
            {
                Source = new UrlWebViewSource
                {
                    Url = "http://blog.xamarin.com/",
                },
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    webView
                }
            };
        }
コード例 #8
0
        public BlogDetailsView(FeedItem item)
        {
            BindingContext = item;
            var webView = new WebView
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            webView.Source = new HtmlWebViewSource
            {
                Html = item.Description
            };
            Content = new StackLayout
            {
                Children =
        {
          webView
        }
            };
            var share = new ToolbarItem
            {
                Icon = "ic_share.png",
                Text = "Share",
                Command = new Command(() => DependencyService.Get<IShare>()
                  .ShareText("Be sure to read @shanselman's " + item.Title + " " + item.Link))
            };

            ToolbarItems.Add(share);
        }
コード例 #9
0
        internal void SignIn(WebView browser)
		{
		//	browser.IsVisible = true;
            browser.Source = LoginUri();

            browser.PropertyChanged += browser_PropertyChanged;
        }
コード例 #10
0
            protected override void Dispose(bool disposing)
            {
                _webViewForms = null;
                _webViewDroid = null;

                base.Dispose(disposing);
            }
コード例 #11
0
ファイル: ToPdfService.cs プロジェクト: baskren/Forms9Patch
        /// <summary>
        /// Creates a PNG from the contents of a Xamarin.Forms.WebView
        /// </summary>
        /// <param name="webView">Xamarin.Forms.WebView</param>
        /// <param name="fileName">Name (not path), excluding suffix, of PDF file</param>
        /// <param name="pageSize">PDF page size, in points. (default based upon user's region)</param>
        /// <param name="margin">PDF page's margin, in points. (default is zero)</param>
        /// <returns>Forms9Patch.ToFileResult</returns>
        public static async Task <ToFileResult> ToPdfAsync(this Xamarin.Forms.WebView webView, string fileName, PageSize pageSize = default, PageMargin margin = default)
        {
            _platformToPdfService = _platformToPdfService ?? DependencyService.Get <IToPdfService>();
            if (_platformToPdfService == null)
            {
                throw new NotSupportedException("Cannot get HtmlService: must not be supported on this platform.");
            }
            ToFileResult result = null;

            using (var indicator = ActivityIndicatorPopup.Create())
            {
                if (pageSize is null || pageSize.Width <= 0 || pageSize.Height <= 0)
                {
                    pageSize = PageSize.Default;
                }

                margin = margin ?? new PageMargin();
                if (pageSize.Width - margin.HorizontalThickness < 1 || pageSize.Height - margin.VerticalThickness < 1)
                {
                    return(new ToFileResult(true, "Page printable area (page size - margins) has zero width or height."));
                }

                result = await _platformToPdfService.ToPdfAsync(webView, fileName, pageSize, margin);

                await indicator.CancelAsync();
            }
            await Task.Delay(50);

            return(result);
        }
コード例 #12
0
        public WindowsWebViewPageCS()
        {
            var webView = new Xamarin.Forms.WebView
            {
                HeightRequest = 50,
                Source        = new HtmlWebViewSource
                {
                    Html = @"<html><body><button onclick=""window.alert('Hello World from JavaScript');"">Click Me</button></body></html>"
                }
            };

            webView.On <Windows>().SetIsJavaScriptAlertEnabled(true);

            var toggleButton = new Button {
                Text = "Toggle JavaScript alert"
            };

            toggleButton.Clicked += (sender, e) => webView.On <Windows>().SetIsJavaScriptAlertEnabled(!webView.On <Windows>().IsJavaScriptAlertEnabled());

            Title   = "WebView JavaScript Alert";
            Content = new StackLayout
            {
                Margin   = new Thickness(20),
                Children = { webView, toggleButton }
            };
        }
コード例 #13
0
        //View
        public LoadWebpageDemoPage()
        {
            var heading = new Label
            {
                Text = "Webpage",
                HorizontalOptions = LayoutOptions.Center,
                FontSize = 50,
                FontAttributes = FontAttributes.Bold | FontAttributes.Italic
            };

            var webExample = new WebView
            {
                Source = "https://xamarin.com/branding",
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var mainLayout = new StackLayout
            {
                Children =
                {
                    heading,
                    webExample
                }
            };

            Content = mainLayout;
        }
コード例 #14
0
        public void ToPng(TaskCompletionSource <ToFileResult> taskCompletionSource, Xamarin.Forms.WebView xfWebView, string fileName, int width)
        {
            Device.BeginInvokeOnMainThread(async() =>
            {
                if (Platform.GetRenderer(xfWebView) is Xamarin.Forms.Platform.UWP.WebViewRenderer renderer)
                {
                    var webView = renderer.Control;

                    var contentSize = await webView.WebViewContentSizeAsync();
                    System.Diagnostics.Debug.WriteLine("A contentSize=[" + contentSize + "]");
                    System.Diagnostics.Debug.WriteLine("A webView.Size=[" + webView.Width + "," + webView.Height + "] IsOnMainThread=[" + P42.Utils.Environment.IsOnMainThread + "]");

                    webView.SetValue(BeforeWidthProperty, contentSize.Width);
                    webView.SetValue(BeforeHeightProperty, contentSize.Height);

                    webView.SetValue(PngFileNameProperty, fileName);
                    webView.SetValue(TaskCompletionSourceProperty, taskCompletionSource);
                    webView.SetValue(PngWidthProperty, width);
                    webView.Width = width;

                    webView.NavigationCompleted += NavigationCompleteA;
                    webView.NavigationFailed    += WebView_NavigationFailed;

                    //webView.Width = width;
                    NavigationCompleteA(webView, null);
                }
            });
        }
コード例 #15
0
        public void ToPdf(TaskCompletionSource <ToFileResult> taskCompletionSource, Xamarin.Forms.WebView xfWebView, string fileName, PageSize pageSize, PageMargin margin)
        {
            if (Platform.CreateRendererWithContext(xfWebView, Settings.Context) is IVisualElementRenderer renderer)
            {
                var droidWebView = renderer.View as Android.Webkit.WebView;
                if (droidWebView == null && renderer.View is WebViewRenderer xfWebViewRenderer)
                {
                    droidWebView = xfWebViewRenderer.Control;
                }
                if (droidWebView != null)
                {
                    //var size = new Size(8.5, 11);

                    //var externalPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
                    //using (var dir = new Java.IO.File(externalPath))
                    //using (var file = new Java.IO.File(dir + "/" + fileName + ".pdf"))
                    //{
                    //if (!dir.Exists())
                    //    dir.Mkdir();
                    //if (file.Exists())
                    //    file.Delete();

                    droidWebView.SetLayerType(LayerType.Software, null);
                    droidWebView.Settings.JavaScriptEnabled = true;
#pragma warning disable CS0618 // Type or member is obsolete
                    droidWebView.DrawingCacheEnabled = true;
                    droidWebView.BuildDrawingCache();
#pragma warning restore CS0618 // Type or member is obsolete

                    droidWebView.SetWebViewClient(new WebViewCallBack(taskCompletionSource, fileName, pageSize, margin, OnPageFinished));
                    //}
                }
            }
        }
コード例 #16
0
        public PayByCardPage(string URL, OrderModel orderModel)
        {
            Button button = new Button
            {
                Text            = "Back TO SHOP HOME",
                VerticalOptions = LayoutOptions.StartAndExpand,
                HeightRequest   = 50,
                WidthRequest    = 50,
                BackgroundColor = Color.Orange
            };

            button.Clicked += OnButtonClicked;


            string PreparedURL = Prepare_PaymentGatewayCall(orderModel);

            var PaymentPageView = new Xamarin.Forms.WebView
            {
                Source            = (GlobalSettings.WebXPayRequest + PreparedURL),
                HeightRequest     = (Application.Current.MainPage.Height * 90 / 100),
                WidthRequest      = (Application.Current.MainPage.Width),
                FlowDirection     = FlowDirection.MatchParent,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            PaymentPageView.BackgroundColor = Color.Yellow;
            Content = new StackLayout {
                Children = { PaymentPageView, button }
            };
        }
コード例 #17
0
        public FacebookLoginPage(FacebookConnection connection)
        {
            this.Title = "FacebookLoginPage";

         //   Connection = new FacebookConnection(key, secret, scope);
         //   connection.SignInCompleted += Connection_SignInCompleted;
            
            this._Connection = connection;

            this._Browser = new WebView();
			//_Browser.Source = new UrlWebViewSource() { Url = _Connection.LoginUri().AbsoluteUri };
            this._Connection.SignIn(this._Browser);

			Label lbl = new Label ()
			{ Text = "Connecting..." };
			lbl.SetBinding(Label.IsVisibleProperty, "IsVisible", BindingMode.OneWay, new BooleanInverterConverter());
            lbl.BindingContext = this._Browser;

            this._BaseLayout = new StackLayout()
            {
				Orientation = StackOrientation.Vertical,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
			};

            this._BaseLayout.Children.Add(lbl);
            this._BaseLayout.Children.Add(this._Browser);

            this._Browser.IsVisible = false;
                        	

            Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);  // Accomodate iPhone status bar.
            Content = this._BaseLayout;
        }
コード例 #18
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;
        }
コード例 #19
0
        public WebViewDemoPage()
        {
            Label header = new Label
            {
                Text = "WebView",
				FontSize = 50,
				FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            WebView webView = new WebView
            {
                Source = new UrlWebViewSource
                {
                    Url = "https://blog.xamarin.com/",
                },
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    webView
                }
            };
        }
コード例 #20
0
ファイル: ToPngService.cs プロジェクト: tmudford/Forms9Patch
        public async Task <ToFileResult> ToPngAsync(Xamarin.Forms.WebView webView, string fileName)
        {
            var taskCompletionSource = new TaskCompletionSource <ToFileResult>();

            ToPng(taskCompletionSource, webView, fileName);
            return(await taskCompletionSource.Task);
        }
コード例 #21
0
ファイル: PrintService.cs プロジェクト: wx0322/Forms9Patch
 public Task PrintAsync(Xamarin.Forms.WebView webView, string jobName, FailAction failAction)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (string.IsNullOrWhiteSpace(jobName))
         {
             jobName = Forms9Patch.ApplicationInfoService.Name;
         }
         WebViewPrintHelper printHelper = null;
         var properties = new Dictionary <string, string>
         {
             { "class", "Forms9Patch.UWP.PrintService" },
             { "method", "PrintAsync" },
         };
         try
         {
             if (webView.Source is HtmlWebViewSource htmlSource && !string.IsNullOrWhiteSpace(htmlSource.Html))
             {
                 properties["line"] = "47";
                 printHelper        = new WebViewPrintHelper(htmlSource.Html, htmlSource.BaseUrl, jobName);
             }
             else if (webView.Source is UrlWebViewSource urlSource && !string.IsNullOrWhiteSpace(urlSource.Url))
             {
                 properties["line"] = "53";
                 printHelper        = new WebViewPrintHelper(urlSource.Url, jobName);
             }
コード例 #22
0
        public WebPage(CorningLinks link)
        {
            var browser = new WebView();

            browser.Source = link.URL;

            Content = browser;
        }
コード例 #23
0
 private void InitializeComponent()
 {
     this.LoadFromXaml(typeof(MainForm));
     btnStartListening = this.FindByName <Button>("btnStartListening");
     btnStopListening = this.FindByName <Button>("btnStopListening");
     StatusLabel = this.FindByName <Label>("StatusLabel");
     MainWebView = this.FindByName <WebView>("MainWebView");
 }
コード例 #24
0
		public WebPage ()
		{
			var browser = new WebView();

			browser.Source = "http://xamarin.com";

			Content = browser;
		}
コード例 #25
0
		protected override void OnElementChanged (VisualElementChangedEventArgs e)
		{
			base.OnElementChanged (e);

			if (e.NewElement != null) {
				formsWebView = e.NewElement as WebView;
				Delegate = new CustomWebViewDelegate (formsWebView);
			}
		}
コード例 #26
0
ファイル: PaymentPage.xaml.cs プロジェクト: DAKnyazev/M11
 private void Init()
 {
     _browser             = new WebView();
     _browser.Navigating += BrowserOnNavigating;
     LoadingIndicator     = new ActivityIndicator
     {
         Color = Color.FromHex(App.MainColor)
     };
 }
コード例 #27
0
		protected override void OnElementChanged (ElementChangedEventArgs<Xamarin.Forms.WebView> e)
		{
			base.OnElementChanged (e);

			if (e.NewElement != null) {
				formsWebView = e.NewElement;
				Control.SetWebViewClient (new CustomWebViewClient(formsWebView));
			}
		}
コード例 #28
0
 public NewsDetailsView(Headline item)
 {
     BindingContext = item;
     var webView = new WebView ();
     webView.Source = new UrlWebViewSource {
         Url = item.Url
     };
     Content = webView;
 }
コード例 #29
0
		public BlogDetailsView (FeedItem item)
		{
			BindingContext = item;
			var webView = new WebView ();
			webView.Source = new HtmlWebViewSource {
				Html = item.Description
			};
			Content = webView;
		}
		public App ()
		{
			WebView webView = new WebView { Source = "https://www.youtube.com/watch?v=_Idra8rVS1I" };

			// The root page of your application
			MainPage = new ContentPage {
				Content = webView
			};
		}
コード例 #31
0
        public async Task <ToFileResult> ToPngAsync(Xamarin.Forms.WebView webView, string fileName, int width)
        {
            //if (!await XamarinEssentialsExtensions.ConfirmOrRequest<Xamarin.Essentials.Permissions.StorageWrite>())
            //    return new ToFileResult(true, "Write External Stoarge permission must be granted for PNG images to be available.");
            var taskCompletionSource = new TaskCompletionSource <ToFileResult>();

            ToPng(taskCompletionSource, webView, fileName, width);
            return(await taskCompletionSource.Task);
        }
コード例 #32
0
ファイル: WebPage.cs プロジェクト: threezool/LaunchPal
        private Xamarin.Forms.View GenerateBasicPageContent(string urlString)
        {
            var webView = new WebView
            {
                Source = urlString
            };

            return webView;
        }
コード例 #33
0
        public AndroidWebViewPageCS()
        {
            var webView = new Xamarin.Forms.WebView {
                Source = "https://htmlpreview.github.io/?https://github.com/xamarin/xamarin-forms-samples/blob/master/UserInterface/PlatformSpecifics/HTML/mixed_content.html"
            };

            webView.On <Android>().SetMixedContentMode(MixedContentHandling.AlwaysAllow);
            Content = webView;
        }
コード例 #34
0
 public TeamDetailView(Team item )
 {
     BindingContext = item;
     var webView = new WebView ();
     webView.Source = new UrlWebViewSource {
         Url = item.Links.web.teams.href
     };
     Content = webView;
 }
コード例 #35
0
 public PodcastDetalView(Podcast item)
 {
     BindingContext = item;
     var webView = new WebView ();
     webView.Source = new UrlWebViewSource {
         Url = item.Url
     };
     Content = webView;
 }
コード例 #36
0
ファイル: WebsiteView.cs プロジェクト: hojm/Hanselman.Forms
		public WebsiteView (string site, string title)
		{
			this.Title = title;
			var webView = new WebView ();
			webView.Source = new UrlWebViewSource {
				Url = site
			};
			Content = webView;
		}
コード例 #37
0
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                formsWebView = e.NewElement as WebView;
                Delegate     = new CustomWebViewDelegate(formsWebView);
            }
        }
コード例 #38
0
 public void SetupCookies(Xamarin.Forms.WebView webView)
 {
     CookieManager.Instance.Flush();
     CookieManager.AllowFileSchemeCookies();
     CookieManager.SetAcceptFileSchemeCookies(true);
     CookieManager.Instance.AcceptCookie();
     //CookieManager.Instance.AcceptThirdPartyCookies(webView);
     CookieManager.Instance.SetAcceptCookie(true);
     //CookieManager.Instance.SetAcceptThirdPartyCookies(webView, true);
 }
コード例 #39
0
 public void Print(Xamarin.Forms.WebView webView)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         var jobName = "Forms Print";
         WebViewPrintHelper printHelper = null;
         if (Platform.GetRenderer(webView) is Xamarin.Forms.Platform.UWP.WebViewRenderer renderer && renderer.Control is Windows.UI.Xaml.Controls.WebView nativeWebView)
         {
             printHelper = new WebViewPrintHelper(nativeWebView, jobName);
         }
コード例 #40
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.WebView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                formsWebView = e.NewElement;
                Control.SetWebViewClient(new CustomWebViewClient(formsWebView));
            }
        }
コード例 #41
0
ファイル: WebPage.cs プロジェクト: pabalexa/Moments
		private void SetupUserInterface ()
		{
			Title = Strings.WebBrowser;

			webView = new WebView {
				Source = url
			};

			Content = webView;
		}
コード例 #42
0
ファイル: ViewOnlineResource.cs プロジェクト: Un1XX388/LOSS
 public ViewOnlineResource(string page_title, string url)
 {
     // Title of page.
     Title					= page_title;
     // Create web view content page.
     var resource			= new WebView();
     // Set the source for this page (the page as a html stirng).
     resource.Source			= url;
     // Set the created html string to be the content of the page.
     Content					= resource;
 }
コード例 #43
0
        /// <summary>
        /// 관련된 프로퍼티가 무언가 변경되었을때 반응하는 메소드
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == "Source")
            {
                Xamarin.Forms.WebView wv = sender as Xamarin.Forms.WebView;
                string targetUrl         = (wv.Source as UrlWebViewSource).Url;
                Control.LoadUrl(targetUrl);
            }
        }
コード例 #44
0
        public async Task <ToFileResult> ToPngAsync(Xamarin.Forms.WebView webView, string fileName)
        {
            if (!await Permissions.WriteExternalStorage.ConfirmOrRequest())
            {
                return(new ToFileResult(true, "Write External Stoarge permission must be granted for PNG images to be available."));
            }
            var taskCompletionSource = new TaskCompletionSource <ToFileResult>();

            ToPng(taskCompletionSource, webView, fileName);
            return(await taskCompletionSource.Task);
        }
コード例 #45
0
ファイル: ToPdfService.cs プロジェクト: MrClan/Forms9Patch
        public async Task <ToFileResult> ToPdfAsync(Xamarin.Forms.WebView webView, string fileName, PageSize pageSize, PageMargin margin)
        {
            if (!await XamarinEssentialsExtensions.ConfirmOrRequest <Xamarin.Essentials.Permissions.StorageWrite>())
            {
                return(new ToFileResult(true, "Write External Stoarge permission must be granted for PNG images to be available."));
            }
            var taskCompletionSource = new TaskCompletionSource <ToFileResult>();

            ToPdf(taskCompletionSource, webView, fileName, pageSize, margin);
            return(await taskCompletionSource.Task);
        }
コード例 #46
0
		public WebsiteView (Page page)
		{
			Title = page.Title;
			var webView = new WebView {
				Source = new HtmlWebViewSource {
					Html = page.Content
				},
                
			};
			Content = webView;
		}
コード例 #47
0
        protected override void OnAttached()
        {
            if (Element is WebViewForms webViewForms &&
                Control is WebViewDroid webViewDroid)
            {
                _webViewForms = webViewForms;
                _webViewDroid = webViewDroid;

                _effectWebViewClient = new EffectWebViewClient(_webViewForms, _webViewDroid);
                _webViewDroid.SetWebViewClient(_effectWebViewClient);
            }
        }
コード例 #48
0
        protected override void OnDetached()
        {
            if (_effectWebViewClient != null)
            {
                _webViewDroid.SetWebViewClient(null);
                _effectWebViewClient.Dispose();

                _webViewForms        = null;
                _webViewDroid        = null;
                _effectWebViewClient = null;
            }
        }
コード例 #49
0
ファイル: Passo2.xaml.cs プロジェクト: rafaelrmou/AppCursoZ
        public Passo2()
        {
            InitializeComponent ();
            Title = "Aba 2";

            Content = new WebView (){
                Source = new UrlWebViewSource(){
                    Url = "www.google.com"
                },

            };
        }
コード例 #50
0
ファイル: ToPngService.cs プロジェクト: MrClan/Forms9Patch
        public void ToPng(TaskCompletionSource <ToFileResult> taskCompletionSource, Xamarin.Forms.WebView xfWebView, string fileName, int width)
        {
            if (Platform.CreateRendererWithContext(xfWebView, Settings.Context) is IVisualElementRenderer renderer)
            {
                var droidWebView = renderer.View as Android.Webkit.WebView;
                if (droidWebView == null && renderer.View is WebViewRenderer xfWebViewRenderer)
                {
                    droidWebView = xfWebViewRenderer.Control;
                }
                if (droidWebView != null)
                {
                    //var size = new Size(8.5, 11);
                    //var bounds = new Rectangle(droidWebView.Left, droidWebView.Top, droidWebView.Width, droidWebView.Height);
                    var externalPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
                    using (var dir = new Java.IO.File(externalPath))
                        using (var file = new Java.IO.File(dir + "/" + fileName + ".png"))
                        {
                            if (!dir.Exists())
                            {
                                dir.Mkdir();
                            }
                            if (file.Exists())
                            {
                                file.Delete();
                            }

                            /*
                             * Android.Widget.FrameLayout.LayoutParams tmpParams = new Android.Widget.FrameLayout.LayoutParams(width, width);
                             * droidWebView.LayoutParameters = tmpParams;
                             * droidWebView.Layout(0, 0, width, width);
                             * int specWidth = MeasureSpecFactory.MakeMeasureSpec((int)(width * Display.Scale), MeasureSpecMode.Exactly);
                             * //int specHeight = MeasureSpecFactory.MakeMeasureSpec((int)(width * Display.Scale), MeasureSpecMode.Exactly);
                             * int specHeight = MeasureSpecFactory.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
                             * droidWebView.Measure(specWidth, specHeight);
                             * droidWebView.Layout(0, 0, droidWebView.MeasuredWidth, droidWebView.MeasuredHeight);
                             */


                            droidWebView.SetLayerType(LayerType.Software, null);
                            droidWebView.Settings.JavaScriptEnabled = true;
#pragma warning disable CS0618 // Type or member is obsolete
                            droidWebView.DrawingCacheEnabled = true;
                            droidWebView.BuildDrawingCache();
#pragma warning restore CS0618 // Type or member is obsolete

                            droidWebView.SetWebViewClient(new WebViewCallBack(taskCompletionSource, fileName, new PageSize {
                                Width = width
                            }, null, OnPageFinished));
                        }
                }
            }
        }
コード例 #51
0
 public void Print(Xamarin.Forms.WebView webView, string jobName)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (string.IsNullOrWhiteSpace(jobName))
         {
             jobName = Forms9Patch.ApplicationInfoService.Name;
         }
         WebViewPrintHelper printHelper = null;
         if (Platform.GetRenderer(webView) is WebViewRenderer renderer && renderer.Control is Windows.UI.Xaml.Controls.WebView nativeWebView)
         {
             printHelper = new WebViewPrintHelper(nativeWebView, jobName);
         }
コード例 #52
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.WebView> e)
        {
            base.OnElementChanged(e);
            var activity = Xamarin.Forms.Forms.Context as MainActivity;

            if (e.NewElement != null)
            {
                formsWebView = e.NewElement;
                Control.Settings.JavaScriptEnabled = true;
                Control.SetWebViewClient(new CustomWebViewClient(formsWebView));
                Control.SetWebChromeClient(new CustomWebChromeClient(activity));
            }
        }
コード例 #53
0
 public Task PrintAsync(Xamarin.Forms.WebView webView, string jobName)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (string.IsNullOrWhiteSpace(jobName))
         {
             jobName = Forms9Patch.ApplicationInfoService.Name;
         }
         WebViewPrintHelper printHelper = null;
         if (webView.Source is HtmlWebViewSource htmlSource && !string.IsNullOrWhiteSpace(htmlSource.Html))
         {
             printHelper = new WebViewPrintHelper(htmlSource.Html, htmlSource.BaseUrl, jobName);
         }
コード例 #54
0
        public AndroidWebViewZoomPageCS()
        {
            WebView webView = new WebView
            {
                Source = "https://www.xamarin.com"
            };

            webView.On <Android>()
            .SetEnableZoomControls(true)
            .SetDisplayZoomControls(true);

            Title   = "WebView Zoom Controls";
            Content = webView;
        }
コード例 #55
0
ファイル: ToPngService.cs プロジェクト: tmudford/Forms9Patch
        public void ToPng(TaskCompletionSource <ToFileResult> taskCompletionSource, Xamarin.Forms.WebView xfWebView, string fileName)
        {
            Device.BeginInvokeOnMainThread(async() =>
            {
                if (Platform.GetRenderer(xfWebView) is Xamarin.Forms.Platform.UWP.WebViewRenderer renderer)
                {
                    var webView = renderer.Control;

                    webView.SetValue(PngFileNameProperty, fileName);
                    webView.SetValue(TaskCompletionSourceProperty, taskCompletionSource);

                    webView.NavigationCompleted += NavigationCompleteA;
                    webView.NavigationFailed    += WebView_NavigationFailed;
                }
            });
        }
コード例 #56
0
        public void InitLayout()
        {
            m_btnBack          = buttonBack;
            m_btnBack.Clicked += OnClickBack;

            m_btnForward          = buttonForward;
            m_btnForward.Clicked += OnClickFoward;

            m_btnReload          = buttonReload;
            m_btnReload.Clicked += OnClickReload;

            m_textUri            = editTextUri;
            m_textUri.Completed += OnKeyPressTextUri;

            m_webView = webWiew;
        }
コード例 #57
0
ファイル: Print.cs プロジェクト: Sachinj840/UrbanServices
        public void PrintInfo(Xamarin.Forms.WebView Data)
        {
            var droidViewToPrint = Platform.CreateRenderer(Data).ViewGroup.GetChildAt(0) as Android.Webkit.WebView;

            if (droidViewToPrint != null)
            {
                // Only valid for API 19+
                var version = Android.OS.Build.VERSION.SdkInt;

                if (version >= Android.OS.BuildVersionCodes.Kitkat)
                {
                    var printMgr = (PrintManager)Forms.Context.GetSystemService(Context.PrintService);

                    printMgr.Print("Forms-EZ-Print", droidViewToPrint.CreatePrintDocumentAdapter(), null);
                }
            }
        }
コード例 #58
0
ファイル: ToPdfService.cs プロジェクト: tmudford/Forms9Patch
        /// <summary>
        /// Creates a PNG from the contents of a Xamarin.Forms.WebView
        /// </summary>
        /// <param name="webView"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static async Task <ToFileResult> ToPdfAsync(this Xamarin.Forms.WebView webView, string fileName)
        {
            _platformToPdfService = _platformToPdfService ?? DependencyService.Get <IToPdfService>();
            if (_platformToPdfService == null)
            {
                throw new NotSupportedException("Cannot get HtmlService: must not be supported on this platform.");
            }
            ToFileResult result = null;

            using (var indicator = ActivityIndicatorPopup.Create())
            {
                result = await _platformToPdfService.ToPdfAsync(webView, fileName);
            }
            await Task.Delay(50);

            return(result);
        }
コード例 #59
-1
ファイル: Auth0Login.cs プロジェクト: fabianwilliams/jbma
        public Auth0Login()
        {
            Label header = new Label
            {
                Text = "Connect with Untappd",
                FontSize = 25,
                FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            WebView webView = new WebView
            {
                Source = new UrlWebViewSource
                {
                    Url = "https://adotob.auth0.com/authorize?response_type=token&scope=openid&client_id=prt0oxC0CEIB0r9dImcKtx4pCupRJk55&redirect_uri=https://adotob.auth0.com/mobile&connection=untappd",
                },
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            // Build the page.
            this.Content = new StackLayout
            {
                Children =
                {
                    header,
                    webView
                }
                };
        }
コード例 #60
-1
        public PoliciesWebPage()
        {
            // Set Page Title
            Title = "Pace Policies";

            var source = new UrlWebViewSource ();
            source.Url = "http://pace.edu/sexual-assault";
            var webView = new WebView {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    Source = source
            };
            webView.Navigating += (object sender, WebNavigatingEventArgs e) => {
                System.Diagnostics.Debug.WriteLine("Loading");
            };
            webView.Navigated += (object sender, WebNavigatedEventArgs e) => {
                System.Diagnostics.Debug.WriteLine("Done");
            };

            Content = new ContentView {
                Content = new StackLayout {
                    Children = {
                        webView
                    }
                }
            };
        }