当前位置: 首页>>代码示例>>C#>>正文


C# Motion.Start方法代码示例

本文整理汇总了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();
                              }
                          };
        }
开发者ID:SonLamUIT,项目名称:WPSamples,代码行数:14,代码来源:MotionSamplePage.xaml.cs

示例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.");
            }
        }
开发者ID:ZENG-Yuhao,项目名称:Xamarin-CrossPlatform,代码行数:16,代码来源:PhoneOrientation.cs

示例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;
        }
开发者ID:r0t0r-r0t0r,项目名称:GyroControl,代码行数:42,代码来源:MainPageViewModel.cs

示例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
            }
        }
开发者ID:abraxas4,项目名称:AR-Drone-Project,代码行数:23,代码来源:ControlPage.xaml.cs

示例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());
        }
开发者ID:EE590-Spring2014,项目名称:Materials,代码行数:25,代码来源:MainPage.xaml.cs

示例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
        }
开发者ID:WitolProductions,项目名称:XNA-Engine,代码行数:28,代码来源:PhoneHandler.cs

示例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);
        }
开发者ID:jcookems,项目名称:freezing-ninja,代码行数:55,代码来源:MainPage.xaml.cs

示例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");
            }
        }
开发者ID:abraxas4,项目名称:AR-Drone-Project,代码行数:32,代码来源:AutoNavPage.xaml.cs

示例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
        }
开发者ID:jcookems,项目名称:freezing-ninja,代码行数:75,代码来源:MainPage.xaml.cs

示例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);
        }
开发者ID:BohdanSorokin,项目名称:Blogs,代码行数:47,代码来源:GamePage.xaml.cs


注:本文中的Motion.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。