本文整理汇总了C#中Accelerometer类的典型用法代码示例。如果您正苦于以下问题:C# Accelerometer类的具体用法?C# Accelerometer怎么用?C# Accelerometer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Accelerometer类属于命名空间,在下文中一共展示了Accelerometer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ShapePage
public ShapePage()
{
InitializeComponent();
if (accelerometer == null)
{
accelerometer = new Accelerometer();
accelerometer.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20);
accelerometer.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<AccelerometerReading>>(accelerometer_CurrentValueChanged);
accelerometer.Start();
}
BitmapImage bi = new BitmapImage();
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
/*var filestream = store.OpenFile("image.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);
var imageAsBitmap = Microsoft.Phone.PictureDecoder.DecodeJpeg(filestream);
image2.Source = imageAsBitmap;*/
if (store.FileExists("tempJPEG2"))
{
using (IsolatedStorageFileStream fileStream = store.OpenFile("tempJPEG2", System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
bi.SetSource(fileStream);
image2.Source = bi;
}
}
else
{
var filestream = store.OpenFile("image.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);
var imageAsBitmap = Microsoft.Phone.PictureDecoder.DecodeJpeg(filestream);
image2.Source = imageAsBitmap;
}
}
stickerNum = 0;
}
开发者ID:aabrohi,项目名称:kinect-kollage,代码行数:35,代码来源:ShapePage.xaml.cs
示例2: MainPage
// Constructor
public MainPage()
{
InitializeComponent();
statusLocked.Visibility = System.Windows.Visibility.Collapsed;
statusUnlocked.Visibility = System.Windows.Visibility.Collapsed;
accelstatus.Visibility = System.Windows.Visibility.Collapsed;
timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 0, 0, 25);
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
if (Accelerometer.IsSupported)
{
Accelerometer sens = new Accelerometer();
sens.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<AccelerometerReading>>(sens_CurrentValueChanged);
sens.Start();
}
else
{ //It's disabled
accelstatus.IsChecked = true;
statusLocked.Visibility = System.Windows.Visibility.Visible;
statusUnlocked.Visibility = System.Windows.Visibility.Collapsed;
}
}
开发者ID:jessenic,项目名称:wph-orientationlock,代码行数:28,代码来源:MainPage.xaml.cs
示例3: MainPage
// Constructor
public MainPage()
{
InitializeComponent();
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
timer = new DispatcherTimer();
timer.Tick += timer_Tick;
timer.Interval = TimeSpan.FromMilliseconds(66);
if (Accelerometer.IsSupported)
{
accelSensor = new Accelerometer();
accelSensor.TimeBetweenUpdates = TimeSpan.FromMilliseconds(66);
}
if (Compass.IsSupported)
{
compassSensor = new Compass();
compassSensor.TimeBetweenUpdates = TimeSpan.FromMilliseconds(66);
compassSensor.Calibrate += compassSensor_Calibrate;
}
if (Gyroscope.IsSupported)
{
gyroSensor = new Gyroscope();
gyroSensor.TimeBetweenUpdates = TimeSpan.FromMilliseconds(66);
}
}
开发者ID:amrzagloul,项目名称:Windows-Phone-8-In-Action,代码行数:31,代码来源:MainPage.xaml.cs
示例4: Execute
public override void Execute(params string[] args)
{
this.HasCallback = false; // This uses an AsyncCallback
this.successCallback = args[0];
this.errorCallback = args[1];
try
{
if (this.accelerometer == null)
{
this.accelerometer = new Accelerometer();
}
this.accelerometer.ReadingChanged += this.AccelerometerReadingChanged;
this.accelerometer.Start();
}
catch (UnauthorizedAccessException unauthorizedAccessException)
{
this.CallbackName = this.errorCallback;
this.CallbackArgs = new[] { unauthorizedAccessException.Message };
this.SendAsyncResponse();
}
catch (AccelerometerFailedException accelerometerFailedException)
{
this.CallbackName = this.errorCallback;
this.CallbackArgs = new[] { accelerometerFailedException.Message };
this.SendAsyncResponse();
}
}
开发者ID:ARenzi,项目名称:phonegap-wp7,代码行数:30,代码来源:AccelerometergetCurrentAccelerationCommand.cs
示例5: StartMonitoring
static partial void StartMonitoring()
{
accelerometer = new Accelerometer { TimeBetweenUpdates = TimeSpan.FromMilliseconds((long)Interval) };
accelerometer.CurrentValueChanged += AccelerometerOnCurrentValueChanged;
accelerometer.Start();
}
开发者ID:paul33868,项目名称:SimplyMobile,代码行数:7,代码来源:Accelometer.cs
示例6: Aceloro
private void Aceloro(Accelerometer sender, AccelerometerReadingChangedEventArgs args)
{
//gamescreen.batcherBridge.drawText(50f, 50f, 50f, 50f,1, args.Reading.AccelerationX.ToString(), 1f, 1f, 1f, 1f, "ns");
//if(!Settings.vibrate)
// Game.Update1((float)args.Reading.AccelerationX*2, (float)args.Reading.AccelerationY, (float)args.Reading.AccelerationZ);
}
开发者ID:maxhappy,项目名称:TerminalVelocity3d,代码行数:7,代码来源:Main.cs
示例7: AccelerometerShakeDetection
public AccelerometerShakeDetection()
{
var sensor = new Accelerometer();
if (sensor.State == SensorState.NotSupported)
throw new NotSupportedException("Accelerometer not supported on this device");
_sensor = sensor;
}
开发者ID:mbmccormick,项目名称:LaundryMinder,代码行数:7,代码来源:AccelerometerShakeDetection.cs
示例8: ScheduleView
public ScheduleView()
{
InitializeComponent();
this.accelerometer = new Accelerometer();
this.accelerometer.CurrentValueChanged += Accelerometer_CurrentValueChanged;
}
开发者ID:deargle,项目名称:CollegeFootballSchedulePredictor,代码行数:7,代码来源:ScheduleView.xaml.cs
示例9: WP7Input
public WP7Input()
{
#region Accelerometer support
mAccValues = new Vector3();
mAccMeter = new Accelerometer();
mAccMeter.ReadingChanged += new EventHandler<AccelerometerReadingEventArgs>(AccMeterChange);
// event services when accelerometer settings change
// This function is defined in Game1_Accelerometer.
try
{
mAccMeter.Start(); // Starts the acceleromter sampling
}
catch (AccelerometerFailedException ex)
{
System.Diagnostics.Debug.WriteLine("Accelerometer Starting failed!: " + ex.ToString());
}
#endregion
#region Gesture support
//mPinchHasBegin = false;
//TouchPanel.EnabledGestures = GestureType.Tap |
// GestureType.DoubleTap |
// GestureType.Hold |
// GestureType.Flick |
// GestureType.Pinch |
// GestureType.FreeDrag |
// GestureType.PinchComplete;
#endregion
}
开发者ID:AntMartz,项目名称:fat-cats-final,代码行数:29,代码来源:InputSupport_WP7.cs
示例10: Ball
/// <summary>
/// Creates a new ball at position 0,0
/// </summary>
/// <param name="graphicsDevice">Graphics device to load the </param>
public Ball(GraphicsDevice graphicsDevice)
{
X = 0;
Y = 0;
speedX = 0.5f;
speedY = 0.5f;
accelerationSpeed = 1.0f;
speedCap = 5f;
resistance = 0.3f;
if (accelerometer == null)
{
accelerometer = new Accelerometer();
accelerometer.Start();
}
using (var stream = TitleContainer.OpenStream("Content/balle.png"))
{
sprite = Texture2D.FromStream(graphicsDevice, stream);
}
}
开发者ID:AntonyGarand,项目名称:Labyrinth,代码行数:29,代码来源:Ball.cs
示例11: Accelerometer_Click
//get accelerometer values
private void Accelerometer_Click(object sender, RoutedEventArgs e)
{
accelerometer = new Accelerometer();
accelerometer.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20);
accelerometer.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<AccelerometerReading>>(accelerometer_valuechanged);
accelerometer.Start();
}
开发者ID:tarunsharma1,项目名称:phoneaswiiremote,代码行数:8,代码来源:MainPage.xaml.cs
示例12: Ship
public Ship(Game game, Vector2 PosicaoInicial, Texture2D texture, SoundEffect SoundShip)
: base(game, PosicaoInicial, texture)
{
_game = game;
ShipSound = SoundShip;
ShipSound.Play();
SpriteX = 0;
SpriteY = 0;
PosicaoX = (int)PosicaoInicial.X;
PosicaoY = (int)PosicaoInicial.Y;
Vida = 100;
accelReading = new Vector3();
accelSensor = new Accelerometer();
accelSensor.ReadingChanged +=
new EventHandler<AccelerometerReadingEventArgs>(AccelerometerReadingChanged);
try
{
accelSensor.Start();
accelActive = true;
}
catch (AccelerometerFailedException e)
{
accelActive = false;
}
catch (UnauthorizedAccessException e)
{
accelActive = false;
}
}
开发者ID:danielhba,项目名称:Invasion,代码行数:33,代码来源:Ship.cs
示例13: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
accel = new Accelerometer();
accel.Start();
SetupObservable();
}
开发者ID:jwooley,项目名称:RxSamples,代码行数:7,代码来源:MainPage.xaml.cs
示例14: Accelerometro
public Accelerometro()
{
InitializeComponent();
accelerometer = new Accelerometer();
accelerometer.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100);
accelerometer.Start();
myFile = IsolatedStorageFile.GetUserStoreForApplication();
if (!myFile.FileExists("Impo.txt"))
{
IsolatedStorageFileStream dataFile = myFile.CreateFile("Impo.txt");
dataFile.Close();
}
Wb = new WebBrowser();
Connesso = false;
Carica();
System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
dt.Interval = new TimeSpan(0, 0, 0, 0, 250); // 500 Milliseconds
dt.Tick += new EventHandler(dt_Tick);
dt.Start();
}
开发者ID:AndreaBruno,项目名称:Macchinino,代码行数:25,代码来源:Accelerometro.xaml.cs
示例15: AccelerometerSensor
static AccelerometerSensor()
{
MaxValue = 0.6f;
MinValue = -MaxValue;
accelerometer = new Accelerometer();
accelerometer.ReadingChanged += accelerometer_ReadingChanged;
accelerometer.Start();
}
开发者ID:dreasgrech,项目名称:FPE3Sandbox,代码行数:8,代码来源:AccelerometerSensor.cs
示例16: ShakeDetector
public ShakeDetector()
{
if (Accelerometer.IsSupported)
{
var sensor = new Accelerometer();
_sensor = sensor;
}
}
开发者ID:XVincentX,项目名称:SimInfo,代码行数:8,代码来源:ShakeDetector.cs
示例17: AccelerometerCancel
void AccelerometerCancel()
{
if (_accelerometer != null) {
_accelerometer.Stop();
_accelerometer.Dispose();
_accelerometer = null;
}
}
开发者ID:pazof,项目名称:MonoCross,代码行数:8,代码来源:MainPage.xaml.cs
示例18: Initialize
partial void Initialize()
{
if (IsSupported)
{
_sensor = new Accelerometer();
_sensor.CurrentValueChanged += OnSensorValueChanged;
}
}
开发者ID:matthijskoopman,项目名称:Catel,代码行数:8,代码来源:AccelerometerService.wpsl.cs
示例19: PredictionView
public PredictionView()
{
InitializeComponent();
this.DataContext = App.ScheduleViewModel;
this.accelerometer = new Accelerometer();
this.accelerometer.CurrentValueChanged += Accelerometer_CurrentValueChanged;
}
开发者ID:deargle,项目名称:CollegeFootballSchedulePredictor,代码行数:9,代码来源:PredictionView.xaml.cs
示例20: StopMonitoring
static partial void StopMonitoring()
{
if (accelerometer != null)
{
accelerometer.CurrentValueChanged -= AccelerometerOnCurrentValueChanged;
accelerometer.Stop();
accelerometer = null;
}
}
开发者ID:paul33868,项目名称:SimplyMobile,代码行数:9,代码来源:Accelometer.cs
注:本文中的Accelerometer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论