internal async void OpenGpxFile(BikeTouringGISMapViewModel mapViewModel, string path) { if (_loadedFiles.Exists(x => x.Equals(path))) { return; } var gpxFileInformation = new GpxFileReader().LoadFile(path); foreach (var track in gpxFileInformation.Tracks) { bool convertTrack = ConvertTracksToRoutesAutomatically; var convertTrackDialogResult = convertTrack ? MessageDialogResult.Affirmative : MessageDialogResult.FirstAuxiliary; if (!convertTrack) { StringBuilder textBuilder = new StringBuilder(); textBuilder.AppendLine($"Track {track.Name} is defined as track and not as route"); textBuilder.AppendLine(); textBuilder.AppendLine("routes are used by navigation-devices"); textBuilder.AppendLine("tracks are to register where you have been"); textBuilder.AppendLine(); textBuilder.AppendLine("Do you want to convert it to a route?"); convertTrackDialogResult = await ConvertTrackToRoute(textBuilder.ToString()); } switch (convertTrackDialogResult) { case MessageDialogResult.Affirmative: track.IsConvertedToRoute = true; break; case MessageDialogResult.Negative: break; case MessageDialogResult.FirstAuxiliary: return; } } _loadedFiles.Add(path); var geometryFactory = new GeometryFactory(gpxFileInformation); geometryFactory.CreateGeometries(); var layerFactory = new LayerFactory(gpxFileInformation.WayPointsExtent); var routes = layerFactory.CreateRoutes(path, gpxFileInformation.Routes); mapViewModel.AddRoutes(routes); var tracks = layerFactory.CreateTracks(path, gpxFileInformation.Tracks); mapViewModel.AddTracks(tracks); mapViewModel.AddPoIs(gpxFileInformation.WayPoints); }
private async void OpenGPXFile(BikeTouringGISMapViewModel mapViewModel) { Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog(); openFileDialog.Filter = "GPX files (*.gpx)|*.gpx"; openFileDialog.Multiselect = true; openFileDialog.InitialDirectory = KnownFolders.Downloads.Path; if (openFileDialog.ShowDialog() == true) { foreach (var file in openFileDialog.FileNames) { if (!_loadedFiles.Contains(file)) { OpenGpxFile(mapViewModel, file); } } } }