Exemplo n.º 1
0
		public void RunJavaScriptTextInputPanel (WebKit.WKWebView webView, string prompt, string defaultText, WebKit.WKFrameInfo frame, System.Action<string> completionHandler)
		{
			// Create a native UIAlertController with the message
			var alertController = UIAlertController.Create (null, prompt, UIAlertControllerStyle.Alert);

			// Add a text field to the alert, set the placeholder text and keep a refernce to the field
			UITextField alertTextField = null;
			alertController.AddTextField ((textField) => {
				textField.Placeholder = defaultText;
				alertTextField = textField;
			});

			// Pass the text to the completion handler when the "OK" button is tapped
			alertController.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Default, okAction => {
				completionHandler (alertTextField.Text);
			}));

			// If "Cancel" is tapped, we can just return null
			alertController.AddAction (UIAlertAction.Create ("Cancel", UIAlertActionStyle.Default, cancelAction => {
				completionHandler (null);
			}));

			// Present the alert
			PresentViewController (alertController, true, null);
		}
Exemplo n.º 2
0
		public void RunJavaScriptAlertPanel (WebKit.WKWebView webView, string message, WebKit.WKFrameInfo frame, System.Action completionHandler)
		{
			// Create and present a native UIAlertController with the message
			var alertController = UIAlertController.Create (null, message, UIAlertControllerStyle.Alert);
			alertController.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Default, null));
			PresentViewController (alertController, true, null);

			// Call the completion handler 
			completionHandler ();
		}
Exemplo n.º 3
0
		public void StartedProvisionalLoad(WebKit.WebView sender, WebKit.WebFrame forFrame)
		{
			var url = sender.MainFrameUrl;

			if (!Authenticator.HasCompleted) {
				Uri uri;
				if (Uri.TryCreate (url, UriKind.Absolute, out uri)) {
					if (Authenticator.CheckUrl (uri, GetCookies (url)))
						return;
				}
			}
		}
Exemplo n.º 4
0
 void CustomContextMenuManager_ShowContextMenu(object sender, WebKit.ShowContextMenuEventArgs e)
 {
     // Here we handle our custom menu implementation.
     // Remember that firstly we have set Browser.UseDefaultContextMenu = false
     // Otherwise this event will not be fired and the default webkit context
     // menu will be shown.
     ContextMenu Menu;
     if (e.MenuType == WebKit.ContextMenuType.Image)
         Menu = imageContextMenu;
     else if (e.MenuType == WebKit.ContextMenuType.ImageAndLink)
         Menu = imageAndLinkContextMenu;
     else if (e.MenuType == WebKit.ContextMenuType.Link)
         Menu = linkContextMenu;
     else if (e.MenuType == WebKit.ContextMenuType.Input)
         Menu = inputContextMenu;
     else if (e.MenuType == WebKit.ContextMenuType.Form)
         Menu = formContextMenu;
     else Menu = normalContextMenu;
     Menu.Show((sender as WebKitBrowser), e.Location);
 }
Exemplo n.º 5
0
        private void WebViewNavigationRequested(object o, WebKit.NavigationRequestedArgs args)
        {
            Controller.LinkClicked (args.Request.Uri);

            // Don't follow HREFs (as this would cause a page refresh)
            if (!args.Request.Uri.Equals ("file:"))
                args.RetVal = 1;
        }
Exemplo n.º 6
0
		public void WillPerformClientRedirect(WebKit.WebView sender, Foundation.NSUrl toUrl, double secondsDelay, Foundation.NSDate fireDate, WebKit.WebFrame forFrame)
		{
			var url = sender.MainFrameUrl;

			if (!Authenticator.HasCompleted) {
				Uri uri;
				if (Uri.TryCreate(url, UriKind.Absolute, out uri)) {
					if (Authenticator.CheckUrl(uri, GetCookies(url))) {
						forFrame.StopLoading();
						return;
					}
				}
			} else {
				forFrame.StopLoading();
			}
		}
Exemplo n.º 7
0
		/// <summary>
		/// Handles changes in the <title> tag of the WebView
		/// </summary>
		/// <description>
		/// Waits for changes in the title and passes them for processing and deserialization
		/// to the message manager. This method is the link between the designer surface and the
		/// C# backend of the designer.
		/// </description>
		void WebView_OnTitleChanged (object o, WebKit.TitleChangedArgs args)
		{
			try {
				msgManager.HandleMessage (args.Title);
			} catch (Exception ex) {
				System.Diagnostics.Trace.WriteLine (ex.ToString ());
			}
		}
Exemplo n.º 8
0
 private void webKitBrowser1_StatusTextChanged(object sender, WebKit.WebKitBrowserStatusChangedEventArgs e)
 {
     if (sender.Equals(webKitBrowser1))
     statusLabel.Text = e.StatusText; // link hovering status text is only supported in nightly builds
 }
Exemplo n.º 9
0
 private void webKitBrowser1_ShowJavaScriptPromptPanel(object sender, WebKit.ShowJavaScriptPromptPanelEventArgs e)
 {
     e.ReturnValue = Microsoft.VisualBasic.Interaction.InputBox(e.Message, "", e.DefaultValue);
 }
Exemplo n.º 10
0
 private void webKitBrowser1_ShowJavaScriptConfirmPanel(object sender, WebKit.ShowJavaScriptConfirmPanelEventArgs e)
 {
     bool val = (MessageBox.Show(e.Message,"OpenWebKitSharp Example",MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK);
     e.ReturnValue = val;
 }
Exemplo n.º 11
0
 private void webKitBrowser1_ShowJavaScriptAlertPanel(object sender, WebKit.ShowJavaScriptAlertPanelEventArgs e)
 {
     MessageBox.Show(e.Message);
 }
Exemplo n.º 12
0
 private void webKitBrowser1_ProgressChanged(object sender, WebKit.ProgressChangesEventArgs e)
 {
     toolStripProgressBar1.Value = e.Percent;
 }
Exemplo n.º 13
0
 private void webKitBrowser1_NewWindowCreated(object sender, WebKit.NewWindowCreatedEventArgs e)
 {
     AddTab(e.WebKitBrowser);
 }
Exemplo n.º 14
0
 private void webKitBrowser1_FormSubmit(object sender, WebKit.FormDelegateFormEventArgs e)
 {
     //e.Listener.continueSubmit();  from 1.5 Beta 2 this is automatically called
 }
Exemplo n.º 15
0
 private void webKitBrowser1_FaviconAvaiable(object sender, WebKit.FaviconAvailableEventArgs e)
 {
     if (e.Favicon != null)
     {
         fav.Visible = true;
         fav.Image = e.Favicon.ToBitmap();
     }
     else
         fav.Visible = false;
 }