Esempio n. 1
0
 public static void SetDefaultContainer(ICodeBrixContainer container)
 {
     if (_defaultContainer != null)
     {
         throw new InvalidOperationException("The CodeBrixApplication default container can only be set one time at application startup");
     }
     _defaultContainer = container ?? throw new ArgumentNullException(nameof(container));
     CodeBrixViewModelBase.SetDefaultContainer(container);
 }
Esempio n. 2
0
        // ReSharper restore InconsistentNaming

        private static void SubscribeToPageScreenSizeNotifications()
        {
            _pageScreenSizeSubscriber = new object();
            MessagingCenter.Instance.Subscribe <ScreenSizeMessage>(_pageScreenSizeSubscriber, ScreenSizeMessage.OnSizeAllocated,
                                                                   (message) =>
            {
                CodeBrixViewModelBase.OnOrientationChange(message.DeviceOrientation, message.IsPortraitOrientation);
            });
        }
Esempio n. 3
0
        public static void Initialize()
        {
            CodeBrixViewModelBase.DeviceViewOrientationChecker = () =>
            {
                lock (orientationLocker)
                {
                    _lastOrientation = UIDevice.CurrentDevice.Orientation;

                    switch (_lastOrientation)
                    {
                    case UIDeviceOrientation.Portrait:
                        return(DeviceViewOrientation.PortraitNormal);

                    //break;
                    case UIDeviceOrientation.PortraitUpsideDown:
                        return(DeviceViewOrientation.PortraitUpsideDown);

                    //break;
                    case UIDeviceOrientation.LandscapeLeft:
                        return(DeviceViewOrientation.LandscapeLeft);

                    //break;
                    case UIDeviceOrientation.LandscapeRight:
                        return(DeviceViewOrientation.LandscapeRight);

                    //break;
                    case UIDeviceOrientation.Unknown:
                    case UIDeviceOrientation.FaceUp:
                    case UIDeviceOrientation.FaceDown:
                    default:
                        break;     //Going to return Unknown for all of these
                    }
                    return(DeviceViewOrientation.Unknown);
                }
            };

            _notificationCenter = NSNotificationCenter.DefaultCenter;
            _notificationCenter.AddObserver(UIApplication.DidChangeStatusBarOrientationNotification,
                                            DeviceOrientationDidChange);
            UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications();

            CodeBrixViewModelBase.OnOrientationChange(CodeBrixViewModelBase.DeviceViewOrientationChecker.Invoke());
            SubscribeToPageScreenSizeNotifications();
            _initialized = true;
        }