void SegmentValueChanged(object sender, EventArgs e) { if (_viewSegment.SelectedSegment == 0) { if (_previewView != null) { _previewView.RemoveFromSuperview(); _previewView.Dispose(); _previewView = null; } Add(TextView); TextView.BecomeFirstResponder(); } else { if (_previewView == null) { _previewView = new UIWebView(this.View.Bounds); } TextView.RemoveFromSuperview(); Add(_previewView); var markdownService = IoC.Resolve <IMarkdownService>(); var markdownView = new MarkdownView() { Model = markdownService.Convert(TextView.Text) }; _previewView.LoadHtmlString(markdownView.GenerateString(), null); } }
void SegmentValueChanged(object sender, EventArgs e) { if (_viewSegment.SelectedSegment == 0) { if (_previewView != null) { _previewView.RemoveFromSuperview(); _previewView.Dispose(); _previewView = null; } Add(TextView); TextView.BecomeFirstResponder(); } else { // if (_previewView == null) // _previewView = new UIWebView(this.View.Bounds); // // TextView.RemoveFromSuperview(); // Add(_previewView); // // var markdownService = IoC.Resolve<IMarkdownService>(); // var path = MarkdownHtmlGenerator.CreateFile(markdownService.Convert(Text)); // var uri = Uri.EscapeUriString("file://" + path) + "#" + Environment.TickCount; // _previewView.LoadRequest(new MonoTouch.Foundation.NSUrlRequest(new MonoTouch.Foundation.NSUrl(uri))); } }
void TapImageAction1(UITapGestureRecognizer tap) { if (Reachability.IsHostReachable(Settings._baseDomain)) { LoadingOverlay loadingOverlay = new LoadingOverlay(View.Frame); var webView = new UIWebView(View.Frame); webView.LoadFinished += (sender, e) => { loadingOverlay.Hide(); }; var banManProHREF = Settings.BanManProURL.Replace("Task=Get", "Task=Click"); ; webView.LoadRequest(new NSUrlRequest(new NSUrl(banManProHREF))); UIView.BeginAnimations("fadeflag"); UIView.Animate(1, () => { tap.View.Alpha = .5f; }, () => { View.AddSubview(webView); View.AddSubview(loadingOverlay); UIButton closeButton = new UIButton(new CGRect(View.Bounds.Width - 75, 0, 75, 50)); closeButton.SetImage(UIImage.FromBundle("close"), UIControlState.Normal); closeButton.BackgroundColor = UIColor.White.ColorWithAlpha(.5f); closeButton.TouchUpInside += (sender, e) => { try { webView.RemoveFromSuperview(); closeButton.RemoveFromSuperview(); } finally { webView.Dispose(); } }; UIImageView imageView = new UIImageView(new CGRect(View.Bounds.Width - 75, View.Bounds.Height / 2, 75, 50)); imageView.Image = UIImage.FromBundle("swipe_left"); imageView.Alpha = .5f; webView.AddSubview(closeButton); webView.AddSubview(imageView); tap.View.Alpha = 1f; }); UIView.CommitAnimations(); } else { HelperMethods.SendBasicAlert("Connect to a Network", "Please connect to a network to view this ad"); } }
public override void ViewDidDisappear(bool animated) { if (webView != null) { webView.RemoveFromSuperview(); webView.Dispose(); webView = null; } base.ViewWillDisappear(animated); }
public override void ViewDidDisappear(bool animated) { base.ViewDidDisappear(animated); if (WebView != null) { WebView.RemoveFromSuperview(); WebView.Dispose(); WebView = null; } }
void OnDestroy() { // load a blank page before removing it _webview.StopLoading(); _webview.LoadHTMLString("", new NSURL("")); _webview.RemoveFromSuperview(); // _webview.hidden = true; _webview = null; _request = null; _url = null; }
/// <summary> /// Called when a row is touched /// </summary> public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { var url = ""; switch (tableItems[indexPath.Row].Type) { case "Website": //owner.NavigationItem.LeftBarButtonItem = //DisplayModeButtonItem; //owner.NavigationItem.SetRightBarButtonItem( // new UIBarButtonItem(UIBarButtonSystemItem.Undo, (sender, args) => // { // }) //, true); // owner.NavigationItem.Title = tableItems[indexPath.Row].Heading.ToUpper(); //owner.NavigationItem.LeftItemsSupplementBackButton = true; UIBarButtonItem backbutton = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, null); backbutton.Clicked += (o, e) => { webView.RemoveFromSuperview(); }; owner.NavigationItem.LeftBarButtonItem = backbutton; webView = new UIWebView(tableView.Bounds); tableView.AddSubview(webView); url = tableItems[indexPath.Row].Url; // NOTE: https secure request webView.ScalesPageToFit = true; webView.LoadRequest(new NSUrlRequest(new NSUrl(url))); break; case "App": default: return; } //webView = new UIWebView(tableView.Bounds); //tableView.AddSubview(webView); // //Title.Replace("Sodexo","Shark"); // //Title = NSBundle.MainBundle.LocalizedString("Sodexo", "Sodexo"); //var url = "https://xamarin.com"; // NOTE: https secure request //webView.LoadRequest(new NSUrlRequest(new NSUrl(url))); //UIAlertController okAlertController = UIAlertController.Create("Row Selected", tableItems[indexPath.Row].Heading, UIAlertControllerStyle.Alert); //okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); //owner.PresentViewController(okAlertController, true, null); tableView.DeselectRow(indexPath, true); }
protected MarkdownComposerView(IMarkdownService markdownService) { TextView.Font = UIFont.SystemFontOfSize(16f); TextView.Changed += (sender, e) => ViewModel.Text = TextView.Text; this.WhenAnyValue(x => x.ViewModel.Text) .Subscribe(x => Text = x); this.WhenAnyValue(x => x.ViewModel.PostToImgurCommand) .Select(x => x == null ? null : new MarkdownAccessoryView(TextView, ViewModel.PostToImgurCommand)) .Subscribe(x => TextView.InputAccessoryView = x); _viewSegment = new UISegmentedControl(new [] { "Compose", "Preview" }); _viewSegment.SelectedSegment = 0; NavigationItem.TitleView = _viewSegment; _viewSegment.ValueChanged += (sender, e) => { if (_viewSegment.SelectedSegment == 0) { if (_previewView != null) { _previewView.RemoveFromSuperview(); _previewView.Dispose(); _previewView = null; } Add(TextView); TextView.BecomeFirstResponder(); } else { if (_previewView == null) { _previewView = new UIWebView(this.View.Bounds); } TextView.RemoveFromSuperview(); Add(_previewView); var markdownView = new MarkdownView { Model = markdownService.Convert(TextView.Text) }; _previewView.LoadHtmlString(markdownView.GenerateString(), null); } }; }
public override void ViewDidLoad() { const int toolbarHeight = 44; base.ViewDidLoad(); var webViewFrame = this.View.Frame; var toolbarFrame = this.View.Frame; toolbarFrame.Height = toolbarHeight; webViewFrame.Y = toolbarHeight; webViewFrame.Height -= toolbarHeight; // Perform any additional setup after loading the view, typically from a nib. UIWebView webView = new UIWebView(webViewFrame); // YtWebViewDelegate del = new YtWebViewDelegate(); // // webView.Delegate = del; webView.BackgroundColor = UIColor.Black; var doneBarButton = new UIBarButtonItem("Gotowe", UIBarButtonItemStyle.Done, (o, e) => { webView.LoadHtmlString("<html></html>", null); webView.RemoveFromSuperview(); DismissModalViewController(true); }); UIBarButtonItem[] items = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), doneBarButton }; UIToolbar toolbar = new UIToolbar(toolbarFrame); toolbar.SetItems(items, false); toolbar.BarStyle = UIBarStyle.Black; webView.Init(); webView.LoadHtmlString(_html, null); View.Add(webView); View.Add(toolbar); }
protected MarkdownComposerViewController(IMarkdownService markdownService) { TextView.Font = UIFont.PreferredBody; TextView.Changed += (sender, e) => ViewModel.Text = TextView.Text; TextView.InputAccessoryView = new MarkdownAccessoryView(TextView); this.WhenAnyValue(x => x.ViewModel.Text) .Subscribe(x => Text = x); var viewSegment = new UISegmentedControl(new [] { "Compose", "Preview" }); viewSegment.SelectedSegment = 0; NavigationItem.TitleView = viewSegment; viewSegment.ValueChanged += (sender, e) => { if (viewSegment.SelectedSegment == 0) { if (_previewView != null) { _previewView.RemoveFromSuperview(); _previewView.Dispose(); _previewView = null; } Add(TextView); TextView.BecomeFirstResponder(); } else { if (_previewView == null) { _previewView = new UIWebView(this.View.Bounds); } TextView.RemoveFromSuperview(); Add(_previewView); var markdown = markdownService.Convert(TextView.Text); var model = new DescriptionModel(markdown, (int)UIFont.PreferredSubheadline.PointSize); var markdownView = new MarkdownView { Model = model }; _previewView.LoadHtmlString(markdownView.GenerateString(), null); } }; }
public override UITableViewCell GetCell(UITableView tv) { var cell = tv.DequeueReusableCell(CellKey); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, CellKey); cell.SelectionStyle = UITableViewCellSelectionStyle.None; WebView.AutoresizingMask = UIViewAutoresizing.All; } WebView.Frame = new RectangleF(0, 0, cell.ContentView.Frame.Width, cell.ContentView.Frame.Height); WebView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; WebView.RemoveFromSuperview(); cell.ContentView.AddSubview(WebView); cell.ContentView.Layer.MasksToBounds = true; cell.ContentView.AutosizesSubviews = true; cell.SeparatorInset = new UIEdgeInsets(0, 0, 0, 0); return(cell); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. var consentWebView = new UIWebView(View.Bounds); View.AddSubview(consentWebView); var url = _client.CreateConsentUri(Provider.Custom); consentWebView.LoadRequest(new NSUrlRequest(new NSUrl(url))); consentWebView.ShouldStartLoad += (webView, request, navigationType) => { if (request.Url.AbsoluteString.StartsWith(FranceConnectClient.BaseConsentRedirectUri, StringComparison.OrdinalIgnoreCase)) { var task = Task.Factory.StartNew(async () => { await _client.AuthenticateAsync(request.Url.AbsoluteString, Provider.Custom.GetRedirectUri()); var resource = await _client.GetDataAsync(Provider.Custom) as CustomResource; InvokeOnMainThread(() => { ValueOneLabel.Text = resource.ValueOne; ValueTwolabel.Text = resource.ValueTwo; consentWebView.RemoveFromSuperview(); }); }); task.Unwrap().ContinueWith((antecedent) => { InvokeOnMainThread(() => { var alert = UIAlertController.Create("Erreur", "Une erreur est survenue", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); PresentViewController(alert, animated: true, completionHandler: null); }); }, TaskContinuationOptions.OnlyOnFaulted); return false; } return true; }; }
public static void LoadWebViewWithAd(UITapGestureRecognizer tap, Ad ad, UIView mainView) { if (Reachability.IsHostReachable(Settings._baseDomain)) { LoadingOverlay loadingOverlay = new LoadingOverlay(mainView.Frame); var frame = new CGRect(0, 0, mainView.Bounds.Width, mainView.Bounds.Height); var webView = new UIWebView(frame); webView.LoadFinished += (sender, e) => { loadingOverlay.Hide(); }; var url = ad.AircraftForSaleURL; //commenting to test banmanpro //var url = "https://www.globalair.com/banmanpro/ad.aspx?ZoneID=94&Task=Get&Mode=HTML&SiteID=1&PageID=78751"; webView.LoadRequest(new NSUrlRequest(new NSUrl(url))); UIView.BeginAnimations("fadeflag"); UIView.Animate(1, () => { tap.View.Alpha = .5f; }, () => { mainView.AddSubview(webView); mainView.AddSubview(loadingOverlay); UIButton closeButton = new UIButton(new CGRect(mainView.Bounds.Width - 75, 0, 75, 50)); closeButton.SetImage(UIImage.FromBundle("close"), UIControlState.Normal); closeButton.BackgroundColor = UIColor.Black; closeButton.TouchUpInside += (sender, e) => { try { webView.RemoveFromSuperview(); closeButton.RemoveFromSuperview(); } finally { webView.Dispose(); } }; int width, height; if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { width = 110; height = 75; } else { width = 60; height = 40; } UIImageView imageView = new UIImageView(new CGRect(mainView.Bounds.Width - width, mainView.Bounds.Height / 2, width, height)); imageView.Image = UIImage.FromBundle("swipe_left"); imageView.Alpha = .5f; imageView.UserInteractionEnabled = true; imageView.BackgroundColor = UIColor.Gray; imageView.ContentMode = UIViewContentMode.ScaleAspectFit; imageView.Layer.CornerRadius = 20; //imageView.MultipleTouchEnabled = true; webView.AddSubview(imageView); webView.AddSubview(closeButton); tap.View.Alpha = 1f; }); UIView.CommitAnimations(); } else { SendBasicAlert("Connect to a Network", "Please connect to a network to view this ad"); } }
public void HideLogin() { _loginButton.Hidden = true; _logoutButton.Hidden = false; _webView.RemoveFromSuperview(); }
public void Dispose() { WebView.RemoveFromSuperview(); WebView.Dispose(); WebView = null; }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { var cell = tableView.CellAt(indexPath); if (Reachability.IsHostReachable(Settings._baseDomain)) { var ad = Owner.FavoritesAdList[indexPath.Row]; var statusBarHeight = UIApplication.SharedApplication.StatusBarFrame.Height; var tabBarHeight = Owner.TabBarController.TabBar.Bounds.Height; var frame = new CGRect(0, statusBarHeight, Owner.View.Bounds.Width, Owner.View.Bounds.Height - (statusBarHeight + tabBarHeight)); var webView = new UIWebView(frame); LoadingOverlay loadingOverlay = new LoadingOverlay(Owner.View.Frame); webView.LoadFinished += (sender, e) => { loadingOverlay.Hide(); }; var url = ad.AircraftForSaleURL; webView.LoadRequest(new NSUrlRequest(new NSUrl(url))); UIView.BeginAnimations("fadeflag"); UIView.Animate(1, () => { cell.Alpha = .5f; }, () => { Owner.View.AddSubview(webView); Owner.View.AddSubview(loadingOverlay); UIButton closeButton = new UIButton(new CGRect(Owner.View.Bounds.Width - 50, 0, 50, 50)); closeButton.SetImage(UIImage.FromBundle("close"), UIControlState.Normal); closeButton.BackgroundColor = UIColor.Black; closeButton.TouchUpInside += (sender, e) => { try { webView.RemoveFromSuperview(); closeButton.RemoveFromSuperview(); } finally { webView.Dispose(); } }; //Owner.View.AddSubview(closeButton); webView.AddSubview(closeButton); cell.Alpha = 1f; }); UIView.CommitAnimations(); //} } else { HelperMethods.SendBasicAlert("Connect to a Network", "Please connect to a network to view this ad"); } tableView.DeselectRow(indexPath, true); }
public override void ViewDidDisappear(bool animated) { base.ViewDidDisappear(animated); _web.RemoveFromSuperview(); }