private void CalcRA()
        {
            try
            {
                switch (raFormat_)
                {
                case RADecFormat.HMS:
                case RADecFormat.DMS:
                {
                    double min = Convert.ToDouble(textBoxRAMin.Text);
                    if (min < 0)
                    {
                        min = 0;
                    }
                    else if (min > 59)
                    {
                        min = 59;
                    }

                    double sec = Convert.ToDouble(textBoxRASec.Text);
                    if (sec < 0)
                    {
                        sec = 0;
                    }
                    else if (sec >= 60)
                    {
                        sec = 59.9;
                    }

                    double ra;
                    if (ClientCommonAPI.ParseSignedValue(textBoxRADeg.Text, out ra))
                    {
                        ra += (min + sec / 60.0) / 60.0;
                    }
                    else
                    {
                        ra -= (min + sec / 60.0) / 60.0;
                    }
                    ra_hour_ = SkyObjectPosCalc.Rev((raFormat_ == RADecFormat.HMS) ? ra * 15.0 : ra) / 15.0;
                }
                break;

                case RADecFormat.Degree:
                    ra_hour_ = SkyObjectPosCalc.Rev(Convert.ToDouble(textBoxRADeg.Text)) / 15.0;
                    break;
                }
            }
            catch (System.FormatException)
            {
                ra_hour_ = 0;
            }
            ObjectChanged();
        }
Exemplo n.º 2
0
        private double CalcLocation(TextBox tbD, TextBox tbM, TextBox tbS, bool dms)
        {
            try
            {
                if (dms)
                {
                    double min = Convert.ToDouble(tbM.Text);
                    if (min < 0)
                    {
                        min = 0;
                    }
                    else if (min > 59)
                    {
                        min = 59;
                    }

                    double sec = Convert.ToDouble(tbS.Text);
                    if (sec < 0)
                    {
                        sec = 0;
                    }
                    else if (sec >= 60)
                    {
                        sec = 59.9;
                    }

                    double deg;
                    if (ClientCommonAPI.ParseSignedValue(tbD.Text, out deg))
                    {
                        deg += (min + sec / 60.0) / 60.0;
                    }
                    else
                    {
                        deg -= (min + sec / 60.0) / 60.0;
                    }
                    return(deg);
                }
                else
                {
                    return(Convert.ToDouble(tbD.Text));
                }
            }
            catch (System.FormatException)
            {
                return(0);
            }
        }
        private void CalcDec()
        {
            try
            {
                switch (decFormat_)
                {
                case RADecFormat.HMS:
                case RADecFormat.DMS:
                {
                    double min = Convert.ToDouble(textBoxDecMin.Text);
                    if (min < 0)
                    {
                        min = 0;
                    }
                    else if (min > 59)
                    {
                        min = 59;
                    }

                    double sec = Convert.ToDouble(textBoxDecSec.Text);
                    if (sec < 0)
                    {
                        sec = 0;
                    }
                    else if (sec >= 60)
                    {
                        sec = 59.9;
                    }

                    double dec;
                    if (ClientCommonAPI.ParseSignedValue(textBoxDecDeg.Text, out dec))
                    {
                        dec += (min + sec / 60.0) / 60.0;
                    }
                    else
                    {
                        dec -= (min + sec / 60.0) / 60.0;
                    }
                    dec_ = dec;
                }
                break;

                case RADecFormat.Degree:
                    dec_ = Convert.ToDouble(textBoxDecDeg.Text);
                    break;
                }
                if (dec_ < -90)
                {
                    dec_ = -90;
                }
                else if (dec_ > 90)
                {
                    dec_ = 90;
                }
            }
            catch (System.FormatException)
            {
                dec_ = 0;
            }
            ObjectChanged();
        }