示例#1
0
        // Functions
        public ExercisePage()
        {
            // Setup
            InitializeComponent();
            _taskFactory     = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext());
            _viewModel       = new RunningExerciseViewModel(_taskFactory);
            this.DataContext = _viewModel;

            // Add GPS service if is first use
            if (_locationService == null)
            {
                _locationService = new GPSService(GPS_ACCURACY.HIGH, 20);
            }

            // Add handlers
            _locationService.GPSLocationChanged += GPSLocationChanged;
            _locationService.GPSLocationChanged += _viewModel.GPSLocationChanged;

            // Turn on GPS
            _locationService.StartService();

            // Set timer for updating running time
            _runUpdater          = new DispatcherTimer();
            _runUpdater.Interval = TimeSpan.FromSeconds(1);
            _timerTick           = (Object sender, EventArgs args) => { _viewModel.UpdateRunningTime(); };
            _runUpdater.Tick    += _timerTick;
            _runUpdater.Start();
        }