public override void MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Panel panel = (Panel)sender; this.FromPoint = new Point(e.X, e.Y); // draw point MG_BaseDisplay.FillPoint(panel.CreateGraphics(), brush, this.FromPoint, MG_Constant.PointRadius); // screen to map this.MapPoint = MG_BaseRender.ToPoint(this.FromPoint, this.MapView); //1 create a feature // 1.1 set geometry this.Feature.SetGeometry(this.MapPoint); // 1.2 set field value for (int i = 0; i < this.Feature.GetFieldSet().Count(); i++) { this.Feature.SetValue(i, null); } //2 create a new feature MG_Feature newFeature = new MG_Feature(this.Feature); //3 add new feature to layer this.Layer.AddFeature(newFeature); //4 clear data to store the next point this.MapPoint.Clear(); } }
public override void MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { this.IsMouseDown = false; // screen point to map point MG_LineString MapLineString = new MG_LineString(); for (int i = 0; i < this.LineString.Count(); i++) { MG_Point screenPoint = this.LineString.GetAt(i); Point screen = new Point((int)screenPoint.x, (int)screenPoint.y); MG_Point mapPoint = MG_BaseRender.ToPoint(screen, this.MapView); MapLineString.Add(mapPoint); } MG_LineString MapLineStringOther = new MG_LineString(); for (int i = 0; i < this.LineStringOther.Count(); i++) { MG_Point screenPoint = this.LineStringOther.GetAt(i); Point screen = new Point((int)screenPoint.x, (int)screenPoint.y); MG_Point mapPoint = MG_BaseRender.ToPoint(screen, this.MapView); MapLineStringOther.Add(mapPoint); } //1 create a feature // 1.1 set geometry this.Feature.SetGeometry(MapLineString); // 1.2 set field value for (int i = 0; i < this.Feature.GetFieldSet().Count(); i++) { this.Feature.SetValue(i, null); } //2 create a new feature MG_Feature newFeature1 = new MG_Feature(this.Feature); //3 add new feature to layer this.Layer.AddFeature(newFeature1); //4 clear data to store the next linestring this.LineString.Clear(); //1 create a feature // 1.1 set geometry this.Feature.SetGeometry(MapLineStringOther); // 1.2 set field value for (int i = 0; i < this.Feature.GetFieldSet().Count(); i++) { this.Feature.SetValue(i, null); } //2 create a new feature MG_Feature newFeature2 = new MG_Feature(this.Feature); //3 add new feature to layer this.Layer.AddFeature(newFeature2); //4 clear data to store the next linestring this.LineStringOther.Clear(); } }
public override void MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.IsMouseDown = true; Panel panel = (Panel)sender; if (this.Step == 0) { this.Step = 1; this.FromPoint = new Point(e.X, e.Y); // store map point MG_Point mapPoint = MG_BaseRender.ToPoint(this.FromPoint, this.MapView); this.LineString.Add(mapPoint); } else if (this.Step == 1) { this.ToPoint = new Point(e.X, e.Y); // repeat same pattern this.FromPoint = this.ToPoint; // store map point MG_Point mapPoint = MG_BaseRender.ToPoint(this.ToPoint, this.MapView); this.LineString.Add(mapPoint); } } }
private static MG_LineString AsLineString(Geometry g) { MG_LineString lineString = new MG_LineString(); int pointCount = g.GetPointCount(); for (int i = 0; i < pointCount; i++) { MG_Point point = new MG_Point(g.GetX(i), g.GetY(i)); lineString.Add(point); } return(lineString); }
private static MG_MultiPoint AsMultiPoint(Geometry g) { MG_MultiPoint multiPoint = new MG_MultiPoint(); int geometryCount = g.GetGeometryCount(); for (int i = 0; i < geometryCount; i++) { MG_Point point = AsPoint(g.GetGeometryRef(i)); multiPoint.Add(point); } return(multiPoint); }
public override void MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { this.IsMouseDown = false; Panel panel = (Panel)sender; if (this.Step == 0) { } else if (this.Step == 1) { } else if (this.Step == 2) { // add last point this.Point3 = new Point(e.X, e.Y); MG_Point mapPoint3 = MG_BaseRender.ToPoint(Point3, this.MapView); this.LineString.Add(mapPoint3); // add first point again(same to first point) MG_Point firstPoint = MG_BaseRender.ToPoint(this.FromPoint, this.MapView); this.LineString.Add(firstPoint); // add to polygon this.Polygon.Add(this.LineString); //1 create a feature // 1.1 set geometry this.Feature.SetGeometry(this.Polygon); // 1.2 set field value for (int i = 0; i < this.Feature.GetFieldSet().Count(); i++) { this.Feature.SetValue(i, null); } //2 create a new feature MG_Feature newFeature = new MG_Feature(this.Feature); //3 add new feature to layer this.Layer.AddFeature(newFeature); //4 clear data to store the next linestring this.Polygon.Clear(); this.LineString.Clear(); // 5 reset control params this.Step = 0; this.FromPoint = Point.Empty; this.ToPoint = Point.Empty; this.Point3 = Point.Empty; } } }
public static MG_Point ToPoint(Point point, MG_MapView mapview) { MG_Point mp; if (mapview != null) { mp = mapview.Screent2Map(point); } else { mp = new MG_Point(point.X, point.Y); } return(mp); }
private static Point AsPoint(MG_Point point, MG_MapView mapview) { Point sp; if (mapview != null) { sp = mapview.Map2Screen(point); } else { sp = new Point((int)point.x, (int)point.y); } return(sp); }
public static void RenderLineString(Graphics g, Pen pen, MG_MapView mapview, MG_LineString lineString) { int count = lineString.Count(); if (count < 2) { return; } Point[] points = new Point[count]; for (int i = 0; i < count; i++) { MG_Point mp = lineString.GetAt(i); points[i] = AsPoint(mp, mapview); } DrawLineString(g, pen, points); }
public override void MouseUp(object sender, MouseEventArgs e) { if (this.IsMouseDown) { this.IsMouseDown = false; Panel panel = (Panel)sender; this.ToPoint = new Point(e.X, e.Y); // pan map(screen point --->map point) MG_Point mpFrom = MG_BaseRender.ToPoint(this.FromPoint, this.MapView); MG_Point mpTo = MG_BaseRender.ToPoint(this.ToPoint, this.MapView); double xoff = mpFrom.x - mpTo.x; double yoff = mpFrom.y - mpTo.y; this.MapView.XYoff(xoff, yoff); this.CurrentMap.AddZoomToHistory(this.MapView); panel.Refresh(); } }
public static void RenderPolygon(Graphics g, Pen pen, MG_MapView mapview, MG_Polygon polygon) { int countLineString = polygon.Count(); for (int i = 0; i < countLineString; i++) { MG_LineString lineString = polygon.GetAt(i); int countPoint = lineString.Count(); if (countPoint < 3) { return; } Point[] points = new Point[countPoint]; for (int j = 0; j < countPoint; j++) { MG_Point mp = lineString.GetAt(j); points[j] = AsPoint(mp, mapview); } //FillPolygon(g, brush, points); //Pen pen = new Pen(Color.Red, 1); DrawPolygon(g, pen, points); } }
public MG_ToolDrawPoint(MG_Layer layer, MG_MapView mapview) : base(MG_ToolType.Tool_DrawPoint, layer, mapview) { this.MapPoint = new MG_Point(); }
public static void RenderPoint(Graphics g, Brush brush, int radius, MG_MapView mapview, MG_Point point) { //int realValue = GetRealValue(radius, mapview); //if (realValue < MG_Constant.PointRadius) //{ // realValue = MG_Constant.PointRadius; //} Point sp = AsPoint(point, mapview); FillPoint(g, brush, sp, radius); }