예제 #1
0
        private void unlistCustomMap(long id)
        {
            CustomMap cm = CustomMapsCache.getCustomMapById(id);

            if (cm != null)
            {
                for (int i = 0; i < Project.FileDescrList.Count; i++)
                {
                    FormattedFileDescr ffd = (FormattedFileDescr)Project.FileDescrList[i];
                    if (ffd.filename.Equals(cm.Source))
                    {
                        Project.FileDescrList.RemoveAt(i);
                        break;
                    }
                }
            }
        }
예제 #2
0
        /*
         * see http://www.topografix.com/GPX/1/0 for more info
         *
         * Validating your GPX document
         *              Validation is done using the Xerces XML parser. Download the latest Xerces distribution from the Apache website.
         *               Windows users should download the "Latest Xerces-C++ Binary Package for Windows". Unzip the files, and locate the
         *               SAXCount.exe program in the bin folder. This is a command-line utility that will validate your GPX file.
         *
         *      Assuming your GPX file is named my_gpx_file.gpx, and is located in the same folder as SaxCount.exe, use the following
         *       command line to validate your file:
         *
         *                      SaxCount.exe -v=always -n -s -f test.gpx
         *
         *      If your file validates successfully, SAXCount will display a count of the elements in your file, like the following:
         *
         *                      test.gpx: 1012 ms (4025 elems, 1916 attrs, 8048 spaces, 36109 chars)
         *
         *      Any other output from SAXCount.exe indicates that your GPX file is incorrect. It is your responsibility to ensure that any GPX files you create validate successfully against the GPX schema.
         */

        public void doWrite()
        {
            string diag = "Selected format: " + m_selectedFormat + "\r\n\r\n";

            trkpointCount = 0;
            waypointCount = 0;
            // could be "new DateTimeFormatInfo().UniversalSortableDateTimePattern;" - but it has space instead of 'T'

            messageBoxDirty     = true;
            messageTextBox.Text = diag;

            try
            {
                if (m_selectedFormat.Equals(FileStreetsTripsCsv.FormatName))
                {
                    hasSaved = FileAndZipIO.saveCsv(m_selectedFileName, m_tracks, m_saveTracks,
                                                    m_waypoints, m_saveWaypoints, out waypointCount, out trkpointCount);
                }
                else if (m_selectedFormat.Equals(FileEasyGps.FormatName))
                {
                    int tracksCount;
                    hasSaved = FileAndZipIO.saveGpx(m_selectedFileName, m_tracks, m_saveTracks,
                                                    m_waypoints, m_saveWaypoints, out waypointCount, out trkpointCount, out tracksCount);

                    // try suggesting JPEG correlation here, if the folder has any .JPG files
                    if (tracksCount > 0)
                    {
                        bool hasJpegs = false;
                        try
                        {
                            FileInfo      fi = new FileInfo(m_selectedFileName);
                            DirectoryInfo di = fi.Directory;
                            foreach (FileInfo fii in di.GetFiles())
                            {
                                if (fii.Name.ToLower().EndsWith(".jpg"))
                                {
                                    hasJpegs = true;
                                    break;
                                }
                            }
                        }
                        catch
                        {
                        }
                        if (hasJpegs)
                        {
                            string message = "The folder you selected contains images\r\n\r\nDo you want to relate them to trackpoints?";
                            if (Project.YesNoBox(this, message))
                            {
                                Project.photoFileName = m_selectedFileName;
                                Project.pmLastTabMode = 0;
                                DlgPhotoManager dlg = new DlgPhotoManager(0);
                                dlg.setImportButtonsAgitated();
                                dlg.ShowDialog();
                            }
                        }
                    }
                }
                else if (m_selectedFormat.Equals(FileKml.FormatName))
                {
                    string name = new FileInfo(m_selectedFileName).Name;

                    name = name.Substring(0, name.Length - FileKml.FileExtension.Length);

                    GoogleEarthManager.saveTracksWaypoints(
                        m_selectedFileName, name, m_tracks, m_saveTracks,
                        m_waypoints, m_saveWaypoints, out waypointCount, out trkpointCount
                        );
                }
                else
                {
                    messageTextBox.Text = "Error: format " + m_selectedFormat + " not supported for writing.";
                    LibSys.StatusBar.Error("FileExportForm:doWrite() format " + m_selectedFormat + " not supported for writing.");
                    return;
                }

                WaypointsCache.isDirty = false;

                if (waypointCount > 0 || trkpointCount > 0)
                {
                    diag += "OK: " + waypointCount + " waypoints and " + trkpointCount + " legs saved to file.";
                    messageTextBox.ForeColor = Color.Black;

                    FileInfo           fi = new FileInfo(Project.GetLongPathName(m_selectedFileName));
                    FormattedFileDescr fd = new FormattedFileDescr(fi.FullName, m_selectedFormat, persistCheckBox.Checked);
                    Project.FileDescrListAdd(fd);

                    if (!m_selectedFormat.Equals(FileKml.FormatName))                           // can't read back kmz
                    {
                        Project.insertRecentFile(fi.FullName);
                    }
                }
                else
                {
                    diag += "Error: failed to save to file (0 waypoints, 0 legs).";
                    messageTextBox.ForeColor = Color.Red;
                }

                messageTextBox.Text = diag;
            }
            catch (Exception e)
            {
                LibSys.StatusBar.Error("FileExportForm:doWrite() " + e);                 //.Message);
                messageTextBox.Text      = diag + e.Message;
                messageTextBox.ForeColor = Color.Red;
            }
        }