GetCurrentReading() 공개 메소드

public GetCurrentReading ( ) : InclinometerReading
리턴 InclinometerReading
        private void DispatcherTimerOnTick(object sender, object o)
        {
            var currentReading = _inclinometer.GetCurrentReading();

            PitchDegrees = currentReading.PitchDegrees;
            RollDegrees  = currentReading.RollDegrees;
            YawDegrees   = currentReading.YawDegrees;

            SetupNewLocation();
        }
        private void SetupSensor()
        {
            _inclinometer = Sensor.Inclinometer.GetDefault();

            if (_inclinometer == null)
            {
                // tell the user they dont have an inclinometer on the device
            }
            else
            {
                _lastPitchDegrees = _inclinometer.GetCurrentReading().PitchDegrees;
            }
        }
        private void SetupSensor()
        {
            _inclinometer = Sensor.Inclinometer.GetDefault();

            if (_inclinometer == null)
            {
                // tell the user they dont have an inclinometer on the device
            }
            else
            {
                _lastPitchDegrees = _inclinometer.GetCurrentReading().PitchDegrees;
            }
        }
예제 #4
0
파일: Task.cs 프로젝트: eliashuehne/sbr
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            ApplicationDataContainer    settings       = ApplicationData.Current.LocalSettings;
            DeviceWatcherTriggerDetails triggerDetails = (DeviceWatcherTriggerDetails)taskInstance.TriggerDetails;

            bool   surfaceKeyboardAttached = false;
            int    numKeyboardsDetected    = 0;
            string lastID = "";

            foreach (DeviceWatcherEvent e in triggerDetails.DeviceWatcherEvents)
            {
                switch (e.Kind)
                {
                case DeviceWatcherEventKind.Add:
                    //Debug.WriteLine("Add: " + e.DeviceInformation.Id);
                    if ("Surface Keyboard".Equals(e.DeviceInformation.Name))
                    {
                        //Surface Keyboard being attached
                        //Reading sensor data to determine displays
                        Windows.Devices.Sensors.Inclinometer _inclinometer = Inclinometer.GetDefault();
                        if (_inclinometer != null)
                        {
                            Debug.WriteLine("Sensorwert: " + _inclinometer.GetCurrentReading().PitchDegrees);
                            settings.Values["pitch"] = _inclinometer.GetCurrentReading().PitchDegrees;
                            if (_inclinometer.GetCurrentReading().PitchDegrees < 20)
                            {
                                settings.Values["surfaceMode"] = "tablet";
                                sendMessage();
                            }
                            else
                            {
                                settings.Values["surfaceMode"] = "desktop";
                                sendMessage();
                            }
                        }
                        numKeyboardsDetected++;
                        lastID = e.DeviceInformation.Id;
                        //UPDATE. [System.Devices.InterfaceEnabled, True]
                        //surfaceKeyboardAttached = true;
                    }
                    break;

                case DeviceWatcherEventKind.Update:
                    //Debug.WriteLine("Update: " + e.DeviceInformationUpdate.Id);
                    if (settings.Values["id"] != null)
                    {
                        if (settings.Values["id"].Equals(e.DeviceInformationUpdate.Id))
                        {
                            Debug.WriteLine("Surface keyboard detached or attached");
                            surfaceKeyboardAttached = true;
                        }
                    }

                    //Debug.WriteLine("UPDATE. " + string.Join(",", e.DeviceInformationUpdate.Properties.ToList()));
                    break;

                case DeviceWatcherEventKind.Remove:
                    Debug.WriteLine("Remove: " + e.DeviceInformationUpdate.Id);
                    break;
                }
            }
            ;
            if (numKeyboardsDetected == 1)
            {
                settings.Values["id"] = lastID;
            }
            settings.Values["keyboardStatus"] = surfaceKeyboardAttached;
        }