private void DoTransition(UIViewController fromViewController, IBaseViewModel fromViewModel, UIViewController toViewController, IBaseViewModel toViewModel)
        {
            var toViewDismissCommand = toViewModel.DismissCommand;

//            if (toViewController is SettingsViewController)
//            {
//                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(CodeFramework.iOS.Images.Cancel, UIBarButtonItemStyle.Plain, (s, e) => toViewDismissCommand.ExecuteIfCan());
//                toViewDismissCommand.Subscribe(__ => toViewController.DismissViewController(true, null));
//                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
//            }
            if (toViewController is AccountsView)
            {
                var rootNav = (UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController;
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(Images.Cancel, UIBarButtonItemStyle.Plain, (s, e) => toViewDismissCommand.ExecuteIfCan());
                toViewDismissCommand.Subscribe(_ => rootNav.DismissViewController(true, null));
                rootNav.PresentViewController(new UINavigationController(toViewController), true, null);
            }
//            else if (fromViewController is RepositoriesViewController)
//            {
//                fromViewController.NavigationController.PresentViewController(toViewController, true, null);
//            }
            else if (toViewController is MenuView)
            {
                var nav = ((UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController);
                var slideout = new SlideoutNavigationController();
                slideout.MenuViewController = new MenuNavigationController(toViewController, slideout);
                UIView.Transition(nav.View, 0.1, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.TransitionCrossDissolve,
                    () => nav.PushViewController(slideout, false), null);
            }
            else if (toViewController is NewAccountView && fromViewController is StartupView)
            {
                toViewDismissCommand.Subscribe(_ => toViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (fromViewController is MenuView)
            {
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
            else if (toViewController is LanguagesView && fromViewController is RepositoriesTrendingView)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                var ctrlToPresent = new UINavigationController(toViewController);
                ctrlToPresent.TransitioningDelegate = new SlideDownTransition();
                fromViewController.PresentViewController(ctrlToPresent, true, null);
            }
            else
            {
                toViewDismissCommand.Subscribe(_ => toViewController.NavigationController.PopToViewController(fromViewController, true));
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
        }
        private static void DoTransition(UIViewController fromViewController, IBaseViewModel fromViewModel,
            UIViewController toViewController, IBaseViewModel toViewModel)
        {
            var toViewDismissCommand = toViewModel.DismissCommand;

            if (toViewController is LoginViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is MainViewController)
            {
                var nav = ((UINavigationController)UIApplication.SharedApplication.Delegate.GetWindow().RootViewController);
                UIView.Transition(nav.View, 0.6f,
                    UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.TransitionCrossDissolve,
                    () => nav.PushViewController(toViewController, false), null);
            }
            else if (toViewController is AddInterestViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is StumbleViewController || toViewController is RepositoryViewController ||
                     toViewController is StumbledRepositoryViewController || toViewController is SettingsViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is LanguagesViewController && fromViewController is TrendingViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                var ctrlToPresent = new UINavigationController(toViewController);
                ctrlToPresent.TransitioningDelegate = new SlideDownTransition();
                fromViewController.PresentViewController(ctrlToPresent, true, null);
            }
            else if (toViewController is PurchaseProViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(toViewController, true, null);
            }
            else
            {
                toViewDismissCommand.Subscribe(
                    _ => toViewController.NavigationController.PopToViewController(fromViewController, true));
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
        }
Example #3
0
		public static void SelectPicture (UIViewController parent, Action<NSDictionary> callback)
		{
			Init ();
			picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
			_callback = callback;
			parent.PresentViewController (picker, true, null);
		}
 public static void TakePicture(UIViewController parent, Action<NSDictionary> callback)
 {
     Init();
     picker.SourceType = UIImagePickerControllerSourceType.Camera;
     _callback = callback;
     parent.PresentViewController((UIViewController)picker, true, (Action)null);
 }
		/// <summary>
		/// Presents an alert with an OK and a Cancel button.
		/// </summary>
		/// <returns>The <c>UIAlertController</c> for the alert.</returns>
		/// <param name="title">The alert's title.</param>
		/// <param name="description">The alert's Description.</param>
		/// <param name="controller">The Vinew Controller that will present the alert.</param>
		/// <param name="action">The <c>AlertOKCancelDelegate</c> use to respond to the user's action.</param>
		public static UIAlertController PresentOKCancelAlert(string title, string description, UIViewController controller, AlertOKCancelDelegate action) {
			// No, inform the user that they must create a home first
			UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert);

			// Add cancel button
			alert.AddAction(UIAlertAction.Create("Cancel",UIAlertActionStyle.Cancel,(actionCancel) => {
				// Any action?
				if (action!=null) {
					action(false);
				}
			}));

			// Add ok button
			alert.AddAction(UIAlertAction.Create("OK",UIAlertActionStyle.Default,(actionOK) => {
				// Any action?
				if (action!=null) {
					action(true);
				}
			}));

			// Display the alert
			controller.PresentViewController(alert,true,null);

			// Return created controller
			return alert;
		}
        /// <summary>
        /// Shows the crop view and wait for the user's input.
        /// </summary>
        /// <returns>Returns a byte array of the cropped photo or throws an OperationCancelledException if the user cancelled.</returns>
        /// <param name="rootViewController">Root view controller.</param>
        /// <param name="isAnimated">If set to <c>true</c> is animated.</param>
        /// <param name="completionHandler">Completion handler.</param>
        /// <exception cref="System.OperationCanceledException">Thrown when the user hits cancel</exception>
        public Task<byte[]> ShowCropViewAsync(UIViewController rootViewController, bool isAnimated, Action completionHandler)
        {
            var cropViewDelegate = new CropViewControllerDelegate();
            this.Delegate = cropViewDelegate;
            rootViewController.PresentViewController(this, isAnimated, completionHandler);

            return cropViewDelegate.GetResult();
        }
Example #7
0
		public static void Alert (UIViewController controller, string title, string message)
		{
			UIAlertAction action = UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null);
			UIAlertController alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);

			alert.Title = title;
			alert.Message = message;

			alert.AddAction(action);
			controller.PresentViewController(alert, true, null);
		}
Example #8
0
 public static GistCreateView Show(UIViewController parent)
 {
     var ctrl = new GistCreateView();
     var weakVm = new WeakReference<GistCreateViewModel>(ctrl.ViewModel);
     ctrl.ViewModel.SaveCommand.Subscribe(_ => parent.DismissViewController(true, null));
     ctrl.NavigationItem.LeftBarButtonItem = new UIBarButtonItem { Image = Images.Buttons.CancelButton };
     ctrl.NavigationItem.LeftBarButtonItem.GetClickedObservable().Subscribe(_ => {
         weakVm.Get()?.CancelCommand.Execute(null);
         parent.DismissViewController(true, null);
     });
     parent.PresentViewController(new ThemedNavigationController(ctrl), true, null);
     return ctrl;
 }
		/// <summary>
		/// Presents an alert containing only the OK button.
		/// </summary>
		/// <returns>The <c>UIAlertController</c> for the alert.</returns>
		/// <param name="title">The alert's title.</param>
		/// <param name="description">The alert's description.</param>
		/// <param name="controller">The View Controller that will present the alert.</param>
		public static UIAlertController PresentOKAlert(string title, string description, UIViewController controller) {
			// No, inform the user that they must create a home first
			UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert);

			// Configure the alert
			alert.AddAction(UIAlertAction.Create("OK",UIAlertActionStyle.Default,(action) => {}));

			// Display the alert
			controller.PresentViewController(alert,true,null);

			// Return created controller
			return alert;
		}
Example #10
0
        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 MessageForUser(
            UIViewController viewController,
            string messageText,
            string messageTitle,
            QuestionOptions questionType = QuestionOptions.OK,
            Action postiveAction = null,
            Action negativeAction = null
              )
        {
            if (negativeAction == null)
            {
                negativeAction = () => { };
            }

            if (postiveAction == null)
            {
                postiveAction = () => { };
            }
            var okCancelAlertController = UIAlertController.Create(messageTitle, messageText, UIAlertControllerStyle.Alert);

            switch (questionType)
            {
                case QuestionOptions.OK:
                    okCancelAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, alert => postiveAction()));
                    break;
                case QuestionOptions.OkCancel:
                    okCancelAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, alert => postiveAction()));
                    okCancelAlertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, alert => negativeAction()));

                    break;
                case QuestionOptions.YesNo:
                    okCancelAlertController.AddAction(UIAlertAction.Create("Yes", UIAlertActionStyle.Default, alert => postiveAction()));
                    okCancelAlertController.AddAction(UIAlertAction.Create("No", UIAlertActionStyle.Destructive, alert => negativeAction()));

                    break;
                default:
                    break;
            }

            //Present Alert
            viewController.PresentViewController(okCancelAlertController, true, null);
        }
Example #12
0
        public void Save(string filename, string contentType, MemoryStream stream)
        {
            string exception = string.Empty;
            string path      = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            string filePath  = Path.Combine(path, filename);

            try
            {
                FileStream fileStream = File.Open(filePath, FileMode.Create);
                stream.Position = 0;
                stream.CopyTo(fileStream);
                fileStream.Flush();
                fileStream.Close();
            }
            catch (Exception e)
            {
                exception = e.ToString();
            }
            if (contentType == "application/html" || exception != string.Empty)
            {
                return;
            }
            UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController;

            while (currentController.PresentedViewController != null)
            {
                currentController = currentController.PresentedViewController;
            }
            UIView currentView = currentController.View;

            QLPreviewController qlPreview = new QLPreviewController();
            QLPreviewItem       item      = new QLPreviewItemBundle(filename, filePath);

            qlPreview.DataSource = new PreviewControllerDS(item);

            //UIViewController uiView = currentView as UIViewController;

            currentController.PresentViewController((UIViewController)qlPreview, true, (Action)null);
        }
Example #13
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            viewController            = new UIViewController();
            window                    = new UIWindow();
            window.RootViewController = viewController;
            window.MakeKeyAndVisible();

            if (options != null)
            {
                // check for a local notification
                if (options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
                {
                    var localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
                    if (localNotification != null)
                    {
                        UIAlertController okayAlertController = UIAlertController.Create(localNotification.AlertAction, localNotification.AlertBody, UIAlertControllerStyle.Alert);
                        okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                        viewController.PresentViewController(okayAlertController, true, null);

                        // reset our badge
                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                    }
                }
            }

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
                    );
                UIApplication.SharedApplication.RegisterUserNotificationSettings(notificationSettings);
            }

            LoadApplication(new App());
            return(base.FinishedLaunching(app, options));
        }
Example #14
0
        // Based on MonoGame's Guide implementation for iOS
        private string ShowKeyboardInput(
            string defaultText)
        {
            OnKeyboardWillShow();

            IsVisible = true;
            EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);

            keyboardViewController = new KeyboardInputViewController(
                defaultText, gameViewController);

            UIApplication.SharedApplication.InvokeOnMainThread(delegate
            {
                gameViewController.PresentViewController(keyboardViewController, true, null);

                keyboardViewController.View.InputAccepted += (sender, e) =>
                {
                    gameViewController.DismissViewController(true, null);
                    ContentText = keyboardViewController.View.Text;
                    waitHandle.Set();
                    OnKeyboardWillHide();
                };

                keyboardViewController.View.InputCanceled += (sender, e) =>
                {
                    ContentText = null;
                    gameViewController.DismissViewController(true, null);
                    waitHandle.Set();
                    OnKeyboardWillHide();
                };
                OnKeyboardDidShow();
            });
            waitHandle.WaitOne();

            OnReplaceText(new CCIMEKeybardEventArgs(contentText, contentText.Length));
            IsVisible = false;
            return(contentText);
        }
Example #15
0
        public Task <bool> View(Stream stream, string filename)
        {
            try
            {
                string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

                string filePath = Path.Combine(path, filename);

                using (FileStream fileStream = File.Open(filePath, FileMode.Create))
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    stream.CopyTo(fileStream);
                }

                UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController;

                while (currentController.PresentedViewController != null)
                {
                    currentController = currentController.PresentedViewController;
                }

                UIView currentView = currentController.View;

                QLPreviewController qlPreview = new QLPreviewController();

                QLPreviewItem item = new QLPreviewItemBundle(filename, filePath);

                qlPreview.DataSource = new PreviewControllerDS(item);

                currentController.PresentViewController(qlPreview, true, null);

                return(Task.FromResult(true));
            }
            catch
            {
                return(Task.FromResult(false));
            }
        }
        public override Task <Result> Scan(MobileBarcodeScanningOptions options)
        {
            return(Task.Factory.StartNew(() => {
                try
                {
                    scanResultResetEvent.Reset();

                    Result result = null;

                    this.appController.InvokeOnMainThread(() => {
                        //viewController = new ZxingCameraViewController(options, this);
                        viewController = new ZXing.Mobile.ZXingScannerViewController(options, this);

                        viewController.OnScannedResult += barcodeResult => {
                            viewController.InvokeOnMainThread(() => {
                                viewController.Cancel();
                                viewController.DismissViewController(true, null);
                            });

                            result = barcodeResult;
                            scanResultResetEvent.Set();
                        };

                        appController.PresentViewController(viewController, true, null);
                    });

                    scanResultResetEvent.WaitOne();
                    viewController.Dispose();

                    return result;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    return null;
                }
            }));
        }
        public void GetRootViewController()
        {
            string path     = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string filePath = Path.Combine(path, filename);
            //Create a file and write the stream into it.
            FileStream fileStream = File.Open(filePath, FileMode.Create);

            stream.Position = 0;
            stream.CopyTo(fileStream);
            fileStream.Flush();
            fileStream.Close();
            var previewController = new QLPreviewController();

            previewController.DataSource = new QuickLookSource("file://" + filePath);
            UIViewController currentController =
                UIApplication.SharedApplication.KeyWindow.RootViewController;

            while (currentController.PresentedViewController != null)
            {
                currentController = currentController.PresentedViewController;
            }
            currentController.PresentViewController(previewController, true, null);
        }
Example #18
0
        public static bool CheckForLocationPermissionGranted(UIViewController vc)
        {
            if (vc == null)
            {
                return(false);
            }

            if (CoreLocation.CLLocationManager.Status != CoreLocation.CLAuthorizationStatus.AuthorizedAlways && CoreLocation.CLLocationManager.Status != CoreLocation.CLAuthorizationStatus.AuthorizedWhenInUse)
            {
                UIAlertController alertController = UIAlertController.Create(Strings.Basic.error, Strings.Permissions.location_disabled, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create(Strings.Basic.settings, UIAlertActionStyle.Default, delegate
                {
                    UIApplication.SharedApplication.OpenUrl(NSUrl.FromString(UIApplication.OpenSettingsUrlString));
                }));
                alertController.AddAction(UIAlertAction.Create(Strings.Basic.ok, UIAlertActionStyle.Cancel, delegate
                {
                    alertController.DismissViewController(true, null);
                }));
                vc.PresentViewController(alertController, true, null);
                return(false);
            }
            return(true);
        }
Example #19
0
        public Task <Stream> GetImageStreamAsync()
        {
            //Create and define UIImagePickerController
            _imagePicker = new UIImagePickerController()
            {
                SourceType = UIImagePickerControllerSourceType.PhotoLibrary,
                MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary)
            };

            //Set event handlers
            _imagePicker.FinishedPickingMedia += OnImagePickerFinishedPickingMedia;
            _imagePicker.Canceled             += OnImagePickerCancelled;

            //Present UIImagePickerController
            UIWindow         window         = UIApplication.SharedApplication.KeyWindow;
            UIViewController viewController = window.RootViewController;

            viewController.PresentViewController(_imagePicker, true, null);

            //Return task object
            _taskCompletionSource = new TaskCompletionSource <Stream>();
            return(_taskCompletionSource.Task);
        }
Example #20
0
        static void createActionSheet(UIViewController controller, string title, string subtitle, string[] options, EventHandler <Models.UIImageModel> imagePicked)
        {
            // Create a new Alert Controller
            UIAlertController actionSheetAlert = UIAlertController.Create(title, subtitle, UIAlertControllerStyle.ActionSheet);

            // Add Actions
            actionSheetAlert.AddAction(UIAlertAction.Create(options[0], UIAlertActionStyle.Default, (action) => takePhoto(controller, imagePicked)));
            actionSheetAlert.AddAction(UIAlertAction.Create(options[1], UIAlertActionStyle.Default, (action) => selectPhotoFromGallery(controller, imagePicked)));
            actionSheetAlert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (action) => Console.WriteLine("Cancel")));

            // Required for iPad - We must specify a source for the Action Sheet since it is
            // displayed as a popover
            UIPopoverPresentationController presentationPopover = actionSheetAlert.PopoverPresentationController;

            if (presentationPopover != null)
            {
                presentationPopover.SourceView = controller.View;
                presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up;
            }

            // Display the alert
            controller.PresentViewController(actionSheetAlert, true, null);
        }
Example #21
0
        public static void LikeRegistrationRequiredPrompt(UIViewController viewController, UIButton button)
        {
            var alert = UIAlertController.Create("The Like feature requires registration", "This feature will allow you to “Like” your favorite aircraft and write notes.\nWould you like to register now?", UIAlertControllerStyle.ActionSheet);

            alert.AddAction(UIAlertAction.Create("Not Yet", UIAlertActionStyle.Default, null));

            alert.AddAction(UIAlertAction.Create("Register Now", UIAlertActionStyle.Default,
                                                 (action) =>
            {
                FavoriteClassificationsViewController favClassificationsVC = new FavoriteClassificationsViewController(new AircraftGridLayout(viewController));

                viewController.ShowViewController(new UINavigationController(favClassificationsVC), viewController);
            }));



            if (alert.PopoverPresentationController != null)
            {
                alert.PopoverPresentationController.SourceView = button;
                alert.PopoverPresentationController.PermittedArrowDirections = UIPopoverArrowDirection.Up;
            }
            viewController.PresentViewController(alert, animated: true, completionHandler: null);
        }
        public static Task <SampleItem[]> GetSelectedItemsAsync(UIViewController viewController, SampleItem[] items,
                                                                bool allowMultipleSelection)
        {
            var storyboard = UIStoryboard.FromName("Main", null);
            var vc         = (SelectionViewController)storyboard.InstantiateViewController(nameof(SelectionViewController));

            vc._allowMultipleSelection = allowMultipleSelection;
            vc._tcs   = new TaskCompletionSource <SampleItem[]>();
            vc._items = items;
            var nav = new UINavigationController(vc)
            {
                ModalPresentationStyle = UIModalPresentationStyle.FullScreen
            };

            if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
            {
                nav.PresentationController.Delegate = new UIAdaptivePresentationController(vc._tcs);
            }

            viewController.PresentViewController(nav, true, null);

            return(vc._tcs.Task);
        }
Example #23
0
        //创建弹出窗口
        public static UIAlertController ShowMessageBox(this UIViewController viewController, string title, string content, UIAlertAction[] alertActions = null)
        {
            //创建弹出窗口
            UIAlertController alertController = UIAlertController.Create(title, content, UIAlertControllerStyle.Alert);

            //默认只有一个确定按钮
            if (alertActions == null)
            {
                alertActions = new UIAlertAction[] { UIAlertAction.Create("确定", UIAlertActionStyle.Default, null) }
            }
            ;

            //创建按钮
            foreach (UIAlertAction alertAction in alertActions)
            {
                alertController.AddAction(alertAction);
            }

            //显示弹出窗口
            viewController.PresentViewController(alertController, true, null);

            return(alertController);
        }
Example #24
0
        public static void SellerRegistrationRequiredSmallPrompt(UIViewController viewController, UIButton button)
        {
            var alert = UIAlertController.Create("The Order by feature requires registration", "This feature will order the inventory a seller has (example: All of the listings Jetcraft has). Would you like to register now?", UIAlertControllerStyle.ActionSheet);

            alert.AddAction(UIAlertAction.Create("Not Yet", UIAlertActionStyle.Default, null));

            alert.AddAction(UIAlertAction.Create("Register Now", UIAlertActionStyle.Default,
                                                 (action) =>
            {
                FavoriteClassificationsViewController favClassificationsVC = new FavoriteClassificationsViewController(new AircraftGridLayout(viewController));

                viewController.ShowViewController(new UINavigationController(favClassificationsVC), viewController);
            }));



            if (alert.PopoverPresentationController != null)
            {
                alert.PopoverPresentationController.SourceView = button;
                alert.PopoverPresentationController.PermittedArrowDirections = UIPopoverArrowDirection.Any;
            }
            viewController.PresentViewController(alert, animated: true, completionHandler: null);
        }
        public Task <string> GetVideoFileAsync()
        {
            // Create and define UIImagePickerController
            imagePicker = new UIImagePickerController
            {
                SourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum,
                MediaTypes = new string[] { "public.movie" }
            };

            // Set event handlers
            imagePicker.FinishedPickingMedia += OnImagePickerFinishedPickingMedia;
            imagePicker.Canceled             += OnImagePickerCancelled;

            // Present UIImagePickerController
            UIWindow         window         = UIApplication.SharedApplication.KeyWindow;
            UIViewController viewController = window.RootViewController;

            viewController.PresentViewController(imagePicker, true, null);

            // Return Task object
            taskCompletionSource = new TaskCompletionSource <string>();
            return(taskCompletionSource.Task);
        }
Example #26
0
        public System.Threading.Tasks.Task <ScanResult> ScanAsync()
        {
            UIViewController root = UIApplication.SharedApplication.KeyWindow.RootViewController;

            TaskCompletionSource <ScanResult> tcs = new TaskCompletionSource <ScanResult> ();

            var picker = new SIBarcodePicker(licenseKey);

            picker.OverlayController.ShowToolBar(true);
            picker.OverlayController.SetToolBarButtonCaption(cancelText);

            picker.OverlayController.Delegate = new PickerDelegate()
            {
                Picker     = picker,
                Completion = tcs
            };

            root.PresentViewController((UIViewController)picker, true, (Action)null);

            picker.StartScanning();

            return(tcs.Task);
        }
Example #27
0
        private static void Share(UIViewController presentingViewController, string toShare)
        {
            var item = new NSString (toShare);
            var activityItems = new NSObject[] { item };
            var activityViewController = new UIActivityViewController (activityItems, null);
            var excludedActivityTypes = new [] {
                UIActivityType.CopyToPasteboard,
                UIActivityType.Mail,
                UIActivityType.PostToWeibo
            };

            if (!MFMessageComposeViewController.CanSendText) {
                excludedActivityTypes = new [] {
                    UIActivityType.CopyToPasteboard,
                    UIActivityType.Mail,
                    UIActivityType.Message,
                    UIActivityType.PostToWeibo
                };
            }

            activityViewController.ExcludedActivityTypes = excludedActivityTypes;
            presentingViewController.PresentViewController (activityViewController, true, null);
        }
Example #28
0
        public override void ReceivedNotificationResponse(UANotificationResponse notificationResponse, Action completionHandler)
        {
            Console.WriteLine("The user selected the following action identifier::{0}", notificationResponse.ActionIdentifier);

            UANotificationContent notificationContent = notificationResponse.NotificationContent;

            String message   = String.Format("Action Identifier:{0}", notificationResponse.ActionIdentifier);
            String alertBody = notificationContent.AlertBody;

            if (alertBody.Length > 0)
            {
                message += String.Format("\nAlert Body:\n{0}", alertBody);
            }

            String responseText = notificationResponse.ResponseText;

            if (responseText != null)
            {
                message += String.Format("\nResponse:\n{0}", responseText);
            }

            UIAlertController alertController = UIAlertController.Create(title: notificationContent.AlertTitle,
                                                                         message: alertBody,
                                                                         preferredStyle: UIAlertControllerStyle.Alert);

            UIAlertAction okAction = UIAlertAction.Create(title: "OK", style: UIAlertActionStyle.Default, handler: null);

            alertController.AddAction(okAction);

            UIViewController topController = UIApplication.SharedApplication.KeyWindow.RootViewController;

            alertController.PopoverPresentationController.SourceView = topController.View;

            topController.PresentViewController(alertController, true, null);

            completionHandler();
        }
        public override Task <Result> Scan(MobileBarcodeScanningOptions options)
        {
            return(Task.Factory.StartNew(() => {
                try
                {
                    var scanResultResetEvent = new System.Threading.ManualResetEvent(false);
                    Result result = null;

                    this.appController.InvokeOnMainThread(() => {
                        viewController = new ZxingCameraViewController(options, this);

                        viewController.BarCodeEvent += (BarCodeEventArgs e) => {
                            viewController.DismissViewController();

                            result = e.BarcodeResult;
                            scanResultResetEvent.Set();
                        };

                        viewController.Canceled += (sender, e) => {
                            viewController.DismissViewController();

                            scanResultResetEvent.Set();
                        };

                        appController.PresentViewController(viewController, true, () => { });
                    });

                    scanResultResetEvent.WaitOne();

                    return result;
                }
                catch (Exception ex)
                {
                    return null;
                }
            }));
        }
 /// <summary>
 /// Shows a 2-button message. The actions to be executed on each button must be passed.
 /// </summary>
 /// <param name="Title">Title.</param>
 /// <param name="Description">Description.</param>
 /// <param name="stringForActionOne">String for button one.</param>
 /// <param name="actionOne">Action to be executed when button one is pressed.</param>
 /// <param name="stringForActionTwo">String for button two.</param>
 /// <param name="actionTwo">Action to be executed when button two is pressed.</param>
 /// <param name="controller">Controller to show the info message.</param>
 public static void TwoChoiceView(string Title, string Description, string stringForActionOne, Action actionOne, string stringForActionTwo, Action actionTwo, UIViewController controller)
 {
     if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
     {
         var TwoChoiceAlert = UIAlertController.Create(Title, Description,
                                                       UIAlertControllerStyle.Alert);
         TwoChoiceAlert.AddAction(UIAlertAction.Create(stringForActionOne, UIAlertActionStyle.Default,
                                                       alert => {
             actionOne();
         }));
         TwoChoiceAlert.AddAction(UIAlertAction.Create(stringForActionTwo, UIAlertActionStyle.Default,
                                                       alert => {
             actionTwo();
         }));
         controller.PresentViewController(TwoChoiceAlert, true, null);
     }
     else
     {
         UIAlertView alert = new UIAlertView {
             Title   = Title,
             Message = Description
         };
         alert.AddButton(stringForActionOne);
         alert.AddButton(stringForActionTwo);
         alert.Show();
         alert.Clicked += (s, ev) => {
             if (ev.ButtonIndex == 0)
             {
                 actionOne();
             }
             else if (ev.ButtonIndex == 1)
             {
                 actionTwo();
             }
         };
     }
 }
Example #31
0
        /// <summary>
        /// Shows the draft.
        /// </summary>
        /// <param name="subject">The subject.</param>
        /// <param name="body">The body.</param>
        /// <param name="html">if set to <c>true</c> [HTML].</param>
        /// <param name="to">To.</param>
        /// <param name="cc">The cc.</param>
        /// <param name="bcc">The BCC.</param>
        /// <param name="attachments">The attachments.</param>
        public void ShowDraft(
            string subject,
            string body,
            bool html,
            string[] to,
            string[] cc,
            string[] bcc,
            IEnumerable <string> attachments = null)
        {
            if (!MFMailComposeViewController.CanSendMail)
            {
                throw new System.Exception();
            }
            var mailer = new MFMailComposeViewController();

            mailer.SetMessageBody(body ?? string.Empty, html);
            mailer.SetSubject(subject ?? string.Empty);
            mailer.SetCcRecipients(cc);
            mailer.SetToRecipients(to);
            mailer.Finished += (s, e) => ((MFMailComposeViewController)s).DismissViewController(true, () => { });

            if (attachments != null)
            {
                foreach (var attachment in attachments)
                {
                    mailer.AddAttachmentData(NSData.FromFile(attachment), GetMimeType(attachment), Path.GetFileName(attachment));
                }
            }

            UIViewController vc = UIApplication.SharedApplication.KeyWindow.RootViewController;

            while (vc.PresentedViewController != null)
            {
                vc = vc.PresentedViewController;
            }
            vc.PresentViewController(mailer, true, null);
        }
Example #32
0
        private void MenuTapped(UIViewController vc)
        {
            var menuAlertController = UIAlertController.Create("", Strings.LoginAs + " " + UserData.CPRNR, UIAlertControllerStyle.ActionSheet);

            // When user confirms the service
            var logAfAction = UIAlertAction.Create(Strings.LogOff, UIAlertActionStyle.Destructive, action =>
            {
                // Take the user back to Login
                var tabbar = vc.TabBarController;
                var loginController = (LoginViewController)tabbar.ViewControllers[2];
                UserData.IsUserLoggedIn = false;
                tabbar.SelectedViewController = loginController;

            });

            // When user cancels the service
            var cancelAction = UIAlertAction.Create(Strings.Cancel, UIAlertActionStyle.Cancel, action =>
            {
                // Do nothing.

            });

            menuAlertController.AddAction(logAfAction);
            menuAlertController.AddAction(cancelAction);

            var popover = menuAlertController.PopoverPresentationController;

            if (popover != null)
            {
                popover.SourceView = vc.View;
                popover.SourceRect = new CGRect(vc.View.Bounds.Size.Width / 2.0, vc.View.Bounds.Size.Height / 2.0, 1.0, 1.0);
            }

            // Display the alert
            vc.PresentViewController(menuAlertController, true, null);
        }
Example #33
0
        public override void ReceivedForegroundNotification(UANotificationContent notificationContent, Action completionHandler)
        {
            // Application received a foreground notification
            Console.WriteLine("The application received a foreground notification");

            // iOS 10 - let foreground presentations options handle it
            if (NSProcessInfo.ProcessInfo.IsOperatingSystemAtLeastVersion(new NSOperatingSystemVersion(10, 0, 0)))
            {
                completionHandler();
                return;
            }

            UIAlertController alertController = UIAlertController.Create(title: notificationContent.AlertTitle,
                                                                         message: notificationContent.AlertBody,
                                                                         preferredStyle: UIAlertControllerStyle.Alert);

            UIAlertAction okAction = UIAlertAction.Create(title: "OK", style: UIAlertActionStyle.Default, handler: (UIAlertAction action) =>
            {
                NSString messageID = UAInboxUtils.InboxMessageIDFromNotification(notificationContent.NotificationInfo);

                if (messageID != null)
                {
                    UAActionRunner.RunAction("open_mc_action", messageID, UASituation.ManualInvocation);
                }
            });

            alertController.AddAction(okAction);

            UIViewController topController = UIApplication.SharedApplication.KeyWindow.RootViewController;

            alertController.PopoverPresentationController.SourceView = topController.View;

            topController.PresentViewController(alertController, true, null);

            completionHandler();
        }
Example #34
0
        protected override void DisplayLoginPage(Uri uri)
        {
            Assert.State(_controller).IsNull("Login page still displaying another page");

            _controller = new SFSafariViewController(uri, false);
            var loginPageDelegate = new LoginPageDelgate(this);

            loginPageDelegate.OnFinish = ResetStatusBarStyle;
            _controller.Delegate       = loginPageDelegate;

            UIViewController root = _root;

            if (root == null)
            {
                root = UIApplication.SharedApplication.KeyWindow.RootViewController;
            }

            if (root == null)
            {
                throw new InvalidOperationException("Cannot display login page - " +
                                                    "no root view controller specified and " +
                                                    "there is no displayed window or " +
                                                    "displayed window does not have root view controller");
            }

            //Find topmost modal dialog to present login page
            while (root.PresentedViewController != null && root != root.PresentedViewController && !root.PresentedViewController.IsBeingDismissed)
            {
                root = root.PresentedViewController;
            }

            _lastStatusBarStyle = UIApplication.SharedApplication.StatusBarStyle;
            _controller.ModalPresentationStyle = UIModalPresentationStyle.Popover;
            root.PresentViewController(_controller, true, null);
            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.Default;
        }
Example #35
0
        private static void Share(UIViewController presentingViewController, string toShare)
        {
            var item                   = new NSString(toShare);
            var activityItems          = new NSObject[] { item };
            var activityViewController = new UIActivityViewController(activityItems, null);
            var excludedActivityTypes  = new [] {
                UIActivityType.CopyToPasteboard,
                UIActivityType.Mail,
                UIActivityType.PostToWeibo
            };

            if (!MFMessageComposeViewController.CanSendText)
            {
                excludedActivityTypes = new [] {
                    UIActivityType.CopyToPasteboard,
                    UIActivityType.Mail,
                    UIActivityType.Message,
                    UIActivityType.PostToWeibo
                };
            }

            activityViewController.ExcludedActivityTypes = excludedActivityTypes;
            presentingViewController.PresentViewController(activityViewController, true, null);
        }
        public void Authenticate(Uri authorizationUri, Uri redirectUri, RequestContext requestContext)
        {
            UIViewController viewController = null;

            InvokeOnMainThread(() =>
            {
                UIWindow window = UIApplication.SharedApplication.KeyWindow;
                viewController  = CoreUIParent.FindCurrentViewController(window.RootViewController);
            });
            try
            {
                viewController.InvokeOnMainThread(() =>
                {
                    var navigationController =
                        new MsalAuthenticationAgentUINavigationController(
                            authorizationUri.AbsoluteUri,
                            redirectUri.OriginalString,
                            CallbackMethod,
                            CoreUIParent.PreferredStatusBarStyle)
                    {
                        ModalPresentationStyle = CoreUIParent.ModalPresentationStyle,
                        ModalTransitionStyle   = CoreUIParent.ModalTransitionStyle,
                        TransitioningDelegate  = viewController.TransitioningDelegate
                    };

                    viewController.PresentViewController(navigationController, true, null);
                });
            }
            catch (Exception ex)
            {
                throw new AuthClientException(
                          AuthError.AuthenticationUiFailed,
                          "See inner exception for details",
                          ex);
            }
        }
Example #37
0
 public static Task <Result> Scan(UIViewController hostController, MobileBarcodeScanner scanner, MobileBarcodeScanningOptions options)
 {
     return(Task.Factory.StartNew(delegate
     {
         Result result = null;
         var scanResultResetEvent = new ManualResetEvent(false);
         hostController.InvokeOnMainThread(delegate
         {
             // Release previously displayed barcode scanner
             if (currentBarcodeScanner != null)
             {
                 currentBarcodeScanner.Dispose();
                 currentBarcodeScanner = null;
             }
             currentBarcodeScanner = new ZxingCameraViewController(options, scanner);
             // Handle barcode scan event
             currentBarcodeScanner.BarCodeEvent += delegate(BarCodeEventArgs e)
             {
                 currentBarcodeScanner.DismissViewController();
                 result = e.BarcodeResult;
                 scanResultResetEvent.Set();
             };
             // Handle barcode scan cancel event
             currentBarcodeScanner.Canceled += delegate
             {
                 currentBarcodeScanner.DismissViewController();
                 scanResultResetEvent.Set();
             };
             // Display the camera view controller
             hostController.PresentViewController(currentBarcodeScanner, true, delegate {});
         });
         // Wait for scan to complete
         scanResultResetEvent.WaitOne();
         return result;
     }));
 }
        partial void AddPlaneButton_TouchUpInside(UIButton sender)
        {
            if (val.IsPresent(AddPlaneTextField))
            {
                var alert = UIAlertController.Create("Alert!", "Do you want to add: " +
                                                     AddPlaneTextField.Text + " As a plane?",
                                                     UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("YES", UIAlertActionStyle.Default, (obj) =>
                {
                    string plane = AddPlaneTextField.Text.Replace(',', '.');
                    dm.AddPlane(plane);

                    ToastIOS.Toast.MakeText("Plane Added!").Show();
                    AddPlaneTextField.Text = "";
                    stringList             = dm.FillPlanePicker();
                    pickerMaker(stringList, DeletePlaneTextField);
                }));
                alert.AddAction(UIAlertAction.Create("NO", UIAlertActionStyle.Cancel, (obj) =>
                {
                    AddPlaneTextField.Text = "";
                }));
                vc.PresentViewController(alert, true, null);
            }
        }
        private void ShowImagePicker(UIViewController viewController, UIImagePickerControllerSourceType pickerType)
        {
            imagePicker = new UIImagePickerController();

            imagePicker.SourceType = pickerType;
            // only allow photos (not videos)
            imagePicker.MediaTypes = new string[] { UTType.Image };
            if (pickerType == UIImagePickerControllerSourceType.Camera)
            {
                imagePicker.ShowsCameraControls = true;
            }

            imagePicker.FinishedPickingMedia += (s, e) =>
            {
                viewController.InvokeOnMainThread(() =>
                {
                    bool didPickAnImage = e.MediaType == ImageMediaType && e.OriginalImage != null;
                    OnFinishedPicking(didPickAnImage, e.OriginalImage);
                });
            };

            imagePicker.Canceled += (object s, EventArgs e) =>
            {
                OnFinishedPicking(false, null);
            };

            imagePicker.ModalInPopover = true;
            imagePicker.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
            imagePicker.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;

            viewController.PresentViewController(imagePicker, true, null);
        }
            public InfoSrolableResizebleView(RectangleF viewArea, UIViewController controller)
                : base(viewArea)
            {
                _controller = controller;

                this.Frame = viewArea;
                this.ContentSize = viewArea.Size;
                this.AutoresizingMask = UIViewAutoresizing.All;

                _logoImageView = new UIImageView (new UIImage ("Images/Info/logo.png"));

                UIImage originalNormalImage = new UIImage ("Images/Info/button.png");
                UIImage originalHighlightedImage = new UIImage ("Images/Info/button_pressed.png");

                UIImage backgroundNormalImage = ImageHelper.GetStretchableImage ("Images/Info/button.png", (int) (originalNormalImage.Size.Width/2 - 1), (int)(originalNormalImage.Size.Height/2 - 1));
                UIImage backgroundHighlightedImage = ImageHelper.GetStretchableImage ("Images/Info/button_pressed.png", (int) (originalHighlightedImage.Size.Width/2 - 1), (int)(originalHighlightedImage.Size.Height/2 - 1));

                _buttonSize = new SizeF(this.Bounds.Width < this.Bounds.Height ? this.Bounds.Width/2 : this.Bounds.Height/2, backgroundNormalImage.Size.Height);

                this.AddSubview (_logoImageView);

                _infoTextView = new UITextView();

                _infoTextView.Editable = false;
                _infoTextView.Text = "Нам не стыдно за выпускаемые продукты, все они сделаны с вниманием к деталям. Пользователи это ценят, многие наши приложения попадают в топы AppStore и получают высокие оценки. \n\nМы любим своих заказчиков и решаем их задачи. На письма и телефон отвечаем быстро, по праздникам и выходным, делаем работу в срок и никуда не пропадаем.\nЗакажите разработку сейчас! ";
                _infoTextView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

                this.AddSubview (_infoTextView);

                _btnCall = new UIButton (UIButtonType.RoundedRect);
                _btnCall.SetImage (new UIImage ("Images/Info/icon_phone.png"), UIControlState.Normal);
                _btnCall.SetBackgroundImage (backgroundNormalImage, UIControlState.Normal);
                _btnCall.SetBackgroundImage (backgroundHighlightedImage, UIControlState.Highlighted);
                _btnCall.ImageEdgeInsets = new UIEdgeInsets(0,0,10,0);

                _btnSendMessage = new UIButton (UIButtonType.RoundedRect);
                _btnSendMessage.SetImage (new UIImage ("Images/Info/icon_mail.png"), UIControlState.Normal);
                _btnSendMessage.SetBackgroundImage (backgroundNormalImage, UIControlState.Normal);
                _btnSendMessage.SetBackgroundImage (backgroundHighlightedImage, UIControlState.Highlighted);
                _btnSendMessage.ImageEdgeInsets = new UIEdgeInsets(0,0,10,0);
                _btnCall.TouchUpInside += (sender, e) => {
                    UIApplication.SharedApplication.OpenUrl (new NSUrl ("tel:8-812-309-3879"));
                };

                _btnSendMessage.TouchUpInside += (sender, e) =>
                {
                    if (MFMailComposeViewController.CanSendMail) {
                        var mailController = new MFMailComposeViewController ();
                        mailController.SetToRecipients (new string[] { "*****@*****.**" });
                        mailController.Finished += (finishSender, finishE) => { finishE.Controller.DismissViewController (true, null); };
                        _controller.PresentViewController (mailController, true, null);
                    }
                };

                this.AddSubview (_btnCall);
                this.AddSubview (_btnSendMessage);
            }
		/// <summary>
		/// Presents an alert that allows the user to input a single line of text.
		/// </summary>
		/// <returns>The <c>UIAlertController</c> for the alert.</returns>
		/// <param name="title">The alert's title.</param>
		/// <param name="description">The alert's description.</param>
		/// <param name="placeholder">The placholder text that will be displayed when the text field is empty.</param>
		/// <param name="text">The initial value for the text field.</param>
		/// <param name="controller">The View Controller that will present the alert.</param>
		/// <param name="action">The <c>AlertTextInputDelegate</c> that will respond to the user's action.</param>
		public static UIAlertController PresentTextInputAlert(string title, string description, string placeholder, string text, UIViewController controller, AlertTextInputDelegate action) {
			// No, inform the user that they must create a home first
			UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert);
			UITextField field = null;

			// Add and configure text field
			alert.AddTextField ((textField) => {
				// Save the field
				field = textField;

				// Initialize field
				field.Placeholder = placeholder;
				field.Text = text;
				field.AutocorrectionType = UITextAutocorrectionType.No;
				field.KeyboardType = UIKeyboardType.Default;
				field.ReturnKeyType = UIReturnKeyType.Done;
				field.ClearButtonMode = UITextFieldViewMode.WhileEditing;

			});

			// Add cancel button
			alert.AddAction(UIAlertAction.Create("Cancel",UIAlertActionStyle.Cancel,(actionCancel) => {
				// Any action?
				if (action!=null) {
					action(false,"");
				}
			}));

			// Add ok button
			alert.AddAction(UIAlertAction.Create("OK",UIAlertActionStyle.Default,(actionOK) => {
				// Any action?
				if (action!=null && field !=null) {
					action(true, field.Text);
				}
			}));

			// Display the alert
			controller.PresentViewController(alert,true,null);

			// Return created controller
			return alert;
		}
        void ShowWorkflowResults(SBSDKUIWorkflowStepResult[] results, UIViewController viewController)
        {
            WorkflowResultsViewController controller = WorkflowResultsViewController.InstantiateWith(results);

            viewController.PresentViewController(controller, true, null);
        }
Example #43
0
        public static void MakeCall(CallEntity callEntity, UIViewController vc)
        {

            var category = callEntity.Category;
            var choice = callEntity.Choice ?? "";
            var detail = callEntity.Detail ?? "";

            var confirmAlertController = UIAlertController.Create(category + " " + choice + " " + detail, Strings.CallSendMessage, UIAlertControllerStyle.Alert);

            // When user confirms the service
            var okAction = UIAlertAction.Create(Strings.CallSend, UIAlertActionStyle.Destructive, action =>
            {
                ShowLoadingScreen(vc, Strings.SpinnerDataSending);

                new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                {
                    var callEntities = DataHandler.LoadCallsFromLocalDatabase(new LocalDB());

                    vc.InvokeOnMainThread(() =>
                    {
                        if (callEntities != null && callEntities.Length > 0)
                        {
                            // Check if the call already has been made, then return;
                            if (CallHasBeenMade(callEntities, callEntity)) return;
                        }
          
                        new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                        {
                            // Make the async patient call here
                            try
                            {
                                ICall patientCall = new PatientCall();
                                // Assign the callid with the returned MongoDB id
                                callEntity._id = patientCall.MakeCall(callEntity);

                                vc.InvokeOnMainThread(() =>
                                {
                                    // Call successfull, take the user to myCalls passing the viewcontroller and the requested call
                                    GoToMyCalls(vc,callEntity);

                                });
                            }
                            catch (Exception ex)
                            {
                                // Hide the loading screen
                                Console.WriteLine("ERROR making call: " + ex.Message);

                                vc.InvokeOnMainThread(() =>
                                {
                                    loadingOverlay.Hide();
                                    new UIAlertView(Strings.Error, Strings.ErrorSendingCall, null, Strings.OK, null).Show();
                                });
                            }

                        })).Start();
                        
                    });

                })).Start();

    
                new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                {
                    
                })).Start();

            });

            // When user cancels the service
            var cancelAction = UIAlertAction.Create(Strings.Cancel, UIAlertActionStyle.Cancel, action =>
            {
                // Do nothing.

            });

            confirmAlertController.AddAction(okAction);
            confirmAlertController.AddAction(cancelAction);

            // Display the alert
            vc.PresentViewController(confirmAlertController, true, null);
        }
		public async Task PerformActionOnDocument (DocumentReference docRef, UIViewController fromController, UIBarButtonItem fromButton)
		{
			try {
				
				if (docRef == null)
					return;

				var ad = this;

				if (ad.DismissSheetsAndPopovers ())
					return;

				NSObject[] items = new NSObject[0];
				UIActivity[] aa = new UIActivity[0];

				try {

					var d = (await docRef.Open ()) as TextDocument;

					if (d != null) {
						items = await d.GetActivityItemsAsync (fromController);
						aa = await d.GetActivitiesAsync (fromController);
					}

					await docRef.Close ();
									
				} catch (Exception ex) {
					Debug.WriteLine (ex);
				}

				if (items.Length > 0) {
					var tcs = new TaskCompletionSource<bool> ();
					var a = new UIActivityViewController (items, aa);
					a.ModalPresentationStyle = UIModalPresentationStyle.Popover;

					a.CompletionHandler = (x,success) => {
						Console.WriteLine ("COMPLETE {0} {1}", x, success);
						tcs.SetResult (success);
					};

					if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
						if (a.PopoverPresentationController != null) {
							try {
								a.PopoverPresentationController.BarButtonItem = fromButton;
							} catch (Exception) {
								a.PopoverPresentationController.SourceView = fromController.View;
							}
						}
					}

					fromController.PresentViewController (a, true, null);

					await tcs.Task;
				}

			} catch (Exception ex) {
				Console.WriteLine ("Perform Act of Doc Failed: " + ex);
			}

		
		}
        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(Resources.IAuthenticationBroker_AuthenticationCanceled));
                    }
                    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 Methods
        private void ShowImageViewerByScalingDownFromOffscreenPositionWithViewController(UIViewController viewController)
        {
            Flags.IsAnimatingAPresentationOrDismissal = true;
            View.UserInteractionEnabled = false;

            SnapshotView = SnapshotFromParentmostViewController (viewController);

            if (BackgroundStyle == JTSImageViewControllerBackgroundStyle.ScaledDimmedBlurred) {
                BlurredSnapshotView = BlurredSnapshotFromParentmostViewController (viewController);
                SnapshotView.AddSubview (BlurredSnapshotView);
                BlurredSnapshotView.Alpha = 0;
            }

            View.InsertSubview (SnapshotView, 0);
            StartingInfo.StartingInterfaceOrientation = UIApplication.SharedApplication.StatusBarOrientation;
            LastUsedOrientation = UIApplication.SharedApplication.StatusBarOrientation;

            RectangleF referenceFrameInWindow = ImageInfo.ReferenceView.ConvertRectToView (ImageInfo.ReferenceRect, null);
            StartingInfo.StartingReferenceFrameForThumbnailInPresentingViewControllersOriginalOrientation = View.ConvertRectFromView (referenceFrameInWindow, null);

            ScrollView.AddSubview (ImageView);
            viewController.PresentViewController (this, false, () => {
                if (UIApplication.SharedApplication.StatusBarOrientation != StartingInfo.StartingInterfaceOrientation) {
                    StartingInfo.PresentingViewControllerPresentedFromItsUnsupportedOrientation = true;
                }

                ScrollView.Alpha = 0;
                ScrollView.Frame = View.Bounds;
                UpdateScrollViewAndImageViewForCurrentMetrics();

                float scaling = JTSImageViewController.JTSImageViewController_MaxScalingForExpandingOffscreenStyleTransition;
                ScrollView.Transform = CGAffineTransform.MakeScale(scaling, scaling);

                float duration = JTSImageViewController.JTSImageViewController_TransitionAnimationDuration;

                // dispatch_async(dispatch_get_main_queue()
                UIView.Animate(duration, 0, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseInOut, () => {
                    // animation
                    Flags.IsTransitioningFromInitialModalToInteractiveState = true;

                    UIApplication.SharedApplication.SetStatusBarHidden(true, UIStatusBarAnimation.Fade);
                    float scaling_new = JTSImageViewController.JTSImageViewController_MinimumBackgroundScaling;

                    // weakSelf.snapshotView.transform = CGAffineTransformConcat(weakSelf.snapshotView.transform, CGAffineTransformMakeScale(scaling, scaling));
                    SnapshotView.Transform = SnapshotView.Transform * CGAffineTransform.MakeScale(scaling_new, scaling_new);

                    if (BackgroundStyle == JTSImageViewControllerBackgroundStyle.ScaledDimmedBlurred)
                        BlurredSnapshotView.Alpha = 1;

                    AddMotionEffectsToSnapshotView();
                    BlackBackdrop.Alpha = AlphaForBackgroundDimmingOverlay();

                    ScrollView.Alpha = 1;
                    ScrollView.Transform = CGAffineTransform.MakeIdentity();

                    if (Image == null) 
                        ProgressContainer.Alpha = 1;

                }, () => {
                    // completion handler
                    Flags.IsTransitioningFromInitialModalToInteractiveState = false;
                    Flags.IsAnimatingAPresentationOrDismissal = false;
                    View.UserInteractionEnabled = true;
                    Flags.IsPresented = true;

                    if (Flags.ImageDownloadFailed)
                        Dismiss(true);
                });
            });
        }
        /// <summary>
        /// Presents a new color picker.
        /// </summary>
        /// <param name="parent">The parent <see cref="UIViewController"/>.</param>
        /// <param name="title">The picker title.</param>
        /// <param name="initialColor">The initial selected color.</param>
        /// <param name="done">The method invoked when the picker closes.</param>
        /// <param name="colorPicked">The method invoked as colors are picked.</param>
        public static void Present(UIViewController parent, string title, UIColor initialColor, Action<UIColor> done, Action<UIColor> colorPicked)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }

            var picker = new ColorPickerViewController
            {
                Title = title,
                SelectedColor = initialColor
            };
            picker.ColorPicked += (_, args) =>
            {
                if (colorPicked != null)
                {
                    colorPicked(args.SelectedColor);
                }
            };

            var pickerNav = new UINavigationController(picker);
            pickerNav.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
            pickerNav.NavigationBar.Translucent = false;

            var doneBtn = new UIBarButtonItem(UIBarButtonSystemItem.Done);
            picker.NavigationItem.RightBarButtonItem = doneBtn;
            doneBtn.Clicked += delegate
            {
                if (done != null)
                {
                    done(picker.SelectedColor);
                }

                // hide the picker
                parent.DismissViewController(true, null);
            };

            // show the picker
            parent.PresentViewController(pickerNav, true, null);
        }
Example #48
0
 public static void Modal(UIViewController current, UIViewController next)
 {
     var nav = new UINavigationController (next);
     current.PresentViewController (nav, true, null);
 }
		public void ShowStorage (UIViewController controller)
		{			
			if (DismissSheetsAndPopovers ()) {
				return;
			}

			var pform = new StorageForm ();

			var n = new UINavigationController (pform);
			n.NavigationBar.BarStyle = Theme.NavigationBarStyle;
			n.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
			controller.PresentViewController (n, true, null);
		}
Example #50
0
		/// <summary>
		/// Отображение SearchViewController с таблицей
		/// </summary>
		/// <param name="context">Context.</param>
		/// <param name="senderVc">Sender vc.</param>
		/// <param name="searchStations">Search stations.</param>
		void ShowSearchSearchView (string context, UIViewController senderVc, IList<SectionStation> searchStations){
			var tableTest = new CitiesScheduleView (showAll,context,searchStations);
			tableTest.TableView.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag;
			var searchController = new UISearchController (tableTest);
			searchController.DimsBackgroundDuringPresentation = true;
			searchController.ObscuresBackgroundDuringPresentation = true;
			searchController.DefinesPresentationContext = false;
			senderVc.DefinesPresentationContext = true;
			searchController.SearchResultsUpdater = tableTest;
			senderVc.PresentViewController (searchController, true, null);
		}
Example #51
0
        public static void Show(UIViewController controller, string email, AuthResult res, Mode mode, bool googleAuth = false)
        {
            switch (res)
            {
            case AuthResult.InvalidCredentials:
                if (mode == Mode.Login && !googleAuth)
                {
                    new UIAlertView(
                        "AuthErrorLoginTitle".Tr(),
                        "AuthErrorLoginMessage".Tr(),
                        null, "AuthErrorOk".Tr()).Show();
                }
                else if (mode == Mode.Login && googleAuth)
                {
                    new UIAlertView(
                        "AuthErrorGoogleLoginTitle".Tr(),
                        "AuthErrorGoogleLoginMessage".Tr(),
                        null, "AuthErrorOk".Tr()).Show();
                }
                else if (mode == Mode.Signup)
                {
                    new UIAlertView(
                        "AuthErrorSignupTitle".Tr(),
                        "AuthErrorSignupMessage".Tr(),
                        null, "AuthErrorOk".Tr()).Show();
                }
                break;

            case AuthResult.NoDefaultWorkspace:
                if (MFMailComposeViewController.CanSendMail)
                {
                    var dia = new UIAlertView(
                        "AuthErrorNoWorkspaceTitle".Tr(),
                        "AuthErrorNoWorkspaceMessage".Tr(),
                        null, "AuthErrorNoWorkspaceCancel".Tr(),
                        "AuthErrorNoWorkspaceOk".Tr());
                    dia.Clicked += (sender, e) => {
                        if (e.ButtonIndex == 1)
                        {
                            var mail = new MFMailComposeViewController();
                            mail.SetToRecipients(new[] { "AuthErrorNoWorkspaceEmail".Tr() });
                            mail.SetSubject("AuthErrorNoWorkspaceSubject".Tr());
                            mail.SetMessageBody(String.Format("AuthErrorNoWorkspaceBody".Tr(), email), false);
                            mail.Finished += delegate {
                                controller.DismissViewController(true, null);
                            };

                            controller.PresentViewController(mail, true, null);
                        }
                    };
                    dia.Show();
                }
                else
                {
                    new UIAlertView(
                        "AuthErrorNoWorkspaceTitle".Tr(),
                        "AuthErrorNoWorkspaceMessage".Tr(),
                        null, "AuthErrorOk".Tr()).Show();
                }
                break;

            case AuthResult.NetworkError:
                new UIAlertView(
                    "AuthErrorNetworkTitle".Tr(),
                    "AuthErrorNetworkMessage".Tr(),
                    null, "AuthErrorOk".Tr()).Show();
                break;

            default:
                new UIAlertView(
                    "AuthErrorSystemTitle".Tr(),
                    "AuthErrorSystemMessage".Tr(),
                    null, "AuthErrorOk".Tr()).Show();
                break;
            }
        }
Example #52
0
            public void Create( UIViewController parentViewController, UIView parentView, string name, string description, string[] values, bool requiredField, string attribKey )
            {
                AttribKey = attribKey;

                // store our parent and the required flag
                ParentView = parentView;
                ParentViewController = parentViewController;

                Required = requiredField;

                // populate our values list
                Values = values;

                // setup the controls
                Layer.AnchorPoint = CGPoint.Empty;

                // header label
                Header = new UILabel( );
                Header.Layer.AnchorPoint = CGPoint.Empty;
                Header.Text = name; //uiControlAttrib.Name;
                Header.Font = FontManager.GetFont( Settings.General_BoldFont, Config.Instance.VisualSettings.SmallFontSize );
                Theme.StyleLabel( Header, Config.Instance.VisualSettings.LabelStyle );
                AddSubview( Header );

                RequiredAnchor = new RequiredAnchor( );
                RequiredAnchor.AttachToTarget( Header );
                RequiredAnchor.Hidden = !requiredField;

                // setup the value and button
                ValueLabel = new UILabel( );
                ValueLabel.Layer.AnchorPoint = CGPoint.Empty;
                ValueLabel.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
                //ValueLabel.Text = Values[ 0 ];
                Theme.StyleLabel( ValueLabel, Config.Instance.VisualSettings.LabelStyle );
                AddSubview( ValueLabel );

                ValueSymbol = new UILabel( );
                AddSubview( ValueSymbol );
                ValueSymbol.Text = "";
                ValueSymbol.Font = FontManager.GetFont( "Bh", 36 );
                ValueSymbol.TextColor = Theme.GetColor( Config.Instance.VisualSettings.LabelStyle.TextColor );
                ValueSymbol.SizeToFit( );

                ButtonOverlay = new UIButton();
                ButtonOverlay.Layer.AnchorPoint = CGPoint.Empty;
                ButtonOverlay.BackgroundColor = UIColor.Clear;
                ButtonOverlay.Layer.Opacity = .50f;
                AddSubview( ButtonOverlay );

                // finally, setup the popup when the button is tapped
                ButtonOverlay.TouchUpInside += (object sender, EventArgs e ) =>
                    {
                        UIAlertController actionSheet = UIAlertController.Create( Header.Text,
                            description,
                            UIAlertControllerStyle.ActionSheet );

                        // the device is a tablet, anchor the menu
                        actionSheet.PopoverPresentationController.SourceView = ButtonOverlay;
                        actionSheet.PopoverPresentationController.SourceRect = ButtonOverlay.Bounds;

                        // for each campus, create an entry in the action sheet, and its callback will assign
                        // that campus index to the user's viewing preference
                        for( int i = 0; i < Values.Length; i++ )
                        {
                            UIAlertAction valueAction = UIAlertAction.Create( Values[ i ], UIAlertActionStyle.Default, delegate(UIAlertAction obj)
                                {
                                    ValueLabel.Text = obj.Title;

                                    // update the value field and button overlay
                                    ValueLabel.SizeToFit( );
                                    ButtonOverlay.Bounds = ValueLabel.Bounds;
                                    UpdateLayout( );
                                } );

                            actionSheet.AddAction( valueAction );
                        }

                        // let them cancel, too
                        UIAlertAction cancelAction = UIAlertAction.Create( FamilyManager.Strings.General_Cancel, UIAlertActionStyle.Cancel, delegate { });
                        actionSheet.AddAction( cancelAction );

                        ParentViewController.PresentViewController( actionSheet, true, null );
                    };
            }
Example #53
0
 public void ShouldPresentViewController(UIViewController controller)
 {
     Device.BeginInvokeOnMainThread(() => _viewController?.PresentViewController(controller, true, null));
 }
Example #54
0
        public static void Show (UIViewController controller, string email, AuthResult res, Mode mode, bool googleAuth=false)
        {
            switch (res) {
            case AuthResult.InvalidCredentials:
                if (mode == Mode.Login && !googleAuth) {
                    new UIAlertView (
                        "AuthErrorLoginTitle".Tr (),
                        "AuthErrorLoginMessage".Tr (),
                        null, "AuthErrorOk".Tr ()).Show ();
                } else if (mode == Mode.Login && googleAuth) {
                    new UIAlertView (
                        "AuthErrorGoogleLoginTitle".Tr (),
                        "AuthErrorGoogleLoginMessage".Tr (),
                        null, "AuthErrorOk".Tr ()).Show ();
                } else if (mode == Mode.Signup) {
                    new UIAlertView (
                        "AuthErrorSignupTitle".Tr (),
                        "AuthErrorSignupMessage".Tr (),
                        null, "AuthErrorOk".Tr ()).Show ();
                }
                break;
            case AuthResult.NoDefaultWorkspace:
                if (MFMailComposeViewController.CanSendMail) {
                    var dia = new UIAlertView (
                        "AuthErrorNoWorkspaceTitle".Tr (),
                        "AuthErrorNoWorkspaceMessage".Tr (),
                        null, "AuthErrorNoWorkspaceCancel".Tr (),
                        "AuthErrorNoWorkspaceOk".Tr ());
                    dia.Clicked += (sender, e) => {
                        if (e.ButtonIndex == 1) {
                            var mail = new MFMailComposeViewController ();
                            mail.SetToRecipients (new[] { "AuthErrorNoWorkspaceEmail".Tr () });
                            mail.SetSubject ("AuthErrorNoWorkspaceSubject".Tr ());
                            mail.SetMessageBody (String.Format ("AuthErrorNoWorkspaceBody".Tr (), email), false);
                            mail.Finished += delegate {
                                controller.DismissViewController (true, null);
                            };

                            controller.PresentViewController (mail, true, null);
                        }
                    };
                    dia.Show ();
                } else {
                    new UIAlertView (
                        "AuthErrorNoWorkspaceTitle".Tr (),
                        "AuthErrorNoWorkspaceMessage".Tr (),
                        null, "AuthErrorOk".Tr ()).Show();
                }
                break;
            case AuthResult.NetworkError:
                new UIAlertView (
                    "AuthErrorNetworkTitle".Tr (),
                    "AuthErrorNetworkMessage".Tr (),
                    null, "AuthErrorOk".Tr ()).Show ();
                break;
            default:
                new UIAlertView (
                    "AuthErrorSystemTitle".Tr (),
                    "AuthErrorSystemMessage".Tr (),
                    null, "AuthErrorOk".Tr ()).Show ();
                break;
            }
        }
Example #55
0
		public void NewComment (UIViewController parent, Action<string> action)
		{
            Title = Title;
            ReturnAction = action;
            _previousController = parent;
            TextView.BecomeFirstResponder ();
            var nav = new UINavigationController(this);
            parent.PresentViewController(nav, true, null);
		}
        private void ShowImageViewerByExpandingFromOriginalPositionFromViewController(UIViewController viewController)
        {
            Flags.IsAnimatingAPresentationOrDismissal = true;
            View.UserInteractionEnabled = false;

            SnapshotView = SnapshotFromParentmostViewController (viewController);

            // The view is gone!? well guess we wont be showing any picture then.
            if (SnapshotView == null)
                return;
           
            if (BackgroundStyle == JTSImageViewControllerBackgroundStyle.ScaledDimmedBlurred) {
                BlurredSnapshotView = BlurredSnapshotFromParentmostViewController (viewController);
                SnapshotView.AddSubview (BlurredSnapshotView);
                BlurredSnapshotView.Alpha = 0;
            }

            View.InsertSubview (SnapshotView, 0);
            StartingInfo.StartingInterfaceOrientation = UIApplication.SharedApplication.StatusBarOrientation;
            LastUsedOrientation = UIApplication.SharedApplication.StatusBarOrientation;

            RectangleF referenceFrameInWindow = ImageInfo.ReferenceView.ConvertRectToView (ImageInfo.ReferenceRect, null);
            StartingInfo.StartingReferenceFrameForThumbnailInPresentingViewControllersOriginalOrientation = View.ConvertRectFromView (referenceFrameInWindow, null);

            View.AddSubview (ImageView);

            viewController.PresentViewController (this, false, () => {
                if (UIApplication.SharedApplication.StatusBarOrientation != StartingInfo.StartingInterfaceOrientation) {
                    StartingInfo.PresentingViewControllerPresentedFromItsUnsupportedOrientation = true;
                }

                RectangleF referenceFrameInMyView = View.ConvertRectFromView(referenceFrameInWindow, null);
                StartingInfo.StartingReferenceFrameForThumbnail = referenceFrameInMyView;
                UpdateScrollViewAndImageViewForCurrentMetrics();

                bool mustRotateDuringTransition = UIApplication.SharedApplication.StatusBarOrientation != StartingInfo.StartingInterfaceOrientation;
                if (mustRotateDuringTransition) {
                    RectangleF newStartingRect = SnapshotView.ConvertRectToView(StartingInfo.StartingReferenceFrameForThumbnail, View);
                    ImageView.Frame = newStartingRect;
                    UpdateScrollViewAndImageViewForCurrentMetrics();

                    ImageView.Transform = SnapshotView.Transform;
                    PointF centerInRect = new PointF(0 + StartingInfo.StartingReferenceFrameForThumbnail.Size.Width/2.0f, 0 + StartingInfo.StartingReferenceFrameForThumbnail.Size.Height/2.0f);
                    ImageView.Center = centerInRect;
                }

                /* OPTIONAL METHOD TO IMPLEMENT IN THE FUTURE
                if ([self.optionsDelegate respondsToSelector:@selector(imageViewerShouldFadeThumbnailsDuringPresentationAndDismissal:)]) {
                    if ([self.optionsDelegate imageViewerShouldFadeThumbnailsDuringPresentationAndDismissal:self]) {
                        [self.imageView setAlpha:0];
                        [UIView animateWithDuration:0.15f animations:^{
                            [self.imageView setAlpha:1];
                        }];
                    }
                }
                */

                float duration = JTSImageViewController.JTSImageViewController_TransitionAnimationDuration;
                UIView.Animate(duration, 0, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseInOut, () => {
                    // animations
                    Flags.IsTransitioningFromInitialModalToInteractiveState = true;

                    // if ([UIApplication sharedApplication].jts_usesViewControllerBasedStatusBarAppearance) {
                    //    [weakSelf setNeedsStatusBarAppearanceUpdate];
                    UIApplication.SharedApplication.SetStatusBarHidden(true, UIStatusBarAnimation.Fade);

                    float scaling = JTSImageViewController.JTSImageViewController_MinimumBackgroundScaling;

                    // weakSelf.snapshotView.transform = CGAffineTransformConcat(weakSelf.snapshotView.transform, CGAffineTransformMakeScale(scaling, scaling));
                    SnapshotView.Transform = SnapshotView.Transform * CGAffineTransform.MakeScale(scaling, scaling);

                    if (BackgroundStyle == JTSImageViewControllerBackgroundStyle.ScaledDimmedBlurred) {
                        BlurredSnapshotView.Alpha = 1;
                    }
                    AddMotionEffectsToSnapshotView();
                    BlackBackdrop.Alpha = JTSImageViewController_DefaultAlphaForBackgroundDimmingOverlay;

                    if (mustRotateDuringTransition)
                        ImageView.Transform = CGAffineTransform.MakeIdentity();

                    RectangleF endFrameForImageView;
                    if (Image != null) {
                        endFrameForImageView = ResizedFrameForAutorotatingImageView(Image.Size);
                    }   else {
                        endFrameForImageView = ResizedFrameForAutorotatingImageView(ImageInfo.ReferenceRect.Size);
                    }

                    ImageView.Frame = endFrameForImageView;

                    PointF endCenterForImageView = new PointF(View.Bounds.Size.Width/2.0f, View.Bounds.Size.Height/2.0f);
                    ImageView.Center = endCenterForImageView;

                    if (Image == null) {
                        ProgressContainer.Alpha = 1.0f;
                    }

                }, () => {
                    // completion handler
                    Flags.IsManuallyResizingTheScrollViewFrame = true;
                    ScrollView.Frame = View.Bounds;
                    Flags.IsManuallyResizingTheScrollViewFrame = false;
                    ScrollView.AddSubview(ImageView);

                    Flags.IsTransitioningFromInitialModalToInteractiveState = false;
                    Flags.IsAnimatingAPresentationOrDismissal = false;
                    Flags.IsPresented = true;

                    UpdateScrollViewAndImageViewForCurrentMetrics();

                    if (Flags.ImageDownloadFailed) {
                        Dismiss(true);
                    } else {
                        View.UserInteractionEnabled = true;
                    }

                });

            });
        }
Example #57
0
        private Task <MediaFile> GetMediaAsync(UIImagePickerControllerSourceType sourceType, string mediaType, StoreCameraMediaOptions options = null)
        {
            UIWindow window = UIApplication.SharedApplication.KeyWindow;

            if (window == null)
            {
                throw new InvalidOperationException("There's no current active window");
            }

            UIViewController viewController = window.RootViewController;

            if (viewController == null)
            {
                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");
                }
                else
                {
                    viewController = window.RootViewController;
                }
            }

            while (viewController.PresentedViewController != null)
            {
                viewController = viewController.PresentedViewController;
            }

            MediaPickerDelegate ndelegate = new MediaPickerDelegate(viewController, sourceType, options);
            var od = Interlocked.CompareExchange(ref this.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);
                ndelegate.Popover.Delegate = new MediaPickerPopoverDelegate(ndelegate, picker);
                ndelegate.DisplayPopover();
            }
            else
            {
                viewController.PresentViewController(picker, true, null);
            }

            return(ndelegate.Task.ContinueWith(t =>
            {
                if (this.popover != null)
                {
                    this.popover.Dispose();
                    this.popover = null;
                }

                Interlocked.Exchange(ref this.pickerDelegate, null);
                return t;
            }).Unwrap());
        }
Example #58
0
		public async Task<string> Activate(UIViewController parent, Mode mode)
		{
			_isActivated = true;
			parent.PresentViewController(this, false, Do.Nothing);

			if(IsIPhone)
				_fakeField.BecomeFirstResponder();
				
			ResetPassword();
			ResetPinBoxes();
			ChangePinBoxBallColor(_settings.Appearence.PinBoxBallColor);

			SetMode(mode);

			return await PasswordEntered ();
		}