public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
        {
            var requestedOrientation  = OrientationConverter.ToDisplayOrientation(toInterfaceOrientation);
            var supportedOrientations = (_gameViewController as iOSGameViewController).SupportedOrientations;

            return((supportedOrientations & requestedOrientation) != 0);
        }
Пример #2
0
        private void ViewController_InterfaceOrientationChanged(object sender, EventArgs e)
        {
            var orientation = OrientationConverter.ToDisplayOrientation(
                _viewController.InterfaceOrientation);

            // FIXME: The presentation parameters for the GraphicsDevice should
            //        be managed by the GraphicsDevice itself.  Not by
            //        iOSGamePlatform.
            var gdm = (GraphicsDeviceManager)Game.Services.GetService(typeof(IGraphicsDeviceManager));

            TouchPanel.DisplayOrientation = orientation;

            if (gdm != null)
            {
                var presentParams = gdm.GraphicsDevice.PresentationParameters;
                presentParams.BackBufferWidth  = gdm.PreferredBackBufferWidth;
                presentParams.BackBufferHeight = gdm.PreferredBackBufferHeight;

                presentParams.DisplayOrientation = orientation;

                // Recalculate our views.
                ViewController.View.LayoutSubviews();

                gdm.ApplyChanges();
            }
        }
Пример #3
0
        public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
        {
            DisplayOrientation supportedOrientations = OrientationConverter.Normalize(SupportedOrientations);
            var toOrientation = OrientationConverter.ToDisplayOrientation(toInterfaceOrientation);

            return((toOrientation & supportedOrientations) == toOrientation);
        }
Пример #4
0
        public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
        {
            DisplayOrientation supportedOrientations;

            if (SupportedOrientations == DisplayOrientation.Default)
            {
                supportedOrientations = GetDefaultSupportedOrientations();
            }
            else
            {
                supportedOrientations = OrientationConverter.Normalize(SupportedOrientations);
            }
            var toOrientation = OrientationConverter.ToDisplayOrientation(toInterfaceOrientation);

            return((toOrientation & supportedOrientations) == toOrientation);
        }
Пример #5
0
        /// <summary>
        /// Gets the default supported orientations as specified in the
        /// Info.plist for the application.
        /// </summary>
        private DisplayOrientation GetDefaultSupportedOrientations()
        {
            if (_defaultSupportedOrientations.HasValue)
            {
                return(_defaultSupportedOrientations.Value);
            }

            var      key = new NSString("UISupportedInterfaceOrientations");
            NSObject arrayObj;

            if (!NSBundle.MainBundle.InfoDictionary.TryGetValue(key, out arrayObj))
            {
                _defaultSupportedOrientations = OrientationConverter.Normalize(DisplayOrientation.Default);
                return(_defaultSupportedOrientations.Value);
            }

            DisplayOrientation orientations = (DisplayOrientation)0;
            var supportedOrientationStrings = NSArray.ArrayFromHandle <NSString> (arrayObj.Handle);

            foreach (var orientationString in supportedOrientationStrings)
            {
                var s = (string)orientationString;
                if (!s.StartsWith("UIInterfaceOrientation"))
                {
                    continue;
                }
                s = s.Substring("UIInterfaceOrientation".Length);

                try {
                    var supportedOrientation = (UIInterfaceOrientation)Enum.Parse(
                        typeof(UIInterfaceOrientation), s);
                    orientations |= OrientationConverter.ToDisplayOrientation(supportedOrientation);
                } catch {
                }
            }

            if (orientations == (DisplayOrientation)0)
            {
                orientations = OrientationConverter.Normalize(DisplayOrientation.Default);
            }

            _defaultSupportedOrientations = orientations;
            return(_defaultSupportedOrientations.Value);
        }
Пример #6
0
        public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation()
        {
            DisplayOrientation supportedOrientations = OrientationConverter.Normalize(SupportedOrientations);

            if ((supportedOrientations & OrientationConverter.ToDisplayOrientation(this.InterfaceOrientation)) != 0)
            {
                return(this.InterfaceOrientation);
            }
            else if ((supportedOrientations & DisplayOrientation.LandscapeRight) != 0)
            {
                return(UIInterfaceOrientation.LandscapeRight);
            }
            else if ((supportedOrientations & DisplayOrientation.LandscapeLeft) != 0)
            {
                return(UIInterfaceOrientation.LandscapeLeft);
            }
            else
            {
                return(UIInterfaceOrientation.Portrait);
            }
        }