Пример #1
0
        public void SetViewRect(Coordinates[] corners)
        {
            if (corners.Length != 4)
            {
                return;
            }
            bool change = false;

            if (this.corners != null)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (this.corners[i] != corners[i])
                    {
                        change = true;
                        break;
                    }
                }
            }
            else
            {
                change = true;
            }

            if (!change)
            {
                return;
            }
            if (Settings.Active.LocalHorizonMode)
            {
                cornersAltAz = new Coordinates[4];
                for (int i = 0; i < 4; i++)
                {
                    this.cornersAltAz[i] = Coordinates.EquitorialToHorizon(corners[i], SpaceTimeController.Location, SpaceTimeController.Now);
                }
            }

            this.corners = corners;

            RefreshHint();
        }
        private void UpdateLiveValuesPlanet()
        {
            raText.Text   = Coordinates.FormatDMS(target.Lng);
            decText.Text  = Coordinates.FormatDMSWide(target.Lat);
            raLabel.Text  = "Lng:";
            decLabel.Text = "Lat:";
            Coordinates altAz = Coordinates.EquitorialToHorizon(Coordinates.FromRaDec(target.RA, target.Dec), SpaceTimeController.Location, SpaceTimeController.Now);

            altText.Hide();
            azText.Hide();
            altLabel.Hide();
            azLabel.Hide();
            riseLabel.Hide();
            setLabel.Hide();
            transitLabel.Hide();
            transitText.Hide();
            magnitudeLabel.Hide();
            distanceLabel.Hide();
            magnitudeValue.Hide();
            riseText.Hide();
            setText.Hide();
            transitText.Hide();
            distanceValue.Hide();
        }
        private void UpdateLiveValues()
        {
            if (target != null)
            {
                if (target.Type == ImageSetType.Planet || target.Type == ImageSetType.Earth)
                {
                    UpdateLiveValuesPlanet();
                    return;
                }

                raText.Text  = Coordinates.FormatHMS(target.RA);
                decText.Text = Coordinates.FormatDMSWide(target.Dec);
                Coordinates altAz = Coordinates.EquitorialToHorizon(Coordinates.FromRaDec(target.RA, target.Dec), SpaceTimeController.Location, SpaceTimeController.Now);
                altText.Text = Coordinates.FormatDMSWide(altAz.Alt);
                azText.Text  = Coordinates.FormatDMSWide(altAz.Az);

                AstroCalc.RiseSetDetails details;
                // try
                {
                    if (target.Classification == Classification.SolarSystem)
                    {
                        double jNow             = ((int)((int)SpaceTimeController.JNow) + .5);
                        AstroCalc.AstroRaDec p1 = Planets.GetPlanetLocation(target.Name, jNow - 1);
                        AstroCalc.AstroRaDec p2 = Planets.GetPlanetLocation(target.Name, jNow);
                        AstroCalc.AstroRaDec p3 = Planets.GetPlanetLocation(target.Name, jNow + 1);

                        int type = 0;
                        switch (target.Name)
                        {
                        case "Sun":
                            type = 1;
                            break;

                        case "Moon":
                            type = 2;
                            break;

                        default:
                            type = 0;
                            break;
                        }
                        details = AstroCalc.AstroCalc.GetRiseTrinsitSet(jNow, SpaceTimeController.Location.Lat, -SpaceTimeController.Location.Lng, p1.RA, p1.Dec, p2.RA, p2.Dec, p3.RA, p3.Dec, type);
                    }
                    else
                    {
                        details = AstroCalc.AstroCalc.GetRiseTrinsitSet(((int)SpaceTimeController.JNow) + .5, SpaceTimeController.Location.Lat, -SpaceTimeController.Location.Lng, target.RA, Target.Dec, target.RA, Target.Dec, target.RA, Target.Dec, 0);
                    }


                    if (details.bValid)
                    {
                        riseText.Text    = UiTools.FormatDecimalHours(details.Rise);
                        transitText.Text = UiTools.FormatDecimalHours(details.Transit);
                        setText.Text     = UiTools.FormatDecimalHours(details.Set);
                    }
                    else
                    {
                        if (details.bNeverRises)
                        {
                            riseText.Text = transitText.Text = setText.Text = Language.GetLocalizedText(934, "Never Rises");
                        }
                        else
                        {
                            riseText.Text = transitText.Text = setText.Text = Language.GetLocalizedText(935, "Never Sets");
                        }
                    }
                    if (target.Distance != 0)
                    {
                        this.distanceValue.Text = UiTools.FormatDistance(target.Distance);
                    }
                    else
                    {
                        this.distanceValue.Text = Language.GetLocalizedText(281, "n/a");
                    }
                }
                //catch
                {
                }
            }
        }