Пример #1
0
        private void startButton_Click(object sender, EventArgs e)
        {
            List <string> file = new List <string>();
            double        x1   = double.Parse(f1X.Text, CultureInfo.InvariantCulture);
            double        y1   = double.Parse(f1Y.Text, CultureInfo.InvariantCulture);
            double        x2   = double.Parse(f2X.Text, CultureInfo.InvariantCulture);
            double        y2   = double.Parse(f2Y.Text, CultureInfo.InvariantCulture);
            double        x3   = double.Parse(f3X.Text, CultureInfo.InvariantCulture);
            double        y3   = double.Parse(f3Y.Text, CultureInfo.InvariantCulture);

            file.Add(x1.ToString("0.00000000", System.Globalization.CultureInfo.InvariantCulture) + "," + y1.ToString("0.00000000", System.Globalization.CultureInfo.InvariantCulture) + "," + x2.ToString("0.00000000", System.Globalization.CultureInfo.InvariantCulture) + "," + y2.ToString("0.00000000", System.Globalization.CultureInfo.InvariantCulture) + "," + x3.ToString("0.00000000", System.Globalization.CultureInfo.InvariantCulture) + "," + y3.ToString("0.00000000", System.Globalization.CultureInfo.InvariantCulture));
            _fileWork.WriteFile(file.FirstOrDefault(), false, true);
            foreach (var point in _сalculation.coordsim)
            {
                float rasst1 = (float)(Math.Sqrt(Math.Pow(point.X - x1, 2) + Math.Pow(point.Y - y1, 2)) / 1000000);
                float rasst2 = (float)(Math.Sqrt(Math.Pow(point.X - x2, 2) + Math.Pow(point.Y - y2, 2)) / 1000000);
                float rasst3 = (float)(Math.Sqrt(Math.Pow(point.X - x3, 2) + Math.Pow(point.Y - y3, 2)) / 1000000);
                _fileWork.WriteFile((rasst1.ToString("0.00000000", System.Globalization.CultureInfo.InvariantCulture) + "," + rasst2.ToString("0.00000000", System.Globalization.CultureInfo.InvariantCulture) + "," + rasst3.ToString("0.00000000", System.Globalization.CultureInfo.InvariantCulture)), true, true);
            }
        }
Пример #2
0
        public Bitmap Main()
        {
            int i           = 0;
            var text        = _fileWork.ReadFile();
            var firstString = text.FirstOrDefault().Split(",");
            var d1          = new Distance
            {
                X = double.Parse(firstString[0], CultureInfo.InvariantCulture),
                Y = double.Parse(firstString[1], CultureInfo.InvariantCulture)
            };
            var d2 = new Distance
            {
                X = double.Parse(firstString[2], CultureInfo.InvariantCulture),
                Y = double.Parse(firstString[3], CultureInfo.InvariantCulture)
            };
            var d3 = new Distance
            {
                X = double.Parse(firstString[4], CultureInfo.InvariantCulture),
                Y = double.Parse(firstString[5], CultureInfo.InvariantCulture)
            };

            text.RemoveAt(0);
            bmp  = new Bitmap(700, 500);
            bmp2 = new Bitmap(700, 500);
            bmp3 = new Bitmap(700, 500);
            Graphics graph = Graphics.FromImage(bmp);
            Pen      pen   = new Pen(Color.Black);
            Pen      pen2  = new Pen(Color.Blue);

            pen2.Width = (float)2;
            graph.TranslateTransform(700 / 2, 500 / 2);
            PointF bpoint = new PointF();

            foreach (var signals in text)
            {
                var signalArr = signals.Split(",");
                d1.R = double.Parse(signalArr[0], CultureInfo.InvariantCulture);
                d2.R = double.Parse(signalArr[1], CultureInfo.InvariantCulture);
                d3.R = double.Parse(signalArr[2], CultureInfo.InvariantCulture);
                var point = Draw(d1, d2, d3, graph, pen);
                if (i == 0)
                {
                    string pointT = point.X.ToString() + " " + point.Y.ToString();
                    _fileWork.WriteFile(pointT, false, false);
                }
                else
                {
                    string pointT = point.X.ToString() + " " + point.Y.ToString();
                    _fileWork.WriteFile(pointT, true, false);
                }
                if (i != 0 && i != text.Count())
                {
                    graph.DrawLine(pen2, point, bpoint);
                    bpoint = point;
                    i++;
                }
                else if (i == 0)
                {
                    bpoint = point;
                    i++;
                }
            }
            return(bmp);
        }