Udostępnij za pośrednictwem


Inclinometer.ReadingChanged Event

Definition

Occurs each time the inclinometer reports a new sensor reading.

// Register
event_token ReadingChanged(TypedEventHandler<Inclinometer, InclinometerReadingChangedEventArgs const&> const& handler) const;

// Revoke with event_token
void ReadingChanged(event_token const* cookie) const;

// Revoke with event_revoker
Inclinometer::ReadingChanged_revoker ReadingChanged(auto_revoke_t, TypedEventHandler<Inclinometer, InclinometerReadingChangedEventArgs const&> const& handler) const;
public event TypedEventHandler<Inclinometer,InclinometerReadingChangedEventArgs> ReadingChanged;
function onReadingChanged(eventArgs) { /* Your code */ }
inclinometer.addEventListener("readingchanged", onReadingChanged);
inclinometer.removeEventListener("readingchanged", onReadingChanged);
- or -
inclinometer.onreadingchanged = onReadingChanged;
Public Custom Event ReadingChanged As TypedEventHandler(Of Inclinometer, InclinometerReadingChangedEventArgs) 

Event Type

Examples

The following example demonstrates how a UWP app built with C# and XAML registered its ReadingChanged event handler.

private void ScenarioEnable(object sender, RoutedEventArgs e)
{
    if (_inclinometer != null)
    {
        // Establish the report interval
        _inclinometer.ReportInterval = _desiredReportInterval;

        Window.Current.VisibilityChanged += new WindowVisibilityChangedEventHandler(VisibilityChanged);
        _inclinometer.ReadingChanged += new TypedEventHandler<Inclinometer, InclinometerReadingChangedEventArgs>(ReadingChanged);

        ScenarioEnableButton.IsEnabled = false;
        ScenarioDisableButton.IsEnabled = true;
    }
    else
    {
        rootPage.NotifyUser("No inclinometer found", NotifyType.StatusMessage);
    }
}

The following example shows the ReadingChanged event handler.

async private void ReadingChanged(object sender, InclinometerReadingChangedEventArgs e)
{
    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
        InclinometerReading reading = e.Reading;
        ScenarioOutput_X.Text = String.Format("{0,5:0.00}", reading.PitchDegrees);
        ScenarioOutput_Y.Text = String.Format("{0,5:0.00}", reading.RollDegrees);
        ScenarioOutput_Z.Text = String.Format("{0,5:0.00}", reading.YawDegrees);
    });
}

Remarks

Applications can set the frequency of this event by setting the ReportInterval property.

Applies to