Пример #1
0
        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;
        }
Пример #2
0
 public DrawEventArgs(DrawingMode drawingMode, List <PointLatLng> drawingPoints, Pen stroke, Brush fill)
 {
     DrawingMode = drawingMode;
     if (drawingMode == DrawingMode.Polygon)
     {
         Polygon = new GMapDrawPolygon(drawingPoints, drawingMode.ToString());
         if (fill != null)
         {
             Polygon.Fill = (Brush)fill.Clone();
         }
         if (stroke != null)
         {
             Polygon.Stroke = (Pen)stroke.Clone();
         }
         Polygon.IsHitTestVisible = true;
     }
     else if (drawingMode == DrawingMode.Rectangle)
     {
         Rectangle = new GMapDrawRectangle(drawingPoints, drawingMode.ToString());
         if (fill != null)
         {
             Rectangle.Fill = (Brush)fill.Clone();
         }
         if (stroke != null)
         {
             Rectangle.Stroke = (Pen)stroke.Clone();
         }
         Rectangle.IsHitTestVisible = true;
     }
     else if (drawingMode == DrawingMode.Route)
     {
         Route = new GMapDrawRoute(drawingPoints, drawingMode.ToString());
         if (stroke != null)
         {
             Route.Stroke = (Pen)stroke.Clone();
         }
         Route.IsHitTestVisible = true;
     }
     else if (drawingMode == DrawingMode.Line)
     {
         Line = new GMapDrawLine(drawingPoints, drawingMode.ToString());
         if (stroke != null)
         {
             Line.Stroke = (Pen)stroke.Clone();
         }
         Line.IsHitTestVisible = true;
     }
 }
Пример #3
0
        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);
                    }
                }
            }
        }