This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task GetSubscriptions(string tenantId) | |
{ | |
var requestUrl = "https://management.azure.com/subscriptions?api-version=2015-01-01"; | |
try { | |
var data = await DependencyService.Get<IAuthenticator> ().AuthenticateSilently (tenantId, | |
App.ManagementResourceUri, App.ClientId); | |
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", data.AccessToken); | |
var subsriptionResponse = await client.GetStringAsync (requestUrl); | |
var subscriptions = JsonConvert.DeserializeObject<SubscriptionResponse>(subsriptionResponse); | |
foreach (var subscription in subscriptions.SubscriptionCollection) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task GetTenants() | |
{ | |
var requestUrl = "https://management.azure.com/tenants?api-version=2015-01-01"; | |
try { | |
var tenantResponse = await client.GetStringAsync(requestUrl); | |
tenantCollection = JsonConvert.DeserializeObject<TenantResponse> (tenantResponse); | |
} | |
catch (Exception ex) { | |
await DisplayAlert("Error!", ex.Message, "Dismiss"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void BtnStart_OnClicked(object sender, EventArgs e) | |
{ | |
CrossDeviceMotion.Current.Start(MotionSensorType.Accelerometer, MotionSensorDelay.Ui); | |
CrossDeviceMotion.Current.SensorValueChanged += (s, a) => | |
{ | |
switch (a.SensorType) | |
{ | |
case MotionSensorType.Accelerometer: | |
lblXAxis.Text = ((MotionVector)a.Value).X.ToString("F"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override void ViewDidLoad() | |
{ | |
base.ViewDidLoad(); | |
_motionManager = new CMMotionManager(); | |
_motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue, (data, error) => | |
{ | |
lblXAxis.Text = data.Acceleration.X.ToString("F"); | |
lblYAxis.Text = data.Acceleration.Y.ToString("F"); | |
lblZAxis.Text = data.Acceleration.Z.ToString("F"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Activity(Label = "Accelerometer_Droid", MainLauncher = true, Icon = "@drawable/icon")] | |
public class MainActivity : Activity, ISensorEventListener | |
{ | |
private SensorManager _sensorManager; | |
private static readonly object _syncLock = new object(); | |
private TextView x_axis; private TextView y_axis; private TextView z_axis; | |
protected override void OnCreate(Bundle bundle) | |
{ | |
base.OnCreate(bundle); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed partial class MainPage : Page | |
{ | |
private Accelerometer _accelerometer; | |
public MainPage() | |
{ | |
this.InitializeComponent(); | |
this.NavigationCacheMode = NavigationCacheMode.Required; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For Gyrometer | |
private async void ReadingChanged(object sender, GyrometerReadingChangedEventArgs e) | |
{ | |
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | |
{ | |
GyrometerReading reading = e.Reading; | |
txtXAxis.Text = String.Format("{0,5:0.00}", reading.AngularVelocityX); | |
txtYAxis.Text = String.Format("{0,5:0.00}", reading.AngularVelocityY); | |
txtZAxis.Text = String.Format("{0,5:0.00}", reading.AngularVelocityZ); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For Gyrometer | |
if (_gyrometer != null) | |
{ | |
// Establish the report interval for all scenarios | |
uint minReportInterval = _gyrometer.MinimumReportInterval; | |
uint reportInterval = minReportInterval > 16 ? minReportInterval : 16; | |
_gyrometer.ReportInterval = reportInterval; | |
// Assign an event handler for the gyrometer reading-changed event | |
_gyrometer.ReadingChanged += ReadingChanged; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Gyrometer _gyrometer; | |
private SimpleOrientationSensor _simpleorientation; | |
private LightSensor _lightsensor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_gyrometer = Gyrometer.GetDefault(); | |
_simpleorientation = SimpleOrientationSensor.GetDefault(); | |
_lightsensor = LightSensor.GetDefault(); |
NewerOlder