Compartilhar via


Inclinometer.ReadingChanged Evento

Definição

Ocorre sempre que o inclinômetro relata uma nova leitura do sensor.

// 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) 

Tipo de evento

Exemplos

O exemplo a seguir demonstra como um aplicativo UWP criado com C# e XAML registrou seu manipulador de eventos ReadingChanged .

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);
    }
}

O exemplo a seguir mostra o manipulador de eventos ReadingChanged.

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);
    });
}

Comentários

Os aplicativos podem definir a frequência desse evento definindo a propriedade ReportInterval .

Aplica-se a