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 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); } } }
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 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 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(); } }