public SensorValueChangedEventArgs(DeviceSensorValues sv, DeviceSensorType st)
 {
     SensorValues = sv;
     SensorType = st;
 }
        public void OnSensorChanged(SensorEvent e)
        {
            if (SensorValueChanged == null)
                return;

            DeviceSensorValues sensorValues = new DeviceSensorValues(e.Values[0], e.Values[1], e.Values[2]);

            switch (e.Sensor.Type)
            {
                case SensorType.Accelerometer:
                    SensorValueChanged(this, new SensorValueChangedEventArgs(sensorValues, DeviceSensorType.Accelerometer));
                    break;
                case SensorType.Gravity:
                    if (isOrientationRawActivated)
                    {
                        //gravity = sensorValues.getCopy ();
                        filterLowPass(sensorValues.Values, gravity.Values, 0.8f);
                    }
                    SensorValueChanged(this, new SensorValueChangedEventArgs(sensorValues, DeviceSensorType.Gravimeter));
                    break;
                case SensorType.Gyroscope:
                    SensorValueChanged(this, new SensorValueChangedEventArgs(sensorValues, DeviceSensorType.Gyroscope));
                    break;
                case SensorType.MagneticField:
                    if (isOrientationRawActivated) {
                        magnetic = sensorValues.getCopy ();
                        if (gravity != null) {
                            float[] R1 = new float[9];
                            float[] R = new float[9];
                            float[] I = new float[9];
                            if (SensorManager.GetRotationMatrix(R1, I, gravity.Values, magnetic.Values))
                            {
                                //remap y axis to z axis
                                SensorManager.RemapCoordinateSystem(R1, Axis.X, Axis.Z, R);
                                //R = R1;
                                DeviceSensorValues orienValues = new DeviceSensorValues ();
                                SensorManager.GetOrientation(R, orienValues.Values);
                                SensorValueChanged(this, new SensorValueChangedEventArgs(orienValues, DeviceSensorType.OrientationRaw));
                            }
                        }
                    }
                    SensorValueChanged(this, new SensorValueChangedEventArgs(sensorValues, DeviceSensorType.Magnetometer));
                    break;
                case SensorType.Orientation:
                    SensorValueChanged(this, new SensorValueChangedEventArgs(sensorValues, DeviceSensorType.Orientation));
                    break;
            }
        }