Ejemplo n.º 1
0
 public override void OnOrientationChanged(int orientation)
 {
     if (orientation != OrientationUnknown)
     {
         OrientationChanged?.Invoke(orientation);
     }
 }
Ejemplo n.º 2
0
        private void ColorSelectedSide()
        {
            this.Triangles = new OrientationGizmo(4, this.HighlightedSide, this.SelectedSide, false).Triangles;
            this.UpdateBinding();

            OrientationChanged?.Invoke(null, this.SelectedSide);
        }
Ejemplo n.º 3
0
        protected void OnOrientationChanged(object sender, NSNotificationEventArgs args)
        {
            var rotaion = DeviceRotation;

            switch (UIDevice.CurrentDevice.Orientation)
            {
            case UIDeviceOrientation.Portrait:
                DeviceRotation = DeviceRotation.Portrait;
                break;

            case UIDeviceOrientation.LandscapeRight:
                DeviceRotation = DeviceRotation.Landscape;
                break;

            case UIDeviceOrientation.PortraitUpsideDown:
                DeviceRotation = DeviceRotation.ReversePortrait;
                break;

            case UIDeviceOrientation.LandscapeLeft:
                DeviceRotation = DeviceRotation.ReverseLandscape;
                break;
            }

            if (rotaion != DeviceRotation)
            {
                OrientationChanged?.Invoke(this, DeviceRotation);
            }
        }
Ejemplo n.º 4
0
 protected virtual void OnOrientationChanged(Orientation newOrientation)
 {
     if (OrientationChanged != null)
     {
         OrientationChanged.Invoke(this, new OrientationChangedEventArgs(newOrientation));
     }
 }
Ejemplo n.º 5
0
        private async Task ProcessOrientationMessage(OrientationMessage orientationMsg)
        {
            DateTime originalEventUTC = DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Utc);

            if (orientationMsg.OriginalEventUTCTime != null)
            {
                originalEventUTC = DateTime.Parse(orientationMsg.OriginalEventUTCTime, null, System.Globalization.DateTimeStyles.RoundtripKind);
            }
            lock (OrientationChanged)
            {
                if (originalEventUTC >= _lastOrientationUTC)
                {
                    Log.WriteLine("OrientationMsgHandler invoking event. original event UTC {0} prev {1}", originalEventUTC.ToString("o"), _lastOrientationUTC.ToString("o"));
                    OrientationChanged?.Invoke(this, orientationMsg.OrientationState);
                    _lastOrientationUTC = originalEventUTC;
                }
                else
                {
                    Log.WriteLine("OrientationMsgHandler ignoring stale message. original event UTC {0} prev {1}", originalEventUTC.ToString("o"), _lastOrientationUTC.ToString("o"));
                }
            }
            await Task.CompletedTask;

            return;
        }
Ejemplo n.º 6
0
        internal void HandleConfigurationChange()
        {
            var previousOrientation = CurrentOrientation;

            Initialize();
            if (previousOrientation != CurrentOrientation)
            {
                OrientationChanged?.Invoke(this, CurrentOrientation);
            }
        }
        public override void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
        {
            base.ViewWillTransitionToSize(toSize, coordinator);

            if (View.Hidden)
            {
                return;
            }

            OrientationChanged?.Invoke(this, new SideMenuNavigationControllerOrientationChangedEventArgs(coordinator, toSize));
        }
 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);
     }
 }
Ejemplo n.º 9
0
 private void InitializeOrientation()
 {
     _didChangeStatusBarOrientationObserver = NSNotificationCenter
                                              .DefaultCenter
                                              .AddObserver(
         UIApplication.DidChangeStatusBarOrientationNotification,
         n =>
     {
         UpdateCurrentOrientation();
         OrientationChanged?.Invoke(this, CurrentOrientation);
     }
         );
 }
Ejemplo n.º 10
0
 private void CalculateCurrentOrientation(SimpleOrientation orientation)
 {
     if (_currentOrientation != orientation)
     {
         _currentOrientation = orientation;
         var args = new SimpleOrientationSensorOrientationChangedEventArgs()
         {
             Orientation = orientation,
             Timestamp   = DateTimeOffset.Now,
         };
         OrientationChanged?.Invoke(this, args);
     }
 }
Ejemplo n.º 11
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());
 }
Ejemplo n.º 12
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);
         }
     });
 }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
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();
     }
 }
Ejemplo n.º 15
0
 public static void OnOrientationChanged()
 {
     OrientationChanged?.Invoke();
 }
Ejemplo n.º 16
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
                });
            }
        }
Ejemplo n.º 17
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);
 }
Ejemplo n.º 20
0
 protected void FireOrientationChanged()
 {
     OrientationChanged?.Invoke(this, new EventArgs());
 }
Ejemplo n.º 21
0
        //---------------------------------------------------------------------------

        private void OnOrientationChanged(Vector2 oldOrientation, Vector2 newOrientation)
        {
            OrientationChanged?.Invoke(oldOrientation, newOrientation);
        }
Ejemplo n.º 22
0
 /// <summary>
 ///     When orientation changes
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnOrientationChanged(OrientationChangedEventArgs e)
 {
     OrientationChanged?.Invoke(this, e);
 }