private void ClearTempDrawing() { tempPolygonsOverlay.Polygons.Clear(); tempPolygonsOverlay.Markers.Clear(); tempPolygonsOverlay.Routes.Clear(); if (drawingPolygon != null) { drawingPolygon.Dispose(); drawingPolygon = null; } drawingPoints.Clear(); if (drawingCircle != null) { drawingCircle.Dispose(); drawingCircle = null; } if (drawingRoute != null) { drawingRoute.Dispose(); drawingRoute = null; } if (drawingLine != null) { drawingLine.Dispose(); drawingLine = null; } drawingMode = DrawingMode.None; }
public DrawEventArgs(DrawingMode drawingMode, PointLatLng centerPoint, PointLatLng edgePoint, Pen stroke, Brush fill) { DrawingMode = drawingMode; Circle = new GMapDrawCircle(centerPoint, edgePoint, stroke, fill); }
private void MapControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { isLeftButtonDown = true; if (drawingMode == DrawingMode.Polygon) { drawingPoints.Add(MapControl.FromLocalToLatLng(e.X, e.Y)); if (drawingPolygon == null) { drawingPolygon = new GMapPolygon(drawingPoints, "Polygon"); drawingPolygon.Fill = Fill; drawingPolygon.Stroke = Stroke; drawingPolygon.IsHitTestVisible = false; tempPolygonsOverlay.Polygons.Add(drawingPolygon); MapControl.Refresh(); } else { drawingPolygon.Points.Clear(); drawingPolygon.Points.AddRange(drawingPoints); MapControl.UpdatePolygonLocalPosition(drawingPolygon); MapControl.Refresh(); } } if (drawingMode == DrawingMode.Route) { drawingPoints.Add(MapControl.FromLocalToLatLng(e.X, e.Y)); if (drawingRoute == null) { drawingRoute = new GMapDrawRoute(drawingPoints, "Route"); if (Stroke != null) { drawingRoute.Stroke = Stroke; } drawingRoute.IsHitTestVisible = false; tempPolygonsOverlay.Routes.Add(drawingRoute); MapControl.Refresh(); } else { drawingRoute.Points.Clear(); drawingRoute.Points.AddRange(drawingPoints); MapControl.UpdateRouteLocalPosition(drawingRoute); MapControl.Refresh(); } } if (drawingMode == DrawingMode.Line) { drawingPoints.Add(MapControl.FromLocalToLatLng(e.X, e.Y)); if (drawingLine == null) { drawingLine = new GMapDrawLine(drawingPoints, "Line"); if (Stroke != null) { drawingLine.Stroke = Stroke; } drawingLine.IsHitTestVisible = false; tempPolygonsOverlay.Routes.Add(drawingLine); MapControl.Refresh(); } else { drawingLine.Points.Clear(); drawingLine.Points.AddRange(drawingPoints); MapControl.UpdateRouteLocalPosition(drawingLine); MapControl.Refresh(); } } if (drawingMode == DrawingMode.Rectangle) { drawingPoints.Add(MapControl.FromLocalToLatLng(e.X, e.Y)); if (drawingPolygon == null) { drawingPolygon = new GMapPolygon(drawingPoints, "Rectangle"); drawingPolygon.Fill = Fill; drawingPolygon.Stroke = Stroke; drawingPolygon.IsHitTestVisible = false; tempPolygonsOverlay.Polygons.Add(drawingPolygon); } } if (drawingMode == DrawingMode.Circle) { PointLatLng center = MapControl.FromLocalToLatLng(e.X, e.Y); drawingPoints.Add(center); if (drawingCircle == null) { drawingCircle = new GMapDrawCircle(center, center, Stroke, Fill); tempPolygonsOverlay.Markers.Add(drawingCircle); } } } }