public void ShareUrl(object sender, Uri uri) { var item = new NSUrl(uri.AbsoluteUri); var activityItems = new NSObject[] { item }; UIActivity[] applicationActivities = null; var activityController = new UIActivityViewController (activityItems, applicationActivities); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { var window = UIApplication.SharedApplication.KeyWindow; var pop = new UIPopoverController (activityController); var barButtonItem = sender as UIBarButtonItem; if (barButtonItem != null) { pop.PresentFromBarButtonItem(barButtonItem, UIPopoverArrowDirection.Any, true); } else { var rect = new CGRect(window.RootViewController.View.Frame.Width / 2, window.RootViewController.View.Frame.Height / 2, 0, 0); pop.PresentFromRect (rect, window.RootViewController.View, UIPopoverArrowDirection.Any, true); } } else { var viewController = UIApplication.SharedApplication.KeyWindow.RootViewController; viewController.PresentViewController(activityController, true, null); } }
protected override void OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs<Xamarin.Forms.Button> e) { base.OnElementChanged (e); if (e.NewElement != null) { Control.TouchUpInside += delegate(object sender, EventArgs e2) { var formsView = new CommonFormsView (); var rect = new CGRect (0, 0, 400, 400); var iOSView = FormsViewToNativeiOS.ConvertFormsToNative (formsView, rect); var viewController = new UIViewController(); viewController.Add(iOSView); viewController.View.Frame = rect; var popoverController = new UIPopoverController(viewController); popoverController.ContentViewController.View.BackgroundColor = viewController.View.BackgroundColor; popoverController.PopoverContentSize = rect.Size; var frame = UIApplication.SharedApplication.KeyWindow.RootViewController.View.Frame; popoverController.PresentFromRect (Control.Frame, UIApplication.SharedApplication.KeyWindow.RootViewController.View, 0, true); }; } }
void OnActionSheetDismissed(UIActionSheet sheet, int buttonIndex) { if (sheet != null) { sheet.Dispose(); sheet = null; } picker = new UIImagePickerController(); picker.Delegate = new PhotoPickerDelegate(this); switch (buttonIndex) { case 0: // Choose Photo picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary; picker.AllowsEditing = true; break; case 1: // Take Photo picker.SourceType = UIImagePickerControllerSourceType.Camera; picker.CameraDevice = UIImagePickerControllerCameraDevice.Rear; picker.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo; picker.CameraFlashMode = UIImagePickerControllerCameraFlashMode.Auto; picker.ShowsCameraControls = true; picker.AllowsEditing = true; break; } popover = new UIPopoverController(picker); popover.DidDismiss += OnPopoverDismissed; popover.PresentFromRect(PhotoRect, this, UIPopoverArrowDirection.Any, true); }
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); }
/// <summary> /// Presents popover. /// </summary> private void _PresentPopover(UIViewControllerWithPopover viewCtrl, RectangleF frame) { var popoverController = new UIPopoverController(viewCtrl); viewCtrl.PopoverController = popoverController; popoverController.PresentFromRect(frame, View, UIPopoverArrowDirection.Any, true); }
private void Open() { CreatePopoverController(); var size = _popover .ContentViewController .View .Subviews[0] .SizeThatFits( new CGSize( Math.Min(DefaultPopoverWidth, this.MaxWidth), this.MaxHeight ) ); var preferredSize = new CGSize(DefaultPopoverWidth, size.Height); _popover.ContentViewController.PreferredContentSize = preferredSize; if (preferredSize.Height <= 0) { this.Log().Warn($"Did not present Popover with preferred size of {preferredSize}"); } else { _popover.PresentFromRect( (Anchor ?? this).Bounds, (Anchor ?? this), UIPopoverArrowDirection.Down | UIPopoverArrowDirection.Up, // TODO: Expose parameters true ); } }
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { picker = new DatePickerController(DateValue); nav = new UINavigationController(picker); popover = new UIPopoverController(nav); if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0)) { picker.PreferredContentSize = DatePickerSize; nav.PreferredContentSize = DatePickerSize; } else { picker.ContentSizeForViewInPopover = DatePickerSize; nav.ContentSizeForViewInPopover = DatePickerSize; } popover.PopoverContentSize = DatePickerSize; nav.Delegate = new DatePickerNavigationDelegate(); picker.DatePicked += OnDatePicked; picker.Popover = popover; var cell = GetActiveCell(); //popover.DidDismiss += (sender, e) => { // popover.Dispose (); // popover = null; // picker.Dispose (); // picker = null; //}; popover.PresentFromRect(cell.Frame, tableView, UIPopoverArrowDirection.Up, true); }
public static void ShareUrl(string url, UIBarButtonItem barButtonItem = null) { try { var item = new NSUrl(url); var activityItems = new NSObject[] { item }; UIActivity[] applicationActivities = null; var activityController = new UIActivityViewController(activityItems, applicationActivities); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { var window = UIApplication.SharedApplication.KeyWindow; var pop = new UIPopoverController(activityController); if (barButtonItem != null) { pop.PresentFromBarButtonItem(barButtonItem, UIPopoverArrowDirection.Any, true); } else { var rect = new CGRect(window.RootViewController.View.Frame.Width / 2, window.RootViewController.View.Frame.Height / 2, 0, 0); pop.PresentFromRect(rect, window.RootViewController.View, UIPopoverArrowDirection.Any, true); } } else { var viewController = UIApplication.SharedApplication.KeyWindow.GetVisibleViewController(); viewController.PresentViewController(activityController, true, null); } } catch { } }
void OpenOptionView(object sender, EventArgs ea) { optionVisible = true; if (!Utility.IsIPad) { if (!showOptions) { this.ShowOptionView(); } else { this.HideOptionView(); } showOptions = !showOptions; } else { //iPad view, present PopOver OptionViewController optionController = new OptionViewController(); optionController.OptionView = optionView; UIPopoverController popover = new UIPopoverController(optionController); popover.SetPopoverContentSize(new CGSize(320.0, 400.0), true); UIBarButtonItem barbtn = sender as UIBarButtonItem; UIView view = barbtn.ValueForKey(new NSString("view")) as UIView; CGRect frame = new CGRect(this.View.Frame.Width - view.Frame.Width, view.Frame.Y + 23, view.Frame.Width, view.Frame.Height); popover.PresentFromRect(frame, this.View, UIPopoverArrowDirection.Up, true); } }
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { if (picker == null) { picker = new UIImagePickerController(); } picker.Delegate = new MyDelegate(this, tableView, path); switch (UIDevice.CurrentDevice.UserInterfaceIdiom) { case UIUserInterfaceIdiom.Pad: RectangleF useRect; popover = new UIPopoverController(picker); var cell = tableView.CellAt(path); if (cell == null) { useRect = rect; } else { useRect = cell.Frame; } popover.PresentFromRect(useRect, dvc.View, UIPopoverArrowDirection.Any, true); break; default: case UIUserInterfaceIdiom.Phone: dvc.ActivateController(picker, dvc); break; } currentController = dvc; }
/// <summary> /// Handles the <see cref="E:Started" /> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="eventArgs">The <see cref="EventArgs"/> instance containing the event data.</param> private void OnStarted(object sender, EventArgs eventArgs) { var button = UIButton.FromType(UIButtonType.System); button.SetTitle("OK", UIControlState.Normal); button.Frame = new CGRect(0, 250, 320, 50); button.TouchUpInside += (s, e) => { UpdatePickerFromModel(_picker.Model as PickerSource); }; _picker.Frame = new CGRect(0, 0, 320, 250); var vc = new UIViewController { _picker, button }; vc.View.Frame = new CGRect(0, 0, 320, 300); vc.PreferredContentSize = new CGSize(320, 300); _popOver = new UIPopoverController(vc); _popOver.PresentFromRect(new CGRect(Control.Frame.Width / 2, Control.Frame.Height - 3, 0, 0), Control, UIPopoverArrowDirection.Any, true); _popOver.DidDismiss += (s, e) => { _popOver = null; Control.ResignFirstResponder(); }; }
public NumberEntryView() { BackgroundColor = UIColor.White; BorderStyle = UITextBorderStyle.RoundedRect; this.KeyboardType = UIKeyboardType.DecimalPad; this.ShouldBeginEditing = (t) =>{ if(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone || popover != null && popover.PopoverVisible) return true; var num = new NumberInputViewController(this); popover = new UIPopoverController(num){ }; popover.PresentFromRect(this.Frame,this.Superview, UIPopoverArrowDirection.Any,true); popover.DidDismiss += (object sender, EventArgs e) => { this.ResignFirstResponder(); popover.Dispose(); num.Dispose(); popover = null; }; this.SelectAll(this); return true; }; this.EditingDidEnd += (s,e) => { if(NewValue != null) NewValue(Text); if(popover != null && popover.PopoverVisible) popover.Dismiss(true); }; this.InputView = new UIView (new RectangleF (0, 0, 0, 0)); }
void DisplayMusicOptions() { if (UserInterfaceIdiomIsPhone) { flipsideViewController = new FlipsideViewController(this); flipsideViewController.Done += (button, even) => { DismissViewController(true, null); }; PresentViewController(flipsideViewController, true, null); } else { if (flipsidePopoverController == null) { var controller = new FlipsideViewController(this); flipsidePopoverController = new UIPopoverController(controller); flipsidePopoverController.PopoverContentSize = new SizeF(320f, 460f); controller.Done += delegate { flipsidePopoverController.Dismiss(true); }; } if (flipsidePopoverController.PopoverVisible) { flipsidePopoverController.Dismiss(true); } else { flipsidePopoverController.PresentFromRect(musicButton.Frame, View, UIPopoverArrowDirection.Any, true); } } }
public override void TouchesEnded(NSSet touches, UIEvent evt) { if (Platform.IsIpad) { var picker = Handler.CreatePicker(); Handler.UpdatePicker(InputView); picker.SizeToFit(); var view = new UIViewController { View = picker }; if (view.RespondsToSelector(selPreferredContentSize)) { view.PreferredContentSize = picker.SizeThatFits(CoreGraphics.CGSize.Empty); } else { view.ContentSizeForViewInPopover = picker.SizeThatFits(CoreGraphics.CGSize.Empty); } popover = new UIPopoverController(view); popover.PresentFromRect(Bounds, this, UIPopoverArrowDirection.Any, true); popover.DidDismiss += (sender, e) => { Handler.UpdateValue(picker); popover.Dispose(); popover = null; }; } else { Handler.UpdatePicker(InputView); BecomeFirstResponder(); } }
private void OpenAddPatternView() { UIImagePickerController ctrl = null; ctrl = Camera.SelectPicture(this, (dic) => { var original = dic[UIImagePickerController.OriginalImage] as UIImage; if (original == null) { return; } var atsvc = new AddToAlbumViewController(original, null, false); atsvc.Success = () => DismissPopupOfModal(ctrl); ctrl.PushViewController(atsvc, true); }, () => { DismissPopupOfModal(ctrl); }); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { _pop = new UIPopoverController(ctrl); _pop.PopoverContentSize = new System.Drawing.SizeF(320, 480); _pop.PresentFromRect(this.View.Frame, this.View, UIPopoverArrowDirection.Left, false); } else { PresentViewController(ctrl, true, null); } }
/// <summary> /// Notify button event /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> void BtnNotify_TouchUpInside(object sender, EventArgs e) { SyncNotification SyncNotification = this.Storyboard.InstantiateViewController("SyncNotification") as SyncNotification; UIPopoverController cl = new UIPopoverController(SyncNotification); cl.PresentFromRect(btnNotify.Frame, View, UIPopoverArrowDirection.Any, true); clearSeen(); }
public void ShareLocalFile(string localFilePath, string title = "", object view = null) { try { if (string.IsNullOrWhiteSpace(localFilePath)) { Console.WriteLine("Plugin.ShareFile: ShareLocalFile Warning: localFilePath null or empty"); return; } var window = UIApplication.SharedApplication.KeyWindow; var vc = window.RootViewController; while (vc.PresentedViewController != null) { vc = vc.PresentedViewController; } //var rootController = UIApplication.SharedApplication.KeyWindow.RootViewController; var sharedItems = new List <NSObject>(); var fileName = Path.GetFileName(localFilePath); var fileUrl = NSUrl.FromFilename(localFilePath); sharedItems.Add(fileUrl); UIActivity[] applicationActivities = null; var activityViewController = new UIActivityViewController(sharedItems.ToArray(), applicationActivities); // Subject if (!string.IsNullOrWhiteSpace(title)) { activityViewController.SetValueForKey(NSObject.FromObject(title), new NSString("subject")); } if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { vc.PresentViewController(activityViewController, true, null); } else { var shareView = view as UIView; if (shareView != null) { UIPopoverController popCont = new UIPopoverController(activityViewController); popCont.PresentFromRect(shareView.Frame, shareView, UIPopoverArrowDirection.Any, true); } else { throw new Exception("view is null: for iPad you must pass the view paramater. The view parameter should be the view that triggers the share action, i.e. the share button."); } } } catch (Exception ex) { if (ex != null && !string.IsNullOrWhiteSpace(ex.Message)) { Console.WriteLine("Exception in Plugin.ShareFile: ShareLocalFile Exception: {0}", ex); } } }
public void PresentFromPopover(UIView sender,float x,float y,float vwidth) { popover = new UIPopoverController(this) { PopoverContentSize = new SizeF(vwidth, 600) }; popover.PresentFromRect (new CoreGraphics.CGRect (x, y, 1, 1), sender, UIPopoverArrowDirection.Any, true); }
public void PresentFromPopover(UIView sender,float x,float y) { popover = new UIPopoverController(this) { PopoverContentSize = new SizeF(400, 590) }; popover.PresentFromRect (new CoreGraphics.CGRect (x, y, 1, 1), sender, UIPopoverArrowDirection.Any, true); this.View.Layer.Frame = new CoreGraphics.CGRect (0, 0, 400, 590); }
public void PresentFromPopover(UIView sender) { popover = new UIPopoverController(this) { PopoverContentSize = new SizeF(320, 350) }; var frame = new RectangleF(0, 0,(float)sender.Frame.Width, (float)sender.Frame.Height); popover.PresentFromRect(frame, sender, UIPopoverArrowDirection.Down, true); }
partial void ShowGoToTableView(NSObject sender) { UIStoryboard storyboard = UIStoryboard.FromName("PBOPageNavigation", NSBundle.MainBundle); UIViewController navController = (UIViewController)storyboard.InstantiateViewController("PBOPageNavigation"); UIPopoverController tagManagePopoverController = new UIPopoverController(navController); tagManagePopoverController.BackgroundColor = UIColor.White; AppDisplayUtil.Instance.SetPopoverController(tagManagePopoverController); tagManagePopoverController.SetPopoverContentSize(new CGSize(640, 256), false); tagManagePopoverController.PresentFromRect(new CGRect(ContentWebView.Frame.Size.Width - 480, -225, 640, 256), this.View, UIPopoverArrowDirection.Up, true); //-225 }
public void PresentFromRect() { if (_device != UIUserInterfaceIdiom.Pad) { Assert.Inconclusive("Not running on iPad!"); return; } var popOver = new UIPopoverController(_controller); popOver.PresentFromRect(new CGRect(), new UIView(), UIPopoverArrowDirection.Any, true); }
private void ShowMarkerUnitPopover(UIView view, int channel) { var content = new PopoverContentViewController <MarkerUnit> (); content.ValueChanged += (object s, EnumEventArgs <MarkerUnit> e) => { DisplaySettings.MarkerUnits [channel] = e.Value; }; DetailViewPopover = new UIPopoverController(content); DetailViewPopover.PopoverContentSize = content.ContentBounds.Size; DetailViewPopover.PresentFromRect(view.Frame, View, UIPopoverArrowDirection.Any, true); }
public void PresentFromRect_BadView() { if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Pad) { Assert.Inconclusive("Requires iPad"); } TestRuntime.AssertNotDevice("ObjectiveC exception crash on devices - bug #3980"); using (var vc = new UIViewController()) using (var bbi = new UIBarButtonItem(UIBarButtonSystemItem.Action)) using (var pc = new UIPopoverController(vc)) { // 'vc' has never been shown #if NET Assert.Throws <ObjCException> (() => pc.PresentFromRect(new CGRect(10, 10, 100, 100), vc.View, UIPopoverArrowDirection.Down, true)); #else Assert.Throws <MonoTouchException> (() => pc.PresentFromRect(new CGRect(10, 10, 100, 100), vc.View, UIPopoverArrowDirection.Down, true)); #endif // fails with: // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window. } }
void ShowInPopOver() { if (vc == null) { vc = new EqualizerPickerViewController() { PresetSelected = (preset) => SelectedItem = preset, }; pop = new UIPopoverController(vc); } pop.PopoverContentSize = pickerView.Frame.Size; pop.PresentFromRect(Frame, this.Superview, UIPopoverArrowDirection.Up, true); }
public static void TakePicture(UIViewController parent, Action<NSDictionary> callback) { Init (); picker.SourceType = UIImagePickerControllerSourceType.Camera; _callback = callback; if (AppDelegate.UserInterfaceIdiomIsPhone == false) { popover = new UIPopoverController (picker); popover.PresentFromRect (new RectangleF (150, 150, 500, 500), parent.View, UIPopoverArrowDirection.Any, true); } else { parent.PresentViewController (picker, true, null); } }
public InvoiceLineCell() : base(Key) { AutoAddSubview(Description = new UILabel { Text = "Description", }, 4 ); AutoAddSubview(Price = new UILabel { Text = "Price", TextAlignment = UITextAlignment.Center }, 2); AutoAddSubview(Discount = new UIBorderedButton() { Title = "0", Tapped = (b) => { if (popup != null) { popup.Dispose(); } var d = new DiscountViewController(line.Price) { DollarChanged = (dollar) => { popup.Dismiss(true); Line.Discount = dollar; } }; popup = new UIPopoverController(d); popup.DidDismiss += (object sender, EventArgs e) => { line.Discount = 0; d.Dispose(); popup.Dispose(); popup = null; }; popup.PresentFromRect(Discount.Bounds, Discount, UIPopoverArrowDirection.Any, true); } }, 2); AutoAddSubview(TransTypeButton = new UIBorderedButton { Title = "S", TintColor = Color.LightBlue }); TransTypeButton.TouchUpInside += (sender, e) => { var sheet = new SimpleActionSheet(); var types = Database.Main.Table <TransactionType>().ToList(); types.ForEach(x => sheet.Add(x.Description, Color.LightBlue, () => Line.TransType = x)); sheet.ShowFrom(TransTypeButton.Bounds, TransTypeButton, true); }; AddSubview(Total = new UILabel { Text = "Total", TextAlignment = UITextAlignment.Center }, 9, columnspan: 2); }
void OnActionSheetDismissed(UIActionSheet sheet, int buttonIndex) { sheet.Dispose(); picker = null; if (buttonIndex == -1) { return; } CancelPhotoTask(); switch (buttons[buttonIndex]) { case PhotoResponse.ChoosePhoto: picker = new AircraftPhotoPickerController(); picker.Delegate = new AircraftPhotoPickerDelegate(this); picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary; picker.AllowsEditing = true; break; case PhotoResponse.CapturePhoto: picker = new AircraftPhotoPickerController(); picker.Delegate = new AircraftPhotoPickerDelegate(this); picker.SourceType = UIImagePickerControllerSourceType.Camera; picker.CameraDevice = UIImagePickerControllerCameraDevice.Rear; picker.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo; picker.CameraFlashMode = UIImagePickerControllerCameraFlashMode.Auto; picker.ShowsCameraControls = true; picker.AllowsEditing = true; break; case PhotoResponse.FlightAware: FetchPhotograph(true); break; case PhotoResponse.UnsetPhoto: Photograph = null; break; } if (picker != null) { popover = new UIPopoverController(picker); popover.DidDismiss += OnPopoverDismissed; popover.PresentFromRect(PhotoRect, this, UIPopoverArrowDirection.Any, true); } }
public void ShowPopoverRecentHistory(object sender, EventArgs e) { UINavigationController navController = new UINavigationController(new PopoverHistoryTableViewController()); navController.NavigationBar.BarTintColor = UIColor.White; UIPopoverController historyPop = new UIPopoverController(navController); historyPop.BackgroundColor = UIColor.White; AppDisplayUtil.Instance.SetPopoverController(historyPop); UIView viewOfBarButtonItem = (UIView)((UIBarButtonItem)sender).ValueForKey(new NSString("view")); historyPop.PresentFromRect(viewOfBarButtonItem.Frame, viewOfBarButtonItem.Superview, UIPopoverArrowDirection.Up, true); }
public void HighlightText() { CGRect selecteTextFrame = GetSelectedTextFrame(); CGRect textFrame = new CGRect(selecteTextFrame.X, selecteTextFrame.Y + 44, selecteTextFrame.Width, selecteTextFrame.Height); HighlightTableViewControllerController highLightVC = new HighlightTableViewControllerController(); UINavigationController highLightNav = new UINavigationController(highLightVC); highLightNav.View.BackgroundColor = UIColor.White; highLightNav.NavigationBar.TintColor = UIColor.Red; UIPopoverController highPopoverController = new UIPopoverController(highLightNav); highPopoverController.PopoverContentSize = new CGSize(320, 328); AppDisplayUtil.Instance.SetPopoverController(highPopoverController); highPopoverController.PresentFromRect(textFrame, Superview, UIPopoverArrowDirection.Any, true); }
void Button1_TouchUpInside(object sender, EventArgs e) { if (UserInterfaceIdiomIsPhone) { var navController = new UINavigationController(_colorPickerViewController); PresentViewController(navController, true, null); } else { var navController = new UINavigationController(_colorPickerViewController); _popoverController = new UIPopoverController(navController); _popoverController.PresentFromRect(((UIButton)sender).Frame, View, UIPopoverArrowDirection.Up, true); } }
public async void ShowPopoverAsync(NSObject sender) { // Set the sender to a UIButton. UIButton tappedButton = (UIButton)sender; var content = new PopoverContentViewController(); DetailPopover = new UIPopoverController(content); DetailPopover.PopoverContentSize = new SizeF(375, 375); DetailPopover.PresentFromRect(tappedButton.Frame, View, UIPopoverArrowDirection.Any, true); // await! control returns to the caller var result = await WaitAsync(); content.WebViewContent = result; }
partial void ShowRegionsSelectorTableView(Foundation.NSObject sender) { RegionsTableViewController regionsTVC = new RegionsTableViewController(SetSelectedRegion, selectedRegionTextField.Text); UIPopoverController popoverController = new UIPopoverController(regionsTVC); popoverController.BackgroundColor = UIColor.White; popoverController.SetPopoverContentSize(new CoreGraphics.CGSize(340, 230), true); AppDisplayUtil.Instance.SetPopoverController(popoverController); CGRect anchorFrame = ((UIButton)sender).Frame; anchorFrame.Width /= 2; popoverController.PresentFromRect(new CGRect(75, 30, 0, 0), (UIView)sender, UIPopoverArrowDirection.Any, true); }
private void NoteTextController() { CGRect selecteTextFrame = GetSelectedTextFrame(); CGRect textFrame = new CGRect(selecteTextFrame.X, selecteTextFrame.Y + 44, selecteTextFrame.Width, selecteTextFrame.Height); UIStoryboard storyboard = UIStoryboard.FromName("NoteTextNavgation", NSBundle.MainBundle); NoteViewController controllerVC = (NoteViewController)storyboard.InstantiateViewController("NoteTextNavgationer"); UINavigationController navController = new UINavigationController(controllerVC); navController.NavigationBar.Translucent = false; navController.EdgesForExtendedLayout = UIRectEdge.None; UIPopoverController tagManagePopoverController = new UIPopoverController(navController); tagManagePopoverController.BackgroundColor = UIColor.White; AppDisplayUtil.Instance.SetPopoverController(tagManagePopoverController); tagManagePopoverController.PresentFromRect(textFrame, Superview, UIPopoverArrowDirection.Any, true); }
public static void SelectPicture(UIViewController parent, Action <NSDictionary> callback) { Init(); picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary; _callback = callback; if (AppDelegate.UserInterfaceIdiomIsPhone == false) { popover = new UIPopoverController(picker); popover.PresentFromRect(new RectangleF(150, 150, 500, 500), parent.View, UIPopoverArrowDirection.Any, true); } else { parent.PresentViewController(picker, true, null); } }
private void InitializeUI() { UIPopoverController myPopOver = new UIPopoverController(new MediaSummaryViewController()); btnMediaSummary.TouchUpInside += (sender, e) => { myPopOver.PopoverContentSize = new SizeF(450f, 420f); myPopOver.PresentFromRect(btnMediaSummary.Frame, this.View, UIPopoverArrowDirection.Down, true); UpdateButtonNumber(); }; txtInput = new UITextView(); txtInput.Frame = new RectangleF(20, 20, 380, 320); txtInput.BackgroundColor = UIColor.FromRGB(242, 242, 242); txtInput.Text = "Voer hier tekst in..."; View.Add(txtInput); }
public void PresentFromRect() { if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Pad) { return; } using (var vc = new UIViewController()) using (var bbi = new UIBarButtonItem(UIBarButtonSystemItem.Action)) using (var pc = new UIPopoverController(vc)) { var view = UIApplication.SharedApplication.KeyWindow; pc.PresentFromRect(new RectangleF(10, 10, 100, 100), view, UIPopoverArrowDirection.Down, true); pc.Dismiss(true); // works (as long as we dismiss the popover before disposing) } }
public void ShareLocalFile(string localFilePath, string title = "", object view = null) { try { if (string.IsNullOrWhiteSpace(localFilePath)) { Console.WriteLine("Plugin.ShareFile: ShareLocalFile Warning: localFilePath null or empty"); return; } var rootController = UIApplication.SharedApplication.KeyWindow.RootViewController; var sharedItems = new List <NSObject>(); var fileName = Path.GetFileName(localFilePath); var fileUrl = NSUrl.FromFilename(localFilePath); sharedItems.Add(fileUrl); UIActivity[] applicationActivities = null; var activityViewController = new UIActivityViewController(sharedItems.ToArray(), applicationActivities); // Subject if (!string.IsNullOrWhiteSpace(title)) { activityViewController.SetValueForKey(NSObject.FromObject(title), new NSString("subject")); } if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { rootController.PresentViewController(activityViewController, true, null); } else { // Tablet var popup = new UIPopoverController(activityViewController); UIView tabview = UIApplication.SharedApplication.KeyWindow.RootViewController.View; CGRect rect = new CGRect(tabview.Frame.Width / 2, tabview.Frame.Height, 50, 50); popup.PresentFromRect(rect, tabview, UIPopoverArrowDirection.Any, true); } } catch (Exception ex) { if (ex != null && !string.IsNullOrWhiteSpace(ex.Message)) { Console.WriteLine("Exception in Plugin.ShareFile: ShareLocalFile Exception: {0}", ex); } } }
public static void Share(string title = null, string body = null, string url = null, UIBarButtonItem barButtonItem = null) { try { var activityItems = new List <NSObject>(); if (body != null) { activityItems.Add(new NSString(body)); } if (url != null) { activityItems.Add(new NSUrl(url)); } UIActivity[] applicationActivities = null; var activityController = new UIActivityViewController(activityItems.ToArray(), applicationActivities); if (title != null) { activityController.SetValueForKey(new NSString(title), new NSString("subject")); } if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { var window = UIApplication.SharedApplication.KeyWindow; var pop = new UIPopoverController(activityController); if (barButtonItem != null) { pop.PresentFromBarButtonItem(barButtonItem, UIPopoverArrowDirection.Any, true); } else { var rect = new CGRect(window.RootViewController.View.Frame.Width / 2, window.RootViewController.View.Frame.Height / 2, 0, 0); pop.PresentFromRect(rect, window.RootViewController.View, UIPopoverArrowDirection.Any, true); } } else { var viewController = UIApplication.SharedApplication.KeyWindow.GetVisibleViewController(); viewController.PresentViewController(activityController, true, null); } } catch { } }
public void ShareUrl(string url) { var item = new NSUrl(new Uri(url).AbsoluteUri); var activityItems = new NSObject[] { item }; UIActivity[] applicationActivities = null; var activityController = new UIActivityViewController (activityItems, applicationActivities); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { var window = ((UIApplicationDelegate)UIApplication.SharedApplication.Delegate).Window; var pop = new UIPopoverController (activityController); pop.PresentFromRect (new CoreGraphics.CGRect (window.RootViewController.View.Frame.Width / 2, window.RootViewController.View.Frame.Height / 2, 0, 0), window.RootViewController.View, UIPopoverArrowDirection.Any, true); } else { _modalHost.PresentModalViewController(activityController, true); } }
public override void ViewDidLoad() { base.ViewDidLoad (); // make the main content area scroll over two pages this.scrollView.ContentSize = new SizeF (this.scrollView.Bounds.Width * 2, this.scrollView.Bounds.Height); this.scrollView.PagingEnabled = true; // add page one var nibObjects = NSBundle.MainBundle.LoadNib("DashboardPageOneView", this, null); _pageOne = (DashboardPageOneView)Runtime.GetNSObject(nibObjects.ValueAt(0)); _pageOne.Frame = this.scrollView.Bounds; this.scrollView.Add(_pageOne); // add page two nibObjects = NSBundle.MainBundle.LoadNib("DashboardPageTwoView", this, null); _pageTwo = (DashboardPageTwoView)Runtime.GetNSObject(nibObjects.ValueAt(0)); _pageTwo.Frame = new RectangleF (new PointF(this.scrollView.Bounds.Width, 0), this.scrollView.Bounds.Size); this.scrollView.Add(_pageTwo); // Need to set the repo for our views FetchDataForRepo ("tastejs", "PropertyCross"); // Add the touch handler to the repo summary this.repoSummary.SetTapHandler ( nameLabelFrame => { if(_repoSelectorVC == null) { _repoSelectorVC = new RepoSelectorViewControllerController (_githubUserName, repoName => { InvokeOnMainThread(() => { _popover.Dismiss(true); FetchDataForRepo (_githubUserName, repoName); }); }); } _popover = new UIPopoverController(_repoSelectorVC); _popover.PresentFromRect (nameLabelFrame, this.repoSummary, UIPopoverArrowDirection.Up, true); }); }
public override void ViewDidLoad() { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. //DVC is the source one - the one we start with. Most of it's stuff is just setup dvc = new DialogViewController(null, false); var root = new RootElement("Hello there"); var section = new Section(); for(int i = 0; i < 10; i++) { //urgh, using lambas, so we need to capture a few things locally. //never sure if I have to do this with int's or not tho int locali = i; //make the local element, the one in the main list StyledStringElement localElement = null; localElement = new StyledStringElement("Hello " + i.ToString (), delegate {; //when you tap on the item, make a new root, // which is a radio list. Select item 1 (the second one) by default // but only cos I want to, no real reason :) RadioGroup radioGroup = new RadioGroup(1); //create 3 elements. This is stupid code copy and paste, they all do the same thing // I guess you'd make this from an array or database? var childroot = new RootElement("child", radioGroup) { new Section() { // I've made a custom RadioElement (down the bottom) // that, when selected, calls us back new CheckedRadioElement("First", delegate(CheckedRadioElement cre) { // .. and we dismiss the popover, grab the value out, and then tell the // main dvc to reload/redisplay itself. popOver.Dismiss(true); localElement.Caption = cre.Caption; dvc.ReloadData(); }), // these 2 are the same - just other data. Use a database or an array :) new CheckedRadioElement("Second", delegate(CheckedRadioElement cre) { popOver.Dismiss(true); localElement.Caption = cre.Caption; dvc.ReloadData(); }), new CheckedRadioElement("Third", delegate(CheckedRadioElement cre) { popOver.Dismiss(true); localElement.Caption = cre.Caption; dvc.ReloadData(); }) } }; //make the child DVC. This is the one which goes into the popover. // false on the end, 'cos we are not pushing it into a UINavigationController var childdvc = new DialogViewController(childroot, false); childdvc.Style = UITableViewStyle.Plain; //this does tho! //get the rect of the last section var newrootSize = childdvc.TableView.RectForSection (childroot.Count - 1); //and make that the size. Or 700... which ever is smaller. childdvc.ContentSizeForViewInPopover = new SizeF (300, Math.Min (newrootSize.Bottom, 700)); //make the popover and set its size popOver = new UIPopoverController(childdvc); //and show the popover. We ask the tableview for the rect of the item we selected. // and in this case, we want to see it on the right (arrow == left) popOver.PresentFromRect(dvc.TableView.RectForRowAtIndexPath(localElement.IndexPath), dvc.TableView, UIPopoverArrowDirection.Left, true); }) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; section.Add (localElement); } root.Add (section); dvc.Root = root; //temp view is because a normal DVC wants to take over the whole screen, we I'm constraining it to a 300x300 area, which I think is about // what you had. Thats the only reason tho. var tempView = new UIView(new RectangleF(10,10,300,300)); tempView.AddSubview(dvc.TableView); View.Add (tempView); }
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path) { if (picker == null) picker = new UIImagePickerController (); picker.Delegate = new ImagePickerControllerDelegate (this, tableView, path); switch (UIDevice.CurrentDevice.UserInterfaceIdiom){ case UIUserInterfaceIdiom.Pad: popover = new UIPopoverController (picker); popover.PresentFromRect (rect, dvc.View, UIPopoverArrowDirection.Any, true); break; default: case UIUserInterfaceIdiom.Phone: dvc.ActivateController (picker, dvc); break; } currentController = dvc; }
/// <summary> /// Presents popover /// </summary> private void PresentPopover(UIViewControllerWithPopover viewCtrl, RectangleF frame) { var popoverController = new UIPopoverController(viewCtrl); viewCtrl.PopoverController = popoverController; popoverController.PresentFromRect(frame, View, UIPopoverArrowDirection.Any, true); }
void initializeMoveLager() { lagerselect = new SelectLager (); this.inStorage.TouchUpInside += (object sender, EventArgs e) => { if(UserInterfaceIdiomIsPhone){ ancestor.NavigationController.PushViewController(lagerselect,true); }else{ popme = new UIPopoverController (lagerselect); popme.PresentFromRect (this.inStorage.Bounds, this.View, UIPopoverArrowDirection.Up, true); } }; lagerselect.DismissEvent += (object sender, LagerClickedEventArgs e) => { if(UserInterfaceIdiomIsPhone){ ancestor.NavigationController.PopViewControllerAnimated(true); }else{ popme.Dismiss (true); } boks.LagerID = e.Lager.ID; SetLagerButtonLabel (this.boks); AppDelegate.dao.SaveLagerObject(this.boks); RaiseSavedEvent(); }; }
private void ShowImagePickerView() { UIApplication.SharedApplication.InvokeOnMainThread (delegate { UIImagePickerController imagePickerController = new UIImagePickerController(); imagePickerController.FinishedPickingImage += HandleImagePickerControllerFinishedPickingImage; imagePickerController.FinishedPickingMedia += HandleImagePickerControllerFinishedPickingMedia; imagePickerController.Canceled += HandleImagePickerControllerCanceled; if(IPhoneUtils.GetInstance().IsIPad()) { try { // in iPad, the UIImagePickerController should be presented inside a UIPopoverController, otherwise and exception is raised popover = new UIPopoverController(imagePickerController); UIView view = IPhoneServiceLocator.CurrentDelegate.MainUIViewController ().View; //RectangleF frame = new RectangleF(new PointF(0,0),new SizeF(view.Frame.Size.Width, view.Frame.Size.Height)); RectangleF frame = new RectangleF(new PointF(0,0),new SizeF(0,0)); popover.PresentFromRect(frame, view, UIPopoverArrowDirection.Up, true); }catch(Exception ex) { INotification notificationService = (INotification)IPhoneServiceLocator.GetInstance ().GetService ("notify"); if (notificationService != null) { notificationService.StartNotifyAlert ("Media Alert", "Unable to reach Photo Library", "OK"); } if(popover != null && popover.PopoverVisible) { popover.Dismiss(true); popover.Dispose(); } } } else { IPhoneServiceLocator.CurrentDelegate.MainUIViewController ().PresentModalViewController (imagePickerController, true); } }); }
private void OpenAddPatternView() { UIImagePickerController ctrl = null; ctrl = Camera.SelectPicture(this, (dic) => { var original = dic[UIImagePickerController.OriginalImage] as UIImage; if (original == null) return; var atsvc = new AddToAlbumViewController(original, null, false); atsvc.Success = () => DismissPopupOfModal(ctrl); ctrl.PushViewController(atsvc, true); }, () => { DismissPopupOfModal(ctrl); }); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { _pop = new UIPopoverController (ctrl); _pop.PopoverContentSize = new System.Drawing.SizeF(320, 480); _pop.PresentFromRect(this.View.Frame, this.View, UIPopoverArrowDirection.Left, false); } else { PresentViewController(ctrl, true, null); } }
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { if (picker == null) picker = new UIImagePickerController (); picker.Delegate = new MyDelegate (this, tableView, path); var hasCamera = picker.MediaTypes; picker.SourceType = hasCamera.Length == 1 ? UIImagePickerControllerSourceType.PhotoLibrary : UIImagePickerControllerSourceType.Camera; switch (UIDevice.CurrentDevice.UserInterfaceIdiom){ case UIUserInterfaceIdiom.Pad: RectangleF useRect; popover = new UIPopoverController (picker); var cell = tableView.CellAt (path); if (cell == null) useRect = rect; else rect = cell.Frame; popover.PresentFromRect (rect, dvc.View, UIPopoverArrowDirection.Any, true); break; default: case UIUserInterfaceIdiom.Phone: dvc.ActivateController (picker); break; } currentController = dvc; }
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { picker = new DatePickerController (DateValue); nav = new UINavigationController (picker); popover = new UIPopoverController (nav); if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0)) { picker.PreferredContentSize = DatePickerSize; nav.PreferredContentSize = DatePickerSize; } else { picker.ContentSizeForViewInPopover = DatePickerSize; nav.ContentSizeForViewInPopover = DatePickerSize; } popover.PopoverContentSize = DatePickerSize; nav.Delegate = new DatePickerNavigationDelegate (); picker.DatePicked += OnDatePicked; picker.Popover = popover; var cell = GetActiveCell (); //popover.DidDismiss += (sender, e) => { // popover.Dispose (); // popover = null; // picker.Dispose (); // picker = null; //}; popover.PresentFromRect (cell.Frame, tableView, UIPopoverArrowDirection.Up, true); }
public void PresentFromPopover(UIView sender,float x,float y,float vwidth ) { popover = new UIPopoverController(this) { PopoverContentSize = new SizeF(vwidth, uvheight) }; //this.View.Layer.Frame = new CoreGraphics.CGRect (0, 0, width, Height+88); // this.mutListView.Layer.Frame = new CoreGraphics.CGRect (0, 88, width, Height); //this.NavBar.Layer.Frame = new CoreGraphics.CGRect (0, 0, width, 44); //this.searchBar.Layer.Frame = new CoreGraphics.CGRect (0, 44, width, 44); //this.mutListView.BackgroundColor = UIColor.Red; //mutListView.TranslatesAutoresizingMaskIntoConstraints = false; //View.AddConstraint ( // NSLayoutConstraint.Create ( mutListView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 0, width) //); popover.PresentFromRect (new CoreGraphics.CGRect (x, y, 1, 1), sender, UIPopoverArrowDirection.Any, true); this.View.Layer.Frame = new CoreGraphics.CGRect (0, 0, vwidth, uvheight); }
public InvoiceSideBar() { this.Layer.BorderColor = UIColor.Black.ColorWithAlpha (.25f).CGColor; this.Layer.BorderWidth = .5f; BackgroundColor = Theme.Current.SideBarBackGroundColor;//UIColor.DarkGray; AddSubview (tableView = new UITableView (RectangleF.Empty, UITableViewStyle.Grouped) { BackgroundColor = UIColor.Clear, Source = source = new CellTableViewSource { (customer = new CustomerPickerCell { Tapped = async () => { CustomerSearchViewController customerSearch; popover = new UIPopoverController (new UINavigationController (customerSearch = new CustomerSearchViewController { CustomerPicked = (c) => { Invoice.Customer = c; popover.Dismiss (true); popover.Dispose (); if(Invoice.Customer.IsNew) { // NewCustomerInfoViewController newCust; newCustPopover = new UIPopoverController(new UINavigationController(newCust = new NewCustomerInfoViewController())); newCust.Popover = newCustPopover; newCust.HowTheyHeard = (i) => { invoice.AddItem(i); newCustPopover.Dismiss(true); newCustPopover.Dispose(); }; newCustPopover.PresentFromRect (customer.Frame, tableView, UIPopoverArrowDirection.Right, true); // } } }) { NavigationBar = { BarStyle = UIBarStyle.BlackTranslucent, } }); customerSearch.Popover = popover; popover.PresentFromRect (customer.Frame, tableView, UIPopoverArrowDirection.Right, true); } }), (subtotal = new SubTotalCell ()), (discount = new DiscountCell { AddDiscount = () =>{ } }), (total = new TotalCell ()), new PayCell { Frame = new RectangleF(0,0,320,60), Text = "Checkout", TintColor = UIColor.White, Tapped = () => { Checkout (); } }, (lastPostedChange = new LastPostedCell () { }), (printLastInvoice = new PrintLastInvoiceCell{ Text = "Print last invoice", Tapped = ()=>{ WebService.Main.PrintInvoice(Settings.Shared.LastPostedInvoice); } }), }, ScrollEnabled = false, TableHeaderView = new UIView (new RectangleF (0, 0, 0, 64)), }); Binding.Create (() => lastPostedChange.DetailTextLabel.Text == Settings.Shared.LastPostedChangeString); customerInfo = new UITableViewCell[] { (email = new MiniCell { TextLabel = { Text = "Email" }, Tapped = ()=>{ showEditor(email); }, }), (phoneNumber = new MiniCell { TextLabel = { Text = "Phone" }, Tapped = ()=>{ showEditor(phoneNumber); }, }), (onAccount = new MiniCell { TextLabel = { Text = "On Account" }, Tapped = ()=>{ showEditor(onAccount); }, }), }; }
void initializeMoveLager() { Console.WriteLine("initializemovelager"); sl = new SelectLager (); this.btnIn.TouchUpInside += (object sender, EventArgs e) => { Console.WriteLine("touchupinside"); if(UserInterfaceIdiomIsPhone){ Console.WriteLine("iphone??"); ancestor.NavigationController.PushViewController(sl,true); }else{ Console.WriteLine("ipad??"); Ic = new UIPopoverController (sl); Ic.PresentFromRect (this.btnIn.Bounds, this.View, UIPopoverArrowDirection.Up, true); } }; sl.DismissEvent += (object sender, LagerClickedEventArgs e) => { Console.WriteLine("dismiss?"); if(UserInterfaceIdiomIsPhone){ sl.NavigationController.DismissViewController(true,null); //nc.PopViewControllerAnimated(true); }else{ Ic.Dismiss (true); } if(MyCurrentObject != null){ this.MyCurrentObject.LagerID = e.Lager.ID; SetLagerButtonLabel (this.MyCurrentObject); AppDelegate.dao.SaveLagerObject(this.MyCurrentObject); RaiseSavedEvent(); } }; }
void initializePlaceObject() { sc = new SelectContainer (); this.btnInContainer.TouchUpInside += (object sender, EventArgs e) => { if(UserInterfaceIdiomIsPhone){ //PresentViewControllerAsync(sc,true); //nc.PushViewController(sc, true); ancestor.NavigationController.PushViewController(sc,true); }else{ Ic = new UIPopoverController (sc); Ic.PresentFromRect (this.btnInContainer.Bounds, this.View, UIPopoverArrowDirection.Up, true); } }; sc.DismissEvent += (object sender, ContainerClickedEventArgs e) => { if(UserInterfaceIdiomIsPhone){ sc.NavigationController.PopViewControllerAnimated(true); }else{ Ic.Dismiss (true); } this.currentItem.boxID = e.container.ID; SetContainerButtonLabel (this.currentItem); AppDelegate.dao.SaveItem(this.currentItem); }; SelectLager sl = new SelectLager (); this.btnInLocation.TouchUpInside += (object sender, EventArgs e) => { if(UserInterfaceIdiomIsPhone){ //PresentViewControllerAsync(sl,true); ancestor.NavigationController.PushViewController(sl,true); }else{ pc = new UIPopoverController (sl); pc.PresentFromRect (this.btnInLocation.Bounds, this.View, UIPopoverArrowDirection.Up, true); } }; sl.DismissEvent += (object sender, LagerClickedEventArgs e) => { if(UserInterfaceIdiomIsPhone){ sl.NavigationController.PopViewControllerAnimated(true); }else{ pc.Dismiss (true); } this.currentItem.LagerID = e.Lager.ID; SetLocationButtonLabel (this.currentItem); AppDelegate.dao.SaveItem(this.currentItem); }; }
protected override Task<string> LoginAsyncOverride() { var tcs = new TaskCompletionSource<string>(); var auth = new WebRedirectAuthenticator(StartUri, EndUri); auth.ShowUIErrors = false; auth.ClearCookiesBeforeLogin = false; UIViewController c = auth.GetUI(); UIViewController controller = null; UIPopoverController popover = null; auth.Error += (o, e) => { NSAction completed = () => { Exception ex = e.Exception ?? new Exception(e.Message); tcs.TrySetException(ex); }; if (controller != null) controller.DismissViewController(true, completed); if (popover != null) { popover.Dismiss(true); completed(); } }; auth.Completed += (o, e) => { NSAction completed = () => { if (!e.IsAuthenticated) tcs.TrySetException(new InvalidOperationException("Authentication was cancelled by the user.")); else tcs.TrySetResult(e.Account.Properties["token"]); }; if (controller != null) controller.DismissViewController(true, completed); if (popover != null) { popover.Dismiss(true); completed(); } }; controller = view as UIViewController; if (controller != null) { controller.PresentViewController(c, true, null); } else { UIView v = view as UIView; UIBarButtonItem barButton = view as UIBarButtonItem; popover = new UIPopoverController(c); if (barButton != null) popover.PresentFromBarButtonItem(barButton, UIPopoverArrowDirection.Any, true); else popover.PresentFromRect(rect, v, UIPopoverArrowDirection.Any, true); } return tcs.Task; }
private async Task<Auth0User> SendLoginAsync( RectangleF rect, object view, string connection, bool withRefreshToken, string scope, string title) { // Launch server side OAuth flow using the GET endpoint scope = IncreaseScopeWithOfflineAccess(withRefreshToken, scope); var tcs = new TaskCompletionSource<Auth0User> (); var auth = await this.GetAuthenticator (connection, scope, title); UIViewController c = auth.GetUI(); UIViewController controller = null; UIPopoverController popover = null; auth.Error += (o, e) => { if (controller != null) { controller.DismissViewController (true, null); } if (popover != null) { popover.Dismiss (true); } var ex = e.Exception ?? new AuthException (e.Message); tcs.TrySetException (ex); }; auth.Completed += (o, e) => { if (controller != null) { controller.DismissViewController (true, null); } if (popover != null) { popover.Dismiss (true); } if (!e.IsAuthenticated) { tcs.TrySetCanceled(); } else { this.SetupCurrentUser (e.Account.Properties); tcs.TrySetResult (this.CurrentUser); } }; controller = view as UIViewController; if (controller != null) { controller.PresentViewController (c, true, null); } else { UIView v = view as UIView; UIBarButtonItem barButton = view as UIBarButtonItem; popover = new UIPopoverController (c); if (barButton != null) { popover.PresentFromBarButtonItem (barButton, UIPopoverArrowDirection.Any, true); } else { popover.PresentFromRect (rect, v, UIPopoverArrowDirection.Any, true); } } return await tcs.Task; }
public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { if (picker == null) picker = new UIImagePickerController(); picker.Delegate = new MyDelegate(this, tableView, path); switch (UIDevice.CurrentDevice.UserInterfaceIdiom) { case UIUserInterfaceIdiom.Pad: RectangleF useRect; popover = new UIPopoverController(picker); var cell = tableView.CellAt(path); if (cell == null) useRect = rect; else useRect = cell.Frame; popover.PresentFromRect(useRect, dvc.View, UIPopoverArrowDirection.Any, true); break; default: case UIUserInterfaceIdiom.Phone: dvc.ActivateController(picker, dvc); break; } currentController = dvc; }
partial void chooseEvidence_iPad(MonoTouch.UIKit.UIButton sender) { if (popOver == null || popOver.ContentViewController == null) { pickerController = new UIImagePickerController(); pickerController.Delegate = new pickerDelegate(this); UIActionSheet actionSheet = new UIActionSheet("")//Actionsheet with blank title { "Choose a photo", "Take a photo", "Cancel" }; actionSheet.Style = UIActionSheetStyle.Automatic; actionSheet.ShowInView(btnChooseEvidence); actionSheet.Clicked += delegate(object s, UIButtonEventArgs e) { switch(e.ButtonIndex) { case 0: // Pick a photo pickerController.SourceType = UIImagePickerControllerSourceType.PhotoLibrary; pickerController.AllowsEditing = true; popOver = new UIPopoverController(pickerController); popOver.PresentFromRect(btnChooseEvidence.Frame, this.ParentViewController.View, UIPopoverArrowDirection.Any, true); break; case 1: // Take a photo pickerController.SourceType = UIImagePickerControllerSourceType.Camera; pickerController.AllowsEditing = true; popOver = new UIPopoverController(pickerController); popOver.PresentFromRect(btnChooseEvidence.Frame, this.ParentViewController.View, UIPopoverArrowDirection.Any, true); break; case 2: // Cancel break; }; }; } }
// Purpose: According to the seleted row in the table, it shows a PopupViewController // - if the first row -> show VCSelectTask // Example Row = 0 + Section = 0 -> show VCSelectTask public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { if (indexPath.Section == 0) { switch (indexPath.Row) { case 0: { // Show all Tasks // Show the PopContentViewController // First create our UI Control with the Table view if (_person == null) return; if(_task != null) _tasks = BusinessLayer.Task.GetTasks(_person.ID, ref Application._user); // Open the VCSelectTask Dialog addItemController = Storyboard.InstantiateViewController<VCSelectTask>(); addItemController._container = this; addItemController._tasks = _tasks; PresentViewController (addItemController, true, null); break; } } } else if (indexPath.Section == 1) { if (controlsEnabled == false) return; switch (indexPath.Row) { case 0: // Show all Ansprechpartnern // Show the PopContentViewController // First create our UI Control with the Table view if (_person == null) return; var taskAnsprechpartnern = BusinessLayer.Ansprechpartner.GetAnsprechpartnern(_person.ID, NSLocale.CurrentLocale.LanguageCode.ToUpper(),ref Application._user); var contentAnsprechpartner = new PopoverContentTaskAnsprechpartner(taskAnsprechpartnern); // Then the PopoverControl DetailViewPopover = new UIPopoverController(contentAnsprechpartner); DetailViewPopover.PopoverContentSize = new CGSize(320, 320); DetailViewPopover.PresentFromRect(tableView.CellAt(indexPath).Frame, View, UIPopoverArrowDirection.Any, true); // Pass a reference of the PopoverControl to the UI Control -> It needs this the control to close it when a row is selected contentAnsprechpartner._container = this; // Last but not least we need to handle the row that is selected break; case 1: // Deselect the row, so we can give full focus the TxtTaskText tableView.DeselectRow(indexPath, true); TxtTaskText.BecomeFirstResponder(); break; case 2: // Show all Types // Show the PopContentViewController // First create our UI Control with the Table view // get the data if (_taskTyps == null) _taskTyps = BusinessLayer.Task.GetTaskTyps(ref Application._user); var content = new PopoverContentTaskTypes(_taskTyps); // Then the PopoverControl DetailViewPopover = new UIPopoverController(content); DetailViewPopover.PopoverContentSize = new CGSize(320, 320); DetailViewPopover.PresentFromRect(tableView.CellAt(indexPath).Frame, View, UIPopoverArrowDirection.Any, true); // Pass a reference of the PopoverControl to the UI Control -> It needs this the control to close it when a row is selected content._container = this; // Last but not least we need to handle the row that is selected break; case 3: // Show all Arts // Show the PopContentViewController // First create our UI Control with the Table view if (_taskArts == null) _taskArts = BusinessLayer.Task.GetTaskArts(ref Application._user); var contentArt = new PopoverContentTaskArt(_taskArts); // Then the PopoverControl DetailViewPopover = new UIPopoverController(contentArt); DetailViewPopover.PopoverContentSize = new CGSize(320, 320); DetailViewPopover.PresentFromRect(tableView.CellAt(indexPath).Frame, View, UIPopoverArrowDirection.Any, true); // Pass a reference of the PopoverControl to the UI Control -> It needs this the control to close it when a row is selected contentArt._container = this; // Last but not least we need to handle the row that is selected break; case 4: // Show all Status // Show the PopContentViewController // First create our UI Control with the Table view List<string> statusList = new List<string>(); statusList.Add("0"); statusList.Add("1"); var contentStatus = new PopoverContentTaskStatus(statusList); // Then the PopoverControl DetailViewPopover = new UIPopoverController(contentStatus); DetailViewPopover.PopoverContentSize = new CGSize(320, 100); DetailViewPopover.PresentFromRect(tableView.CellAt(indexPath).Frame, View, UIPopoverArrowDirection.Any, true); // Pass a reference of the PopoverControl to the UI Control -> It needs this the control to close it when a row is selected contentStatus._container = this; // Last but not least we need to handle the row that is selected break; case 5: // Show TelefonStart // Show User and Abteilung // Show the PopContentViewController // First create our UI Control with the Table view var taskMitarbeitern = BusinessLayer.Task.GetMitarbeitern(ref Application._user); var contentMitarbeiter = new PopoverContentTaskMitarbeiterAbteilung(taskMitarbeitern); // Then the PopoverControl DetailViewPopover = new UIPopoverController(contentMitarbeiter); DetailViewPopover.PopoverContentSize = new CGSize(320, 320); DetailViewPopover.PresentFromRect(tableView.CellAt(indexPath).Frame, View, UIPopoverArrowDirection.Any, true); // Pass a reference of the PopoverControl to the UI Control -> It needs this the control to close it when a row is selected contentMitarbeiter._container = this; // Last but not least we need to handle the row that is selected break; case 6: // Show Date and Time // Run the DateTime popover control and set this object as an observer DateTime dt; if (TxtTaskDate.Text.Trim() != "") { dt = Convert.ToDateTime(TxtTaskDate.Text + " " + TxtTaskTime.Text + ":00"); } else dt = DateTime.Now; _popoverContentDate = new PopoverContentDateTime(this); _popoverContentDate.Initialize(tableView.CellAt(indexPath).Frame, this.View, UIDatePickerMode.DateAndTime, dt); break; case 7: // Show TelefonDauer break; } } }
void OnActionSheetDismissed(UIActionSheet sheet, int buttonIndex) { sheet.Dispose (); picker = null; if (buttonIndex == -1) return; CancelPhotoTask (); switch (buttons[buttonIndex]) { case PhotoResponse.ChoosePhoto: picker = new AircraftPhotoPickerController (); picker.Delegate = new AircraftPhotoPickerDelegate (this); picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary; picker.AllowsEditing = true; break; case PhotoResponse.CapturePhoto: picker = new AircraftPhotoPickerController (); picker.Delegate = new AircraftPhotoPickerDelegate (this); picker.SourceType = UIImagePickerControllerSourceType.Camera; picker.CameraDevice = UIImagePickerControllerCameraDevice.Rear; picker.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo; picker.CameraFlashMode = UIImagePickerControllerCameraFlashMode.Auto; picker.ShowsCameraControls = true; picker.AllowsEditing = true; break; case PhotoResponse.FlightAware: FetchPhotograph (true); break; case PhotoResponse.UnsetPhoto: Photograph = null; break; } if (picker != null) { popover = new UIPopoverController (picker); popover.DidDismiss += OnPopoverDismissed; popover.PresentFromRect (PhotoRect, this, UIPopoverArrowDirection.Any, true); } }
public void showEditor(UIView fromView) { CustomerInformationViewController customerSearch; popover = new UIPopoverController (new UINavigationController (customerSearch = new CustomerInformationViewController { Customer = Invoice.Customer, Created = (c) => { Invoice.Customer = c; popover.Dismiss (true); popover.Dispose (); } }) { NavigationBar = { BarStyle = UIBarStyle.BlackTranslucent, } }); customerSearch.Popover = popover; popover.PresentFromRect (fromView.Frame, tableView, UIPopoverArrowDirection.Right, true); }