Exemple #1
0
        private void DrawPoint(Point point)
        {
            var brush  = GetBrush(point);
            var symbol = GetSymbol(point);

            graphics.DrawString(symbol.Char.ToString(), symbol.Font, brush, MapToScreen(point.X, point.Y), symbol.Format);
        }
Exemple #2
0
        private static void SetSymbol(string[] line, ref Point point)
        {
            var fontFamily = "MapInfo Symbols";
            var symbolByte = Convert.ToInt32(line[0].Substring(1, line[0].Length - 1)) + 1;
            var color      = IntToColor(Convert.ToInt32(line[1]));
            var symbolSize = Convert.ToInt32(line[2].Substring(0, line[2].Length - 1));
            var style      = new Style
            {
                Brush  = new SolidBrush(color),
                Symbol = new Symbol
                {
                    Font = new Font(fontFamily, symbolSize),
                    Char = (char)symbolByte
                }
            };

            point.Style = style;
        }
Exemple #3
0
        private void AddPoint(StreamReader sr, ref string tmp, ref string[] line)
        {
            // Координаты точки
            var x     = double.Parse(line[1], CultureInfo.InvariantCulture);
            var y     = double.Parse(line[2], CultureInfo.InvariantCulture);
            var point = new Point(x, y);

            // Чтение символа
            if (line.Length == 3)
            {
                if (!sr.EndOfStream)
                {
                    tmp = sr.ReadLine()?.Trim();
                }

                line = tmp?.Split(' ');
                if (line?[0] == "Symbol")
                {
                    tmp  = tmp?.Replace(" ", string.Empty).Replace(line[0], string.Empty);
                    line = tmp?.Split(',');
                    SetSymbol(line, ref point);
                    if (!sr.EndOfStream)
                    {
                        tmp = sr.ReadLine()?.Trim();
                    }
                }
            }
            else if (line[3] == "Symbol")
            {
                tmp  = tmp.Replace(" ", string.Empty).Replace(line[0] + line[1] + line[2] + line[3], string.Empty);
                line = tmp.Split(',');
                SetSymbol(line, ref point);
                if (!sr.EndOfStream)
                {
                    tmp = sr.ReadLine()?.Trim();
                }
            }

            Data.Add(point);
        }
Exemple #4
0
        public static IEnumerable <Layer> CreateTestLayers()
        {
            var lineStyle = new Style
            {
                Pen = new Pen(Color.Red, 2)
                {
                    DashStyle = DashStyle.Dash
                }
            };

            var polygonStyle = new Style
            {
                Brush = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Red, Color.Green)
            };

            var point = new Point(0, 500);

            var line1 = new Line(0, -50, 0, 50)
            {
                Style = lineStyle
            };

            var line2 = new Line(-50, 0, 50, 0)
            {
                Style = lineStyle
            };

            var polyline = new Polyline();

            polyline.AddNode(0, 0);
            polyline.AddNode(200, 100);
            polyline.AddNode(200, -100);

            var polygon1 = new Polygon {
                Style = polygonStyle
            };

            polygon1.AddNode(0, 0);
            polygon1.AddNode(-200, 100);
            polygon1.AddNode(-200, -100);

            var polygon2 = new Polygon {
                Style = polygonStyle
            };

            polygon2.AddNode(0, 0.111);
            polygon2.AddNode(0.55, 0.99);
            polygon2.AddNode(0.8, 0.7);

            var polygons = new List <Polygon>(10000);

            for (int x = 0, b = -349; x < 100; x++, b += 7)
            {
                for (int j = 0, a = -349; j < 100; j++, a += 7)
                {
                    Polygon polygon = new Polygon();
                    polygon.AddNode(a, b);
                    polygon.AddNode(a + 5, b);
                    polygon.AddNode(a + 5, b + 5);
                    polygon.AddNode(a, b + 5);
                    polygons.Add(polygon);
                }
            }

            var layer1 = new Layer("Test1");

            layer1.Add(polygon1);
            layer1.Add(polygon2);
            polygons.ForEach(polygon => layer1.Add(polygon));

            var layer2 = new Layer("Test2");

            layer2.Add(line1);
            layer2.Add(line2);
            layer2.Add(polyline);

            var layer3 = new Layer("Test3");

            layer3.Add(point);

            return(new Layer[] { layer1, layer2, layer3 });
        }