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(); } }
private static MG_Polygon AsPolygon(Geometry g) { MG_Polygon polygon = new MG_Polygon(); int geometryCount = g.GetGeometryCount(); for (int i = 0; i < geometryCount; i++) { MG_LineString lineString = AsLineString(g.GetGeometryRef(i)); polygon.Add(lineString); } return(polygon); }
private static MG_MultiLineString AsMultiLineString(Geometry g) { MG_MultiLineString multiLineString = new MG_MultiLineString(); int geometryCount = g.GetGeometryCount(); for (int i = 0; i < geometryCount; i++) { MG_LineString lineString = AsLineString(g.GetGeometryRef(i)); multiLineString.Add(lineString); } return(multiLineString); }
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); }
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 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); } }
protected bool QuitEdit = false; //if quit edit linestring public MG_ToolDrawDoubleLineString(MG_Layer layer, MG_MapView mapview) : base(MG_ToolType.Tool_DrawDoubleLineString, layer, mapview) { this.LineString = new MG_LineString(); this.LineStringOther = new MG_LineString(); }
public MG_ToolDrawPolygon(MG_Layer layer, MG_MapView mapview) : base(MG_ToolType.Tool_DrawPolygon, layer, mapview) { this.LineString = new MG_LineString(); this.Polygon = new MG_Polygon(); }