Exemplo n.º 1
0
        private void ExportGpx()
        {
            using (var sfd = new SaveFileDialog
              {
            Title = Strings.ExportGPXTitle,
            Filter = Strings.FileFilter_GpxFiles,
            FileName =
              ((canvas.Document.FileName != null
              ? Path.GetFileNameWithoutExtension(canvas.Document.FileName)
              : Path.GetFileNameWithoutExtension(untitledDocumentFileNameProposal))),
            FilterIndex = 1,
            AddExtension = true,
            OverwritePrompt = true
              })
              {
            if (ApplicationSettings.InitialFolders.ContainsKey(ApplicationSettings.FileDialogType.ExportFile))
            {
              sfd.InitialDirectory = ApplicationSettings.InitialFolders[ApplicationSettings.FileDialogType.ExportFile];
            }

            if (sfd.ShowDialog() == DialogResult.OK)
            {
              try
              {
            BeginWork();
            using (var stream = new FileStream(sfd.FileName, FileMode.Create))
            {
              var gpxExporter = new GpxExporter(canvas.CurrentSession, stream);
              gpxExporter.Export();
              stream.Close();
            }
            ApplicationSettings.InitialFolders[ApplicationSettings.FileDialogType.ExportImage] =
              Path.GetDirectoryName(sfd.FileName);
            EndWork();
              }
              catch (Exception ex)
              {
            EndWork();
            Util.ShowExceptionMessageBox(ex, Strings.Error_ExportRoute);
              }
            }
              }
        }
 /// <summary>
 /// Exports the QuickRouteJpegExtensionData object to a GPX file.
 /// </summary>
 /// <param name="stream">The stream to export the gpx file to.backbuffer</param>
 public void ToGpx(Stream stream)
 {
     var gpxExporter = new GpxExporter(Sessions[0], stream);
       gpxExporter.Export();
 }