Exemplo n.º 1
0
        private void PictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            list = new List <Point>(); flag = false;

            float           km    = (((float)pictureBox1.Height) / (15 * 10)) / 2;
            PointF          point = new PointF(pictureBox1.Width / 2, pictureBox1.Height / 2);
            PolarCoordinate polar = new PolarCoordinate();

            double[] ar = polar.Polar(point, ex, ey);
            Airplane.StartAzimuth  = ar[1];
            Airplane.StartDistance = ar[0] / km;
            textBox2.Text          = Airplane.StartAzimuth.ToString();
            textBox3.Text          = Airplane.StartDistance.ToString();
        }
Exemplo n.º 2
0
        void instal()
        {
            PolarCoordinate polar = new PolarCoordinate();

            a2 = 0; buf = new List <PointF[]>();
            foreach (Air air in Com.air)
            {
                buf.Add(polar.XY(air.Trajectory, pictureBox1.Width, pictureBox1.Height, scale, air.Lenght, air.Speed));
                min[a2]     = polar.XY(air.Trajectory, pictureBox1.Width, pictureBox1.Height, scale, air.Lenght, air.Speed).Length;
                percent[a2] = 100 / min[a2];
                cone[a2]    = (int)(max[a2] / percent[a2]);
                a2++;
            }

            ok = true; sd = true;
        }
Exemplo n.º 3
0
        int targetObjectNumber = 0;     // Нумерация создаваемых целей

        private void ButtonAddTarget_Click(object sender, EventArgs e)
        {
            pictureBoxTarget.Refresh();
            targetStarted = false;

            Airplane.vys    = AltiMetr.Altimeter.ToArray();
            Airplane.Namber = Convert.ToInt32(textBoxTargetNum.Text);
            Airplane.Speed  = 0.0001F * Convert.ToSingle(textBoxSpeed.Text);
            int             count       = 0;
            PointF          pointCenter = new PointF(pictureBoxTarget.Width / 2, pictureBoxTarget.Height / 2);
            PolarCoordinate polar       = new PolarCoordinate();
            float           km          = (((float)pictureBoxTarget.Height) / (15 * 10)) / 2;

            foreach (Point h in list)
            {
                count++;
                double[] ar = polar.Polar(pointCenter, h.X, h.Y);
            }
            Airplane.Lenght     = count;
            Airplane.Trajectory = new double[count, 2];
            count = 0;
            foreach (Point h in list)
            {
                double[] ar = polar.Polar(pointCenter, h.X, h.Y);
                Airplane.Trajectory[count, 0] = ar[0] / km;
                Airplane.Trajectory[count, 1] = ar[1];
                count++;
            }
            Airplane.Hi = true;
            Air air = new Air();

            air.Number        = Airplane.Namber;
            air.Lenght        = Airplane.Lenght;
            air.Speed         = Airplane.Speed;
            air.His           = Airplane.His;
            air.Distance      = Airplane.Distance;
            air.Trajectory    = Airplane.Trajectory;
            air.XY            = Airplane.XY;
            air.vys           = Airplane.vys;
            air.EndAzimuth    = Airplane.EndAzimuth;
            air.EndDistance   = Airplane.EndDistance;
            air.StartAzimuth  = Airplane.StartAzimuth;
            air.StartDistance = Airplane.StartDistance;
            Com.air.Add(air);
            Com.cons++;
            textBoxTargetNum.Text = Com.cons.ToString();
        }
Exemplo n.º 4
0
        public void Line(Graphics e, int width, int height, int scale, bool mar, int Lenght, PointF[] XY, double[,] Trajectory)
        {
            float  km    = (((float)height) / (scale * 10)) / 2;
            PointF centr = new PointF(width / 2, height / 2);

            XY = new PointF[Lenght];
            PolarCoordinate polar = new PolarCoordinate();

            for (int a = 0; a < Lenght; a++)
            {
                XY[a] = polar.Angel(centr, Trajectory[a, 1], Trajectory[a, 0] * km);
            }
            if (mar == true)
            {
                e.DrawLines(Pens.White, XY);
            }
        }
Exemplo n.º 5
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Airplane.Namber = Convert.ToInt32(textBox1.Text);
            Airplane.Speed  = 0.0001f * Convert.ToSingle(textBox6.Text);
            int             count = 0;
            PointF          point = new PointF(pictureBox1.Width / 2, pictureBox1.Height / 2);
            PolarCoordinate polar = new PolarCoordinate();
            float           km    = (((float)pictureBox1.Height) / (15 * 10)) / 2;

            foreach (Point h in list)
            {
                count++;
                double[] ar = polar.Polar(point, h.X, h.Y);
            }
            Airplane.Lenght     = count;
            Airplane.Trajectory = new double[count, 2];
            count = 0;
            foreach (Point h in list)
            {
                double[] ar = polar.Polar(point, h.X, h.Y);
                Airplane.Trajectory[count, 0] = ar[0] / km;
                Airplane.Trajectory[count, 1] = ar[1];
                count++;
            }
            Airplane.Hi = true;
            Air air = new Air();

            air.Namber     = Airplane.Namber;
            air.Lenght     = Airplane.Lenght;
            air.Speed      = Airplane.Speed;
            air.His        = Airplane.His;
            air.Distance   = Airplane.Distance;
            air.Trajectory = Airplane.Trajectory;
            air.XY         = Airplane.XY;
            //air.EndAzimuth = Airplane.EndAzimuth;
            //air.EndDistance = Airplane.EndDistance;
            //air.StartAzimuth = Airplane.StartAzimuth;
            //air.StartDistance = Airplane.StartDistance;
            Com.air.Add(air);
            Com.cons++;
            textBox1.Text = Com.cons.ToString();
        }
Exemplo n.º 6
0
        private void TargetStart(MouseEventArgs e)
        {
            targetObjectNumber++;
            list     = new List <Point>();
            AltiMetr = new AltiMetro(targetObjectNumber - 1);
            AltiMetr.Altimeter.Add(double.Parse(textBoxAltimeter.Text));
            float           km          = (((float)pictureBoxTarget.Height) / (15 * 10)) / 2;
            PointF          pointCenter = new PointF(pictureBoxTarget.Width / 2, pictureBoxTarget.Height / 2);
            PolarCoordinate polar       = new PolarCoordinate();

            double[] ar = polar.Polar(pointCenter, e.X, e.Y);
            Airplane.StartAzimuth     = ar[1];
            Airplane.StartDistance    = ar[0] / km;
            textBoxStartAzimut.Text   = Airplane.StartAzimuth.ToString();
            textBoxStartDistance.Text = Airplane.StartDistance.ToString();
            Point targetPoint = new Point(e.X, e.Y);

            list.Add(targetPoint);
            targetStarted = true;
        }
Exemplo n.º 7
0
        public void Point(Graphics e, int width, int height, int scale, double a, double d, string text)
        {
            float km = (((float)height) / (scale * 10)) / 2;

            if (Airplane.image != null)
            {
                int CentrImageX = Airplane.image.Width / 2;
                int CentrImageY = Airplane.image.Height / 2;
                e.DrawImage(Airplane.image, 400 - CentrImageX, 400 - CentrImageY);
            }
            double          Azimut   = a;
            double          Distance = (km * d);
            PointF          point    = new PointF(width / 2, height / 2);
            PolarCoordinate polar    = new PolarCoordinate();
            PointF          pointF   = polar.Angel(point, Azimut, Distance);

            double[] ar = polar.Polar(point, pointF.X, pointF.Y);
            e.DrawString(text + "\n Азимут = " + ar[1].ToString("0") + "\n Дальность = " + (ar[0] / km).ToString("0"), new Font("Arial", 8), Brushes.White, pointF.X + 5, pointF.Y + 5);
            Rectangle re = new Rectangle((int)pointF.X, (int)pointF.Y, 4, 4);

            e.FillPie(Brushes.Red, re, 0, 360);
        }
Exemplo n.º 8
0
        private void TargetContinue(MouseEventArgs e)
        {
            RadarDraw RD = new RadarDraw();
            //flag = false;
            float           km    = (((float)pictureBoxTarget.Height) / (15 * 10)) / 2;
            PointF          point = new PointF(pictureBoxTarget.Width / 2, pictureBoxTarget.Height / 2);
            PolarCoordinate polar = new PolarCoordinate();

            double[] ar = polar.Polar(point, e.X, e.Y);
            Airplane.EndAzimuth  = ar[1];
            Airplane.EndDistance = ar[0] / km;
            Point  targetPoint       = new Point(e.X, e.Y);
            string targetPointString = targetPoint.X.ToString() + ' ' + targetPoint.Y.ToString() + '\n';

            //File.AppendAllText($"target{targetObjectNumber}.ini", targetPointString);
            list.Add(targetPoint);
            if (list.Count > 1)
            {
                RadarDraw.DrawLines(GRAPH, list);
            }
            textBoxEndAzimut.Text   = Airplane.EndAzimuth.ToString();
            textBoxEndDistance.Text = Airplane.EndDistance.ToString();
        }
Exemplo n.º 9
0
        private void PictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            float           km    = (((float)pictureBox1.Height) / (15 * 10)) / 2;
            PointF          point = new PointF(pictureBox1.Width / 2, pictureBox1.Height / 2);
            PolarCoordinate polar = new PolarCoordinate();

            double[] ar = polar.Polar(point, ex, ey);
            Airplane.EndAzimuth  = ar[1];
            Airplane.EndDistance = ar[0] / km;
            textBox4.Text        = Airplane.EndAzimuth.ToString();
            textBox5.Text        = Airplane.EndDistance.ToString();

            int count = 0;


            foreach (Point h in list)
            {
                count++;
                double[] array = polar.Polar(point, h.X, h.Y);
            }
            Airplane.Lenght     = count;
            Airplane.Trajectory = new double[count, 2];
            double[,] mile      = new double[count, 2];
            count = 0;
            foreach (Point h in list)
            {
                mile[count, 0] = h.X;
                mile[count, 1] = h.Y;
                double[] array = polar.Polar(point, h.X, h.Y);
                Airplane.Trajectory[count, 0] = ar[0] / km;
                Airplane.Trajectory[count, 1] = ar[1];
                count++;
            }
            Airplane.Distance = polar.Kilometers(mile, Airplane.Lenght) / km;
            label1.Text       = "Растояние : " + Airplane.Distance.ToString("0.00") + " км";
        }
Exemplo n.º 10
0
        public void His(Graphics e, int width, int height, int scale, PointF point, bool mar, bool mar1, bool his, int nam, float a, int a1, bool sd)
        {
            // float km = (((float)height) / (scale * 10)) / 2;


            PointF          centr = new PointF(width / 2, height / 2);
            PolarCoordinate polar = new PolarCoordinate();

            float  km     = (((float)height) / (scale * 10)) / 2;
            double radius = polar.Polar(centr, point.X, point.Y)[0];
            double azimut = polar.Polar(centr, point.X, point.Y)[1];
            float  ps     = (float)(1 + (radius / 60));
            float  pg     = (float)(1 + (radius / 60));
            PointF pf1    = polar.Angel(centr, azimut, radius);
            PointF pf2    = polar.Angel(centr, azimut, radius + ps);
            PointF pf4    = polar.Angel(centr, azimut, radius + ps - pg * 2);
            float  pe     = (float)(10 + (radius / 20));
            float  pe1    = (float)(5 + (radius / 20));
            double D1     = (Coma.radius[a1] / km) / 0.4;
            double A1     = Coma.azimut[a1] / 0.0878;
            double AH     = A1 - 11;
            double AK     = A1 + 11;
            double AHO    = A1 - 22;
            double AKO    = A1 + 22;
            double DO     = D1 + 1;

            if (AH < 0)
            {
                AH += 4096;
            }
            if (AHO < 0)
            {
                AHO += 4096;
            }
            if (a < azimut + 3 && a > azimut - 3)
            {
                Coma.pf1[a1] = pf1; Coma.pf2[a1] = pf2; Coma.pf4[a1] = pf4; Coma.azimut[a1] = azimut; Coma.radius[a1] = radius;
                if (his == true)
                {
                    hi = "0";
                }
                else
                {
                    hi = "1";
                }

                if (his == true)
                {
                    Coma.text[nam] = AH.ToString("0") + "," + AK.ToString("0") + "," + D1.ToString("0") + "," + hi + "," + AHO.ToString("0") + "," + AKO.ToString("0") + "," + DO.ToString("0") + ";" + "\r\n";
                }
                else
                {
                    Coma.text[nam] = AH.ToString("0") + "," + AK.ToString("0") + "," + D1.ToString("0") + "," + hi + ";" + "\r\n";
                }
            }
            if (sd == true)
            {
                Coma.pf1[a1] = pf1; Coma.pf2[a1] = pf2; Coma.pf4[a1] = pf4; Coma.azimut[a1] = azimut; Coma.radius[a1] = radius;
            }

            if (Coma.radius[a1] / km < 150 && Coma.radius[a1] / km > 15)
            {
                e.DrawLine(new Pen(Color.FromArgb(255, 170, 130, 0), pe), Coma.pf1[a1].X, Coma.pf1[a1].Y, Coma.pf2[a1].X, Coma.pf2[a1].Y);
                if (his == true)
                {
                    e.DrawLine(new Pen(Color.FromArgb(255, 170, 130, 0), pe1), Coma.pf1[a1].X, Coma.pf1[a1].Y, Coma.pf4[a1].X, Coma.pf4[a1].Y);
                }
            }

            if (a == 0)
            {
                foreach (string bn in Coma.text)
                {
                    Coma.file[Coma.cs] += bn;
                }

                Coma.cs++;
            }


            e.DrawString(nam + " ) " + "Азимут " + Coma.azimut[a1].ToString("0.000") + "  " + "Дальность " + (Coma.radius[a1] / km).ToString("0.000"), new Font("Arial", 8), Brushes.White, 10, 40 + (nam * 15));
            if (mar == true)
            {
                e.DrawString(nam.ToString(), new Font("Arial", 8), Brushes.White, Coma.pf1[a1].X - 10, Coma.pf1[a1].Y - 15);
            }

            if (mar1 == true)
            {
                e.DrawString("Азимут " + Coma.azimut[a1].ToString("0") + "\r\n" + "Дальность " + (Coma.radius[a1] / km).ToString("0"), new Font("Arial", 8), Brushes.White, Coma.pf1[a1].X, Coma.pf1[a1].Y);
            }
        }
Exemplo n.º 11
0
        public void His(Graphics e, int width, int height, int scale, PointF point, bool mar, bool mar1, bool his, int nam, float a, int a1, bool sd, double vys)
        {
            double D1  = 0;
            double A1  = 0;
            double AH  = 0;
            double AK  = 0;
            double DO  = 0;
            double AHO = 0;
            double AKO = 0;
            double VYS = 0;

            PolarCoordinate polar  = new PolarCoordinate();
            PointF          center = new PointF(width / 2, height / 2);

            float km = (((float)height) / (scale * 10)) / 2;

            double radius = polar.Polar(center, point.X, point.Y)[0];
            double azimut = polar.Polar(center, point.X, point.Y)[1];
            float  ps     = (float)(1 + (radius / 60));
            float  pg     = (float)(1 + (radius / 60));
            PointF pf1    = polar.Angel(center, azimut, radius);
            PointF pf2    = polar.Angel(center, azimut, radius + ps);
            PointF pf4    = polar.Angel(center, azimut, radius + ps - pg * 2);
            float  pe     = (float)(10 + (radius / 20));
            float  pe1    = (float)(5 + (radius / 20));

            try
            {
                D1  = Coma.radius[a1] / km / 0.4;
                A1  = Coma.azimut[a1] / 0.0878;
                AH  = A1 - 11;
                AK  = A1 + 11;
                AHO = A1 - 22;
                AKO = A1 + 22;
                DO  = D1 + 1;
                VYS = vys;
                if (AH < 0)
                {
                    AH += 4096;
                }
                if (AHO < 0)
                {
                    AHO += 4096;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Ошибка приложения!\nMessage: " +
                    ex.Message + '\n' +
                    "StackTrace: " + ex.StackTrace +
                    "\nПриложение будет остановлено",
                    "Radar ERROR"
                    );
            }

            if (a < azimut + 3 && a > azimut - 3)
            {
                try
                {
                    Coma.pf1[a1]    = pf1;
                    Coma.pf2[a1]    = pf2;
                    Coma.pf4[a1]    = pf4;
                    Coma.azimut[a1] = azimut;
                    Coma.radius[a1] = radius;
                    Coma.vys[a1]    = vys;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Message: " + ex.Message + '\n' + "StackTrace: " + ex.StackTrace, "Radar ERROR");
                }

                if (his == true)
                {
                    hi = "0";
                }
                else
                {
                    hi = "1";
                }

                if (his == true)
                {
                    Coma.text[nam] =
                        AH.ToString("0") + "," +
                        AK.ToString("0") + "," +
                        D1.ToString("0") + "," +
                        hi + ","
                        + AHO.ToString("0") + "," +
                        AKO.ToString("0") + "," +
                        DO.ToString("0") + "," +
                        VYS.ToString("0") + ";" + "\r\n";
                }
                else
                {
                    Coma.text[nam] =
                        AH.ToString("0") + "," +
                        AK.ToString("0") + "," +
                        D1.ToString("0") + "," +
                        hi + "," +
                        VYS.ToString("0") + ";" + "\r\n";//вывод данных
                }
            }

            if (sd == true)
            {
                Coma.pf1[a1]    = pf1;
                Coma.pf2[a1]    = pf2;
                Coma.pf4[a1]    = pf4;
                Coma.azimut[a1] = azimut;
                Coma.radius[a1] = radius;
                Coma.vys[a1]    = vys;
            }

            if (Coma.radius[a1] / km < 150 && Coma.radius[a1] / km > 15)
            {
                e.DrawLine(
                    new Pen(Color.FromArgb(255, 170, 130, 0), pe),
                    Coma.pf1[a1].X,
                    Coma.pf1[a1].Y,
                    Coma.pf2[a1].X,
                    Coma.pf2[a1].Y);
                if (his == true)
                {
                    e.DrawLine(
                        new Pen(Color.FromArgb(255, 170, 130, 0), pe1),
                        Coma.pf1[a1].X,
                        Coma.pf1[a1].Y,
                        Coma.pf4[a1].X,
                        Coma.pf4[a1].Y);
                }
            }
            if (a == 0)
            {
                foreach (string bn in Coma.text)
                {
                    Coma.file[Coma.cs] += bn;
                }
                Coma.cs++;
            }
            const string Format       = "0,0";
            string       azimutStr1   = Coma.azimut[a1].ToString(Format);
            string       distanceStr1 = (Coma.radius[a1] / km).ToString(Format);
            string       altitudeStr1 = Coma.vys[a1].ToString();

            e.DrawString(
                nam + " ) " +
                " Азимут: " + azimutStr1 + " " +
                "\t Дальность: " + distanceStr1 + " " +
                "\tBысота: " + altitudeStr1,
                new Font("Consolas", 8), Brushes.White, 10, 40 + (nam * 15));;     //основное поле

            if (mar == true)
            {
                e.DrawString(nam.ToString(), new Font("Consolas", 8), Brushes.White, Coma.pf1[a1].X - 10, Coma.pf1[a1].Y - 15);
            }

            if (mar1 == true)
            {
                string azimutStr   = Coma.azimut[a1].ToString(Format);
                string distanceStr = (Coma.radius[a1] / km).ToString(Format);
                e.DrawString(
                    "Азимут " + azimutStr + "\r\n" +
                    "Дальность " + distanceStr,
                    new Font("Consolas", 8),
                    Brushes.White, Coma.pf1[a1].X, Coma.pf1[a1].Y);
            }
        }