Exemplo n.º 1
0
        public MainViewModel(IScheduler backgroundScheduler, IFileChooserUi fileChooser)
        {
            var gpxReplays = loadGpxDataCommand.RegisterAsyncFunction(_ =>
            {
                using (var stream = fileChooser.ChooseFile().Result)
                {
                    // Stream.Null means the user cancelled the file choosing
                    // TODO: A better way for ChooseFile to indicate user cancelling
                    if (stream == Stream.Null)
                    {
                        return(Observable.Empty <GpxSection>());
                    }

                    var reader = new GpxReader(stream);
                    return(reader.Points.Replay(backgroundScheduler));
                }
            });

            currentSection = gpxReplays.Switch().ToProperty(this, x => x.CurrentSection);
        }
Exemplo n.º 2
0
        public MainViewModel(IScheduler backgroundScheduler, IFileChooserUi fileChooser)
        {
            var gpxReplays = loadGpxDataCommand.RegisterAsyncFunction(_ =>
                                   {
                                       using (var stream = fileChooser.ChooseFile().Result)
                                       {
                                           // Stream.Null means the user cancelled the file choosing
                                           // TODO: A better way for ChooseFile to indicate user cancelling
                                           if (stream == Stream.Null)
                                           {
                                               return Observable.Empty<GpxSection>();
                                           }

                                           var reader = new GpxReader(stream);
                                           return reader.Points.Replay(backgroundScheduler);
                                       }
                                   });

            currentSection = gpxReplays.Switch().ToProperty(this, x => x.CurrentSection);
        }