Esempio n. 1
0
        /// <summary>
        /// The timer has elapsed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            //OsmSharp.Logging.Log.TraceEvent("MapViewAnimator", System.Diagnostics.TraceEventType.Verbose,
            //    string.Format("Animation Step BEGIN: z:{0} -c:{1} - t:{2}", _mapView.MapZoom, _mapView.MapCenter, _mapView.MapTilt));

            _currentStep++;
            if (_currentStep < _maxSteps)
            {                                             // there is still need for a change.
                GeoCoordinate center = new GeoCoordinate( // update center.
                    (_mapView.MapCenter.Latitude + _stepCenter.Latitude),
                    (_mapView.MapCenter.Longitude + _stepCenter.Longitude));
                float  mapZoom = _mapView.MapZoom + _stepZoom;                // update zoom.
                Degree mapTilt = _mapView.MapTilt + _stepTilt;                // update tilt.
                _mapView.SetMapView(center, mapTilt, mapZoom);
                //OsmSharp.Logging.Log.TraceEvent("MapViewAnimator", System.Diagnostics.TraceEventType.Verbose,
                //                                string.Format("Animation Step END: z:{0} -c:{1} - t:{2}", _mapView.MapZoom, _mapView.MapCenter, _mapView.MapTilt));
                return;
            }
            else if (_currentStep == _maxSteps)
            { // this is the last step.
                _mapView.SetMapView(_targetCenter, _targetTilt, _targetZoom);
            }

            // enable auto invalidate.
            //_mapView.Invalidate ();
            //_mapView.AutoInvalidate = true;
            _mapView.RegisterAnimator(null);
            _timer.Stop(); // stop the timer.
        }