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); }
// ReSharper restore InconsistentNaming private static void SubscribeToPageScreenSizeNotifications() { _pageScreenSizeSubscriber = new object(); MessagingCenter.Instance.Subscribe <ScreenSizeMessage>(_pageScreenSizeSubscriber, ScreenSizeMessage.OnSizeAllocated, (message) => { CodeBrixViewModelBase.OnOrientationChange(message.DeviceOrientation, message.IsPortraitOrientation); }); }
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; }