Beispiel #1
0
        private static void InfoOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
        {
            if (propertyChangedEventArgs.PropertyName != "CurrentOrientation")
            {
                return;
            }

            switch (Device.Info.CurrentOrientation)
            {
            case global::Xamarin.Forms.Internals.DeviceOrientation.Landscape:
            case global::Xamarin.Forms.Internals.DeviceOrientation.LandscapeRight:
            case global::Xamarin.Forms.Internals.DeviceOrientation.LandscapeLeft:
            {
                DeviceOrientationChanged?.Invoke(
                    new DeviceOrientationChangedEventHandlerArgs(DeviceOrientation.Landscape));
                break;
            }

            case global::Xamarin.Forms.Internals.DeviceOrientation.PortraitUp:
            case global::Xamarin.Forms.Internals.DeviceOrientation.PortraitDown:
            case global::Xamarin.Forms.Internals.DeviceOrientation.Portrait:
            {
                DeviceOrientationChanged?.Invoke(
                    new DeviceOrientationChangedEventHandlerArgs(DeviceOrientation.Portrait));
                break;
            }

            default:
            {
                DeviceOrientationChanged?.Invoke(
                    new DeviceOrientationChangedEventHandlerArgs(DeviceOrientation.Undefined));
                break;
            }
            }
        }
        private void SystemEvents_DisplaySettingsChanged(Object sender, EventArgs e)
        {
            if (IsMonitoring)
            {
                DeviceOrientations previousDeviceOrientation = CurrentDeviceOrientation;
                DeviceOrientations currentDeviceOrientation  = GetDeviceOrientation(DisplayProperties.CurrentOrientation);

                CurrentDeviceOrientation = currentDeviceOrientation;

                if (previousDeviceOrientation != currentDeviceOrientation && DeviceOrientationChanged != null)
                {
                    DeviceOrientationChanged.Invoke(this, new DeviceOrientationChangedEventArgs(previousDeviceOrientation, currentDeviceOrientation));
                }
            }
        }
    private void Update()
    {
        UpdateCurrentOrientation();

        if (prevOrientation != currOrientation)
        {
            if (currOrientation == ScreenOrientation.LandscapeLeft ||
                currOrientation == ScreenOrientation.LandscapeRight)
            {
                CurrentGeneralOrientation = GeneralOrientation.Landscape;
                GeneralOrientationChanged?.Invoke(CurrentGeneralOrientation);
            }
            else if (currOrientation == ScreenOrientation.Portrait ||
                     currOrientation == ScreenOrientation.PortraitUpsideDown)
            {
                CurrentGeneralOrientation = GeneralOrientation.Portrait;
                GeneralOrientationChanged?.Invoke(CurrentGeneralOrientation);
            }

            DeviceOrientationChanged?.Invoke(currOrientation);
        }

        prevOrientation = currOrientation;
    }
Beispiel #4
0
 /// <summary>
 /// Overrides this method if want to handle behavior when the device orientation is changed.
 /// If base.OnRegionFormatChanged() is not called, the event 'RegionFormatChanged' will not be emitted.
 /// </summary>
 /// <param name="e">The device orientation changed event argument</param>
 /// <since_tizen> 3 </since_tizen>
 protected virtual void OnDeviceOrientationChanged(DeviceOrientationEventArgs e)
 {
     DeviceOrientationChanged?.Invoke(this, e);
 }
Beispiel #5
0
 internal void OnDeviceOrientationChangedCallback(int orientation)
 {
     DeviceOrientationChanged?.Invoke(this, new DeviceOrientationEventArgs((DeviceOrientation)orientation));
 }