コード例 #1
0
 private static void AddJob(IntervalCallback callback, ConcurrentBag <IntervalCallback> queue)
 {
     IntervalThreadIDs.TryGetValue(Thread.CurrentThread.ManagedThreadId, out bool isIntervalThread);
     if (isIntervalThread)
     {
         throw new InvalidOperationException("Can't schedule job from a job callback.");
     }
     lock (SyncLock) { queue.Add(callback); }
 }
コード例 #2
0
        public DistancePathAnimation(List <PathPoint> path, IntervalCallback intervalCallback, bool isGeodesic, int?duration)
#endif
        {
            _path       = path;
            _isGeodesic = isGeodesic;
            _duration   = duration;



            _timerId          = new DispatcherTimer();
            _timerId.Interval = new TimeSpan(0, 0, 0, 0, _delay);
            double _distance = 0;

            _timerId.Tick += (s, a) =>
            {
                if (!_isPaused)
                {
                    double progress = (double)(_frameIdx * _delay) / (double)_duration.Value;

                    if (progress > 1)
                    {
                        progress = 1;
                    }

                    if (intervalCallback != null)
                    {
                        List <PathPoint> temppath = path.FindAll(o => o.distance >= _distance);
                        intervalCallback(new Location(temppath[0].latitude, temppath[0].longitude, (double)temppath[0].height), path.Count - temppath.Count, _frameIdx);
                    }

                    if (progress == 1)
                    {
                        _timerId.Stop();
                    }

                    _distance += 100;
                }
            };
        }
コード例 #3
0
ファイル: PathAnimation.cs プロジェクト: inigofu/biketrainer
        public PathAnimation(LocationCollection path, IntervalCallback intervalCallback, bool isGeodesic, int?duration)
#endif
        {
            _path       = path;
            _isGeodesic = isGeodesic;
            _duration   = duration;

            PreCalculate();

            _timerId          = new DispatcherTimer();
            _timerId.Interval = new TimeSpan(0, 0, 0, 0, _delay);

            _timerId.Tick += (s, a) =>
            {
                if (!_isPaused)
                {
                    double progress = (double)(_frameIdx * _delay) / (double)_duration.Value;

                    if (progress > 1)
                    {
                        progress = 1;
                    }

                    if (intervalCallback != null)
                    {
                        intervalCallback(_intervalLocs[_frameIdx], _intervalIdx[_frameIdx], _frameIdx);
                    }

                    if (progress == 1)
                    {
                        _timerId.Stop();
                    }

                    _frameIdx++;
                }
            };
        }
コード例 #4
0
 internal static void HourlyJob(IntervalCallback callback) => AddJob(callback, Hourly);
コード例 #5
0
 internal static void DailyJob(IntervalCallback callback) => AddJob(callback, Daily);
コード例 #6
0
 public PathAnimation(List <BasicGeoposition> path, IntervalCallback intervalCallback, bool isGeodesic, int?duration)
コード例 #7
0
        /// <summary>This class extends from the BaseAnimation class and cycles through a set of coordinates over a period of time, calculating mid-point coordinates along the way.</summary>
        /// <param name="path">An array of locations to cycle through.</param>
        /// <param name="intervalCallback">A function that is called when a frame is to be rendered. This callback function recieves four values; current cordinate, index on path and frame index.</param>
        /// <param name="isGeodesic">Indicates if the path should follow the curve of the earth.</param>
        /// <param name="duration">Length of time in ms that the animation should run for. Default is 1000 ms.</param>
#if WINDOWS_PHONE
        public PathAnimation(GeoCoordinateCollection path, IntervalCallback intervalCallback, bool isGeodesic, int?duration)