本文整理汇总了C#中Motion.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Motion.Start方法的具体用法?C# Motion.Start怎么用?C# Motion.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Motion
的用法示例。
在下文中一共展示了Motion.Start方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MotionSamplePage
public MotionSamplePage()
{
InitializeComponent();
Loaded += (s, e) =>
{
if (Motion.IsSupported)
{
_m = new Motion();
_m.CurrentValueChanged += MotionCurrentValueChanged;
_m.Start();
}
};
}
示例2: PhoneOrientation
public PhoneOrientation()
{
values = new float[3];
motion = new Motion();
motion.CurrentValueChanged +=
new EventHandler<SensorReadingEventArgs<MotionReading>>(motion_CurrentValueChanged);
// Try to start the Motion API.
try
{
motion.Start();
} catch (Exception e)
{
MessageBox.Show("unable to start the Motion API.");
}
}
示例3: MainPageViewModel
public MainPageViewModel()
{
startMagic.Subscribe(_ => OnStartMagic());
performAction.Subscribe(_ => OnPerformAction());
var motionValues = Observable.Create<EventPattern<SensorReadingEventArgs<MotionReading>>>(o =>
{
var motion = new Motion();
motion.TimeBetweenUpdates = TimeSpan.FromSeconds(0.09);
var readings = Observable.FromEventPattern<SensorReadingEventArgs<MotionReading>>(h => motion.CurrentValueChanged += h, h => motion.CurrentValueChanged -= h);
var readingsSubscription = readings.Subscribe(o);
motion.Start();
var motionStopper = Disposable.Create(() => motion.Stop());
return new CompositeDisposable(readingsSubscription, motionStopper, motion);
}).Publish().RefCount();
motionValues = Observable.Never<EventPattern<SensorReadingEventArgs<MotionReading>>>();
var motionReadings = motionValues.Select(x => x.EventArgs.SensorReading);
motionReadings.Select(x => FormatVector3(x.DeviceAcceleration)).DistinctUntilChanged().ToProperty(this, x => x.DeviceAcceleration, out deviceAcceleration);
motionReadings.Select(x => FormatVector3(x.DeviceRotationRate)).DistinctUntilChanged().ToProperty(this, x => x.DeviceRotationRate, out deviceRotationRate);
motionReadings.Select(x => FormatVector3(x.Gravity)).DistinctUntilChanged().ToProperty(this, x => x.Gravity, out gravity);
motionReadings.Select(x => ProcessAngle(x.Attitude.Yaw)).ToProperty(this, x => x.Yaw, out yaw);
motionReadings.Select(x => ProcessAngle(x.Attitude.Pitch)).ToProperty(this, x => x.Pitch, out pitch);
motionReadings.Select(x => ProcessAngle(x.Attitude.Roll)).ToProperty(this, x => x.Roll, out roll);
Byte0 = 0;
Byte1 = 4;
Byte2 = 2;
Byte3 = 100;
Byte4 = 7;
Byte5 = 0;
Byte6 = 0;
Byte7 = 0x20;
FourBytes = 0;
}
示例4: ControlPage
// Constructor
public ControlPage()
{
InitializeComponent();
Traces = new ObservableCollection<string>();
//TraceBox.DataContext = Traces;
time = new DispatcherTimer();
motion = new Motion();
motion.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<MotionReading>>(motion_CurrentValueChanged);
try
{
motion.Start();
}
catch (InvalidOperationException)
{
#if UNITTEST
#else
MessageBox.Show("Unable to start the motion API");
#endif
}
}
示例5: setupSensors
private void setupSensors()
{
// Initialize the combined orientation sensor
try
{
motion = new Motion();
motion.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100);
motion.CurrentValueChanged += motion_CurrentValueChanged;
motion.Start();
}
catch
{
// Print out an error
MessageBox.Show("Could not initialize Motion API. This phone does not have the necessary sensors to run this code properly!");
// The kill the current application
Application.Current.Terminate();
}
// Setup sound output
sio = new SoundIO();
sio.audioOutEvent += sio_audioOutEvent;
sio.start();
at = new AudioTool(sio.getOutputNumChannels(), sio.getOutputSampleRate());
}
示例6: EnableMotion
/// <summary>
/// Enables our Motion sensor if the device supports it
/// </summary>
public static void EnableMotion()
{
#if WINDOWS_PHONE
if (!Motion.IsSupported)
Motion.Stop();
else
{
Motion = new Motion
{
TimeBetweenUpdates = TimeSpan.FromMilliseconds(30)
};
Motion.CurrentValueChanged += MotionCurrentValueChanged;
try
{
Motion.Start();
MotionEnabled = true;
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
#endif
}
示例7: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if (!IsolatedStorageSettings.ApplicationSettings.Contains("LocationConsent"))
{
MessageBoxResult result =
MessageBox.Show("This app accesses your phone's location. Is that ok?",
"Location",
MessageBoxButton.OKCancel);
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = (result == MessageBoxResult.OK);
IsolatedStorageSettings.ApplicationSettings.Save();
}
if ((bool)IsolatedStorageSettings.ApplicationSettings["LocationConsent"])
{
geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;
geolocator.MovementThreshold = 1; // The units are meters.
geolocator.StatusChanged += (sender, args) =>
{
status = args.Status;
ShowLoc();
};
geolocator.PositionChanged += (sender, args) =>
{
coordinate = args.Position.Coordinate;
ShowLoc();
};
}
if (Motion.IsSupported)
{
motion = new Motion();
motion.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20);
motion.CurrentValueChanged += (sender, e2) => CurrentValueChanged(e2.SensorReading);
// Try to start the Motion API.
try
{
motion.Start();
}
catch (Exception)
{
MessageBox.Show("unable to start the Motion API.");
}
}
Appointments appointments = new Appointments();
appointments.SearchCompleted += (sender, e2) =>
{
DateList.ItemsSource = e2.Results.OrderBy(p => p.StartTime);
Waiter(false);
};
appointments.SearchAsync(DateTime.Now, DateTime.Now.AddDays(7), null);
}
示例8: AutoNavPage
// Constructor
public AutoNavPage()
{
InitializeComponent();
Traces = new ObservableCollection<string>();
//TraceBox.DataContext = Traces;
time = new DispatcherTimer();
motion = new Motion();
imageLayer = new MapLayer();
navMap.Children.Add(imageLayer);
current = defaultStartLocation; // Default location - middle of field
current.Course = 0.0; // Start facing North for reference
motion.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<MotionReading>>(motion_CurrentValueChanged);
waypoints = new Queue<GeoCoordinate>();
gpsBox.Visibility = System.Windows.Visibility.Collapsed;
Join();
setMap();
try
{
motion.Start();
}
catch (InvalidOperationException)
{
//MessageBox.Show("Unable to start the motion API");
}
}
示例9: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
#if WINDOWS_PHONE
if (!IsolatedStorageSettings.ApplicationSettings.Contains("LocationConsent"))
{
MessageBoxResult result =
MessageBox.Show("This app accesses your phone's location. Is that ok?",
"Location",
MessageBoxButton.OKCancel);
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = (result == MessageBoxResult.OK);
IsolatedStorageSettings.ApplicationSettings.Save();
}
if ((bool)IsolatedStorageSettings.ApplicationSettings["LocationConsent"])
#endif
#if WINDOWS_PHONE || NETFX_CORE
{
geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;
geolocator.MovementThreshold = 1; // The units are meters.
geolocator.StatusChanged += (sender, args) =>
{
status = args.Status.ToString();
ShowLoc();
};
geolocator.PositionChanged += (sender, args) =>
{
coordinate = new GeoCoord(args.Position.Coordinate.Latitude,
args.Position.Coordinate.Longitude,
args.Position.Coordinate.Accuracy);
ShowLoc();
};
}
#endif
#if WINDOWS_PHONE
if (Motion.IsSupported)
{
motion = new Motion();
motion.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20);
motion.CurrentValueChanged += (sender, e2) => CurrentValueChanged(e2.SensorReading);
// Try to start the Motion API.
try
{
motion.Start();
}
catch (Exception)
{
MessageBox.Show("unable to start the Motion API.");
}
}
Appointments appointments = new Appointments();
appointments.SearchCompleted += (sender, e2) =>
{
List<FakeAppointment> res = e2.Results.Select(p => new FakeAppointment(p)).ToList();
if (res.Count == 0)
{
res.Add(new FakeAppointment( "Zumo test Team meeting", new DateTime(2013, 7, 25), "Conf Room 2/2063 (8) AV" ));
}
this.DateList.ItemsSource = res.OrderBy(p => p.StartTime);
Waiter(false);
};
appointments.SearchAsync(DateTime.Now, DateTime.Now.AddDays(7), null);
#else
List<FakeAppointment> res = new List<FakeAppointment>();
if (res.Count == 0)
{
res.Add(new FakeAppointment("Zumo test Team meeting", new DateTime(2013, 7, 25), "Conf Room 2/2063 (8) AV"));
}
this.DateList.ItemsSource = res.OrderBy(p => p.StartTime);
Waiter(false);
#endif
}
示例10: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Set the sharing mode of the graphics device to turn on XNA rendering
graphicsDevice = SharedGraphicsDeviceManager.Current.GraphicsDevice;
graphicsDevice.SetSharingMode(true);
// Create a new RenderTarget2D to handle screen captures.
target2D = new RenderTarget2D(graphicsDevice, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, false, SurfaceFormat.Alpha8, DepthFormat.Depth24);
// Motion
if (Motion.IsSupported)
{
motion = new Motion();
motion.Start();
useMotion = true;
}
if (Compass.IsSupported)
{
// Instantiate the compass.
compass = new Compass();
// Specify the desired time between updates. The sensor accepts
// intervals in multiples of 20 ms.
compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20);
compass.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<CompassReading>>(compass_CurrentValueChanged);
compass.Start();
}
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);
Matrix projection = Matrix.CreatePerspectiveFieldOfView(
MathHelper.PiOver4, graphicsDevice.Viewport.AspectRatio, 1.0f, 10000.0f);
meshes = new List<TexturedMeshObject>();
center = new Vector3(0, earthdOffset, 0);
AddPlanetoidMesh(ref projection, center, "Earth");
AddPlanetoidMesh(ref projection, new Vector3(2038.0f, earthdOffset, 0), "Moon");
AddPlanetoidMesh(ref projection, new Vector3(203.8f, earthdOffset, 0), "Moon");
// Start the timer
timer.Start();
base.OnNavigatedTo(e);
}