コード例 #1
0
        public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
        {
            UIViewController masterViewController = viewControllers[0];
            UIViewController detailViewController = viewControllers[1];

            masterViewController.DidRotate(fromInterfaceOrientation);
            detailViewController.DidRotate(fromInterfaceOrientation);

            switch (InterfaceOrientation)
            {
            case UIInterfaceOrientation.Portrait:
                TouchFactory.NotifyOrientationChanged(iApp.Orientation.Portrait);
                break;

            case UIInterfaceOrientation.PortraitUpsideDown:
                TouchFactory.NotifyOrientationChanged(iApp.Orientation.PortraitUpsideDown);
                break;

            case UIInterfaceOrientation.LandscapeLeft:
                TouchFactory.NotifyOrientationChanged(iApp.Orientation.LandscapeLeft);
                break;

            case UIInterfaceOrientation.LandscapeRight:
                TouchFactory.NotifyOrientationChanged(iApp.Orientation.LandscapeRight);
                break;
            }
        }
コード例 #2
0
        public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
        {
            base.DidRotate(fromInterfaceOrientation);

            // we don't want to fire the event here if there's a splitviewcontroller
            // because it would cause the event to be fired once for each active controller
            if (TouchFactory.Instance.SplitViewController == null)
            {
                switch (InterfaceOrientation)
                {
                case UIInterfaceOrientation.Portrait:
                    TouchFactory.NotifyOrientationChanged(iApp.Orientation.Portrait);
                    break;

                case UIInterfaceOrientation.PortraitUpsideDown:
                    TouchFactory.NotifyOrientationChanged(iApp.Orientation.PortraitUpsideDown);
                    break;

                case UIInterfaceOrientation.LandscapeLeft:
                    TouchFactory.NotifyOrientationChanged(iApp.Orientation.LandscapeLeft);
                    break;

                case UIInterfaceOrientation.LandscapeRight:
                    TouchFactory.NotifyOrientationChanged(iApp.Orientation.LandscapeRight);
                    break;
                }
            }
        }
コード例 #3
0
        public void InsertView(int index, IMXView view)
        {
            Parameter.CheckIndex(ViewControllers, "history", index);

            var vcs = ViewControllers;

            vcs[index] = TouchFactory.GetNativeObject <UIViewController>(view, "view");
            SetViewControllers(vcs, false);
        }
コード例 #4
0
            public void AddChild(IElement element)
            {
                UIView view = TouchFactory.GetNativeObject <UIView>(element, "element");

                if (view != null)
                {
                    AddSubview(view);
                }
            }
コード例 #5
0
            public void RemoveChild(IElement element)
            {
                UIView view = TouchFactory.GetNativeObject <UIView>(element, "element");

                if (view != null)
                {
                    view.RemoveFromSuperview();
                }
            }
コード例 #6
0
            public void InsertView(int index, IMXView view)
            {
                //increment index so that this controller cannot be removed
                Parameter.CheckIndex(NavigationController.ViewControllers, "history", ++index);

                var vcs = NavigationController.ViewControllers;

                vcs[index] = TouchFactory.GetNativeObject <UIViewController>(view, "view");
                NavigationController.SetViewControllers(vcs, false);
            }
コード例 #7
0
        public virtual void ReplaceView(IMXView currentView, IMXView newView)
        {
            var controller = TouchFactory.GetNativeObject <UIViewController>(currentView, "currentView");
            var index      = Parameter.CheckObjectExists(ViewControllers, "history", controller, "currentView");

            var vcs = ViewControllers;

            vcs[index] = TouchFactory.GetNativeObject <UIViewController>(newView, "newView");
            SetViewControllers(vcs, false);
        }
コード例 #8
0
            public IMXView[] PopToView(IMXView view)
            {
                var controller = TouchFactory.GetNativeObject <UIViewController>(view, "view");

                Parameter.CheckObjectExists(NavigationController.ViewControllers, "history", controller, "view");

//	            regularPop = NavigationController.TopViewController != controller;

                var controllers = NavigationController.PopToViewController(controller, true);

                return(controllers == null ? null : controllers.OfType <IMXView>().Select(v => { var p = v as IPairable; return p == null ? v : (p.Pair as IMXView) ?? v; }).ToArray());
            }
コード例 #9
0
        public void AddChild(IElement element)
        {
            UIView view = TouchFactory.GetNativeObject <UIView>(element, "element");

            if (view != null)
            {
                ScrollView.AddSubview(view);

                var handler = PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs("Children"));
                }
            }
        }
コード例 #10
0
        public void RemoveChild(IElement element)
        {
            UIView view = TouchFactory.GetNativeObject <UIView>(element, "element");

            if (view != null)
            {
                view.RemoveFromSuperview();

                var handler = PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs("Children"));
                }
            }
        }
コード例 #11
0
            public void PushView(IMXView view)
            {
                var controller = TouchFactory.GetNativeObject <UIViewController>(view, "view");

                if (Views.Count() < 1)
                {
                    NavigationController.PushViewController(this, false);
                    NavigationController.PushViewController(controller, true);
                    controller.NavigationItem.HidesBackButton = false;
                }
                else
                {
                    NavigationController.PushViewController(controller, true);
                }
            }
コード例 #12
0
        public IMXView[] PopToView(IMXView view)
        {
            var controller = TouchFactory.GetNativeObject <UIViewController>(view, "view");

            // 8 is not accurately reflecting what controllers are in the stack after a replace.
            // this means the check will fail even though it should pass.
            // forego the check for now until we find a way to fix it.  works fine on 7.
            if (!UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                Parameter.CheckObjectExists(ViewControllers, "history", controller, "view");
            }

            var controllers = PopToViewController(controller, true);

            return(controllers == null ? null : controllers.OfType <IMXView>().Select(v => { var p = v as IPairable; return p == null ? v : (p.Pair as IMXView) ?? v; }).ToArray());
        }
コード例 #13
0
        private void ActionSheetClicked(object sender, UIButtonEventArgs e)
        {
            if (e.ButtonIndex < menuButtons.Count)
            {
                var item = TouchFactory.GetNativeObject <UIBarButtonItem>(menuButtons[(int)e.ButtonIndex], "menuButton");
                if (item != null && item.Target != null && item.Action != null)
                {
                    UIViewController obj = null;
                    if (parentView != null)
                    {
                        obj = parentView.GetSuperview <IListView>() as UIViewController;
                    }
                    else if (parentItem != null)
                    {
                        obj = parentItem.GetSuperview();
                    }

                    item.Target.PerformSelector(item.Action, obj, 0);
                }
            }
        }
コード例 #14
0
ファイル: GridCell.cs プロジェクト: Zebra/iFactr-iOS
        public void AddChild(IElement element)
        {
            UIView view = TouchFactory.GetNativeObject <UIView>(element, "element");

            if (view != null)
            {
                ContentView.AddSubview(view);

                // for backward compatibility with ICustomItems that use ViewWithTag()
                for (int i = 2; i < ContentView.Subviews.Length; i++)
                {
                    ContentView.Subviews[i].Tag = i - 1;
                }

                var handler = PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs("Children"));
                }
            }
        }
コード例 #15
0
            public void ReplaceView(IMXView currentView, IMXView newView)
            {
                // replacing this view is not allowed
                if (currentView == this)
                {
                    if (NavigationController.ViewControllers.Length == 1)
                    {
                        PushView(newView);
                    }
                    else
                    {
                        InsertView(1, newView);
                    }
                    return;
                }

                var controller = TouchFactory.GetNativeObject <UIViewController>(currentView, "currentView");
                var index      = Parameter.CheckObjectExists(NavigationController.ViewControllers, "history", controller, "currentView");

                var vcs = NavigationController.ViewControllers;

                vcs[index] = TouchFactory.GetNativeObject <UIViewController>(newView, "newView");
                NavigationController.SetViewControllers(vcs, false);
            }
コード例 #16
0
ファイル: Printer.cs プロジェクト: Zebra/iFactr-iOS
        public static void Print(string url)
        {
            if (!UIPrintInteractionController.PrintingAvailable)
            {
                new UIAlertView(TouchFactory.Instance.GetResourceString("PrintErrorTitle"),
                                TouchFactory.Instance.GetResourceString("PrintError"), null,
                                TouchFactory.Instance.GetResourceString("Dismiss"), null).Show();

                return;
            }

            string printUrl = null;
            int    index    = url.IndexOf('?');

            if (index >= 0)
            {
                HttpUtility.ParseQueryString(url.Substring(index)).TryGetValue("url", out printUrl);
            }

            UIPrintInfo printInfo = UIPrintInfo.PrintInfo;

            printInfo.OutputType = UIPrintInfoOutputType.General;
            printInfo.Duplex     = UIPrintInfoDuplex.LongEdge;

            if (!string.IsNullOrEmpty(printUrl) && !PrintUrl(printUrl))
            {
                new UIAlertView(TouchFactory.Instance.GetResourceString("PrintErrorTitle"),
                                string.Format(TouchFactory.Instance.GetResourceString("PrintUrlError"), printUrl), null,
                                TouchFactory.Instance.GetResourceString("Dismiss"), null).Show();

                return;
            }

            var navContext = iApp.CurrentNavContext.ActiveLayer.NavContext;
            var stack      = PaneManager.Instance.FromNavContext(navContext.NavigatedActivePane, navContext.NavigatedActiveTab) as BaseNavigationController;

            if (stack == null || stack.CurrentView == null)
            {
                return;
            }

            UIViewController controller = TouchFactory.GetNativeObject <UIViewController>(stack.CurrentView, "view");
            UIView           view       = controller.View;

            if (controller is IBrowserView)
            {
                view = view.Subviews.FirstOrDefault(sv => sv is UIWebView);
            }

            if (!(view is UIWebView) || !PrintUrl(((UIWebView)view).Request.Url.AbsoluteString))
            {
                printInfo.JobName = controller.NavigationItem.Title;
                UIPrintInteractionController.SharedPrintController.PrintInfo = printInfo;

                view.ViewPrintFormatter.StartPage = 0;
                UIPrintInteractionController.SharedPrintController.PrintFormatter = view.ViewPrintFormatter;
            }

            UIPrintInteractionCompletionHandler completionHandler = FinishPrinting;

            if (TouchFactory.Instance.LargeFormFactor)
            {
                UIViewController top = ModalManager.GetTopmostViewController(null);

                nfloat barHeight = TouchFactory.Instance.IsLandscape ? UIApplication.SharedApplication.StatusBarFrame.Width
                                        : UIApplication.SharedApplication.StatusBarFrame.Height;

                nfloat centerX = TouchFactory.Instance.IsLandscape ? top.View.Center.Y : top.View.Center.X;

                UIPrintInteractionController.SharedPrintController.PresentFromRectInView(
                    new CoreGraphics.CGRect(centerX, stack.NavigationBar.Frame.Height + barHeight, 1, 1), top.View, true, completionHandler);
            }
            else
            {
                UIPrintInteractionController.SharedPrintController.Present(true, completionHandler);
            }
        }
コード例 #17
0
        public override void ViewWillAppear(bool animated)
        {
            UIViewController presenter = null;

            var splitController = PresentingViewController as MGSplitViewController;

            if (splitController != null && PopoverPresentationController != null)
            {
                foreach (var controller in splitController.GetControllers())
                {
                    var viewController = controller;
                    var navController  = controller as UINavigationController;
                    var tabController  = controller as UITabBarController;
                    if (tabController != null)
                    {
                        viewController = tabController.SelectedViewController;
                        navController  = viewController as UINavigationController;
                    }

                    if (navController != null)
                    {
                        viewController = navController.TopViewController;
                    }

                    if (viewController != null && viewController.NavigationItem != null && viewController.NavigationItem.RightBarButtonItems != null &&
                        viewController.NavigationItem.RightBarButtonItems.Any(b => b == PopoverPresentationController.BarButtonItem))
                    {
                        presenter = viewController;
                    }
                }
            }

            if (presenter == null)
            {
                var tabController = PresentingViewController as UITabBarController;
                presenter = tabController == null ? PresentingViewController : tabController.SelectedViewController;

                var navController = presenter as UINavigationController;
                if (navController != null)
                {
                    presenter = navController.TopViewController;
                }
            }

            if (Actions.Length - 1 < menuButtons.Count)
            {
                var weakPresenter = new WeakReference(presenter);

                for (int i = Actions.Length - 1; i < menuButtons.Count; i++)
                {
                    var menuButton = menuButtons[i];
                    AddAction(UIAlertAction.Create(menuButton.Title, UIAlertActionStyle.Default, (o) =>
                    {
                        var item = TouchFactory.GetNativeObject <UIBarButtonItem>(menuButton, "menuButton");
                        if (item != null && item.Target != null && item.Action != null)
                        {
                            item.Target.PerformSelector(item.Action, weakPresenter.Target as NSObject, 0);
                        }
                    }));
                }
            }
        }
コード例 #18
0
ファイル: UIViewExtensions.cs プロジェクト: Zebra/iFactr-iOS
        public static void SetMenu(this UIViewController controller, IMenu menu)
        {
            if (menu != null && menu.ButtonCount > 0)
            {
                if (menu.ButtonCount > 1)
                {
                    bool isNew = false;
                    if (menu.ImagePath != null)
                    {
                        try
                        {
                            controller.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIImage.FromBundle(menu.ImagePath), UIBarButtonItemStyle.Plain, null);
                            isNew = true;
                        }
                        catch
                        {
                        }
                    }
                    else if (!string.IsNullOrEmpty(menu.Title))
                    {
                        controller.NavigationItem.RightBarButtonItem = new UIBarButtonItem(menu.Title, UIBarButtonItemStyle.Plain, null);
                        isNew = true;
                    }

                    if (controller.NavigationItem.RightBarButtonItem == null)
                    {
                        controller.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action);
                        isNew = true;
                    }

                    if (isNew)
                    {
                        controller.NavigationItem.RightBarButtonItem.Clicked += (o, e) =>
                        {
                            var alert = (menu as UIAlertController) ?? (menu.Pair as UIAlertController);
                            if (alert != null)
                            {
                                if (alert.PopoverPresentationController != null)
                                {
                                    alert.PopoverPresentationController.BarButtonItem = controller.NavigationItem.RightBarButtonItem;
                                }
                                ModalManager.EnqueueModalTransition(ModalManager.GetTopmostViewController(null), alert, true);
                            }
                            else
                            {
                                var action = (menu as UIActionSheet) ?? (menu.Pair as UIActionSheet);
                                if (action != null)
                                {
                                    action.ShowFrom(controller.NavigationItem.RightBarButtonItem, true);
                                }
                            }
                        };
                    }

                    var sheet = (menu as UIActionSheet) ?? (menu.Pair as UIActionSheet);
                    if (sheet != null)
                    {
                        if (sheet.CancelButtonIndex <= 0)
                        {
                            sheet.Add(TouchFactory.Instance.GetResourceString("Cancel"));
                            sheet.CancelButtonIndex = sheet.ButtonCount - 1;
                        }
                    }
                }
                else
                {
                    controller.NavigationItem.RightBarButtonItem = TouchFactory.GetNativeObject <UIBarButtonItem>(menu.GetButton(0), "menuButton");
                }
            }
            else
            {
                controller.NavigationItem.RightBarButtonItem = null;
            }
        }
コード例 #19
0
 public virtual void PushView(IMXView view)
 {
     PushViewController(TouchFactory.GetNativeObject <UIViewController>(view, "view"), ViewControllers.Any(vc => !(vc is VanityView)));
 }