Esempio n. 1
0
        /// <summary>
        /// Starts an animation to the given parameters.
        /// </summary>
        /// <param name="center"></param>
        /// <param name="zoomLevel"></param>
        /// <param name="mapTilt"></param>
        /// <param name="time"></param>
        public void Start(GeoCoordinate center, float zoomLevel, Degree mapTilt, TimeSpan time)
		{
			// stop the previous timer.
			if (_timer != null)
			{ // timer exists, it might be active disable it immidiately.
				// cancel previous status.
				_timerStatus.Cancelled = true;
				_timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
				_timer.Dispose();
			}

            // Create the animation function.
            _animationFunction = CubicBezier.createEase();

			// Initialaize the start and end state of the map.
            _startState = new MapAnimationState(_mapView.MapZoom, _mapView.MapTilt, _mapView.MapCenter);
            _endState   = new MapAnimationState(zoomLevel, mapTilt, center);
            _currentState = new MapAnimationState(_mapView.MapZoom, _mapView.MapTilt, _mapView.MapCenter);

			OsmSharp.Logging.Log.TraceEvent("MapViewAnimator", OsmSharp.Logging.TraceEventType.Verbose,
				string.Format("Started new animation to z:{0} t:{1} c:{2} from z:{3} t:{4} c:{5}.",
					_endState.Zoom, _endState.Tilt, _endState.Center.ToString(), 
					_mapView.MapZoom, _mapView.MapTilt, _mapView.MapCenter.ToString()));

			// disable auto invalidate.
			_mapView.RegisterAnimator(this);

            _startTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            _duration = (long)time.TotalMilliseconds;
            _endTime = _startTime + _duration;

			// start the timer.
			// create a new timer.
			_timerStatus = new AnimatorStatus();
			_timer = new Timer(new TimerCallback(_timer_Elapsed), _timerStatus, 0, (int)_minimumTimeSpan.TotalMilliseconds);
            
		}