Пример #1
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;
            }
        }
Пример #2
0
 private void DlgPhotoManager_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     Project.photoModeReprocess = false;
     This = null;
 }
Пример #3
0
 private static void _photoSelectComplete()
 {
     DlgPhotoManager dlg = new DlgPhotoManager(4);
     //dlg.TopMost = true;
     dlg.Show();		// ShowDialog doesn't work here, the dialog appears and closes right away
     dlg.BringToFront();
 }
Пример #4
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose( bool disposing )
 {
     This = null;
     if( disposing )
     {
         if(components != null)
         {
             components.Dispose();
         }
     }
     photoViewerControl.Dispose();
     base.Dispose( disposing );
 }
Пример #5
0
        // 0 - asooc.tab,  1 - trackpoints tab,  2 - unrelated tab,   3 - options tab
        public DlgPhotoManager(int mode)
        {
            if(This != null)
            {
                This.Dispose();
            }

            This = this;
            m_mode = mode;

            Project.photoModeReprocess = false;
            Project.photoSelectPhotoMode = 0;

            DlgPhotoFullSize.DisposeIfUp();

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            setTimeShiftButton.Enabled = false;		// note: also serves as a flag
            origButtonBackColor = saveTimeShiftButton.BackColor;

            this.SuspendLayout();

            hintLabel.Text = hintText;

            this.timeZoneComboBox.Items.AddRange(MyTimeZone.TimeZones);

            // making photoViewerControl as dumb VS Designer removes it:
            this.photoViewerControl = new LibSys.PhotoViewerControl();
            this.photoViewerPanel.Controls.AddRange(new System.Windows.Forms.Control[] { this.photoViewerControl });
            this.photoViewerControl.Dock = DockStyle.Fill;
            this.photoViewerControl.Cursor = System.Windows.Forms.Cursors.Hand;
            //this.photoViewerControl.Location = new System.Drawing.Point(336, 176);
            this.photoViewerControl.Name = "photoViewerControl";
            this.photoViewerControl.photoDescr = null;
            //this.photoViewerControl.Size = new System.Drawing.Size(224, 184);
            this.photoViewerControl.TabIndex = 112;
            this.photoViewerControl.Click += new System.EventHandler(this.photoViewerControl_Click);

            // making myFileOrFolder control as dumb VS Designer removes it:
            this.myFileOrFolder = new LibSys.MyFileOrFolder();
            this.myFileOrFolder.Dock = DockStyle.Fill;
            this.fileOrFolderPanel.Controls.Add(this.myFileOrFolder);
            this.myFileOrFolder.Name = "myFileOrFolder";
            this.myFileOrFolder.browseFileButton.Click += new System.EventHandler(this.browseFileButton_Click);
            this.myFileOrFolder.browseFolderButton.Click += new System.EventHandler(this.browseFolderButton_Click);
            this.myFileOrFolder.verifyGalleryButton.Click += new System.EventHandler(this.verifyGalleryButton_Click);
            this.myFileOrFolder.importFileButton.Click += new System.EventHandler(this.importFileButton_Click);
            this.myFileOrFolder.importFolderButton.Click += new System.EventHandler(this.importFolderButton_Click);
            this.myFileOrFolder.importGalleryButton.Click += new System.EventHandler(this.importGalleryButton_Click);
            this.myFileOrFolder.tabControl1.SelectedIndexChanged += new System.EventHandler(this.myFileOrFolder_ModeChanged);

            configureReprocessButton();		// "Reprocess File" or "Reprocess Folder"

            this.ResumeLayout(true);

            // whatever is needed to initialize checkboxes etc:
            keepInViewCheckBox.Checked = m_keepInView;
            zoomInCheckBox.Checked = m_doZoomIn;

            configureTimeshiftChoices(false, true);
            shiftTypeComboBox.SelectedIndex = m_photoTimeShiftTypeSelected;

            if(Project.photoGalleryPictureSize >= Project.photoGalleryPictureSizes.Length)
            {
                Project.photoGalleryPictureSize = 2;
            }
            pictureSizeComboBox.SelectedIndex = Project.photoGalleryPictureSize;

            this.trackpointsDataGrid.MouseUp += new System.Windows.Forms.MouseEventHandler(this.trackpointsDataGrid_MouseUp);

            this.unrelatedDataGrid.MouseUp += new System.Windows.Forms.MouseEventHandler(this.unrelatedDataGrid_MouseUp);

            Project.setDlgIcon(this);
        }
Пример #6
0
        private void MainForm_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            this.Focus();
            this.BringToFront();

            try
            {
                string[] fileNames = (string[])e.Data.GetData("FileDrop");

                bool anySuccess = FileAndZipIO.readFiles(fileNames);

                if(anySuccess)	// we need to zoom into whole set of dropped files, or refresh in case of JPG
                {
                    this.wptEnabled(true);
                    if(!m_cameraManager.zoomToCorners())
                    {
                        m_cameraManager.ProcessCameraMove();	// nowhere to zoom in - just refresh
                    }
                }
                else if(fileNames.GetLength(0) == 1 && fileNames[0].ToLower().EndsWith(".jpg"))
                {
                    DlgPhotoManager dlg = new DlgPhotoManager(2);
                    dlg.TopMost = true;
                    dlg.ShowDialog();
                }
            }
            catch
            {
                LibSys.StatusBar.Trace("* Error: drag-and-drop... cannot accept file(s)");
            }
            e.Effect = DragDropEffects.None;
            Cursor.Current = Cursors.Default;
        }