Exemplo n.º 1
0
 protected virtual void OnOrientationChanged(Orientation newOrientation)
 {
     if (OrientationChanged != null)
     {
         OrientationChanged.Invoke(this, new OrientationChangedEventArgs(newOrientation));
     }
 }
Exemplo n.º 2
0
 private void SimpleOrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args)
 {
     if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown)
     {
         // Only raise the OrientationChanged event if the device is not parallel to the ground. This allows users to take pictures of documents (FaceUp)
         // or the ceiling (FaceDown) in portrait or landscape, by first holding the device in the desired orientation, and then pointing the camera
         // either up or down, at the desired subject.
         //Note: This assumes that the camera is either facing the same way as the screen, or the opposite way. For devices with cameras mounted
         //      on other panels, this logic should be adjusted.
         OrientationChanged?.Invoke(this, false);
     }
 }
Exemplo n.º 3
0
 private void InitializeOrientation()
 {
     _didChangeStatusBarOrientationObserver = NSNotificationCenter
                                              .DefaultCenter
                                              .AddObserver(
         UIApplication.DidChangeStatusBarOrientationNotification,
         n =>
     {
         UpdateCurrentOrientation();
         OrientationChanged?.Invoke(this, CurrentOrientation);
     }
         );
 }
Exemplo n.º 4
0
 private void CalculateCurrentOrientation(SimpleOrientation orientation)
 {
     if (_currentOrientation != orientation)
     {
         _currentOrientation = orientation;
         var args = new SimpleOrientationSensorOrientationChangedEventArgs()
         {
             Orientation = orientation,
             Timestamp   = DateTimeOffset.Now,
         };
         OrientationChanged?.Invoke(this, args);
     }
 }
Exemplo n.º 5
0
 private void SetOrientation(View3DOrientationEnum value)
 {
     _orientation = value;
     projectionToolStripButton.Image = Orientation switch
     {
         View3DOrientationEnum.XZ => Properties.Resources.zxProjection,
         View3DOrientationEnum.YX => Properties.Resources.xyProjection,
         View3DOrientationEnum.ZY => Properties.Resources.yzProjection,
         View3DOrientationEnum.ZX => Properties.Resources.xzProjection,
         View3DOrientationEnum.YZ => Properties.Resources.zyProjection,
         View3DOrientationEnum.XY => Properties.Resources.yxProjection,
         _ => throw new InvalidCaseException(nameof(Orientation), Orientation, 891466),
     };
     OrientationChanged?.Invoke(this, new EventArgs());
 }
Exemplo n.º 6
0
 private void SetCurrentOrientation(SimpleOrientation orientation)
 {
     CoreDispatcher.Main.RunAsync(CoreDispatcherPriority.Normal, async ct =>
     {
         if (_currentOrientation != orientation)
         {
             _currentOrientation = orientation;
             var args            = new SimpleOrientationSensorOrientationChangedEventArgs()
             {
                 Orientation = orientation,
                 Timestamp   = DateTimeOffset.Now,
             };
             OrientationChanged?.Invoke(this, args);
         }
     });
 }
Exemplo n.º 7
0
        public override void OnConfigurationChanged(Configuration newConfig)
        {
            base.OnConfigurationChanged(newConfig);

            var orientation = new OrientationChangedEventArgs(ScreenOrientation.Undefined);

            if (newConfig.Orientation == global::Android.Content.Res.Orientation.Landscape)
            {
                orientation = new OrientationChangedEventArgs(ScreenOrientation.Landscape);
            }
            else if (newConfig.Orientation == global::Android.Content.Res.Orientation.Portrait || newConfig.Orientation == global::Android.Content.Res.Orientation.Square)
            {
                orientation = new OrientationChangedEventArgs(ScreenOrientation.Portrait);
            }

            OrientationChanged?.Invoke(this, orientation);
        }
Exemplo n.º 8
0
 public void RunOrientationAssist()
 {
     this.Orientation = SanitizeOriention(this.orientationSensor.GetOrientation());
     OrientationChanged?.Invoke(new Orientation(this.Orientation));
     if (IsAssistEnabled)
     {
         if ((++assistCount % FramesPerAssist == 0))
         {
             Debug.WriteLine($"Orient: {Orientation}");
             Debug.WriteLine($"Target: {Target}");
             HandleOrientationOffset(this.Orientation - this.Target);
         }
     }
     else
     {
         this.motorController.Yaw   = 0;
         this.motorController.Pitch = 0;
         this.motorController.Roll  = 0;
         this.motorController.UpdateMotors();
     }
 }
Exemplo n.º 9
0
        void ISensorEventListener.OnSensorChanged(SensorEvent?e)
        {
            if (e is null)
            {
                return;
            }
            float[]? rotationMatrix = null;

            if (e.Sensor == _rotationSensor)
            {
                var rotationVector = e.Values.ToArray();
                rotationMatrix = new float[9];
                SensorManager.GetRotationMatrixFromVector(rotationMatrix, rotationVector);
            }
            else if (e.Sensor == _accelerometer)
            {
                _lastAccelerometer = e.Values.ToArray();
            }
            else if (e.Sensor == _magnetometer)
            {
                _lastMagnetometer = e.Values.ToArray();
            }
            if (_lastAccelerometer != null && _lastMagnetometer != null)
            {
                rotationMatrix = new float[9];
                float[] magnetic = new float[9];
                SensorManager.GetRotationMatrix(rotationMatrix, magnetic, _lastAccelerometer, _lastMagnetometer);
                _lastMagnetometer  = null;
                _lastAccelerometer = null;
            }
            if (rotationMatrix != null)
            {
                Android.Hardware.Axis ax, ay;
                switch (_windowManager?.DefaultDisplay?.Rotation)
                {
                case SurfaceOrientation.Rotation90:
                    ax = Android.Hardware.Axis.Z;
                    ay = Android.Hardware.Axis.MinusX;
                    break;

                case SurfaceOrientation.Rotation180:
                    ax = Android.Hardware.Axis.MinusX;
                    ay = Android.Hardware.Axis.MinusZ;
                    break;

                case SurfaceOrientation.Rotation270:
                    ax = Android.Hardware.Axis.MinusZ;
                    ay = Android.Hardware.Axis.X;
                    break;

                case SurfaceOrientation.Rotation0:
                default:
                    ax = Android.Hardware.Axis.X;
                    ay = Android.Hardware.Axis.Z;
                    break;
                }
                float[] adjustedRotationMatrix = new float[9];
                SensorManager.RemapCoordinateSystem(rotationMatrix, ax, ay, adjustedRotationMatrix);
                // Transform rotation matrix into azimuth/pitch/roll
                float[] orientation = new float[3];
                SensorManager.GetOrientation(adjustedRotationMatrix, orientation);

                OrientationChanged?.Invoke(this, new CompassOrientationEventArgs()
                {
                    Transformation = adjustedRotationMatrix,
                    Orientation    = orientation,
                    Accuracy       = _currentAccuracy
                });
            }
        }
Exemplo n.º 10
0
        private void OnWindowOrientationChanged(Orientation newOrinetation)
        {
            WindowOrientationChangedEventArgs windowOrientationChangedEventArgs = new(this, newOrinetation);

            OrientationChanged.Invoke(this, windowOrientationChangedEventArgs);
        }
 private void HandleOrientationChanged(bool updatePreviewStreamRequired)
 {
     OrientationChanged?.Invoke(this, updatePreviewStreamRequired);
 }
 private void DisplayInformation_OrientationChanged(DisplayInformation sender, object args)
 {
     OrientationChanged?.Invoke(this, true);
 }
Exemplo n.º 13
0
 public static void OnOrientationChanged()
 {
     OrientationChanged?.Invoke();
 }
Exemplo n.º 14
0
 /// <summary>
 ///     When orientation changes
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnOrientationChanged(OrientationChangedEventArgs e)
 {
     OrientationChanged?.Invoke(this, e);
 }
Exemplo n.º 15
0
        //---------------------------------------------------------------------------

        private void OnOrientationChanged(Vector2 oldOrientation, Vector2 newOrientation)
        {
            OrientationChanged?.Invoke(oldOrientation, newOrientation);
        }
Exemplo n.º 16
0
 protected void FireOrientationChanged()
 {
     OrientationChanged?.Invoke(this, new EventArgs());
 }