示例#1
0
        public void OnGpsLocationUpdate() // IGpsListener
        {
            timeStampLastGps = DateTime.Now.Ticks;

            accelerometerProvider.SetSpeed(gpsProvider.GetSpeed());

            if (IsResultAvailable() == false)
            {
                // vehicle is standing still before launch -> make location of launch more precise by averaging all locations
                // OR
                // in mode "brake" we are waiting until target speed is reached -> update last known location
                runData.AddStartLocation(gpsProvider, accelerometerProvider.GetTimeStamp());
            }

            // switch distance indicator according to traveled distance
            if (isAccelerationMode == true)
            {
                if (isDemoMode == false) // if demo mode -> distance indicator is disabled
                {
                    float distance = runData.GetDistanceFiltered();

                    if ((distance <= 201) && (imgDistanceOff.IsVisible == false))
                    {
                        // no distance traveled
                        imgDistanceOff.IsVisible     = true;
                        imgDistanceQuarter.IsVisible = false;
                        imgDistanceHalf.IsVisible    = false;
                    }
                    else if ((distance > 402) && (distance <= 804) && (imgDistanceQuarter.IsVisible == false))
                    {
                        // quarter of a mile passed
                        imgDistanceQuarter.IsVisible = true;
                        imgDistanceHalf.IsVisible    = false;
                        imgDistanceOff.IsVisible     = false;
                    }
                    else if ((distance > 804) && (imgDistanceHalf.IsVisible == false))
                    {
                        // half of a mile passed
                        imgDistanceHalf.IsVisible    = true;
                        imgDistanceQuarter.IsVisible = false;
                        imgDistanceOff.IsVisible     = false;
                    }
                }
            }
        }