private void ExifGpsView_Parse(object sender, ConvertEventArgs e)
        {
            GpsCoordinate c = new GpsCoordinate();

            c.FromString(e.Value.ToString());
            e.Value = c;
        }
Beispiel #2
0
        //model
        private bool SaveToPicture(PictureMetaData pic, bool commit)
        {
            if (this.updateLatitude.Checked)
            {
                if (this.txtLatitudeRef.Text != "")
                {
                    pic.GpsLatitudeRef = this.txtLatitudeRef.Text;
                    GpsCoordinate c = new GpsCoordinate();
                    c.FromString(this.txtLatitude.Text);
                    pic.GpsLatitude = c;
                }
                else
                {
                    pic.GpsLatitude    = null;
                    pic.GpsLatitudeRef = "";
                }
            }

            if (this.updateLongitude.Checked)
            {
                if (this.txtLongitudeRef.Text != "")
                {
                    pic.GpsLongitudeRef = this.txtLongitudeRef.Text;
                    GpsCoordinate c = new GpsCoordinate();
                    c.FromString(this.txtLongitude.Text);
                    pic.GpsLongitude = c;
                }
                else
                {
                    pic.GpsLongitude    = null;
                    pic.GpsLongitudeRef = "";
                }
            }

            if (this.updateAltitude.Checked)
            {
                if (this.txtAltitudeRef.Text != "")
                {
                    pic.GpsAltitudeRef = this.txtAltitudeRef.Text;
                    pic.GpsAltitude    = this.numAltitude.Value;
                }
                else
                {
                    pic.GpsAltitudeRef = "";
                    pic.GpsAltitude    = null;
                }
            }

            if (this.updateSpeed.Checked)
            {
                if (this.txtSpeedRef.Text != "")
                {
                    pic.GpsSpeedRef = this.txtSpeedRef.Text;
                    pic.GpsSpeed    = this.numSpeed.Value;
                }
                else
                {
                    pic.GpsSpeedRef = "";
                    pic.GpsSpeed    = null;
                }
            }

            if (this.updateTrack.Checked)
            {
                if (this.txtTrackRef.Text != "")
                {
                    pic.GpsTrackRef = this.txtTrackRef.Text;
                    pic.GpsTrack    = this.numTrack.Value;
                }
                else
                {
                    pic.GpsTrackRef = "";
                    pic.GpsTrack    = null;
                }
            }

            if (this.updateImgDirection.Checked)
            {
                if (this.txtImgDirectionRef.Text != "")
                {
                    pic.GpsImgDirectionRef = this.txtImgDirectionRef.Text;
                    pic.GpsImgDirection    = this.numImgDirection.Value;
                }
                else
                {
                    pic.GpsImgDirectionRef = "";
                    pic.GpsImgDirection    = null;
                }
            }

            if (this.updateDateTime.Checked)
            {
                DateTime datePart = this.dateGPSDate.Value;
                DateTime timePart = this.dateGPSTime.Value;

                datePart = datePart.AddHours(-datePart.Hour);
                datePart = datePart.AddMinutes(-datePart.Minute);
                datePart = datePart.AddSeconds(-datePart.Second);

                datePart = datePart.AddHours(timePart.Hour);
                datePart = datePart.AddMinutes(timePart.Minute);
                datePart = datePart.AddSeconds(timePart.Second);

                pic.GpsDateTimeStamp = datePart;
            }

            if (pic.GpsLongitude == null && pic.GpsLatitude == null && !pic.GpsAltitude.HasValue && !pic.GpsSpeed.HasValue && !pic.GpsTrack.HasValue && !pic.GpsImgDirection.HasValue)
            {
                pic.GpsDateTimeStamp = null;
                pic.GpsVersionIdRemove();
            }
            else
            {
                pic.GpsVersioIdInit();
            }

            if (commit)
            {
                if (!pic.SaveChanges())
                {
                    return(this.ShowFileVanishedMsg(pic.Filename));
                }
            }

            return(true);
        }