Example #1
0
 private async Task <MemoryActivity> Import(string fileName)
 {
     using (var input = await TestFileHelper.OpenForReadAsync(fileName))
     {
         var activity = new MemoryActivity();
         var importer = new GpxImporter(activity);
         importer.Load(input);
         //var exporter = new FitExporter(activity);
         //using (var output = await TestFileHelper.OpenForWriteAsync(_fileName + ".fit"))
         //{
         //    exporter.Save(output);
         //}
         return(activity);
     }
 }
Example #2
0
        protected void Start(Stream source, int millisecondsDelay)
        {
            if (_task != null)
            {
                return;
            }

            _task = Task.Run(() =>
            {
                // import activity from GPX
                var activity = new MemoryActivity();
                var importer = new GpxImporter(activity);
                importer.Load(source);
                // mock positions from the activity
                while (true)
                {
                    foreach (var frame in activity.TimeFrames)
                    {
                        Task.Delay(millisecondsDelay).Wait(); // wait for 1 second
                        if (!_isConnected)
                        {
                            continue;
                        }

                        if (frame.Position.HasValue)
                        {
                            if (StatusChanged != null)
                            {
                                _status.Position = frame.Position.Value;
                                var args         = new GeoLocatorStatusChangedEventArgs(_status);
                                StatusChanged(this, args);
                            }
                        }
                    }
                }
            });
            _task.ConfigureAwait(false);
        }