/// <summary> /// Initializes a new instance of the <see cref="AcceleratorSensorPage"/> class. /// </summary> public GyroscopePage() { var device = Resolver.Resolve<IDevice> (); Title ="Accelerator Sensor"; if (device.Gyroscope == null) { Content = new Label () { TextColor = Color.Red, Text = "Device does not have gyroscope sensor or it is not enabled." }; return; } this.gyroscope = device.Gyroscope; var grid = new StackLayout (); this.xsensor = new SensorBarView () { HeightRequest = 75, WidthRequest = 250, MinimumHeightRequest = 10, MinimumWidthRequest = 50, BackgroundColor = BackgroundColor // VerticalOptions = LayoutOptions.Fill, // HorizontalOptions = LayoutOptions.Fill }; this.ysensor = new SensorBarView() { HeightRequest = 75, WidthRequest = 250, MinimumHeightRequest = 10, MinimumWidthRequest = 50, BackgroundColor = BackgroundColor // VerticalOptions = LayoutOptions.Fill, // HorizontalOptions = LayoutOptions.Fill }; this.zsensor = new SensorBarView() { HeightRequest = 75, WidthRequest = 250, MinimumHeightRequest = 10, MinimumWidthRequest = 50, BackgroundColor = BackgroundColor // VerticalOptions = LayoutOptions.Fill, // HorizontalOptions = LayoutOptions.Fill }; grid.Children.Add (new Label () { Text = string.Format ("Accelerometer data for {0}", device.Name) }); grid.Children.Add (new Label () { Text = "X", XAlign = TextAlignment.Center }); grid.Children.Add (this.xsensor); grid.Children.Add (new Label () { Text = "Y", XAlign = TextAlignment.Center }); grid.Children.Add (this.ysensor); grid.Children.Add (new Label () { Text = "Z", XAlign = TextAlignment.Center }); grid.Children.Add (this.zsensor); Content = grid; }
public AcceleratorSensorPage() { var device = Resolver.Resolve <IDevice> (); this.Title = "Accelerator Sensor"; if (device.Accelerometer == null) { this.Content = new Label() { TextColor = Color.Red, Text = "Device does not have accelerometer sensor or it is not enabled." }; return; } this.accelerometer = device.Accelerometer; var grid = new StackLayout(); this.xsensor = new SensorBarView() { HeightRequest = 75, WidthRequest = 250, MinimumHeightRequest = 10, MinimumWidthRequest = 50, BackgroundColor = this.BackgroundColor // VerticalOptions = LayoutOptions.Fill, // HorizontalOptions = LayoutOptions.Fill }; this.ysensor = new SensorBarView() { HeightRequest = 75, WidthRequest = 250, MinimumHeightRequest = 10, MinimumWidthRequest = 50, BackgroundColor = this.BackgroundColor // VerticalOptions = LayoutOptions.Fill, // HorizontalOptions = LayoutOptions.Fill }; this.zsensor = new SensorBarView() { HeightRequest = 75, WidthRequest = 250, MinimumHeightRequest = 10, MinimumWidthRequest = 50, BackgroundColor = this.BackgroundColor // VerticalOptions = LayoutOptions.Fill, // HorizontalOptions = LayoutOptions.Fill }; grid.Children.Add(new Label() { Text = string.Format("Accelerometer data for {0}", device.Name) }); grid.Children.Add(new Label() { Text = "X", XAlign = TextAlignment.Center }); grid.Children.Add(xsensor); grid.Children.Add(new Label() { Text = "Y", XAlign = TextAlignment.Center }); grid.Children.Add(ysensor); grid.Children.Add(new Label() { Text = "Z", XAlign = TextAlignment.Center }); grid.Children.Add(zsensor); this.Content = grid; }
/// <summary> /// Initializes a new instance of the <see cref="AcceleratorSensorPage"/> class. /// </summary> public GyroscopePage() { var device = Resolver.Resolve <IDevice> (); if (device != null && device.Gyroscope != null) { this.gyroscope = device.Gyroscope; } else { this.gyroscope = Resolver.Resolve <IGyroscope>() ?? DependencyService.Get <IGyroscope>(); } if (gyroscope == null) { Content = new Label() { TextColor = Color.Red, Text = "Device does not have gyroscope sensor or it is not enabled." }; return; } Title = "Accelerator Sensor"; var grid = new StackLayout(); this.xsensor = new SensorBarView() { HeightRequest = 75, WidthRequest = 250, MinimumHeightRequest = 10, MinimumWidthRequest = 50, BackgroundColor = BackgroundColor // VerticalOptions = LayoutOptions.Fill, // HorizontalOptions = LayoutOptions.Fill }; this.ysensor = new SensorBarView() { HeightRequest = 75, WidthRequest = 250, MinimumHeightRequest = 10, MinimumWidthRequest = 50, BackgroundColor = BackgroundColor // VerticalOptions = LayoutOptions.Fill, // HorizontalOptions = LayoutOptions.Fill }; this.zsensor = new SensorBarView() { HeightRequest = 75, WidthRequest = 250, MinimumHeightRequest = 10, MinimumWidthRequest = 50, BackgroundColor = BackgroundColor // VerticalOptions = LayoutOptions.Fill, // HorizontalOptions = LayoutOptions.Fill }; grid.Children.Add(new Label() { Text = string.Format("Accelerometer data for {0}", device.Name) }); grid.Children.Add(new Label() { Text = "X", XAlign = TextAlignment.Center }); grid.Children.Add(this.xsensor); grid.Children.Add(new Label() { Text = "Y", XAlign = TextAlignment.Center }); grid.Children.Add(this.ysensor); grid.Children.Add(new Label() { Text = "Z", XAlign = TextAlignment.Center }); grid.Children.Add(this.zsensor); Content = grid; }