Esempio n. 1
0
        private void setupButtons()
        {
            if (m_wpt != null)
            {
                btnPanel.Visible   = true;
                fwdButton.Enabled  = ffwdButton.Enabled = PhotoWaypoints.hasNextWaypoint();
                backButton.Enabled = rewindButton.Enabled = PhotoWaypoints.hasPreviousWaypoint();
            }
            else
            {
                // viewing unrelated photos.
                btnPanel.Visible = false;
            }

            PhotoDescr photoDescr = this.photoViewerControl.photoDescr;

            if (photoDescr != null)
            {
                this.Text = "Photo Preview - " + photoDescr.imageName;
            }

            if (photoDescr != null && photoDescr.imageSourceIsLocal)
            {
                this.deleteButton.Enabled = true;
            }
            else
            {
                this.deleteButton.Enabled = false;
            }
        }
Esempio n. 2
0
        // can be called from different thread:
        public static void BringFormUp(PhotoDescr photoDescr, Waypoint wpt)
        {
            try
            {
                if (wpt != null)
                {
                    m_wpt = wpt;
                    PhotoWaypoints.SetCurrentWaypoint(m_wpt);
                }
                else
                {
                    m_wpt = PhotoWaypoints.CurrentWaypoint();
                }

                if (photoDescr == null)
                {
                    try
                    {
                        photoDescr = PhotoDescr.FromThumbnail(m_wpt.ThumbSource);
                    }
                    // An invalid image will throw an OutOfMemoryException
                    // exception
                    catch (OutOfMemoryException)
                    {
                    }
                }
                else if (wpt == null)
                {
                    m_wpt = null;                       // from Unrelated photos
                }
                m_photoDescr = photoDescr;

                if (This == null)
                {
                    if (Project.mainForm.InvokeRequired)
                    {
                        Project.mainForm.Invoke(new MethodInvoker(RunPhotoFullSizeForm));
                    }
                    else
                    {
                        RunPhotoFullSizeForm();
                    }
                }
                else
                {
                    if (Project.mainForm.InvokeRequired)
                    {
                        Project.mainForm.Invoke(new MethodInvoker(RunBringUp));
                    }
                    else
                    {
                        RunBringUp();
                    }
                }
            }
            catch {}
        }
Esempio n. 3
0
        protected override bool ProcessDialogKey(Keys keyData)
        {
            //LibSys.StatusBar.Trace("ProcessDialogKey: " + keyData);

            bool keystrokeProcessed = true;

            switch (keyData)
            {
            case Keys.Escape:
            case Keys.Alt | Keys.F4:
                this.Close();
                break;

            case Keys.PageUp:
                PhotoWaypoints.FirstWaypoint();
                preview();
                break;

            case Keys.PageDown:
                PhotoWaypoints.LastWaypoint();
                preview();
                break;

            case Keys.Back:
            case Keys.Up:
            case Keys.Left:
                PhotoWaypoints.PreviousWaypoint();
                preview();
                break;

            case Keys.Down:
            case Keys.Right:
                PhotoWaypoints.NextWaypoint();
                preview();
                break;

            default:
                keystrokeProcessed = false;                         // let KeyPress event handler handle this keystroke.
                break;
            }
            if (keystrokeProcessed)
            {
                return(true);
            }
            else
            {
                return(base.ProcessDialogKey(keyData));
            }
        }
Esempio n. 4
0
        private void zoomCloseButton_Click(object sender, System.EventArgs e)
        {
            Waypoint wpt = PhotoWaypoints.CurrentWaypoint();

            if (wpt != null)
            {
                if (Math.Round(PictureManager.This.CameraManager.Location.Elev / 10.0d) != Math.Round(Project.CAMERA_HEIGHT_REAL_CLOSE * 100.0d))
                {
                    DlgPhotoManager.savedLocation = new GeoCoord(PictureManager.This.CameraManager.Location);
                }
                GeoCoord newLocation = new GeoCoord(wpt.Location);
                newLocation.Elev = Project.CAMERA_HEIGHT_REAL_CLOSE * 1000.0d;                          // for 1m/pixel
                PictureManager.This.CameraManager.SpoilPicture();
                PictureManager.This.CameraManager.Location = newLocation;                               // calls ProcessCameraMove();
                zoomCloseButton.Enabled = false;
                zoomOutButton.Enabled   = true;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// returns true if it could actually find something to display
        /// </summary>
        /// <returns></returns>
        private bool preview()
        {
            bool ret = false;

            disableButtons();
            // Create an Image object from the specified file.
            try
            {
                m_wpt = PhotoWaypoints.CurrentWaypoint();
                if (m_wpt != null)
                {
                    PhotoDescr photoDescr = PhotoDescr.FromThumbnail(m_wpt.ThumbSource);

                    photoViewerControl.photoDescr = m_photoDescr = photoDescr;

                    setPhotoDetail();
                    if (m_keepInView)
                    {
                        PictureManager.This.CameraManager.keepInView(m_wpt.Location);
                    }
                    PictureManager.This.CameraManager.MarkLocation(m_wpt.Location, 0);
                    ret = true;
                }
                else
                {
                    photoViewerControl.photoDescr = m_photoDescr = null;
                }
            }
            // An invalid image will throw an OutOfMemoryException
            // exception
            catch (OutOfMemoryException)
            {
                throw new InvalidOperationException("'" + m_wpt.ThumbSource + "' is not a valid image file.");
            }

            if (ret)
            {
                setupButtons();
            }
            DlgPhotoManager.sync(false);
            this.BringToFront();

            return(ret);
        }
Esempio n. 6
0
        private void deleteButton_Click(object sender, System.EventArgs e)
        {
            if (m_photoDescr != null && m_photoDescr.imageSourceIsLocal)
            {
                string imageSource = m_photoDescr.imageSource;
                try
                {
                    string msg;
                    int    pos = imageSource.IndexOf("|");
                    if (pos > 0)
                    {
                        // this is a .zip or .gpz file
                        string zipFileName   = imageSource.Substring(0, pos);
                        string photoFileName = imageSource.Substring(pos + 1);
                        msg = "Will permanently delete entry '" + photoFileName + "' from the zip archive '" + zipFileName
                              + "'.\n\nThe zip archive file will NOT be deleted.\n\nAre you sure?";
                    }
                    else
                    {
                        // plain file
                        msg = "Will permanently delete file '" + imageSource + "' from disk.\n\nAre you sure?";
                    }

                    string fileToDelete = null;

                    if (Project.YesNoBox(this, msg))
                    {
                        if (m_wpt != null)
                        {
                            if (m_wpt.TrackId == -1)
                            {
                                WaypointsCache.RemoveWaypointById(m_wpt.Id);
                            }
                            PhotoWaypoints.RemoveWaypoint(m_wpt);                                       // from track too, if any

                            photoViewerControl.photoDescr = null;

                            fileToDelete = m_photoDescr.deleteFromDisk();

                            if (preview())                                      // will find current waypoint, if any, and set m_photoDescr
                            {
                                setPhotoDetail();
                                photoViewerControl.Refresh();
                            }
                            else
                            {
                                // no image to display, need to wrap up
                                m_photoDescr = null;
                                this.Close();
                            }
                            PictureManager.This.Refresh();
                        }
                        else
                        {
                            PhotoWaypoints.RemoveUnrelatedById(m_photoDescr.Id);

                            fileToDelete = m_photoDescr.deleteFromDisk();

                            if (PhotoWaypoints.PhotosUnrelated.Count > 0)
                            {
                                photoViewerControl.photoDescr = m_photoDescr = (PhotoDescr)PhotoWaypoints.PhotosUnrelated.GetByIndex(0);
                                setPhotoDetail();
                                photoViewerControl.Refresh();
                                this.setupButtons();
                                this.BringToFront();
                            }
                            else
                            {
                                photoViewerControl.photoDescr = m_photoDescr = null;
                                this.Close();
                            }
                        }

                        DlgPhotoManager.sync(true);

                        if (fileToDelete != null)
                        {
                            GC.Collect();
                            FileInfo fi = new FileInfo(fileToDelete);
                            fi.Delete();
                        }
                    }
                }
                catch (Exception exc)
                {
                    Project.ErrorBox(this, "Failed to delete " + imageSource + "\n\nException: " + exc.Message);
                    this.Close();
                }
            }
        }
Esempio n. 7
0
 private void ffwdButton_Click(object sender, System.EventArgs e)
 {
     PhotoWaypoints.LastWaypoint();
     preview();
 }
Esempio n. 8
0
 private void backButton_Click(object sender, System.EventArgs e)
 {
     PhotoWaypoints.PreviousWaypoint();
     preview();
 }
Esempio n. 9
0
 private void rewindButton_Click(object sender, System.EventArgs e)
 {
     PhotoWaypoints.FirstWaypoint();
     preview();
 }