private void OK_Click(object sender, EventArgs e)
 {
     try
     {
         editTarget.Names          = names.Text.Split(new char[] { ';' });;
         editTarget.RA             = Coordinates.Parse(ra.Text);
         editTarget.Dec            = Coordinates.Parse(dec.Text);
         editTarget.Magnitude      = Convert.ToDouble(mag.Text);
         editTarget.Distance       = Convert.ToDouble(DistanceValue.Text);
         editTarget.ZoomLevel      = Coordinates.Parse(zoom.Text) * 6;
         editTarget.Classification = (Classification)Enum.Parse((typeof(Classification)), classification.SelectedItem.ToString());
         editTarget.ThumbNail      = null;
         if (Constellations.Abbreviations.ContainsKey(constellation.SelectedItem.ToString()))
         {
             editTarget.Constellation = Constellations.Abbreviations[constellation.SelectedItem.ToString()];
         }
         else
         {
             editTarget.Constellation = "NA";
         }
         FolderBrowser.AllDirty = true;
         this.Close();
     }
     catch
     {
         MessageBox.Show("There are errors in the properties. Properties must be in the correct format.", "Object Properties Editor");
     }
 }
Beispiel #2
0
        private void ChooseLocation_Click(object sender, EventArgs e)
        {
            LocationSetup dialog = new LocationSetup();

            dialog.Sky = false;

            dialog.Latitude     = Coordinates.Parse(this.latText.Text);
            dialog.Longitude    = Coordinates.Parse(this.lngText.Text);
            dialog.LocationName = this.locationName.Text;
            dialog.Altitude     = Convert.ToDouble(this.Altitude.Text.Replace("m", "").Replace("'", ""));

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                this.latText.Text            = Coordinates.FormatDMS(Properties.Settings.Default.LocationLat = dialog.Latitude);
                this.lngText.Text            = Coordinates.FormatDMS(Properties.Settings.Default.LocationLng = dialog.Longitude);
                this.locationName.Text       = Properties.Settings.Default.LocationName = dialog.LocationName;
                this.Altitude.Text           = (Properties.Settings.Default.LocationAltitude = dialog.Altitude).ToString() + "m";
                SpaceTimeController.Altitude = Properties.Settings.Default.LocationAltitude;
                SpaceTimeController.Location = Coordinates.FromLatLng(Properties.Settings.Default.LocationLat, Properties.Settings.Default.LocationLng);
            }
        }
Beispiel #3
0
        public double ParseAndValidateCoordinate(TextBox input, double defValue, ref bool failed)
        {
            bool   sucsess = false;
            double result  = defValue;

            sucsess = Coordinates.Validate(input.Text);



            if (sucsess)
            {
                result          = Coordinates.Parse(input.Text);
                input.BackColor = UiTools.TextBackground;
            }
            else
            {
                input.BackColor = Color.Red;
                failed          = true;
            }

            return(result);
        }
        private void goButton_Click(object sender, System.EventArgs e)
        {
            Latitude  = Coordinates.Parse(txtLat.Text);
            Longitude = Coordinates.Parse(txtLong.Text);

            if (Latitude == 0)
            {
                Latitude = 1 / (360 * 60 * 60 * .5);
            }

            double alt = Altitude;

            try
            {
                alt = Convert.ToDouble(txtAltitude.Text);
            }
            catch
            {
            }
            Altitude     = alt;
            LocationName = this.txtName.Text;
            DialogResult = DialogResult.OK;
            this.Close();
        }
Beispiel #5
0
        private void GoToRADec_Click(object sender, EventArgs e)
        {
            int index = coordinateType.SelectedIndex;


            double ra       = 0;
            double dec      = 0;
            bool   raValid  = false;
            bool   decValid = false;

            switch (index)
            {
            case 0:     // Equitorial
            {
                ra       = Coordinates.ParseRA(raText.Text, false);
                dec      = Coordinates.ParseDec(decText.Text);
                raValid  = Coordinates.ValidateRA(raText.Text);
                decValid = Coordinates.ValidateDec(decText.Text);
            }
            break;

            case 2:     // Galactic
            {
                double l = Coordinates.Parse(raText.Text);
                double b = Coordinates.ParseDec(decText.Text);
                raValid  = Coordinates.Validate(raText.Text);
                decValid = Coordinates.ValidateDec(decText.Text);
                if (raValid && decValid)
                {
                    double[] result = Earth3d.GalactictoJ2000(l, b);
                    ra  = result[0] / 15;
                    dec = result[1];
                }
            }
            break;

            case 3:     // Ecliptic
            {
                double l = Coordinates.Parse(raText.Text);
                double b = Coordinates.ParseDec(decText.Text);
                raValid  = Coordinates.Validate(raText.Text);
                decValid = Coordinates.ValidateDec(decText.Text);
                if (raValid && decValid)
                {
                    AstroCalc.AstroRaDec radec = AstroCalc.AstroCalc.EclipticToJ2000(l, b, SpaceTimeController.JNow);
                    ra  = radec.RA;
                    dec = radec.Dec;
                }
            }
            break;

            case 4:     // Geo
            {
                ra       = -Coordinates.Parse(raText.Text) / 15;
                dec      = Coordinates.ParseDec(decText.Text);
                raValid  = Coordinates.Validate(raText.Text);
                decValid = Coordinates.ValidateDec(decText.Text);
            }
            break;

            case 1:     // alt/az
            {
                double az  = Coordinates.Parse(raText.Text);
                double alt = Coordinates.ParseDec(decText.Text);
                raValid  = Coordinates.Validate(raText.Text);
                decValid = Coordinates.ValidateDec(decText.Text);
                Coordinates radec = Coordinates.HorizonToEquitorial(Coordinates.FromLatLng(alt, az), SpaceTimeController.Location, SpaceTimeController.Now);
                ra  = radec.RA;
                dec = radec.Dec;
            }
            break;
            }
            if (raValid && decValid)
            {
                if (Earth3d.MainWindow.SolarSystemMode)
                {
                    Vector3d pnt = Coordinates.GeoTo3dDouble(dec, Coordinates.Parse(raText.Text));


                    pnt = Vector3d.TransformCoordinate(pnt, Planets.EarthMatrix);
                    pnt.Normalize();
                    Vector2d radec = Coordinates.CartesianToLatLng(pnt);

                    Earth3d.MainWindow.TargetLat  = radec.Y;
                    Earth3d.MainWindow.TargetLong = radec.X - 90;
                }
                else
                {
                    Earth3d.MainWindow.GotoTargetRADec(ra, dec, true, false);
                }
            }
        }