public Line() { BeginPoint = new GEOPoint(); EndPoint = new GEOPoint(); Type = MapObjectType.Line; Style = new LineStyle(); }
private void Map_MouseDown(object sender, MouseEventArgs e) { switch (mapToolType) { case MapToolType.panBtn: { isMouseDown = true; MouseDownPosition = e.Location; break; } case MapToolType.selectBtn: break; case MapToolType.zoominBtn: { isMouseDown = true; point1 = e.Location; Refresh(); break; } case MapToolType.zoomoutBtn: { GEOPoint zoomGeoPoint = ScreenToMap(e.Location); MapCenter.X = -zoomGeoPoint.X; MapCenter.Y = -zoomGeoPoint.Y; MapScale *= 0.8; Refresh(); break; } } }
private void Map_MouseUp(object sender, MouseEventArgs e) { switch (mapToolType) { case MapToolType.panBtn: { isMouseDown = false; break; } case MapToolType.selectBtn: break; case MapToolType.zoominBtn: { GEOPoint zoomGeoPoint = ScreenToMap(e.Location); MapCenter.X = -zoomGeoPoint.X; MapCenter.Y = -zoomGeoPoint.Y; MapScale *= 1.2; isMouseDown = false; Refresh(); //toDo photo break; } case MapToolType.zoomoutBtn: break; } }
private void Map_MouseUp(object sender, MouseEventArgs e) { switch (CurrentTool) { case Tool.Select: double Dx1 = Math.Abs(MouseDownPosition.X - e.X); double Dy1 = Math.Abs(MouseDownPosition.Y - e.Y); if (Dx1 < shake && Dy1 < shake) { GEOPoint searchCenter = ScreenToMap(e.Location); double xMin = searchCenter.X - shake / 2 / MapScale; double xMax = searchCenter.X + shake / 2 / MapScale; double yMin = searchCenter.Y - shake / 2 / MapScale; double yMax = searchCenter.Y + shake / 2 / MapScale; GEORect searchRect = new GEORect(xMin, xMax, yMin, yMax); MapObject result = FindObject(searchRect); } break; case Tool.Pan: IsMouseDown = false; Cursor = Cursors.Default; break; case Tool.ZoomIn: cosmeticLayer.Clear(); double Dx = Math.Abs(MouseDownPosition.X - e.X); double Dy = Math.Abs(MouseDownPosition.Y - e.Y); if (Dx > shake || Dy > shake) { GEOPoint newCenter = ScreenToMap(new System.Drawing.Point((e.X + MouseDownPosition.X) / 2, (e.Y + MouseDownPosition.Y) / 2)); MapCenter = newCenter; if (Width / Dx > Height / Dy) { MapScale *= Width / Dx; } else { MapScale *= Height / Dy; } } else { MapCenter = ScreenToMap(MouseDownPosition); MapScale *= 2; Cursor = Cursors.Cross; } IsMouseDown = false; Refresh(); break; case Tool.ZoomOut: IsMouseDown = false; MapCenter = ScreenToMap(MouseDownPosition); MapScale /= 2; Refresh(); break; } }
public GEOPoint ScreenToMap(System.Drawing.Point screenPoint) { var mapPoint = new GEOPoint(); mapPoint.X = (screenPoint.X - this.Width / 2) / MapScale - MapCenter.X; mapPoint.Y = -(screenPoint.Y - this.Height / 2) / MapScale - MapCenter.Y; return(mapPoint); }
public System.Drawing.Point MapToScreen(GEOPoint mapPoint) { var screenPoint = new System.Drawing.Point(); screenPoint.X = (int)((mapPoint.X + MapCenter.X) * MapScale + this.Width / 2 + 0.5); screenPoint.Y = (int)(-(mapPoint.Y + MapCenter.Y) * MapScale + this.Height / 2 + 0.5); return(screenPoint); }
public Map() { InitializeComponent(); MapScale = 1.0; MapCenter = new GEOPoint(); Layers = new List <Layer>(); mapToolType = MapToolType.panBtn; }
public PolyLine(List<GEOPoint> nodes) { int nodesCount = nodes.Count; Nodes = new List<GEOPoint>(nodesCount); foreach(var node in nodes) { var point = new GEOPoint(node.X, node.Y); Nodes.Add(point); } Type = MapObjectType.PolyLine; }
public Map() { InitializeComponent(); MapScale = 1.0; MapCenter = new GEOPoint(); Layers = new List <Layer>(); IsMouseDown = false; cosmeticLayer = new Layer(); AddLayer(cosmeticLayer); }
private void entireViewBtn_Click(object sender, EventArgs e) { var bounds = mapControl.GEOBounds; double Dx = Math.Abs(bounds.XMax - bounds.XMin); double Dy = Math.Abs(bounds.YMax - bounds.YMin); GEOPoint newCenter = new GEOPoint((bounds.XMin + bounds.XMax) / 2.0, (bounds.YMin + bounds.YMax) / 2.0); mapControl.MapCenter = newCenter; if (Width / Dx < Height / Dy) { mapControl.MapScale = Width / Dx - 0.02; } else { mapControl.MapScale = Height / Dy - 0.02; } mapControl.Refresh(); }
public void InsertNode(int index, GEOPoint point) { Nodes.Insert(index, point); }
public void AddNode(GEOPoint point) { Nodes.Add(point); }
public Point() { Position = new GEOPoint(); Type = MapObjectType.Point; Style = new PointStyle(); }