예제 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //Screen 1920x1080
            // 1 pixel = 10^20 km
            int xCenter = 1920 / 2;
            int yCenter = 1080 / 2;

            base.OnPaint(e);
            Graphics g = e.Graphics;

            Brush aBrushBlack     = (Brush)Brushes.Black;    // Center of map && Text
            Brush aBrushDarckBlue = (Brush)Brushes.DarkBlue; // Center of galaxy
            Brush aBrushGreen     = (Brush)Brushes.Green;    //Coordinates of Sollar Systems

            FontFamily fontFamily = new FontFamily("Arial");
            Font       font       = new Font(
                fontFamily,
                16,
                FontStyle.Regular,
                GraphicsUnit.Pixel);

            Pen redPen   = new Pen(Color.Red, 1);   // map's circles
            Pen bluePen  = new Pen(Color.Blue, 2);
            Pen greenPen = new Pen(Color.Green, 3); //Coordinates of Sollar Systems
            Pen blackPen = new Pen(Color.Black, 4);

            g.DrawString($"Date: {_date.ToString()}", font, aBrushBlack, 1720, 20);
            g.FillRectangle(aBrushBlack, xCenter, yCenter, 2, 2); // Drawing center of map

            //Drawing Circles
            for (int i = 0; i < 1920 / 2; i += 10)
            {
                Rectangle r = new Rectangle(xCenter - i, yCenter - i, 2 * i, 2 * i);
                g.DrawEllipse(redPen, r);
            }
            //Drawing coordinates of Galaxy
            g.FillRectangle(aBrushDarckBlue, xCenter, yCenter, 4, 4);
            g.DrawString($"Center of Galxy : {0} {0}", font, aBrushBlack,
                         xCenter, yCenter);
            //Drawing Solar Systems in Galaxy
            foreach (var solar in _galaxy.SolarSystems)
            {
                float X_solar = (float)solar.Coordinates.Item1;
                float Y_solar = -(float)solar.Coordinates.Item2;
                g.FillRectangle(aBrushGreen, (float)(X_solar * _presist) + xCenter, yCenter + (float)(Y_solar * _presist), 10, 10);
                g.DrawString($"{solar.Name} : {(float)(solar.Coordinates.Item1* _presist)} {(float)(solar.Coordinates.Item2* _presist)}", font, aBrushBlack,
                             (float)(X_solar * _presist) + xCenter, yCenter + (float)(Y_solar * _presist));
                //Drawing Lines of Solar system way
                float    x1     = (float)(X_solar * _presist);
                float    y1     = (float)(-Y_solar * _presist);
                float    x2     = (float)(solar.Vector.Item1 * _presist) + (float)(X_solar * _presist);
                float    y2     = (float)(solar.Vector.Item2 * _presist) - (float)(Y_solar * _presist);
                float    xNew1  = -xCenter;
                float    xNew2  = xCenter;
                float    yNew1  = y1 + ((y2 - y1) / (x2 - x1)) * (xNew1 - x1);
                float    yNew2  = y1 + ((y2 - y1) / (x2 - x1)) * (xNew2 - x1);
                PointF[] points = new PointF[2];
                points[0] = new PointF(xNew1 + xCenter, yCenter - yNew1);
                points[1] = new PointF(xNew2 + xCenter, yCenter - yNew2);
                g.DrawCurve(blackPen, points);
            }
        }
        //Draw fone

        /*      private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
         *    {
         *        base.OnPaint(e);
         *        //Screen 1920x1080
         *        // 1 pixel = 10^6 km
         *        int xCenter = 1920 / 2;
         *        int yCenter = 1080 / 2;
         *        base.OnPaint(e);
         *        Graphics g = e.Graphics;
         *        Brush aBrushBlack = (Brush)Brushes.Black; // Center of map && Text
         *        Brush aBrushDarckBlue = (Brush)Brushes.DarkBlue; // Center of galaxy
         *        Brush aBrushGreen = (Brush)Brushes.Green; //Coordinates of Sollar Systems
         *
         *        FontFamily fontFamily = new FontFamily("Arial");
         *        Font font = new Font(
         *                            fontFamily,
         *                            16,
         *                            FontStyle.Regular,
         *                            GraphicsUnit.Pixel);
         *
         *        Pen redPen = new Pen(Color.Red, 1);  // map's circles
         *        Pen bluePen = new Pen(Color.Blue, 2);
         *        Pen greenPen = new Pen(Color.Green, 3); //Coordinates of Sollar Systems
         *        Pen blackPen = new Pen(Color.Black, 4);
         *        //Drawing Circles
         *        for (int i = 0; i < 1920 / 2; i += 10)
         *        {
         *            Rectangle r = new Rectangle(xCenter - i, yCenter - i, 2 * i, 2 * i);
         *            g.DrawEllipse(redPen, r);
         *        }
         *
         *    }
         *    //Draw coordinates of planets
         *    private void pictureBox2_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
         *    {
         *
         *        //Screen 1920x1080
         *        // 1 pixel = 10^6 km
         *        int xCenter = 1920 / 2;
         *        int yCenter = 1080 / 2;
         *        base.OnPaint(e);
         *        Graphics g = pictureBox1.CreateGraphics();
         #region Pens
         *        Brush aBrushBlack = (Brush)Brushes.Black; // Center of map && Text
         *        Brush aBrushDarckBlue = (Brush)Brushes.DarkBlue; // Center of galaxy
         *        Brush aBrushGreen = (Brush)Brushes.Green; //Coordinates of Sollar Systems
         *
         *        FontFamily fontFamily = new FontFamily("Arial");
         *        Font font = new Font(
         *                            fontFamily,
         *                            16,
         *                            FontStyle.Regular,
         *                            GraphicsUnit.Pixel);
         *
         *        Pen redPen = new Pen(Color.Red, 1);  // map's circles
         *        Pen bluePen = new Pen(Color.Blue, 2);
         *        Pen greenPen = new Pen(Color.Green, 3); //Coordinates of Sollar Systems
         *        Pen blackPen = new Pen(Color.Black, 4);
         #endregion
         *        g.DrawString($"Date: {_date.ToString()}", font, aBrushBlack, 1720, 20);
         *        g.FillRectangle(aBrushBlack, xCenter, yCenter, 2, 2); // Drawing center of map
         *
         *        //Drawing Elipses of Planets
         *        foreach (var pl in _solarSys.Planets)
         *        {
         *            Rectangle r = new Rectangle(xCenter - (int)(pl.ELlipseParamA * _presist), yCenter - (int)(pl.ELlipseParamB * _presist),
         *                                    2 * (int)(pl.ELlipseParamA * _presist), 2 * (int)(pl.ELlipseParamB * _presist));
         *            g.DrawEllipse(bluePen, r);
         *        }
         *        //Drawing coordinates of SUN
         *        g.FillRectangle(aBrushDarckBlue, (float)(_solarSys.SunProp.Coordinates.Item1 * _presist) + xCenter,
         *                        yCenter - (float)(_solarSys.SunProp.Coordinates.Item2 * _presist), 5, 5);
         *        g.DrawString($"{_solarSys.SunProp.Name} : {0} {0}", font, aBrushBlack, xCenter, yCenter);
         *
         *        //Drawing Planets in Solar System
         *        foreach (var planet in _solarSys.Planets)
         *        {
         *            g.FillRectangle(aBrushGreen, (float)(planet.Coordinates.Item1 * _presist) + xCenter, -(float)(planet.Coordinates.Item2 * _presist) + yCenter, 10, 10);
         *            g.DrawString($"{planet.Planet.Name} : {(float)(planet.Coordinates.Item1 * _presist)} {(float)(planet.Coordinates.Item2 * _presist)}", font, aBrushBlack,
         *                                          (float)(planet.Coordinates.Item1 * _presist) + xCenter, -(float)(planet.Coordinates.Item2 * _presist) + yCenter);
         *
         *        }
         *
         *    }*/

        protected override void OnPaint(PaintEventArgs e)
        {
            //Screen 1920x1080
            // 1 pixel = 10^6 km
            int xCenter = 1920 / 2;
            int yCenter = 1080 / 2;

            base.OnPaint(e);
            Graphics g = e.Graphics;

            #region Pens
            Brush aBrushBlack     = (Brush)Brushes.Black;    // Center of map && Text
            Brush aBrushDarckBlue = (Brush)Brushes.DarkBlue; // Center of galaxy
            Brush aBrushGreen     = (Brush)Brushes.Green;    //Coordinates of Sollar Systems

            FontFamily fontFamily = new FontFamily("Arial");
            Font       font       = new Font(
                fontFamily,
                16,
                FontStyle.Regular,
                GraphicsUnit.Pixel);

            Pen redPen   = new Pen(Color.Red, 1);   // map's circles
            Pen bluePen  = new Pen(Color.Blue, 2);
            Pen greenPen = new Pen(Color.Green, 3); //Coordinates of Sollar Systems
            Pen blackPen = new Pen(Color.Black, 4);
            #endregion
            g.DrawString($"Date: {_date.ToString()}", font, aBrushBlack, 1720, 20);
            g.FillRectangle(aBrushBlack, xCenter, yCenter, 2, 2); // Drawing center of map

            //Drawing Circles
            Thread[] threads = new Thread[192 / 2];
            int      count   = 0;;
            for (int i = 0; i < 1920 / 2; i += 10)
            {
                Rectangle r   = new Rectangle((int)xCenter - (int)i, (int)yCenter - (int)i, (int)2 * (int)i, (int)2 * (int)i);
                Rectangle n_r = r;
                /* threads[count] = new Thread(() =>*/ g.DrawEllipse(redPen, n_r);
                // threads[count++].Start();
            }
            foreach (var x in threads)
            {
                //      x.Join();
            }

            //Drawing Elipses of Planets
            foreach (var pl in _solarSys.Planets)
            {
                Rectangle r = new Rectangle(xCenter - (int)(pl.ELlipseParamA * _presist), yCenter - (int)(pl.ELlipseParamB * _presist),
                                            2 * (int)(pl.ELlipseParamA * _presist), 2 * (int)(pl.ELlipseParamB * _presist));
                g.DrawEllipse(bluePen, r);
            }
            //Drawing coordinates of SUN
            g.FillRectangle(aBrushDarckBlue, (float)(_solarSys.SunProp.Coordinates.Item1 * _presist) + xCenter,
                            yCenter - (float)(_solarSys.SunProp.Coordinates.Item2 * _presist), 5, 5);
            g.DrawString($"{_solarSys.SunProp.Name} : {0} {0}", font, aBrushBlack, xCenter, yCenter);


            //Drawing Planets in Solar System
            foreach (var planet in _solarSys.Planets)
            {
                g.FillRectangle(aBrushGreen, (float)(planet.Coordinates.Item1 * _presist) + xCenter, -(float)(planet.Coordinates.Item2 * _presist) + yCenter, 10, 10);
                g.DrawString($"{planet.Planet.Name} : {(float)(planet.Coordinates.Item1 * _presist)} {(float)(planet.Coordinates.Item2 * _presist)}", font, aBrushBlack,
                             (float)(planet.Coordinates.Item1 * _presist) + xCenter, -(float)(planet.Coordinates.Item2 * _presist) + yCenter);
            }
        }