void HandleImagePickerControllerCanceled(object sender, EventArgs e) { UIApplication.SharedApplication.InvokeOnMainThread(delegate { SystemLogger.Log(SystemLogger.Module.PLATFORM, "Canceled picking image "); if (popover != null && popover.PopoverVisible) { popover.Dismiss(true); popover.Dispose(); } else { IPhoneServiceLocator.CurrentDelegate.MainUIViewController().DismissModalViewControllerAnimated(true); } }); }
void HandleSearchButtonTouchUpInside(object sender, EventArgs args) { HidePopovers(); // psc if (psc == null) { psc = new PopoverSearchController(searchString); psc.RowSelectedEvent += HandleSearchResultSelectedEvent; psc.ResizePopoverEvent += (nfloat height) => { // Do not cover the TabBar nfloat viewHeight = this.View.Frame.Height - 55; if (height > viewHeight) { height = viewHeight - 20; } psc.PreferredContentSize = new CGSize(psc.View.Frame.Width, height); }; } // searchViewController searchViewController = new UIPopoverController(psc); searchViewController.DidDismiss += delegate { searchString = psc.SearchDisplayController.SearchBar.Text; searchViewController.Dispose(); searchViewController = null; }; searchViewController.SetPopoverContentSize(new CGSize(psc.View.Frame.Width, psc.View.Frame.Height), true); searchViewController.PresentFromBarButtonItem(searchButton, UIPopoverArrowDirection.Any, true); }
void HandleImagePickerControllerCanceled(object sender, EventArgs e) { UIApplication.SharedApplication.InvokeOnMainThread(delegate { SystemLogger.Log(SystemLogger.Module.PLATFORM, "Canceled picking image "); IPhoneUtils.GetInstance().FireUnityJavascriptEvent("Appverse.Media.onFinishedPickingImage", null); if (popover != null && popover.PopoverVisible) { popover.Dismiss(true); popover.Dispose(); } else { IPhoneServiceLocator.CurrentDelegate.MainUIViewController().DismissModalViewController(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(); } }
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 OnPopoverDismissed(object sender, EventArgs args) { popover.Dispose(); popover = null; picker.Dispose(); picker = null; }
public void NewObjectDispose() { if (_device != UIUserInterfaceIdiom.Pad) { Assert.Inconclusive("Not running on iPad!"); return; } var obj = new UIPopoverController(_controller); obj.Dispose(); }
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); }
private Task <MediaFile> GetMediaAsync(UIImagePickerControllerSourceType sourceType, string mediaType, StoreCameraMediaOptions options = null) { var viewController = FindRootViewController(); var ndelegate = new MediaPickerDelegate(viewController, sourceType, options); var od = Interlocked.CompareExchange(ref pickerDelegate, ndelegate, null); if (od != null) { throw new InvalidOperationException("Only one operation can be active at at time"); } MediaPickerController picker; if (mediaType == TypeAll) { picker = SetupCameraController(ndelegate, (StoreVideoOptions)options); } else { picker = SetupController(ndelegate, sourceType, mediaType, options); } if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && sourceType == UIImagePickerControllerSourceType.PhotoLibrary) { ndelegate.Popover = popover = new UIPopoverController(picker); ndelegate.Popover.Delegate = new MediaPickerPopoverDelegate(ndelegate, picker); ndelegate.DisplayPopover(); } else { if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0)) { picker.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; } viewController.PresentViewController(picker, true, null); } return(ndelegate.Task.ContinueWith(t => { if (popover != null) { popover.Dispose(); popover = null; } Interlocked.Exchange(ref pickerDelegate, null); picker.Dispose(); return t; }).Unwrap()); }
private void Dismiss(UIPopoverController popover, UIViewController picker) { if (popover != null) { popover.Dispose(); popover = null; } try { picker?.Dispose(); } catch { } Interlocked.Exchange(ref pickerDelegate, null); }
void Dismiss(UIPopoverController popover, UIViewController picker) { if (popover != null) { popover.Dispose(); popover = null; } try { picker?.Dispose(); } catch { } GC.Collect(GC.MaxGeneration, GCCollectionMode.Default); Interlocked.Exchange(ref pickerDelegate, null); }
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { picker = new DatePickerController(DateValue); popover = new UIPopoverController(new UINavigationController(picker)); picker.ContentSizeForViewInPopover = DatePickerSize; 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 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 HandleContentSyncErrorButtonTouchUpInside(object sender, EventArgs args) { HidePopovers(); //popoverContentSyncViewController var popover = new PopoverContentSyncViewController(); popover.SyncButtonTouch += HandleSyncButtonTouchEvent; popover.View.Frame = new CGRect(0, 0, 300, 190); // contentSyncViewController contentSyncViewController = new UIPopoverController(popover); contentSyncViewController.DidDismiss += delegate { contentSyncViewController.Dispose(); contentSyncViewController = null; }; contentSyncViewController.SetPopoverContentSize(new CGSize(popover.View.Frame.Width, popover.View.Frame.Height), true); contentSyncViewController.PresentFromBarButtonItem(contentSyncErrorButton, UIPopoverArrowDirection.Any, true); }
void HandleSettingButtonTouchUpInside(object sender, EventArgs args) { HidePopovers(); // psc PopoverSettingController psc = new PopoverSettingController(UITableViewStyle.Grouped); psc.View.Frame = new CGRect(0, 0, 300, 444); psc.RowSelectedEvent += HandleSettingRowSelectedEvent; psc.SyncOnEvent += HandleSyncOnEvent; psc.SyncOffEvent += HandleSyncOffEvent; // settingViewController settingViewController = new UIPopoverController(psc); settingViewController.DidDismiss += delegate { settingViewController.Dispose(); settingViewController = null; }; settingViewController.SetPopoverContentSize(new CGSize(psc.View.Frame.Width, psc.View.Frame.Height), true); settingViewController.PresentFromBarButtonItem(settingButton, UIPopoverArrowDirection.Any, true); }
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)); }
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; //CGRect frame = new CGRect(new PointF(0,0),new SizeF(view.Frame.Size.Width, view.Frame.Size.Height)); CGRect frame = new CGRect(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 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 Task <MediaFile> GetMediaAsync(UIImagePickerControllerSourceType sourceType, string mediaType, StoreCameraMediaOptions options = null) { UIViewController viewController = null; UIWindow window = UIApplication.SharedApplication.KeyWindow; if (window == null) { throw new InvalidOperationException("There's no current active window"); } if (window.WindowLevel == UIWindowLevel.Normal) { viewController = window.RootViewController; } if (viewController == null) { window = UIApplication.SharedApplication.Windows.OrderByDescending(w => w.WindowLevel).FirstOrDefault(w => w.RootViewController != null && w.WindowLevel == UIWindowLevel.Normal); if (window == null) { throw new InvalidOperationException("Could not find current view controller"); } else { viewController = window.RootViewController; } } while (viewController.PresentedViewController != null) { viewController = viewController.PresentedViewController; } MediaPickerDelegate ndelegate = new MediaPickerDelegate(viewController, sourceType, options); var od = Interlocked.CompareExchange(ref pickerDelegate, ndelegate, null); if (od != null) { throw new InvalidOperationException("Only one operation can be active at at time"); } var picker = SetupController(ndelegate, sourceType, mediaType, options); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && sourceType == UIImagePickerControllerSourceType.PhotoLibrary) { ndelegate.Popover = popover = new UIPopoverController(picker); ndelegate.Popover.Delegate = new MediaPickerPopoverDelegate(ndelegate, picker); ndelegate.DisplayPopover(); } else { if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0)) { picker.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; } viewController.PresentViewController(picker, true, null); } return(ndelegate.Task.ContinueWith(t => { if (popover != null) { popover.Dispose(); popover = null; } Interlocked.Exchange(ref pickerDelegate, null); picker.Dispose(); return t; }).Unwrap()); }
public InvoiceViewController () { SetTitle (); Settings.Shared.SubscribeToProperty ("TestMode", SetTitle); var searchBar = new ItemSearchView{ Frame = new System.Drawing.RectangleF (0, 0, 200, 30) }; searchBar.ItemSelected += (Item obj) => { Invoice.AddItem (obj); }; NavigationItem.RightBarButtonItem = new UIBarButtonItem (searchBar); NavigationItem.LeftBarButtonItem = new UIBarButtonItem (UIImage.FromBundle ("menu").ImageWithRenderingMode (UIImageRenderingMode.AlwaysTemplate), UIBarButtonItemStyle.Plain, (s, e) => { //Show simple actionsheet if (sheet != null) { sheet.DismissWithClickedButtonIndex (-1, true); return; } sheet = new SimpleActionSheet { {"New Invoice",async() =>{ if(await AskSave()) NewInvoice(); } }, {"Load Invoice",() => { if(popover != null) { popover.Dismiss(true); } popover = new UIPopoverController(new UINavigationController(new LoadInvoiceViewController(){ InvoiceSelected = async (i) =>{ popover.Dismiss(true); try{ BigTed.BTProgressHUD.ShowContinuousProgress(); if(Invoice != null && Invoice.Id != i.Id) { if(!await AskSave()) return; } Invoice.DeleteLocal(); Invoice = await WebService.Main.GetInvoice(i.Id); Invoice.Save(true); } catch(Exception ex) { Console.WriteLine(ex); } finally{ BigTed.BTProgressHUD.Dismiss(); } }, })); popover.DidDismiss += (sender, evt) => { popover.Dispose(); }; popover.PresentFromBarButtonItem(NavigationItem.LeftBarButtonItem, UIPopoverArrowDirection.Any,true); } }, {"Payout Buy",() => { if(popover != null) { popover.Dismiss(true); } popover = new UIPopoverController(new UINavigationController(new LoadBuyPayoutViewController(){ InvoiceSelected = async (i) =>{ popover.Dismiss(true); try{ BigTed.BTProgressHUD.ShowContinuousProgress(); if(Invoice != null && Invoice.Id != i.Id) { if(!await AskSave()) return; } Invoice.DeleteLocal(); Invoice = await WebService.Main.GetInvoice(i.Id); //Setup payments Database.Main.Table<PaymentType> ().Where (x => x.IsActive) .OrderBy (X => X.SortOrder).ToList ().ForEach (x => Invoice.Payments.Add (new Payment{ PaymentType = x })); Invoice.Save(true); if((i as BuyInvoice).IsOnAccount) Invoice.OnAccountPayment.Amount = Invoice.Total; else Invoice.CashPayment.Amount = Invoice.Total; } catch(Exception ex) { Console.WriteLine(ex); } finally{ BigTed.BTProgressHUD.Dismiss(); } }, })); popover.DidDismiss += (sender, evt) => { popover.Dispose(); }; popover.PresentFromBarButtonItem(NavigationItem.LeftBarButtonItem, UIPopoverArrowDirection.Any,true); } }, {"Settings",() => this.PresentViewControllerAsync (new UINavigationController (new SettingsViewController ()), true)}, }; sheet.Dismissed += (object sender, UIButtonEventArgs e2) => { sheet.Dispose (); sheet = null; }; sheet.ShowFrom (s as UIBarButtonItem, true); }); //this.AutomaticallyAdjustsScrollViewInsets = false; }
/// <summary> /// Gets the media asynchronous. /// </summary> /// <param name="sourceType">Type of the source.</param> /// <param name="mediaType">Type of the media.</param> /// <param name="options">The options.</param> /// <returns>Task<MediaFile>.</returns> /// <exception cref="InvalidOperationException"> /// There's no current active window /// or /// Could not find current view controller /// or /// Only one operation can be active at at time /// </exception> private Task <MediaFile> GetMediaAsync( UIImagePickerControllerSourceType sourceType, string mediaType, MediaStorageOptions options = null) { var window = UIApplication.SharedApplication.KeyWindow; if (window == null) { throw new InvalidOperationException("There's no current active window"); } var viewController = window.RootViewController; #if __IOS_10__ if (viewController == null || (viewController.PresentedViewController != null && viewController.PresentedViewController.GetType() == typeof(UIAlertController))) { window = UIApplication.SharedApplication.Windows.OrderByDescending(w => w.WindowLevel) .FirstOrDefault(w => w.RootViewController != null); if (window == null) { throw new InvalidOperationException("Could not find current view controller"); } viewController = window.RootViewController; } #endif while (viewController.PresentedViewController != null) { viewController = viewController.PresentedViewController; } var ndelegate = new MediaPickerDelegate(viewController, sourceType, options); var od = Interlocked.CompareExchange(ref _pickerDelegate, ndelegate, null); if (od != null) { throw new InvalidOperationException("Only one operation can be active at at time"); } var picker = SetupController(ndelegate, sourceType, mediaType, options); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && sourceType == UIImagePickerControllerSourceType.PhotoLibrary) { ndelegate.Popover = new UIPopoverController(picker) { Delegate = new MediaPickerPopoverDelegate(ndelegate, picker) }; ndelegate.DisplayPopover(); } else { viewController.PresentViewController(picker, true, null); } return(ndelegate.Task.ContinueWith( t => { if (_popover != null) { _popover.Dispose(); _popover = null; } Interlocked.Exchange(ref _pickerDelegate, null); return t; }).Unwrap()); }
private Task <MediaFile> GetMediaAsync(UIImagePickerControllerSourceType sourceType, string mediaType, StoreCameraMediaOptions options = null, CancellationToken token = default(CancellationToken)) { UIViewController viewController = null; UIWindow window = UIApplication.SharedApplication.KeyWindow; if (window == null) { throw new InvalidOperationException("There's no current active window"); } if (window.WindowLevel == UIWindowLevel.Normal) { viewController = window.RootViewController; } if (viewController == null) { window = UIApplication.SharedApplication.Windows.OrderByDescending(w => w.WindowLevel).FirstOrDefault(w => w.RootViewController != null && w.WindowLevel == UIWindowLevel.Normal); if (window == null) { throw new InvalidOperationException("Could not find current view controller"); } else { viewController = window.RootViewController; } } while (viewController.PresentedViewController != null) { viewController = viewController.PresentedViewController; } if (token.IsCancellationRequested) { return(Task.FromResult((MediaFile)null)); } MediaPickerDelegate ndelegate = new MediaPickerDelegate(viewController, sourceType, options, token); var od = Interlocked.CompareExchange(ref pickerDelegate, ndelegate, null); if (od != null) { throw new InvalidOperationException("Only one operation can be active at a time"); } var picker = SetupController(ndelegate, sourceType, mediaType, options); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && sourceType == UIImagePickerControllerSourceType.PhotoLibrary) { ndelegate.Popover = popover = new UIPopoverController(picker); ndelegate.Popover.Delegate = new MediaPickerPopoverDelegate(ndelegate, picker); ndelegate.DisplayPopover(); token.Register(() => { if (popover == null) { return; } NSRunLoop.Main.BeginInvokeOnMainThread(() => { ndelegate.Popover.Dismiss(true); ndelegate.CancelTask(); }); }); } else { if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0)) { picker.ModalPresentationStyle = options?.ModalPresentationStyle == MediaPickerModalPresentationStyle.OverFullScreen ? UIModalPresentationStyle.OverFullScreen : UIModalPresentationStyle.FullScreen; } viewController.PresentViewController(picker, true, null); token.Register(() => { if (picker == null) { return; } NSRunLoop.Main.BeginInvokeOnMainThread(() => { picker.DismissModalViewController(true); ndelegate.CancelTask(); }); }); } return(ndelegate.Task.ContinueWith(t => { try { popover?.Dispose(); } catch { } popover = null; Interlocked.Exchange(ref pickerDelegate, null); try { picker?.Dispose(); } catch { } picker = null; return t; }).Unwrap()); }
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 HandleSettingRowSelectedEvent(NSIndexPath indexPath) { if (indexPath.Section == 0) { if (indexPath.Row == 0) { HidePopovers(); settingViewController.Dispose(); settingViewController = null; // Server Setting OpenSelectServer(); } } else { HidePopovers(); if (indexPath.Row == 0) { // About eBriefing CustomNavigationController navController = new CustomNavigationController(); navController.NavigationBar.TintColor = UIColor.White; navController.SetViewControllers(new UIViewController[] { new AboutViewController() }, false); AppDelegate.Current.Nav.PresentViewController(navController, true, null); } else if (indexPath.Row == 1) { // Tutorial ShowTutorial(true, false, true); } // else if (indexPath.Row == 2) // { // // Privacy Policy // PrivacyPolicyViewController ppvc = new PrivacyPolicyViewController(); // ppvc.DismissEvent += delegate // { // this.DismissCurrentPopinControllerAnimated(true); // }; // ppvc.View.Frame = new CGRect(0, 0, 646, 600); // ppvc.SetPopinTransitionStyle(BKTPopinTransitionStyle.SpringySlide); // ppvc.SetPopinOptions(BKTPopinOption.Default); // ppvc.SetPopinTransitionDirection(BKTPopinTransitionDirection.Top); // this.PresentPopinController(ppvc, true, null); // } else if (indexPath.Row == 2) { if (MFMailComposeViewController.CanSendMail) { // Give Feedback mailer = new EmailComposer(); mailer.Recipient = "*****@*****.**"; mailer.Subject = "eBriefing Feedback (iOS)"; mailer.Body = "eBriefing App Version: " + Settings.AppVersion + "\niOS Version: " + Constants.Version + "\niOS Device: " + UIDevice.CurrentDevice.Model + "\n\nDescription of Problem, Concern, or Question:"; mailer.PresentViewController(this); } else { new UIAlertView("No mail account", "Please set up a Mail account in order to send a mail.", null, "Ok", null).Show(); } } else { // Rate This App MTiRate.iRate.SharedInstance.PromptForRating(); } } }
private static async Task <DropDownListSelection <TItem> > ShowInternal <TSection, TItem>( UIView containerView, object anchorUIElement, UITableViewCellStyle itemStyle, UITableViewStyle headerStyle, IEnumerable <TSection> sections, Func <TSection, GenericTableViewSection <TItem> > sectionDescriber, Func <TItem, GenericCellDescriptor> itemDescriber, UIPopoverArrowDirection arrowDirection, CGSize?fitSize ) where TSection : IEnumerable <TItem> { if (anchorUIElement == null) { throw new ArgumentNullException("anchorView"); } if (!(anchorUIElement is UIView || anchorUIElement is UIBarButtonItem)) { throw new ArgumentOutOfRangeException("anchorView", "Must be a UIView or a UIBarButtonItem"); } var sectionsArray = sections.Select(sectionDescriber).ToArray(); if (sectionsArray.Count() == 1 && string.IsNullOrWhiteSpace(sectionsArray.First().Title)) { headerStyle = UITableViewStyle.Plain; } var selectSignal = new ManualResetEventSlim(); var table = new UITableViewController(headerStyle); table.AutomaticallyAdjustsScrollViewInsets = false; var result = new DropDownListSelection <TItem>(); var popOverController = new UIPopoverController(table); var dropDownSource = new GenericTableViewSource <TItem>( table.TableView, itemStyle, sectionsArray, itemDescriber, (x) => { result.SelectedItem = x; popOverController.Dismiss(false); selectSignal.Set(); } ); popOverController.DidDismiss += (object sender, EventArgs e) => { if (!selectSignal.IsSet) { selectSignal.Set(); } }; ((UITableView)table.View).Source = dropDownSource; // Calculate how wide the view should be by finding how if (fitSize == null) { // calculate the fit size var tableView = (UITableView)table.View; nfloat largestWidth = 0.0f; var sectionHeight = (headerStyle == UITableViewStyle.Plain ? (float)tableView.SectionHeaderHeight : Tools.iOSTool.DefaultGroupedTableViewHeaderHeight); nfloat totalHeight = sectionHeight * sectionsArray.Count(s => !string.IsNullOrWhiteSpace(s.Title)); foreach (var section in sectionsArray) { foreach (var itemDescriptor in ((IEnumerable <TItem>)section.Items).WithDescriptions()) { var index = itemDescriptor.Index; var item = itemDescriptor.Description; var cellSize = (CGSize)dropDownSource.GetCell(tableView, (NSIndexPath)(NSIndexPath.FromRowSection(index, 0))).SizeThatFits((CGSize)CGSize.Empty); if (cellSize.Width > largestWidth) { largestWidth = cellSize.Width; } totalHeight += cellSize.Height; } } fitSize = new CGSize(largestWidth + ItemPadding, totalHeight); } popOverController.SetPopoverContentSize(fitSize.Value, false); TypeSwitch.Do( anchorUIElement, TypeSwitch.Case <UIBarButtonItem>(bbi => popOverController.PresentFromBarButtonItem( (UIBarButtonItem)anchorUIElement, arrowDirection, true ) ), TypeSwitch.Case <UIView>(v => popOverController.PresentFromRect( ((UIView)anchorUIElement).Frame, containerView, arrowDirection, true ) ), TypeSwitch.Case <UITabBarItem>(tb => { var tabBar = containerView as UITabBar; if (tabBar == null) { throw new ArgumentException("Container view must be an UITabBar when the anchor view is an UITabBarItem"); } if (!tabBar.Items.Contains(tb)) { throw new ArgumentException("Container view UITabBar does not contain the anchor view UITabBarItem"); } var index = tabBar.Items.IndexOf(tb); var tabBarItemWidth = tabBar.Frame.Size.Width / tabBar.Items.Count(); var rect = new CGRect(tabBarItemWidth * index, 0f, tabBarItemWidth, tabBar.Frame.Height); popOverController.PresentFromRect( rect, tabBar, arrowDirection, true ); }), TypeSwitch.Default(() => { throw new NotSupportedException("anchorUIElement was {0}".FormatWith(anchorUIElement.GetType().Name)); }) ); await Task.Run(() => selectSignal.Wait()); table.View.DisposeEx(); table.TableView.DisposeEx(); table.Dispose(); popOverController.Dispose(); return(result); }
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); }, }), }; }
public InvoiceViewController() { SetTitle(); Settings.Shared.SubscribeToProperty("TestMode", SetTitle); var searchBar = new ItemSearchView { Frame = new System.Drawing.RectangleF(0, 0, 200, 30) }; searchBar.ItemSelected += (Item obj) => { Invoice.AddItem(obj); }; NavigationItem.RightBarButtonItem = new UIBarButtonItem(searchBar); NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIImage.FromBundle("menu").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIBarButtonItemStyle.Plain, (s, e) => { //Show simple actionsheet if (sheet != null) { sheet.DismissWithClickedButtonIndex(-1, true); return; } sheet = new SimpleActionSheet { { "New Invoice", async() => { if (await AskSave()) { NewInvoice(); } } }, { "Load Invoice", () => { if (popover != null) { popover.Dismiss(true); } popover = new UIPopoverController(new UINavigationController(new LoadInvoiceViewController() { InvoiceSelected = async(i) => { popover.Dismiss(true); try{ BigTed.BTProgressHUD.ShowContinuousProgress(); if (Invoice != null && Invoice.Id != i.Id) { if (!await AskSave()) { return; } } Invoice.DeleteLocal(); Invoice = await WebService.Main.GetInvoice(i.Id); Invoice.Save(true); } catch (Exception ex) { Console.WriteLine(ex); } finally{ BigTed.BTProgressHUD.Dismiss(); } }, })); popover.DidDismiss += (sender, evt) => { popover.Dispose(); }; popover.PresentFromBarButtonItem(NavigationItem.LeftBarButtonItem, UIPopoverArrowDirection.Any, true); } }, { "Payout Buy", () => { if (popover != null) { popover.Dismiss(true); } popover = new UIPopoverController(new UINavigationController(new LoadBuyPayoutViewController() { InvoiceSelected = async(i) => { popover.Dismiss(true); try{ BigTed.BTProgressHUD.ShowContinuousProgress(); if (Invoice != null && Invoice.Id != i.Id) { if (!await AskSave()) { return; } } Invoice.DeleteLocal(); Invoice = await WebService.Main.GetInvoice(i.Id); //Setup payments Database.Main.Table <PaymentType> ().Where(x => x.IsActive) .OrderBy(X => X.SortOrder).ToList().ForEach(x => Invoice.Payments.Add(new Payment { PaymentType = x })); Invoice.Save(true); if ((i as BuyInvoice).IsOnAccount) { Invoice.OnAccountPayment.Amount = Invoice.Total; } else { Invoice.CashPayment.Amount = Invoice.Total; } } catch (Exception ex) { Console.WriteLine(ex); } finally{ BigTed.BTProgressHUD.Dismiss(); } }, })); popover.DidDismiss += (sender, evt) => { popover.Dispose(); }; popover.PresentFromBarButtonItem(NavigationItem.LeftBarButtonItem, UIPopoverArrowDirection.Any, true); } }, { "Settings", () => this.PresentViewControllerAsync(new UINavigationController(new SettingsViewController()), true) }, }; sheet.Dismissed += (object sender, UIButtonEventArgs e2) => { sheet.Dispose(); sheet = null; }; sheet.ShowFrom(s as UIBarButtonItem, true); }); //this.AutomaticallyAdjustsScrollViewInsets = false; }
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { picker = new DatePickerController (DateValue); popover = new UIPopoverController (new UINavigationController (picker)); picker.ContentSizeForViewInPopover = DatePickerSize; 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); }