private void MAP_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (isMouseDown) { switch (ActiveTool) { case MapToolType.select: break; case MapToolType.zoomin: double Dx2 = e.X - mouseDownPosition.X; double Dy2 = e.Y - mouseDownPosition.Y; if (Math.Abs(Dx2) > SHAKE || Math.Abs(Dy2) > SHAKE) { Delete(Cosmetic); Cosmetic.Objects.Remove(border); border = new PolyLine(); border.Style.Fatness = 1; border.Style.LColour = Color.Aqua; GeoPoint first = ScreenToMap(mouseDownPosition); GeoPoint second = ScreenToMap(e.Location); border.AddNode(first); border.AddNode(new GeoPoint(second.x, first.y)); border.AddNode(second); border.AddNode(new GeoPoint(first.x, second.y)); border.AddNode(first); Cosmetic.AddObject(border); Cosmetic.Name = "Рамка"; AddLayer(Cosmetic); Refresh(); } break; case MapToolType.zoomout: break; case MapToolType.pan: double Dx = (e.X - mouseDownPosition.X) / mapScale; double Dy = (e.Y - mouseDownPosition.Y) / mapScale; mapCenter.x -= Dx; mapCenter.y += Dy; this.Refresh(); mouseDownPosition = e.Location; break; default: break; } } } }
private void Form1_Load(object sender, EventArgs e) { Core.Point point = new Core.Point(0, 0); Core.Line line = new Core.Line(1, 2, 500, 300); line.Selected = true; Core.PolyLine polyLine = new Core.PolyLine(); polyLine.AddNode(0, 0); polyLine.AddNode(-500, 300); polyLine.AddNode(-300, -500); polyLine.AddNode(500, 0); // polyLine.RemoveNode(1); // Core.Polygon polygon = new Core.Polygon(); // polygon.AddNode(700, 0); // polygon.AddNode(0, 400); // polygon.AddNode(-100, 0); // polygon.AddNode(0, -300); Core.Polygon polygon1 = new Core.Polygon(); polygon1.AddNode(50, 50); polygon1.AddNode(150, 70); polygon1.AddNode(120, 10); polygon1.AddNode(72, 10); Core.Polygon polygon2 = new Core.Polygon(); polygon2.AddNode(70, 180); polygon2.AddNode(120, 240); polygon2.AddNode(190, 20); polygon2.AddNode(72, 40); Core.Polygon polygon3 = new Core.Polygon(); polygon3.AddNode(-100, -20); polygon3.AddNode(-50, -20); polygon3.AddNode(-50, -140); polygon3.AddNode(-100, -140); Core.Polygon polygon4 = new Core.Polygon(); polygon4.AddNode(-80, -10); polygon4.AddNode(-60, -10); polygon4.AddNode(-60, -70); polygon4.AddNode(-80, -70); SolidBrush ownBrush = new SolidBrush(Color.Aquamarine); Pen ownPen = new Pen(Color.Green); // polygon.OwnBrush = ownBrush; // polygon.OwnPen = ownPen; polygon1.OwnBrush = ownBrush; polygon1.OwnPen = ownPen; /*Core.Node node = polyLine.GetNode(0); * polyLine.Clear();*/ /* for (int i=0; i<100; i++) * { * polyLine.AddNode(i, -i); * } * //polyLine[0] = polyLine[2]; */ Core.VectorLayer layer = new VectorLayer(); layer.AddObject(point); layer.AddObject(line); layer.AddObject(polyLine); // layer.AddObject(polygon); layer.AddObject(polygon1); layer.AddObject(polygon2); layer.AddObject(polygon3); layer.AddObject(polygon4); int pointCount = 0, lineCount = 0, polyLineCount = 0, polygonCount = 0; foreach (MapObject obj in layer._objects) { switch (obj.Type) { case MapObjectType.Point: pointCount++; break; case MapObjectType.Line: lineCount++; break; case MapObjectType.PolyLine: polyLineCount++; break; case MapObjectType.Polygon: polygonCount++; break; } } MyMap.AddLayer(layer); MyMap.MapScale *= 2; }