Пример #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();
            this.NavigationCacheMode = NavigationCacheMode.Required;
            TopLimitLabel.Text       = (MaxSteps[_currentZoomLevel].ToString());
            CenterLimitLabel.Text    = ((MaxSteps[_currentZoomLevel] / 2).ToString());

            Window.Current.VisibilityChanged += async(oo, ee) =>
            {
                if (!ee.Visible && _stepCounter != null)
                {
                    await CallSenseApiAsync(async() =>
                    {
                        await _stepCounter.DeactivateAsync();
                    });
                }
                else if (_stepCounter != null)
                {
                    await CallSenseApiAsync(async() =>
                    {
                        await _stepCounter.ActivateAsync();
                    });

                    // Refresh screen
                    await SetSelectedDayAsync(_selectedDay);
                }
            };
        }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();
            this.NavigationCacheMode = NavigationCacheMode.Required;

            Window.Current.VisibilityChanged += async(oo, ee) =>
            {
                if (!ee.Visible && _activityMonitor != null)
                {
                    await CallSenseApiAsync(async() =>
                    {
                        await _activityMonitor.DeactivateAsync();
                    });
                    await CallSenseApiAsync(async() =>
                    {
                        await _stepCounter.DeactivateAsync();
                    });
                }
                else if (_activityMonitor != null)
                {
                    await CallSenseApiAsync(async() =>
                    {
                        await _activityMonitor.ActivateAsync();
                    });
                    await CallSenseApiAsync(async() =>
                    {
                        await _stepCounter.ActivateAsync();
                    });

                    // Refresh screen
                    await UpdateScreenAsync();
                }
            };
        }
Пример #3
0
 /// <summary>
 /// Called when a page is no longer the active page in a frame.
 /// </summary>
 /// <param name="e">Event arguments</param>
 protected async override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     base.OnNavigatingFrom(e);
     if (_recordingTimer != null)
     {
         _recordingTimer.Stop();
     }
     if (_pMonitor != null)
     {
         await _pMonitor.DeactivateAsync();
     }
     if (_sCounter != null)
     {
         await _sCounter.DeactivateAsync();
     }
     if (_rTracker != null)
     {
         await _rTracker.DeactivateAsync();
     }
     if (_aMonitor != null)
     {
         await _aMonitor.DeactivateAsync();
     }
     _activityRecording.Recorder = null;
     _placesRecording.Recorder   = null;
     _stepsRecording.Recorder    = null;
     _routeRecording.Recorder    = null;
 }
Пример #4
0
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            Window.Current.VisibilityChanged += async(oo, ee) =>
            {
                if (ee.Visible)
                {
                    if (await CallSensorcoreApiAsync(async() =>
                    {
                        if (_stepCounter == null)
                        {
                            // Get sensor instance if needed...
                            _stepCounter = await StepCounter.GetDefaultAsync();
                        }
                        else
                        {
                            // ... otherwise just activate it
                            await _stepCounter.ActivateAsync();
                        }
                    }))
                    {
                        // Display current reading whenever application is brought to foreground
                        await ShowCurrentReading();
                    }
                }
                else
                {
                    // Sensor needs to be deactivated when application is put to background
                    if (_stepCounter != null)
                    {
                        await CallSensorcoreApiAsync(async() => await _stepCounter.DeactivateAsync());
                    }
                }
            };
        }