Example #1
0
        public void StopLapTimer(string errorMessage = null)
        {
            // Stop timing and clean up associated resources
            IsTiming = false;
            lapTimer.StopTiming();
            lapTimer.SectorComplete -= lapTimer_SectorComplete;
            lapTimer.LapComplete    -= lapTimer_LapComplete;
            if (lapUpdateTimer != null)
            {
                lapUpdateTimer.Dispose();
                lapUpdateTimer = null;
            }

            // There may be an incomplete lap in progress, if so then add it to the lap collection
            var finalLap = lapTimer.CurrentLap;

            if (finalLap != null)
            {
                Laps.Add(finalLap);
            }

            // Notify subscribers that timing is complete
            if (TimingStopped != null)
            {
                TimingStopped(this, new TimingStoppedViewModel
                {
                    IsSuccessful      = errorMessage == null,
                    CompletionMessage = errorMessage,
                    GpsDeviceName     = lapTimer.DeviceIdStamp,
                    Laps = Laps,
                    GeneratedTrackSectors = lapTimer.GenerateSectors
                                            ? new ObservableCollection <TrackSectorViewModel>(lapTimer.SectorCoordinates)
                                            : null
                });
            }

            // Fire & forget - don't care about result
            var cameraResult = StopCameraRecordingAndTurnOff();
        }