Beispiel #1
0
 public ReadForm(string str)
 {
     InitializeComponent();
     //this.Text = str;
     readQuestion.Text     = str;
     readQuestion.AutoSize = true;
     readQuestion.Invalidate();
     AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowOnly;
     AutoSize     = true;
     Invalidate();
 }
        private void SearchFunc()
        {
            if (r_SolarEclipse.Checked == true)
            {
                lB_Result.Items.Clear();
                dateList.Clear();
                NoEcl = 0;
                location.MainDateTime = new DateTime((int)nUD_From.Value, 1, 1);
                location.MainDateTime = location.MainDateTime.AddDays(-1);
                this.solarSystemData.PlanetPositions();
                oldElong = this.solarSystemData.SolarSystemObjects.GetObjectByName("Moon").Elongation;
                step     = "day";
                while (location.MainDateTime.Year < (int)nUD_To.Value + 1)
                {
                    prog = ((location.MainDateTime.Year - (int)nUD_From.Value) * 100) / ((int)nUD_To.Value - (int)nUD_From.Value);
                    l_Progress.Invalidate();
                    AddTime(step, 1);
                    this.solarSystemData.PlanetPositions();
                    newElong = this.solarSystemData.SolarSystemObjects.GetObjectByName("Moon").Elongation;
                    if (newElong < 15 && newElong > 1)
                    {
                        step = "hour";
                    }
                    if (newElong < 1)
                    {
                        step = "minute";
                    }
                    if (step == "hour" && newElong > oldElong)
                    {
                        step = "day";
                        AddTime(step, 20);
                    }
                    if (step == "minute" && newElong > oldElong)
                    {
                        if (oldElong < (this.solarSystemData.SolarSystemObjects.GetObjectByName("Moon").Diameter / 7200 + this.solarSystemData.SolarSystemObjects.GetObjectByName("Sun").Diameter / 7200))
                        {
                            AddTime(step, -1);
                            ++NoEcl;
                            lB_Result.Items.Add(NoEcl + ".   " + location.MainDateTime);
                            DateTime tempTime = new DateTime();
                            tempTime = location.MainDateTime;
                            dateList.Add(tempTime);
                            step = "day";
                            AddTime(step, 20);
                        }
                        else
                        {
                            step = "day";
                            AddTime(step, 20);
                        }
                    }
                    oldElong = newElong;
                }
                prog = 100;
                l_Progress.Invalidate();
                b_Search.Visible    = true;
                l_labelProg.Visible = false;
                nUD_From.Enabled    = true;
                nUD_To.Enabled      = true;
                searchThread.Abort();
            }
            if (r_LunarEclipse.Checked == true)
            {
                lB_Result.Items.Clear();
                dateList.Clear();
                NoEcl = 0;
                location.MainDateTime = new DateTime((int)nUD_From.Value, 1, 1);
                location.MainDateTime = location.MainDateTime.AddDays(-1);
                this.solarSystemData.PlanetPositions();
                oldElong = this.solarSystemData.SolarSystemObjects.GetObjectByName("Moon").Elongation;
                step     = "day";
                while (location.MainDateTime.Year < (int)nUD_To.Value + 1)
                {
                    prog = ((location.MainDateTime.Year - (int)nUD_From.Value) * 100) / ((int)nUD_To.Value - (int)nUD_From.Value);
                    l_Progress.Invalidate();
                    AddTime(step, 1);
                    this.solarSystemData.PlanetPositions();
                    newElong = this.solarSystemData.SolarSystemObjects.GetObjectByName("Moon").Elongation;
                    if (newElong > 165 && newElong < 179)
                    {
                        step = "hour";
                    }
                    if (newElong > 179)
                    {
                        step = "minute";
                    }
                    if (step == "hour" && newElong < oldElong)
                    {
                        step = "day";
                        AddTime(step, 20);
                    }
                    if (step == "minute" && newElong < oldElong)
                    {
                        double RZ  = 6378.140;
                        double RS  = 696000;
                        double dS  = this.solarSystemData.SolarSystemObjects.GetObjectByName("Sun").Distance * 1.49597870E8;
                        double dM  = this.solarSystemData.SolarSystemObjects.GetObjectByName("Moon").Distance * 1.49597870E8;
                        double RES = (RZ + RS) * (dS + dM) / dS - RS;
                        this.solarSystemData.SolarSystemObjects.GetObjectByName("Earth shadow").Diameter = 7200 * Math.Atan(RES / dM) * 180 / Math.PI;

                        if (oldElong > 180 - (this.solarSystemData.SolarSystemObjects.GetObjectByName("Moon").Diameter / 7200 + this.solarSystemData.SolarSystemObjects.GetObjectByName("Earth shadow").Diameter / 7200))
                        {
                            AddTime(step, -1);
                            ++NoEcl;
                            lB_Result.Items.Add(NoEcl + ".   " + location.MainDateTime);
                            DateTime tempTime = new DateTime();
                            tempTime = location.MainDateTime;
                            dateList.Add(tempTime);
                            step = "day";
                            AddTime(step, 20);
                        }
                        else
                        {
                            step = "day";
                            AddTime(step, 20);
                        }
                    }
                    oldElong = newElong;
                }
                prog = 100;
                l_Progress.Invalidate();
                b_Search.Visible    = true;
                l_labelProg.Visible = false;
                nUD_From.Enabled    = true;
                nUD_To.Enabled      = true;
                searchThread.Abort();
            }
            if (r_MercuryTranzit.Checked == true)
            {
                lB_Result.Items.Clear();
                dateList.Clear();
                NoEcl = 0;
                location.MainDateTime = new DateTime((int)nUD_From.Value, 1, 1);
                location.MainDateTime = location.MainDateTime.AddDays(-1);
                this.solarSystemData.PlanetPositions();
                oldElong = this.solarSystemData.SolarSystemObjects.GetObjectByName("Mercury").Elongation;
                step     = "day";
                while (location.MainDateTime.Year < (int)nUD_To.Value + 1)
                {
                    prog = ((location.MainDateTime.Year - (int)nUD_From.Value) * 100) / ((int)nUD_To.Value - (int)nUD_From.Value);
                    l_Progress.Invalidate();
                    AddTime(step, 1);
                    this.solarSystemData.PlanetPositions();
                    newElong = this.solarSystemData.SolarSystemObjects.GetObjectByName("Mercury").Elongation;
                    if (newElong < 2)
                    {
                        step = "hour";
                    }
                    if (newElong < 0.4)
                    {
                        step = "minute";
                    }
                    if (step == "hour" && newElong > oldElong)
                    {
                        step = "day";
                        AddTime(step, 20);
                    }
                    if (step == "minute" && newElong > oldElong)
                    {
                        if (oldElong < (this.solarSystemData.SolarSystemObjects.GetObjectByName("Mercury").Diameter / 7200 + this.solarSystemData.SolarSystemObjects.GetObjectByName("Sun").Diameter / 7200))
                        {
                            if (this.solarSystemData.SolarSystemObjects.GetObjectByName("Mercury").Distance < this.solarSystemData.SolarSystemObjects.GetObjectByName("Sun").Distance)
                            {
                                AddTime(step, -1);
                                ++NoEcl;
                                lB_Result.Items.Add(NoEcl + ".  " + location.MainDateTime);
                                DateTime tempTime = new DateTime();
                                tempTime = location.MainDateTime;
                                dateList.Add(tempTime);
                            }
                            step = "day";
                            AddTime(step, 90);
                        }
                        else
                        {
                            step = "day";
                            AddTime(step, 90);
                        }
                    }
                    oldElong = newElong;
                }
                prog = 100;
                l_Progress.Invalidate();
                b_Search.Visible    = true;
                l_labelProg.Visible = false;
                nUD_From.Enabled    = true;
                nUD_To.Enabled      = true;
                searchThread.Abort();
            }
            if (r_VenusTranzit.Checked == true)
            {
                lB_Result.Items.Clear();
                dateList.Clear();
                NoEcl = 0;
                location.MainDateTime = new DateTime((int)nUD_From.Value, 1, 1);
                location.MainDateTime = location.MainDateTime.AddDays(-1);
                this.solarSystemData.PlanetPositions();
                oldElong = this.solarSystemData.SolarSystemObjects.GetObjectByName("Venus").Elongation;
                step     = "day";
                while (location.MainDateTime.Year < (int)nUD_To.Value + 1)
                {
                    prog = ((location.MainDateTime.Year - (int)nUD_From.Value) * 100) / ((int)nUD_To.Value - (int)nUD_From.Value);
                    l_Progress.Invalidate();
                    AddTime(step, 1);
                    this.solarSystemData.PlanetPositions();
                    newElong = this.solarSystemData.SolarSystemObjects.GetObjectByName("Venus").Elongation;
                    if (newElong < 2)
                    {
                        step = "hour";
                    }
                    if (newElong < 0.4)
                    {
                        step = "minute";
                    }
                    if (step == "hour" && newElong > oldElong)
                    {
                        step = "day";
                        AddTime(step, 20);
                    }
                    if (step == "minute" && newElong > oldElong)
                    {
                        if (oldElong < (this.solarSystemData.SolarSystemObjects.GetObjectByName("Venus").Diameter / 7200 + this.solarSystemData.SolarSystemObjects.GetObjectByName("Sun").Diameter / 7200))
                        {
                            if (this.solarSystemData.SolarSystemObjects.GetObjectByName("Venus").Distance < this.solarSystemData.SolarSystemObjects.GetObjectByName("Sun").Distance)
                            {
                                AddTime(step, -1);
                                ++NoEcl;
                                lB_Result.Items.Add(NoEcl + ".  " + location.MainDateTime);
                                DateTime tempTime = new DateTime();
                                tempTime = location.MainDateTime;
                                dateList.Add(tempTime);
                            }
                            step = "day";
                            AddTime(step, 200);
                        }
                        else
                        {
                            step = "day";
                            AddTime(step, 200);
                        }
                    }
                    oldElong = newElong;
                }
                prog = 100;
                l_Progress.Invalidate();
                b_Search.Visible    = true;
                l_labelProg.Visible = false;
                nUD_From.Enabled    = true;
                nUD_To.Enabled      = true;
                searchThread.Abort();
            }
        }