public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			webView = new UIWebView (new RectangleF(0, (_addCancelButton) ? navigationBarHeight : 0, View.Frame.Width, (_addCancelButton) ? View.Frame.Height - navigationBarHeight : View.Frame.Height));
			webView.Delegate = new WebViewDelegate(RequestStarted, RequestFinished);

			if (!_addCancelButton) {
				this.View.AddSubview (webView);
			} else {
				var cancelButton = new UIBarButtonItem (UIBarButtonSystemItem.Cancel);
				cancelButton.Clicked += (object sender, EventArgs e) => {
					_cancelled();
					this.DismissViewController(true, null);
				};

				var navigationItem = new UINavigationItem {
					LeftBarButtonItem = cancelButton
				};

				navigationBar = new UINavigationBar (new RectangleF (0, 0, View.Frame.Width, navigationBarHeight));
				navigationBar.PushNavigationItem (navigationItem, false);

				this.View.AddSubviews (navigationBar, webView);
			}
		}
        bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
        {

            // If the URL is not our own custom scheme, just let the webView load the URL as usual
            var scheme = "app:";

            if (request.Url.Scheme != scheme.Replace(":", ""))
                return true;

            var resources = request.Url.ResourceSpecifier.Split('?');
            var method = resources[0];

            if (method == "QR")
            {
                var scanner = new ZXing.Mobile.MobileBarcodeScanner();
                scanner.Scan().ContinueWith(result => {
                    if (result != null){
                        var code = result.Result.Text;
                        this.InvokeOnMainThread(new NSAction(() => webView.LoadRequest(new NSUrlRequest(new NSUrl(MainUrl + "code?value=" + code)))));
                    }
                });
            }

            return false;
        }
Beispiel #3
0
 public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
 {
     bool shouldStart = true;
     string url = request.Url.ToString();
     if (url.Contains("js-frame"))
     {
         shouldStart = false;
         string pendingArgs = bridge.webBrowser.EvaluateJavascript("window.locationMessenger.pendingArg.toString();");
         // Using JsonConvert.Deserialze<string[]> blows up under MonoTouch, so manually build the array of args instead
         JArray argsJArray = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(pendingArgs);
         string[] args = new string[argsJArray.Count];
         for (int i = 0; i < argsJArray.Count; i++)
             args[i] = (string)argsJArray[i];
         if (args[0] == "HandleScriptPropertyChanged")
         {
             if (args.Length == 3)
                 bridge.HandleScriptPropertyChanged(args[1], args[2], null);
             else
                 bridge.HandleScriptPropertyChanged(args[1], args[2], args[3]);
         }
         else if (args[0] == "InvokeViewModelIndexMethod")
             bridge.InvokeViewModelMethod(args[1], args[2], args[3]);
         else if (args[0] == "InvokeViewModelMethod")
             bridge.InvokeViewModelMethod(args[1], args[2]);
         else if (args[0] == "HandleDocumentReady")
             bridge.HandleDocumentReady();
         else if (args[0] == "HostLog")
             bridge.HostLog(args[1]);
         else
             SpinnakerConfiguration.CurrentConfig.Log(SpinnakerLogLevel.Error,"Ignoring unrecognized call from javascript for [" + args[0] + "] - this means that javascript in the view is trying to reach the host but with bad arguments");
     }
     return shouldStart;
 }
            public WebScrollDelegate( UIWebView parentWebView, NavToolbar toolbar ) : base( toolbar )
            {
                ParentWebView = parentWebView;

                SourceDelegate = ParentWebView.ScrollView.Delegate;
                ParentWebView.ScrollView.Delegate = this;
            }
Beispiel #5
0
        public override bool ShouldStartLoad(UIWebView webView, NSURLRequest request, UIWebViewNavigationType navigationType)
        {
            Debug.Log ("ShouldStartLoad");
            // handle the special url schema as a way to communicate from the web
            NSURL url = request.URL();

            if (url!=null && url.Scheme().Equals("u3dxt"))
            {				object[] paths = url.PathComponents();
                Debug.Log (paths.Length);
                string command = paths[1] as string;
                Debug.Log ("command: " + command);
                if ( command.Equals("say") )
                {
                    string phrase = paths[2] as string;
                    Debug.Log ("Phrase: " + phrase);
                    SpeechXT.Speak(phrase);
                }

                // do not actually load this
                return false;
            }
            else
            {
                return true;
            }
        }
		void ReleaseDesignerOutlets ()
		{
			if (ContentHtml != null) {
				ContentHtml.Dispose ();
				ContentHtml = null;
			}
		}
        public static UIViewController HtmlSelected(ApiNode apiNode)
        {
            var vc = new UIViewController();

            var webView = new UIWebView(UIScreen.MainScreen.Bounds)
            {
                BackgroundColor = UIColor.White,
                ScalesPageToFit = false,
                AutoresizingMask = UIViewAutoresizing.All
            };

            var html = apiNode["content"];

            if (apiNode["contentNode"] != null)
            {
                html = apiNode[apiNode["contentNode"]];
            }

            if (html != null && !html.Contains("<html"))
            {
                html = String.Format("<html><head><link href=\"main-style.css\" rel=\"stylesheet\" type=\"text/css\" /></head><body><h1>{0}</h1>{1}</body><html>", apiNode.Title, html);
            }

            if (html != null)
                webView.LoadHtmlString(html, new NSUrl("HtmlContent/", true));

            vc.NavigationItem.Title = apiNode.Title;

            vc.View.AutosizesSubviews = true;
            vc.View.AddSubview(webView);

            return vc;
        }
        public override void LoadView()
        {
            base.LoadView ();

            bool isV7 = UIDevice.CurrentDevice.CheckSystemVersion (7, 0);

            View.BackgroundColor = UIColor.White;

            niceSegmentedCtrl = new SDSegmentedControl (new string [] { "Google", "Bing", "Yahoo" });

            if (isV7)
                niceSegmentedCtrl.Frame = new RectangleF (0, 10, 320, 44);
            else
                niceSegmentedCtrl.Frame = new RectangleF (0, 0, 320, 44);

            niceSegmentedCtrl.SetImage (UIImage.FromBundle ("google"), 0);
            niceSegmentedCtrl.SetImage (UIImage.FromBundle ("bicon"), 1);
            niceSegmentedCtrl.SetImage (UIImage.FromBundle ("yahoo"), 2);
            niceSegmentedCtrl.ValueChanged += HandleValueChanged;

            if (isV7)
                browser = new UIWebView (new RectangleF (0, 55, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 64));
            else
                browser = new UIWebView (new RectangleF (0, 45, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 64));

            browser.LoadRequest (new NSUrlRequest ( new NSUrl ("http://google.com")));
            browser.AutosizesSubviews = true;

            View.AddSubviews ( new UIView[] { niceSegmentedCtrl, browser });
        }
		void ReleaseDesignerOutlets ()
		{
			if (wvImage != null) {
				wvImage.Dispose ();
				wvImage = null;
			}
		}
		public WebAuthenticatorController (WebAuthenticator authenticator)
		{
			this.authenticator = authenticator;

			authenticator.Error += HandleError;
			authenticator.BrowsingCompleted += HandleBrowsingCompleted;

			//
			// Create the UI
			//
			Title = authenticator.Title;

			NavigationItem.LeftBarButtonItem = new UIBarButtonItem (
				UIBarButtonSystemItem.Cancel,
				delegate {
					Cancel ();
				});

			activity = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.White);
			NavigationItem.RightBarButtonItem = new UIBarButtonItem (activity);

			webView = new UIWebView (View.Bounds) {
				Delegate = new WebViewDelegate (this),
				AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
			};
			View.AddSubview (webView);
			View.BackgroundColor = UIColor.Black;

			//
			// Locate our initial URL
			//
			BeginLoadingInitialUrl ();
		}
        public Task SaveAndLaunchFile(Stream stream, string fileType)
        {
            if (OriginView == null) return Task.FromResult(true);

            var data = NSData.FromStream(stream);
            var width = 824;
            var height = 668;

            var popoverView = new UIView(new RectangleF(0, 0, width, height));
            popoverView.BackgroundColor = UIColor.White;
            var webView = new UIWebView();
            webView.Frame = new RectangleF(0, 45, width, height - 45);

            var b = new UIButton(UIButtonType.RoundedRect);
            b.SetTitle("Done", UIControlState.Normal);
            b.Frame = new RectangleF(10,10, 60, 25);
            b.TouchUpInside += (o, e) => _popoverController.Dismiss(true);

            popoverView.AddSubview(b);
            popoverView.AddSubview(webView);

            var bundlePath = NSBundle.MainBundle.BundlePath;
            System.Diagnostics.Debug.WriteLine(bundlePath);
            webView.LoadData(data, "application/pdf", "utf-8", NSUrl.FromString("http://google.com"));

            var popoverContent = new UIViewController();
            popoverContent.View = popoverView;

            _popoverController = new UIPopoverController(popoverContent);
            _popoverController.PopoverContentSize = new SizeF(width, height);
            _popoverController.PresentFromRect(new RectangleF(OriginView.Frame.Width/2, 50, 1, 1), OriginView, UIPopoverArrowDirection.Any, true);
            _popoverController.DidDismiss += (o, e) => _popoverController = null;

            return Task.FromResult(true);
        }
		void ReleaseDesignerOutlets ()
		{
			if (webView != null) {
				webView.Dispose ();
				webView = null;
			}
		}
		void ReleaseDesignerOutlets ()
		{
			if (LiveChatView != null) {
				LiveChatView.Dispose ();
				LiveChatView = null;
			}
		}
Beispiel #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            Title = "WebView";
            View.BackgroundColor = UIColor.White;

            webView = new UIWebView(View.Bounds);
            View.AddSubview(webView);

            // html, image, css files must have Build Action:Content
            string fileName = "Content/Home.html"; // remember case sensitive

            string localHtmlUrl = Path.Combine(NSBundle.MainBundle.BundlePath, fileName);
            webView.LoadRequest (new NSUrlRequest (new NSUrl (localHtmlUrl, false)));
            webView.ScalesPageToFit = true;
            webView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;

            #region Additional Info
            // can also manually create html
            // passing the 'base' path to LoadHtmlString lets relative Urls for for links, images, etc
            //string contentDirectoryPath = Path.Combine(NSBundle.MainBundle.BundlePath,"Content/");
            //webView.LoadHtmlString ("<html><a href='Home.html'>Click Me</a>", new NSUrl (contentDirectoryPath, true));
            #endregion
        }
Beispiel #15
0
        public static UIViewController AudioSelected(ApiNode apiNode)
        {
            var url = apiNode["videoSrc1"];

            if (apiNode["contentNode"] != null)
            {
                url = apiNode[apiNode["contentNode"]];
            }

            //var videoController = new UIVideoController(url);

            //videoController.NavigationItem.Title = apiNode.Title;

            //return videoController;

            var vc = new UIViewController();

            var webView = new UIWebView(UIScreen.MainScreen.Bounds)
            {
                BackgroundColor = UIColor.White,
                ScalesPageToFit = true,
                AutoresizingMask = UIViewAutoresizing.All
            };

            var request = new NSUrlRequest(new NSUrl(url), NSUrlRequestCachePolicy.UseProtocolCachePolicy, 60);

            webView.LoadRequest(request);

            vc.NavigationItem.Title = apiNode.Title;

            vc.View.AutosizesSubviews = true;
            vc.View.AddSubview(webView);

            return vc;
        }
Beispiel #16
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			txt = new UITextView (new CoreGraphics.CGRect (100, 50, 200, 30));
			txt.BackgroundColor = UIColor.Gray;
			txt.TextColor = UIColor.White;
			txt.Text="https://auth.alipay.com/login/index.htm";

			UIButton btn = new UIButton (UIButtonType.System);
			btn.Frame = new CoreGraphics.CGRect (330, 50, 100, 30);
			btn.SetTitle ("GO", UIControlState.Normal);
			btn.TouchUpInside += Btn_TouchUpInside;

			UIButton btnHtmlString = new UIButton (UIButtonType.System);
			btnHtmlString.Frame = new CoreGraphics.CGRect (450, 50, 100, 30);
			btnHtmlString.SetTitle ("Html String", UIControlState.Normal);
			btnHtmlString.TouchUpInside += BtnHtmlString_TouchUpInside;

			UIButton btnFile = new UIButton (UIButtonType.System);
			btnFile.Frame = new CoreGraphics.CGRect (580, 50, 100, 30);
			btnFile.SetTitle ("Load File", UIControlState.Normal);
			btnFile.TouchUpInside += BtnFile_TouchUpInside;

			// Perform any additional setup after loading the view, typically from a nib.
			webView=new UIWebView(new CoreGraphics.CGRect(100,100,600,700));
			webView.ContentMode = UIViewContentMode.Center;
			
			this.View.AddSubviews (txt, btn, webView, btnHtmlString, btnFile);

		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            navBar = new UIToolbar ();
            navBar.Frame = new RectangleF (0, this.View.Frame.Height-130, this.View.Frame.Width, 40);

            items = new UIBarButtonItem [] {
                new UIBarButtonItem ("Back", UIBarButtonItemStyle.Bordered, (o, e) => { webView.GoBack (); }),
                new UIBarButtonItem ("Forward", UIBarButtonItemStyle.Bordered, (o, e) => { webView.GoForward (); }),
                new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace, null),
                new UIBarButtonItem (UIBarButtonSystemItem.Refresh, (o, e) => { webView.Reload (); }),
                new UIBarButtonItem (UIBarButtonSystemItem.Stop, (o, e) => { webView.StopLoading (); })
            };
            navBar.Items = items;

            SetNavBarColor();

            webView = new UIWebView ();
            webView.Frame = new RectangleF (0, 0, this.View.Frame.Width, this.View.Frame.Height-130);

            webView.LoadStarted += delegate {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            };
            webView.LoadFinished += delegate {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
            };

            webView.ScalesPageToFit = true;
            webView.SizeToFit ();
            webView.LoadRequest (url);

            this.View.AddSubview (webView);
            this.View.AddSubview (navBar);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (!string.IsNullOrEmpty(IdentityProviderName))
                Title = IdentityProviderName;

            _webView = new UIWebView(new RectangleF(0,0, View.Bounds.Width, View.Bounds.Height))
            {
                AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleBottomMargin
            };
            _webView.ShouldStartLoad += ShouldStartLoad;
            _webView.LoadStarted +=
                (sender, args) => UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            _webView.LoadFinished +=
                (sender, args) => UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

            _webView.LoadError += (sender, args) =>
            {
                //Some providers have this strange Frame Interrupted Error :-/
                if (args.Error.Code == 102 && args.Error.Domain == "WebKitErrorDomain") return;

                _messageHub.Publish(new RequestTokenMessage(this) { TokenResponse = null });
            };

            View.AddSubview(_webView);

            _webView.LoadRequest(new NSUrlRequest(Url));
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            App_Window = new UIWindow(UIScreen.MainScreen.Bounds);
            var vc = new UIViewController();
            var view = new UIView();

            var button = UIButton.FromType(UIButtonType.RoundedRect);
            button.Frame = new RectangleF(0, 0, 100, 40);
            button.SetTitle("Do It", UIControlState.Normal);
            button.TouchDown += delegate {
                Test_JSON();
            };
            view.AddSubview(button);

            Browser = new UIWebView();
            Browser.Frame = new RectangleF(0, 50, UIScreen.MainScreen.Bounds.Width,
                UIScreen.MainScreen.Bounds.Height-50);
            view.AddSubview(Browser);

            vc.View = view;
            App_Window.RootViewController = vc;
            App_Window.MakeKeyAndVisible();

            return true;
        }
Beispiel #20
0
		protected override void Dispose (bool disposing)
		{
			if (disposing) {
				_webview = null;
			}
			base.Dispose (disposing);
		}
		private void SetupUserInterface ()
		{
			scrollView = new UIScrollView {
				BackgroundColor = UIColor.Clear.FromHexString ("#094074", 1.0f),
				Frame = new CGRect (0, 0, Frame.Width, Frame.Height * 2)
			};

			licensureLabel = new UILabel {
				Font = UIFont.FromName ("SegoeUI-Light", 25f),
				Frame = new CGRect (0, 20, Frame.Width, 35),
				Text = "Open-Source",
				TextAlignment = UITextAlignment.Center,
				TextColor = UIColor.White
			};

			string localHtmlUrl = Path.Combine (NSBundle.MainBundle.BundlePath, "Licensure.html");
			var url = new NSUrl (localHtmlUrl, false);
			var request = new NSUrlRequest (url);

			webView = new UIWebView () {
				Frame = new CGRect (0, 55, Frame.Width, Frame.Height - 55)
			};
			webView.LoadRequest (request);

			scrollView.ContentSize = new CGSize (Frame.Width, Frame.Height * 2);

			scrollView.Add (licensureLabel);
			scrollView.Add (webView);
			Add (scrollView);
		}
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			var webFrame = UIScreen.MainScreen.ApplicationFrame;

			_webView = new UIWebView(webFrame) {
				BackgroundColor = UIColor.White,
				ScalesPageToFit = true,
				AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
			};

			_webView.LoadStarted += delegate {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
			};
			_webView.LoadFinished += delegate {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
			};
			_webView.LoadError += (webview, args) => {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
					_webView.LoadHtmlString (String.Format ("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
			};

			View.AddSubview(_webView);

			_webView.LoadRequest(new NSUrlRequest(new NSUrl(ViewModel.Uri)));
		}
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var webViewController = new UIViewController ();
            var button = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, null);

            var custom = new UIButton (new RectangleF (0, 0, 26, 15));
            custom.SetBackgroundImage(UIImage.FromFile("./Assets/back.png"), UIControlState.Normal);
            custom.TouchUpInside += (sender, e) => webViewController.NavigationController.PopViewControllerAnimated (true);
            button.CustomView = custom;
            webViewController.NavigationItem.LeftBarButtonItem = button;

            var spinner = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.WhiteLarge);
            spinner.Center = new PointF (160, 160);
            spinner.HidesWhenStopped = true;

            var webView = new UIWebView (tableView.Bounds);
            webView.Opaque = false;
            webView.BackgroundColor = UIColor.Black;
            webView.AddSubview (spinner);
            spinner.StartAnimating ();
            webView.LoadRequest (new NSUrlRequest (new NSUrl (string.Format(RequestConfig.Video, items[indexPath.Row].Id))));
            webViewController.View = webView;
            webViewController.Title = items[indexPath.Row].Category;
            webView.LoadFinished += (object sender, EventArgs e) => {
                spinner.StopAnimating();
            };

            ((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).
                Video.InternalTopNavigation.PushViewController (webViewController,true);

            tableView.DeselectRow (indexPath, true);
        }
        bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
        {
            // If the URL is not our own custom scheme, just let the webView load the URL as usual
            const string scheme = "hybrid:";

            if (request.Url.Scheme != scheme.Replace (":", ""))
                return true;

            // This handler will treat everything between the protocol and "?"
            // as the method name.  The querystring has all of the parameters.
            var resources = request.Url.ResourceSpecifier.Split ('?');
            var method = resources [0];
            var parameters = System.Web.HttpUtility.ParseQueryString (resources [1]);

            if (method == "UpdateLabel") {
                var textbox = parameters ["textbox"];

                // Add some text to our string here so that we know something
                // happened on the native part of the round trip.
                var prepended = string.Format ("C# says: {0}", textbox);

                // Build some javascript using the C#-modified result
                var js = string.Format ("SetLabelText('{0}');", prepended);

                webView.EvaluateJavascript (js);
            }

            return false;
        }
        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            navBar = new UIToolbar();
            navBar.Frame = new CGRect (0, View.Frame.Height-40, View.Frame.Width, 40);
            navBar.TintColor = UIColor.Gray;

            items = new [] {
                new UIBarButtonItem (UIBarButtonSystemItem.Stop, (o, e) => {
                    webView.StopLoading ();
                    DismissViewController (true, null);
                }),
                new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace, null),
                new UIBarButtonItem (UIBarButtonSystemItem.Refresh, (o, e) => webView.Reload ())
            };

            navBar.Items = items;
            webView = new UIWebView ();
            webView.Frame = new CGRect (0, 0, View.Frame.Width, View.Frame.Height-40);
            webView.ScalesPageToFit = true;
            webView.SizeToFit ();
            webView.LoadRequest (url);

            navBar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin;
            webView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;

            View.AddSubviews (new UIView[] { webView, navBar });
        }
		public override bool FinishedLaunching (UIApplication application, NSDictionary options)
		{
			// Register our custom url protocol
			NSUrlProtocol.RegisterClass (new ObjCRuntime.Class (typeof (ImageProtocol)));

			controller = new UIViewController ();

			web = new UIWebView () {
				BackgroundColor = UIColor.White,
				ScalesPageToFit = true,
				AutoresizingMask = UIViewAutoresizing.All
			};
			if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0))
				web.Frame = new CGRect (0, 20,
				                            UIScreen.MainScreen.Bounds.Width,
				                            UIScreen.MainScreen.Bounds.Height - 20);
			else
				web.Frame = UIScreen.MainScreen.Bounds;
			controller.NavigationItem.Title = "Test case";

			controller.View.AutosizesSubviews = true;
			controller.View.AddSubview (web);

			web.LoadRequest (NSUrlRequest.FromUrl (NSUrl.FromFilename (NSBundle.MainBundle.PathForResource ("test", "html"))));

			window = new UIWindow (UIScreen.MainScreen.Bounds);
			window.BackgroundColor = UIColor.White;
			window.MakeKeyAndVisible ();
			window.RootViewController = controller;

			return true;
		}
 void ReleaseDesignerOutlets()
 {
     if (BingWebView != null) {
         BingWebView.Dispose ();
         BingWebView = null;
     }
 }
        public static BaseItemView Create (CGRect frame, NodeViewController nodeViewController, TreeNode node, string filePath, UIColor kleur)
        {
            var view = BaseItemView.Create(frame, nodeViewController, node, kleur);
            UIWebView webView = new UIWebView();

			string extension = Path.GetExtension (filePath);
			if (extension == ".odt") {
				string viewerPath = NSBundle.MainBundle.PathForResource ("over/viewer/index", "html");

				Uri fromUri = new Uri(viewerPath);
				Uri toUri = new Uri(filePath);
				Uri relativeUri = fromUri.MakeRelativeUri(toUri);
				String relativePath = Uri.UnescapeDataString(relativeUri.ToString());

				NSUrl finalUrl = new NSUrl ("#" + relativePath.Replace(" ", "%20"), new NSUrl(viewerPath, false));
				webView.LoadRequest(new NSUrlRequest(finalUrl));
				webView.ScalesPageToFit = true;
				view.ContentView = webView;

				return view;
			} else {
				NSUrl finalUrl = new NSUrl (filePath, false);
				webView.LoadRequest(new NSUrlRequest(finalUrl));
				webView.ScalesPageToFit = true;
				view.ContentView = webView;

				return view;
			}
		
        }
		void ReleaseDesignerOutlets ()
		{
			if (webViewRegister != null) {
				webViewRegister.Dispose ();
				webViewRegister = null;
			}
		}
Beispiel #30
0
        public static void collectDevice()
        {
            string SessionId = Conekta.DeviceFingerPrint ();
            string PublicKey = Conekta.PublicKey;
            string html = "<!DOCTYPE html><html><head></head><body style=\"background: blue;\">";
            html += "<script type=\"text/javascript\" src=\"https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js\" data-conekta-public-key=\"" + PublicKey + "\" data-conekta-session-id=\"" + SessionId + "\"></script>";
            html += "</body></html>";

            string contentPath = Environment.CurrentDirectory;

            #if __IOS__
            UIWebView web = new UIWebView(new RectangleF(new PointF(0,0), new SizeF(0, 0)));
            web.ScalesPageToFit = true;
            web.LoadHtmlString(html, new NSUrl("https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js"));
            Conekta._delegate.View.AddSubview(web);
            #endif

            #if __ANDROID__
            WebView web_view = new WebView(Android.App.Application.Context);
            web_view.Settings.JavaScriptEnabled = true;
            web_view.Settings.AllowContentAccess = true;
            web_view.Settings.DomStorageEnabled = true;
            web_view.LoadDataWithBaseURL(Conekta.UriConektaJs, html, "text/html", "UTF-8", null);
            #endif
        }
Beispiel #31
0
        public TwitterAddUI()
        {
            _s   = null;
            _web = new UIWebView();

            KillCookies();

            Frame                     = new RectangleF(PointF.Empty, new SizeF(200, 200));
            _web.Frame                = new RectangleF(PointF.Empty, Frame.Size);
            _web.AutoresizingMask     = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            _web.ScalesPageToFit      = true;
            _web.Delegate             = new Del(this);
            _web.MultipleTouchEnabled = true;
            ClipsToBounds             = true;
            _web.Hidden               = true;

            Theme.MakeBlack(_web);

            _scanner = ScanningView.Start(this, _web.Frame);

            AddSubview(_web);
        }
Beispiel #32
0
        /// <summary>
        /// Converts HTML to PNG
        /// </summary>
        /// <param name="html">HTML.</param>
        /// <param name="fileName">File name.</param>
        /// <param name="onComplete">On complete.</param>
        public void ToPng(string html, string fileName, Action <string> onComplete)
        {
            var size    = new Size(8.5, 11);
            var webView = new UIWebView(new CGRect(0, 0, (size.Width - 0.5) * 72, (size.Height - 0.5) * 72));

            var callback = new WebViewCallBack(size, fileName, onComplete);

            webView.Delegate               = callback;
            webView.ScalesPageToFit        = false;
            webView.UserInteractionEnabled = false;
            webView.BackgroundColor        = UIColor.White;
            webView.LoadHtmlString(html, null);
            Device.StartTimer(TimeSpan.FromSeconds(10), () =>
            {
                if (!callback.Failed && !callback.Completed)
                {
                    System.Diagnostics.Debug.WriteLine("TIMEOUT!!!");
                    callback.LoadingFinished(webView);
                }
                return(false);
            });
        }
        public override bool ShouldStartLoad(UIWebView webView, Foundation.NSUrlRequest request, UIWebViewNavigationType navigationType)
        {
            var url = request.Url.AbsoluteString;

            if (url.Contains(NotSensitive.SystemUrls.github_redirect_url + "/?code") || url.Contains("&code"))
            {
                var separatedByQestionMark = url.Split('?');
                foreach (string sub in separatedByQestionMark)
                {
                    if (sub.Contains("code"))
                    {
                        var seperatedByEquals = sub.Split('=');
                        var token             = seperatedByEquals.Last();
                        if (!String.IsNullOrEmpty(token))
                        {
                            TokenReceived?.Invoke(token);
                        }
                    }
                }
            }
            return(true);
        }
Beispiel #34
0
        public void SetupWeb(string initialTitle, bool enableTitle)
        {
            WebView = new UIWebView()
            {
                ScalesPageToFit      = true,
                MultipleTouchEnabled = true,
                AutoresizingMask     = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth,
            };
            WebView.LoadStarted += delegate
            {
                stopButton.Enabled    = true;
                refreshButton.Enabled = false;
                UpdateNavButtons();
                Util.PushNetworkActive();
            };
            WebView.LoadFinished += delegate
            {
                stopButton.Enabled    = false;
                refreshButton.Enabled = true;
                Util.PopNetworkActive();
                UpdateNavButtons();
                if (enableTitle)
                {
                    title.Text = UpdateTitle();
                }
            };

            if (enableTitle)
            {
                title.Text = initialTitle;
            }
            else
            {
                title.Text = "";
            }
            View.AddSubview(WebView);
            backButton.Enabled    = false;
            forwardButton.Enabled = false;
        }
Beispiel #35
0
            public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
            {
                if (_request != null)
                {
                    _request = null;
                    return(true);
                }

                bool originalResult = ForwardDelegatePredicate("webView:shouldStartLoadWithRequest:navigationType:", webView, request, (int)navigationType, defaultResult: true);

                if (_renderer.Element.ShouldTrustUnknownCertificate != null)
                {
                    if (originalResult)
                    {
                        _request = request;
                        new NSUrlConnection(request, this, startImmediately: true);
                    }
                    return(false);
                }

                return(originalResult);
            }
Beispiel #36
0
        public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            var vc = new WebViewController(this)
            {
                Autorotate = dvc.Autorotate
            };

            web = new UIWebView(UIScreen.MainScreen.ApplicationFrame)
            {
                BackgroundColor  = UIColor.White,
                ScalesPageToFit  = true,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            };
            web.LoadStarted += delegate {
                NetworkActivity = true;
                var indicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
                vc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(indicator);
                indicator.StartAnimating();
            };
            web.LoadFinished += delegate {
                NetworkActivity = false;
                vc.NavigationItem.RightBarButtonItem = null;
            };
            web.LoadError += (webview, args) => {
                NetworkActivity = false;
                vc.NavigationItem.RightBarButtonItem = null;
                if (web != null)
                {
                    web.LoadHtmlString(
                        String.Format("<html><center><font size=+5 color='red'>{0}:<br>{1}</font></center></html>",
                                      "An error occurred:", args.Error.LocalizedDescription), null);
                }
            };
            vc.NavigationItem.Title = Caption;
            vc.View.AddSubview(web);

            dvc.ActivateController(vc);
            web.LoadRequest(NSUrlRequest.FromUrl(nsUrl));
        }
        private void SetConsumptionBarChartWebView(List <ConsumptionModel> consumpModels)
        {
            string[][] r      = Array.ConvertAll(consumpModels.Select(x => new { x.Name, x.Consumed, x.Expected, x.Overused }).ToArray(), x => new string[] { x.Name, x.Consumed, x.Expected, x.Overused });
            string[]   Labels = null;
            try
            {
                Labels = consumpModels.Select(x => x.Name.Split('-')[1]).ToArray();
            }
            catch (Exception ex)
            {
                Labels = consumpModels.Select(x => x.Name).ToArray();
            }
            string[] Consumed = consumpModels.Select(x => x.Consumed.Replace('K', ' ').Trim()).ToArray();
            string[] Expected = consumpModels.Select(x => x.Expected.Replace('K', ' ').Trim()).ToArray();
            string[] Overused = consumpModels.Select(x => x.Overused.Replace('K', ' ').Trim()).ToArray();

            localChartView = new UIWebView()
            {
                Frame = new CGRect(0, this.NavigationController.NavigationBar.Bounds.Bottom + 60, View.Bounds.Width, 330),
            };
            string content      = string.Empty;
            string fileName     = "Content/ChartC3.html"; // remember case-sensitive
            string localHtmlUrl = Path.Combine(NSBundle.MainBundle.BundlePath, fileName);
            string localJSUrl   = Path.Combine(NSBundle.MainBundle.BundlePath, "Content/Chart.bundle.min.js");

            using (StreamReader sr = new StreamReader(localHtmlUrl))
            {
                content = sr.ReadToEnd();
            }
            content = content.Replace("ChartJS", localJSUrl);
            content = content.Replace("LabelsData", "'" + string.Join("','", Labels) + "'");
            content = content.Replace("ConsumedData", "'" + string.Join("','", Consumed) + "'");
            content = content.Replace("ExpectedData", "'" + string.Join("','", Expected) + "'");
            content = content.Replace("OverusedData", "'" + string.Join("','", Overused) + "'");
            localChartView.LoadHtmlString(content, new NSUrl(localHtmlUrl, true));
            //localChartView.ScalesPageToFit = true;
            //localChartView.LoadUrl("file:///android_asset/ChartC3.html");
            View.AddSubview(localChartView);
        }
Beispiel #38
0
        public WebElement(string cellKey)
        {
            Key     = new NSString(cellKey);
            WebView = new UIWebView();
            WebView.ScrollView.ScrollEnabled = false;
            WebView.ScrollView.Bounces       = false;
            WebView.ShouldStartLoad          = (w, r, n) => ShouldStartLoad(r, n);
            WebView.LoadFinished            += (sender, e) =>
            {
                if (LoadFinished != null && HasValue)
                {
                    LoadFinished();
                }
            };

            HeightChanged = (x) => {
                if (Section != null || Section.Root != null)
                {
                    Section.Root.Reload(this, UITableViewRowAnimation.None);
                }
            };
        }
Beispiel #39
0
        public override void LoadView()
        {
            base.LoadView();

            bool isV7 = UIDevice.CurrentDevice.CheckSystemVersion(7, 0);

            View.BackgroundColor = UIColor.White;

            niceSegmentedCtrl = new SDSegmentedControl(new string [] { "Google", "Bing", "Yahoo" });

            if (isV7)
            {
                niceSegmentedCtrl.Frame = new RectangleF(0, 10, 320, 44);
            }
            else
            {
                niceSegmentedCtrl.Frame = new RectangleF(0, 0, 320, 44);
            }

            niceSegmentedCtrl.SetImage(UIImage.FromBundle("google"), 0);
            niceSegmentedCtrl.SetImage(UIImage.FromBundle("bicon"), 1);
            niceSegmentedCtrl.SetImage(UIImage.FromBundle("yahoo"), 2);
            niceSegmentedCtrl.ValueChanged += HandleValueChanged;

            if (isV7)
            {
                browser = new UIWebView(new RectangleF(0, 55, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 64));
            }
            else
            {
                browser = new UIWebView(new RectangleF(0, 45, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 64));
            }

            browser.LoadRequest(new NSUrlRequest(new NSUrl("http://google.com")));
            browser.AutosizesSubviews = true;

            View.AddSubviews(new UIView[] { niceSegmentedCtrl, browser });
        }
        protected virtual UIViewController ConstructDefaultViCo()
        {
            var viewController = new UIViewController();

            viewController.View.BackgroundColor = (UIColor)Theme.ColorPalette.Accent;

            var webView = new UIWebView(new CoreGraphics.CGRect(0, 0, DeviceInfo.ScreenWidth, DeviceInfo.ScreenHeight));

            webView.Opaque                            = false;
            webView.BackgroundColor                   = UIColor.Clear;
            webView.ScrollView.BackgroundColor        = UIColor.Clear;
            webView.ScrollView.ScrollEnabled          = false;
            webView.ScrollView.UserInteractionEnabled = false;
            webView.UserInteractionEnabled            = false;

            var path = NSBundle.MainBundle.PathForResource("loader", "html");

            webView.LoadRequest(NSUrlRequest.FromUrl(NSUrl.FromString(path)));

            viewController.View.AddSubview(webView);

            return(viewController);
        }
Beispiel #41
0
        private void OpenBrowserOnThread(object browserCommandObject)
        {
            BrowserCommand browserCommand = (BrowserCommand)browserCommandObject;

            UIApplication.SharedApplication.InvokeOnMainThread(delegate {
                IPhoneUIViewController contentController = new IPhoneUIViewController(browserCommand.Title, browserCommand.ButtonText);
                UIWebView webView = IPhoneNet.generateWebView();
                contentController.AddInnerView(webView);

                IPhoneServiceLocator.CurrentDelegate.MainUIViewController().PresentModalViewController(contentController, true);
                IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false);
                if (!String.IsNullOrWhiteSpace(browserCommand.Url))
                {
                    NSUrl nsUrl = new NSUrl(browserCommand.Url);
                    NSUrlRequest nsUrlRequest = new NSUrlRequest(nsUrl, NSUrlRequestCachePolicy.ReloadRevalidatingCacheData, 120.0);
                    webView.LoadRequest(nsUrlRequest);
                }
                else if (!String.IsNullOrWhiteSpace(browserCommand.Html))
                {
                    webView.LoadHtmlString(browserCommand.Html, new NSUrl("/"));
                }
            });
        }
Beispiel #42
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            webview_Main = MainTabController.webview_main;

            var url = uriR;

            //loadingOverlay.Hide();

            webview_Main = MainTabController.webview_main;

            webview_Main.Frame = new CoreGraphics.CGRect(0, 20, View.Bounds.Width, View.Bounds.Height - 20);

            webview_Main.LoadRequest(new NSUrlRequest(new NSUrl(url)));
            // Perform any additional setup after loading the view, typically from a nib.


            webview_Main.ScalesPageToFit = true;

            View.AddSubview(webview_Main);
            keeptrackLoading++;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            MyWebView = new UIWebView();
            View.AddSubview(MyWebView);
            MyWebView.LoadRequest(new NSUrlRequest(new NSUrl("https://www.microsoft.com")));

            MyWebView.TranslatesAutoresizingMaskIntoConstraints = false;

            var leadConstraint     = NSLayoutConstraint.Create(MyWebView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1.0f, 0);
            var topConstraint      = NSLayoutConstraint.Create(MyWebView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, TopLayoutGuide, NSLayoutAttribute.Bottom, 1.0f, 0);
            var trailingConstraint = NSLayoutConstraint.Create(MyWebView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1.0f, 0);
            var bottomConstraint   = NSLayoutConstraint.Create(MyWebView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, BottomLayoutGuide, NSLayoutAttribute.Top, 1.0f, 0);

            View.AddConstraints(new NSLayoutConstraint[] { leadConstraint, topConstraint, trailingConstraint, bottomConstraint });


            View.BackgroundColor = UIColor.Purple;

            MyWebView.Delegate = this;
        }
 void ReleaseDesignerOutlets()
 {
     if (lblId != null)
     {
         lblId.Dispose();
         lblId = null;
     }
     if (lblLat != null)
     {
         lblLat.Dispose();
         lblLat = null;
     }
     if (lblLon != null)
     {
         lblLon.Dispose();
         lblLon = null;
     }
     if (webview != null)
     {
         webview.Dispose();
         webview = null;
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // no XIB !
            webView = new UIWebView()
            {
                ScalesPageToFit = false
            };

            basedir = Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            basedir = basedir.Replace("Documents", "Monospace2.app");

            webView.LoadHtmlString(FormatText(), new NSUrl(basedir + "/Sponsors/", true));

            // Set the web view to fit the width of the app.
            webView.SizeToFit();

            // Reposition and resize the receiver
            webView.Frame = new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height - 90);

            // Add the table view as a subview
            this.View.AddSubview(webView);
        }
        public ViewController(IntPtr handle) : base(handle)
        {
            webView                 = new UIWebView();
            webView.Opaque          = false;
            webView.BackgroundColor = UIColor.Yellow;
            webView.LoadFinished   += WebView_LoadFinished;
            webView.ScrollView.UserInteractionEnabled = false;

            button.SetTitle("Zoom In", UIControlState.Normal);
            button.TouchUpInside  += Button_TouchUpInside;
            button.BackgroundColor = UIColor.Black;

            button1.SetTitle("Zoom Out", UIControlState.Normal);
            button1.TouchUpInside  += Button_TouchUpInside1;
            button1.BackgroundColor = UIColor.Black;

            Stream stream = typeof(ViewController).GetTypeInfo().Assembly.GetManifestResourceStream("StampWebView.Approved.html");

            using (StreamReader reader = new StreamReader(stream))
            {
                html = reader.ReadToEnd();
            }
        }
            public override void LoadFailed(UIWebView webView, NSError error)
            {
                controller.activity.StopAnimating();

                webView.UserInteractionEnabled = true;

                if (error != null)
                {
                    if (error.UserInfo != null)
                    {
                        var urlString = error.UserInfo["NSErrorFailingURLStringKey"] as NSString;
                        if (urlString != null)
                        {
                            var url = new Uri(urlString.ToString());
                            if (!url.Equals(lastUrl))   // Prevent loading the same URL multiple times
                            {
                                lastUrl = url;
                                controller.authenticator.OnPageFailed(url);
                            }
                        }
                    }
                }
            }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            base.ViewDidLoad();
            webView = new UIWebView(View.Bounds);
            webView.ScalesPageToFit = false;
            View.AddSubview(webView);
            NSUrlRequest request = new NSUrlRequest(new NSUrl("https://login.microsoftonline.com/CSUB2C.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_b2cSSPR&client_Id=3bdf8223-746c-42a2-ba5e-0322bfd9ff76&nonce=defaultNonce&redirect_uri=com.onmicrosoft.csu://iosresponse/&scope=openid&response_type=id_token&prompt=login"));

            webView.LoadRequest(request);
            webView.LoadError += WebView_LoadError;
            //this.NavigationController.NavigationBarHidden = false;
            //this.NavigationController.NavigationBar.TintColor = UIColor.White;
            //this.NavigationController.NavigationBar.BarTintColor = UIColor.FromRGB(33, 77, 43);
            //this.NavigationController.NavigationBar.BarStyle = UIBarStyle.BlackTranslucent;
            //Email.AutocorrectionType = UITextAutocorrectionType.No;
            //Email.ShouldReturn = delegate
            //{
            //    // Changed this slightly to move the text entry to the next field.
            //    Email.ResignFirstResponder();
            //    return true;
            //};
        }
Beispiel #49
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Pro Upgrade";

            _activityView = new UIActivityIndicatorView
            {
                Color            = Theme.PrimaryNavigationBarColor,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
            };
            _activityView.Frame = new CoreGraphics.CGRect(0, 44, View.Frame.Width, 88f);

            _web = new UIWebView {
                ScalesPageToFit = true, AutoresizingMask = UIViewAutoresizing.All
            };
            _web.LoadFinished   += (sender, e) => _networkActivityService.PopNetworkActive();
            _web.LoadStarted    += (sender, e) => _networkActivityService.PushNetworkActive();
            _web.LoadError      += (sender, e) => _networkActivityService.PopNetworkActive();
            _web.ShouldStartLoad = (w, r, n) => ShouldStartLoad(r, n);

            Load().ToBackground();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // iOS7: Keep content from hiding under navigation bar.
            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                EdgesForExtendedLayout = UIRectEdge.None;
            }

            webView = new UIWebView()
            {
                ScalesPageToFit = false,
            };

            webView.Frame = new RectangleF(0, 0, this.View.Bounds.Width, this.View.Bounds.Height);
            // Add the table view as a subview
            View.AddSubview(webView);

            string homePageUrl = NSBundle.MainBundle.BundlePath + "/About.html";

            webView.LoadRequest(new NSUrlRequest(new NSUrl(homePageUrl, false)));
        }
 public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
 {
     if (navigationType == UIWebViewNavigationType.LinkClicked)
     {
         string path = request.Url.Path.Substring(1);
         string host = request.Url.Host.ToLower();
         if (host == "tweet.mix10.app")
         {
             var tweet = new TWTweetComposeViewController();
             tweet.SetInitialText("@" + path + " #monkeyspace");
             viewController.PresentModalViewController(tweet, true);
         }
         else if (host == "twitter.mix10.app")
         {
             var nsurl = new NSUrl("twitter://user?screen_name=" + viewController.speaker.TwitterHandle);
             UIApplication.SharedApplication.OpenUrl(nsurl);
         }
         else if (host == "session.mix10.app")
         {
             if (sessVC == null)
             {
                 sessVC = new SessionViewController(path);
             }
             else
             {
                 sessVC.Update(path);
             }
             viewController.NavigationController.PushViewController(sessVC, true);
         }
         else
         {
             viewController.NavigationController.PushViewController(new WebViewController(request), true);
             return(false);
         }
     }
     return(true);
 }
Beispiel #52
0
        public WebAuthenticatorController(WebAuthenticator authenticator)
        {
            this.authenticator = authenticator;

            authenticator.Error             += HandleError;
            authenticator.BrowsingCompleted += HandleBrowsingCompleted;

            //
            // Create the UI
            //
            Title = authenticator.Title;

            if (authenticator.AllowCancel)
            {
                NavigationItem.LeftBarButtonItem = new UIBarButtonItem(
                    UIBarButtonSystemItem.Cancel,
                    delegate {
                    Cancel();
                });
            }

            activity = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(activity);

            webView = new UIWebView(View.Bounds)
            {
                Delegate         = new WebViewDelegate(this),
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
            };
            View.AddSubview(webView);
            View.BackgroundColor = UIColor.Black;

            //
            // Locate our initial URL
            //
            BeginLoadingInitialUrl();
        }
Beispiel #53
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary options)
        {
            // Register our custom url protocol
            NSUrlProtocol.RegisterClass(new ObjCRuntime.Class(typeof(ImageProtocol)));

            controller = new UIViewController();

            web = new UIWebView()
            {
                BackgroundColor  = UIColor.White,
                ScalesPageToFit  = true,
                AutoresizingMask = UIViewAutoresizing.All
            };
            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                web.Frame = new CGRect(0, 20,
                                       UIScreen.MainScreen.Bounds.Width,
                                       UIScreen.MainScreen.Bounds.Height - 20);
            }
            else
            {
                web.Frame = UIScreen.MainScreen.Bounds;
            }
            controller.NavigationItem.Title = "Test case";

            controller.View.AutosizesSubviews = true;
            controller.View.AddSubview(web);

            web.LoadRequest(NSUrlRequest.FromUrl(NSUrl.FromFilename(NSBundle.MainBundle.PathForResource("test", "html"))));

            window = new UIWindow(UIScreen.MainScreen.Bounds);
            window.BackgroundColor = UIColor.White;
            window.MakeKeyAndVisible();
            window.RootViewController = controller;

            return(true);
        }
Beispiel #54
0
        // A location bubble was popped.  Notify the server and display the notification string to the user.
        async void Pop(object sender, CLRegionEventArgs e)
        {
            if (!e.Region.Identifier.Equals("RefreshZone")) // Ignore the refresh zone.
            {
                // Get the ID of the bubble that was popped.
                int bubbleId = Int32.Parse(e.Region.Identifier);
                Debug.WriteLine(">>>>> Popped bubble #" + bubbleId.ToString());

                // Notify the server and get notification message.
                EventMobile localEvent = new EventMobile();
                localEvent.BubbleId      = bubbleId;
                localEvent.TimestampJson = DateTime.Now.ToLongTimeString();
                string json = await WebApiPost("api/Event", localEvent);

                if (json != null && json.Length > 0)
                {
                    EventMobile serverEvent = (EventMobile)JsonConvert.DeserializeObject(json, typeof(EventMobile));
                    // If the event has not been suppressed and the server hit didn't fail, process it.
                    if (!serverEvent.Suppressed)
                    {
                        Debug.WriteLine(">>>>> Processing event: Bubble #" + bubbleId.ToString());
                        // Display a notification.
                        DisplayNotification(serverEvent.ProviderName, serverEvent.MsgTitle, serverEvent.Msg, "Popdit" + " " + e.Region.Identifier);
                        // If the pops page is displayed, refresh it.
                        UIWebView webView = (UIWebView)UIApplication.SharedApplication.KeyWindow.RootViewController.View;
                        if (webView.Request.Url.AbsoluteString.Contains("Event"))
                        {
                            webView.LoadRequest(new NSUrlRequest(PopditServer.WebRoot));
                        }
                    }
                    else
                    {
                        Debug.WriteLine(">>>>> Event suppressed: Bubble #" + bubbleId.ToString());
                    }
                }
            }
        }
Beispiel #55
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (!string.IsNullOrEmpty(IdentityProviderName))
            {
                Title = IdentityProviderName;
            }

            _webView = new UIWebView(new CGRect(0, 0, View.Bounds.Width, View.Bounds.Height))
            {
                AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleBottomMargin
            };
            _webView.ShouldStartLoad += ShouldStartLoad;
            _webView.LoadStarted     +=
                (sender, args) => UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            _webView.LoadFinished +=
                (sender, args) => UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

            _webView.LoadError += (sender, args) =>
            {
                //Some providers have this strange Frame Interrupted Error :-/
                if (args.Error.Code == 102 && args.Error.Domain == "WebKitErrorDomain")
                {
                    return;
                }

                _messageHub.Publish(new RequestTokenMessage(this)
                {
                    TokenResponse = null
                });
            };

            View.AddSubview(_webView);

            _webView.LoadRequest(new NSUrlRequest(Url));
        }
Beispiel #56
0
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null || this.Element == null)
            {
                return;
            }
            PdfPage page = (PdfPage)Element;
            string  path;

            if (page.useTemp)
            {
                string tempFolder = new FileManage().GetTempFolder();
                path = System.IO.Path.Combine(tempFolder, page.FileName);
            }
            else
            {
                string libraryFolder = new FileManage().GetLibraryFolder();
                path = System.IO.Path.Combine(libraryFolder, page.FileName);
            }

            UIWebView webView = new UIWebView();

            if (path.EndsWith(".pdf"))
            {
                CGPDFDocument doc = CGPDFDocument.FromFile(path);
                NumberOfPages = doc.Pages;
            }

            NSUrlRequest request = new NSUrlRequest(new NSUrl(path, false));

            webView.LoadRequest(new NSUrlRequest(new NSUrl(path, false)));
            webView.PaginationMode  = UIWebPaginationMode.TopToBottom;
            webView.ScalesPageToFit = true;

            View = webView;
        }
Beispiel #57
0
        private bool ShoulStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
        {
            if (request.Url.AbsoluteString == _redirectUrl)
            {
                _webView.Hidden = true;

                var parameters = request.Body.ToString().ToParamsDictionary();
                foreach (var key in parameters.Keys.ToList())
                {
                    parameters[key] = Uri.UnescapeDataString(parameters[key]);
                }

                _webView.LoadError -= WebView_LoadError;

                if (!_tcs.Task.IsCanceled && !_tcs.Task.IsCompleted)
                {
                    _tcs.TrySetResult(parameters);
                }

                return(false);
            }

            return(true);
        }
Beispiel #58
0
        public TUM(IntPtr handle) : base(handle)
        {
            Title = NSBundle.MainBundle.LocalizedString("TUM", "TUM");
            View.BackgroundColor = UIColor.White;
            webView = new UIWebView(View.Bounds);
            webView.ScrollView.ContentInset = new UIEdgeInsets(0, 0, 45, 0);
            View.AddSubview(webView);
            url = "http://ios.tum.pt/index.html";
            webView.ScalesPageToFit = true;


            if (!Reachability.IsHostReachable("tum.pt"))
            {
                UIAlertView alert = new UIAlertView();
                alert.Title = "Sem ligação à rede";
                alert.AddButton("Continuar");
                alert.Message = "Não conseguirá usar a aplicação sem conexão à rede.";
                alert.Show();
            }
            else
            {
                webView.LoadRequest(new NSUrlRequest(new NSUrl(url)));
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Code to start the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
#endif

            // Perform any additional setup after loading the view, typically from a nib.

            /*Button.AccessibilityIdentifier = "myButton";
             * Button.TouchUpInside += delegate
             * {
             *      var title = string.Format("{0} clicks!", count++);
             *      Button.SetTitle(title, UIControlState.Normal);
             * };*/

            UIWebView webView = new UIWebView(View.Bounds);
            View.AddSubview(webView);

            var url = "https://wikitruth.co";
            webView.LoadRequest(new NSUrlRequest(new NSUrl(url)));
        }
Beispiel #60
0
 public override void Dispose()
 {
     if (activityIndicator != null)
     {
         if (isActivityIndicatorVisible)
         {
             activityIndicator.RemoveFromSuperview();
             isActivityIndicatorVisible = false;
         }
         activityIndicator.Dispose();
         activityIndicator = null;
     }
     if (webView != null)
     {
         webView.StopLoading();
         webView.Delegate = null;
         var localWebView = webView;
         Application.InvokeOnMainThread(() => {
             localWebView.RemoveFromSuperview();                     // RemoveFromSuperview must run in main thread only.
             localWebView.Dispose();
         });
         webView = null;
     }
 }