Пример #1
0
 public void vytvor_slnecnu_sustavu(List<Teleso> objekty)
 {
     bool pom = sustava.mod;
     sustava = new Sustava(G,dt,objekty_k_dispozicii);
     sustava.mod = pom;
     sustava.nastav_pociatocny_stav();
     kresli = new Vykreslovanie(sustava, plocha);
     plocha.Invalidate();
 }
Пример #2
0
        public Vesmir()
        {
            plocha = new Panel
            {
                Size = new Size(1400, 950),
                Location = new Point(5, 10),
                BackColor = Color.Black,
            };
            Controls.Add(plocha);
            plocha.Visible = false;

            cas = new Label
            {
                Parent = plocha,
                Location = new Point(plocha.Location.X + 10, plocha.Location.Y + 10),
                AutoSize = true,
                BackColor = Color.Black,
                ForeColor = Color.White,
                Text = "Day: 0\nYear: 0"
            };
            Controls.Add(cas);
            cas.BringToFront();


            //obrazky planet
            {
                slnko_pic = new PictureBox
                {
                    Size = new Size(30, 30),
                    Location = new Point(0, 0),
                    Image = Properties.Resources.slnko1,
                    //BackColor = Color.Black,
                    Parent = plocha,

                    SizeMode = PictureBoxSizeMode.StretchImage,
                };
                Controls.Add(slnko_pic);
                slnko_pic.Visible = false;

                merkur_pic = new PictureBox
                {
                    Size = new Size(30, 30),
                    Location = new Point(0, 0),
                    BackColor = Color.Transparent,
                    Parent = plocha,
                    Image = Properties.Resources.merkur,
                    SizeMode = PictureBoxSizeMode.StretchImage,
                };
                Controls.Add(merkur_pic);
                merkur_pic.Visible = false;

                venusa_pic = new PictureBox
                {
                    Size = new Size(30, 30),
                    Location = new Point(0, 0),
                    Parent = plocha,
                    Image = Properties.Resources.venusa,
                    SizeMode = PictureBoxSizeMode.StretchImage,
                };
                Controls.Add(venusa_pic);
                venusa_pic.Visible = false;

                zem_pic = new PictureBox
                {
                    Size = new Size(30, 30),
                    Location = new Point(0, 0),
                    Parent = plocha,
                    Image = Properties.Resources.zem,
                    SizeMode = PictureBoxSizeMode.StretchImage,
                };
                Controls.Add(zem_pic);
                zem_pic.Visible = false;

                mars_pic = new PictureBox
                {
                    Size = new Size(30, 30),
                    Location = new Point(0, 0),
                    Parent = plocha,
                    Image = Properties.Resources.mars,
                    SizeMode = PictureBoxSizeMode.StretchImage,
                };
                Controls.Add(mars_pic);
                mars_pic.Visible = false;

                jupiter_pic = new PictureBox
                {
                    Size = new Size(30, 30),
                    Location = new Point(0, 0),
                    Parent = plocha,
                    Image = Properties.Resources.jupiter,
                    SizeMode = PictureBoxSizeMode.StretchImage,
                };
                Controls.Add(jupiter_pic);
                jupiter_pic.Visible = false;

                saturn_pic = new PictureBox
                {
                    Size = new Size(30, 30),
                    Location = new Point(0, 0),
                    BackColor = Color.Transparent,
                    Parent = plocha,
                    Image = Properties.Resources.saturn,
                    SizeMode = PictureBoxSizeMode.StretchImage,
                };
                Controls.Add(saturn_pic);
                saturn_pic.Visible = false;

                uran_pic = new PictureBox
                {
                    Size = new Size(30, 30),
                    Location = new Point(0, 0),
                    BackColor = Color.Transparent,
                    Parent = plocha,
                    Image = Properties.Resources.uran,
                    SizeMode = PictureBoxSizeMode.StretchImage,
                };
                Controls.Add(uran_pic);
                uran_pic.Visible = false;

                neptun_pic = new PictureBox
                {
                    Size = new Size(30, 30),
                    Location = new Point(0, 0),
                    BackColor = Color.Transparent,
                    Parent = plocha,
                    Image = Properties.Resources.neptun,
                    SizeMode = PictureBoxSizeMode.StretchImage,
                };
                Controls.Add(neptun_pic);
                neptun_pic.Visible = false;
            }
           
            G = 6.67 * Math.Pow(10, -11);
            G = G * (5.972 / 3.375) * Math.Pow(10, -9);

            //nacitanie vstupu
            {
                var data = Properties.Resources.planety.Split(Convert.ToChar("\n"));

                //nazov, m, e, a, r

                Slnko = new Teleso(data[1].Split(), slnko_pic);
                Merkur = new Teleso(data[2].Split(), merkur_pic);
                Venusa = new Teleso(data[3].Split(), venusa_pic);
                Zem = new Teleso(data[4].Split(), zem_pic);
                Mars = new Teleso(data[5].Split(), mars_pic);
                Jupiter = new Teleso(data[6].Split(), jupiter_pic);
                Saturn = new Teleso(data[7].Split(), saturn_pic);
                Uran = new Teleso(data[8].Split(), uran_pic);
                Neptun = new Teleso(data[9].Split(), neptun_pic);

            }
            
            objekty_k_dispozicii = new Teleso[] { Slnko, Merkur, Venusa, Zem, Mars, Jupiter, Saturn, Uran, Neptun};
            viditelne_objekty = new List<Teleso>();

            viditelne_objekty.Add(Slnko);
            viditelne_objekty.Add(Merkur);
            viditelne_objekty.Add(Venusa);
            viditelne_objekty.Add(Zem);
            viditelne_objekty.Add(Mars);
            viditelne_objekty.Add(Jupiter);
            viditelne_objekty.Add(Saturn);
            viditelne_objekty.Add(Uran);
            viditelne_objekty.Add(Neptun);

            //mod = true;
            sustava = new Sustava(G, dt, objekty_k_dispozicii);

            //posledne presne pre neptun: dt = 1000000
            dt = 300000;
            t = 0;         

            zapnut = new Button
            {
                Location = new Point(500, 500),
                Size = new Size(400, 50),
                Text = "Start the simulation",
                Parent = plocha
            };
            Controls.Add(zapnut);
            zapnut.BringToFront();            
            zapnut.Click += new EventHandler(zapnut_Click);
            //zapnut.Visible = false;

            reset = new Button
            {
                Size = new Size(200,45),
                Location = new Point(1675,15),
                Text = "Reset",
                Font = new Font(Font.FontFamily, 12)
            };
            Controls.Add(reset);
            reset.Click += new EventHandler(reset_Click);
            
            mode = new Button
            {
                Text = "Mode: Heliocentric",
                Location = new Point(1450,70),
                Size = new Size (430,40),
                Font = new Font(Font.FontFamily,12)
            };
            Controls.Add(mode);
            mode.Click += new EventHandler(mode_Click);

            timer = new Timer
            {
                Interval = 1,
            };
            timer.Tick += new EventHandler(tick);
            //timer.Start();

            start_stop = new Button
            {
                Location = new Point(1450, 15),
                Size = new Size(200,45),
                Text = "Start",
                Font = new Font(Font.FontFamily, 12)
            };
            Controls.Add(start_stop);
            start_stop.Click += new EventHandler(start_stop_Click);

            kresli = new Vykreslovanie(sustava, plocha);

            //kresli.preskaluj(sustava);
            //kresli.helio();

            sustava.mod = true;

            InitializeComponent();
        }