public override void OnMouseDown(int x, int y, System.Windows.Forms.MouseEventArgs e) { RgPoint P1 = mScreenDisplay.DisplayTransformation.ToUnit(new System.Drawing.PointF(x, y)); Carto.FetureLayer featurelyr = mMapCtrl.Map.CurrentLayer as Carto.FetureLayer; if (featurelyr != null && featurelyr.ShapeType == RgEnumShapeType.RgPoint) { featurelyr.AddFeature(P1); } mMapCtrl.Refresh(); }
public override void OnMouseDown(int x, int y, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { n++; if (n <= 1) { line = new LineString(); RgPoint pt = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y)); line.Vertices.Add(pt); lastPoint1Unit = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y)); lastPoint2 = new PointF(x, y); } else { RgPoint ptNext = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y)); line.Vertices.Add(ptNext); lastPoint1Unit = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y)); lastPoint2 = new PointF(x, y); mScreenDisplay.NewObject = line; mMapCtrl.Refresh(); } } else { Carto.FetureLayer featurelyr = mMapCtrl.Map.CurrentLayer as Carto.FetureLayer; if (featurelyr != null && featurelyr.ShapeType == RgEnumShapeType.RgLineString) { featurelyr.mGeometries.Add(line); } n = 0; mScreenDisplay.NewObject = null; mMapCtrl.Refresh(); } }
public override void OnMouseUp(int x, int y) { if (m_selection != null) { List <Feature> SelectFeatures = new List <Feature>(); screenSelRect = m_selection.ScreenRect(); RgPoint lowLeft = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(screenSelRect.Left, screenSelRect.Bottom)); RgPoint upRight = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(screenSelRect.Right, screenSelRect.Top)); BoundingBox box = new BoundingBox(lowLeft, upRight); //RectangleF selectionRect = m_selection.Selection(m_canvaswrapper); if (screenSelRect != Rectangle.Empty) { // is any selection rectangle. use it for selection for (int i = 0; i < mMap.Layers.Count; i++) { ILayer lyr = mMap.Layers[i]; if (lyr is FetureLayer) { Carto.FetureLayer featlyr = lyr as Carto.FetureLayer; SelectFeatures = featlyr.GetHitObjects(box, m_selection.AnyPoint()); if (SelectFeatures != null) { for (int j = 0; j < SelectFeatures.Count; j++) { SelectFeatures[j].IsSelected = true; } if (mMap.Selection == null) { mMap.Selection = new MapSelection(); } mMap.Selection.SelectedFeatures.AddRange(SelectFeatures); } } } } else { for (int i = 0; i < mMap.Layers.Count; i++) { ILayer lyr = mMap.Layers[i]; if (lyr is FetureLayer) { Carto.FetureLayer featlyr = lyr as Carto.FetureLayer; RgPoint mousepoint = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y)); SelectFeatures = featlyr.GetHitObjects(mousepoint, 0.1); if (SelectFeatures != null) { for (int j = 0; j < SelectFeatures.Count; j++) { SelectFeatures[j].IsSelected = true; } if (mMap.Selection == null) { mMap.Selection = new MapSelection(); } mMap.Selection.SelectedFeatures.AddRange(SelectFeatures); } } } } mMapCtrl.Refresh(); m_selection = null; } }
public override void OnMouseDown(int x, int y, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { n++; if (n == 1) { RGeos.Geometries.RgPoint pt = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y)); RGeos.Geometries.RgPoint P0 = new RGeos.Geometries.RgPoint(pt.X, pt.Y); RGeos.Geometries.RgPoint P1 = new RGeos.Geometries.RgPoint(pt.X, pt.Y); RGeos.Geometries.RgPoint P2 = new RGeos.Geometries.RgPoint(pt.X, pt.Y); vertices.Add(P0); vertices.Add(P1); vertices.Add(P2); line = new LinearRing(vertices); } else if (n == 2) { PointF p2 = new PointF(x, y); RGeos.Geometries.RgPoint pt1 = vertices[0]; RGeos.Geometries.RgPoint pt2 = mScreenDisplay.DisplayTransformation.ToUnit(p2); vertices[1] = pt2; mScreenDisplay.StartDrawing(mMapCtrl.CreateGraphics(), 1); mScreenDisplayDraw.DrawLine(pt1, pt2, Pens.Blue); mScreenDisplay.FinishDrawing(); //n = 0; } else if (n == 3) { PointF p1 = new PointF(x, y); RGeos.Geometries.RgPoint pt = mScreenDisplay.DisplayTransformation.ToUnit(p1); vertices[2] = pt; polygon.ExteriorRing = line; if (line != null) { SolidBrush brush = new SolidBrush(Color.Blue); Pen pen = new Pen(brush); mScreenDisplay.NewObject = polygon; mMapCtrl.Refresh(); } } else { PointF p1 = new PointF(x, y); RGeos.Geometries.RgPoint pt = mScreenDisplay.DisplayTransformation.ToUnit(p1); RGeos.Geometries.RgPoint P4 = pt; vertices.Add(P4); SolidBrush brush = new SolidBrush(Color.Blue); Pen pen = new Pen(brush); mScreenDisplay.NewObject = polygon; mMapCtrl.Refresh(); } } else if (e.Button == MouseButtons.Right) { Carto.FetureLayer featurelyr = mMapCtrl.Map.CurrentLayer as Carto.FetureLayer; if (featurelyr != null && featurelyr.ShapeType == RgEnumShapeType.RgPolygon) { featurelyr.AddFeature(polygon); } vertices = new List <RGeos.Geometries.RgPoint>(); polygon = new Polygon(); tempPolygon = new Polygon(); mScreenDisplay.NewObject = null; n = 0; mMapCtrl.Refresh(); } }