MonoTouch.Dialog.WebElement.Selected C# (CSharp) Method

Selected() public method

public Selected ( DialogViewController dvc, UITableView tableView, NSIndexPath path ) : void
dvc DialogViewController
tableView UITableView
path NSIndexPath
return void
		public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
		{
			if (!Url.StartsWith("http:")){
				tableView.DeselectRow(path, false);
				UIApplication.SharedApplication.OpenUrl(nsUrl);
				return;
			}
			
			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'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
			};
			vc.NavigationItem.Title = Caption;
			vc.View = web;
			
			dvc.ActivateController (vc, dvc);
			web.LoadRequest (NSUrlRequest.FromUrl (nsUrl));
		}
	}