private void CoordinateDisplay(object sender, GeoMouseArgs e) { string locStr = "X:" + e.GeographicLocation.X.ToString("F6"); locStr += " Y:" + e.GeographicLocation.Y.ToString("F6"); CoordinateTxt.Caption = locStr; }
protected override void OnMouseUp(GeoMouseArgs e) { if (e.Button != MouseButtons.Left) { return; } Rectangle rtol = new Rectangle(e.X - 8, e.Y - 8, 16, 16); Rectangle rstr = new Rectangle(e.X - 1, e.Y - 1, 2, 2); Extent tolerant = e.Map.PixelToProj(rtol); Extent strict = e.Map.PixelToProj(rstr); var _chart = _vhf.ShellService.WinChart; var data_service = _vhf.ProjectController.ActiveDataService; if (Grid != null && _chart != null && data_service.Source != null) { var selected = Grid.Select(strict, out tolerant); if (selected.Count > 0) { var fea = selected[0]; var hru = int.Parse(fea.DataRow["HRU_ID"].ToString()); int ntime = data_service.Source.Size[1]; float[] yy = new float[ntime]; for (int i = 0; i < ntime; i++) { yy[i] = data_service.Source[data_service.Source.SelectedVariableIndex, i, hru - 1]; } _chart.Plot <float>(data_service.Source.DateTimes, yy, "HRU_" + hru.ToString(), SeriesChartType.FastLine); } } }
/// <summary> /// This method occurs as the mouse moves. /// </summary> /// <param name="e">The GeoMouseArcs class describes the mouse condition along with geographic coordinates.</param> protected override void OnMouseMove(GeoMouseArgs e) { if (_standBy) { return; } // End snapping changes if (_coordinates != null && _coordinates.Count > 0) { List <Point> points = _coordinates.Select(coord => Map.ProjToPixel(coord)).ToList(); Rectangle oldRect = SymbologyGlobal.GetRectangle(_mousePosition, points[points.Count - 1]); Rectangle newRect = SymbologyGlobal.GetRectangle(e.Location, points[points.Count - 1]); Rectangle invalid = Rectangle.Union(newRect, oldRect); invalid.Inflate(20, 20); Map.Invalidate(invalid); } // End snapping changes base.OnMouseMove(e); _coordinateDialog.X = e.GeographicLocation.X; _coordinateDialog.Y = e.GeographicLocation.Y; _mousePosition = SnapInfo?.Coordinate != null?Map.ProjToPixel(SnapInfo.Coordinate) : e.Location; }
protected override void OnMouseDown(GeoMouseArgs e) { if (e.Button == MouseButtons.Left) { _isEnabled = false; _currentPoint = e.Location; int x = _currentPoint.X; int y = _currentPoint.Y; System.Drawing.Point point = new System.Drawing.Point(x, y); _points = point; _coordinatePoints = this._map.PixelToProj(new System.Drawing.Point(_points.X, _points.Y)); IMapPointLayer pointLayer = GetPointLayer(); _point = new NetTopologySuite.Geometries.Point(_coordinatePoints); pointLayer.DataSet.AddFeature(_point as IGeometry); _map.Refresh(); _isEnabled = true; } else if (e.Button == MouseButtons.Right) { this.Enabled = false; string bufferType = "PointBuffer"; Buffer pointBuffer = new Buffer(bufferType); pointBuffer.ShowDialog(); _map.FunctionMode = FunctionMode.Pan; } base.OnMouseDown(e); }
/// <inheritdoc /> protected override void OnMouseUp(GeoMouseArgs e) { if (e.Button == MouseButtons.Left && _dragging) { _dragging = false; Map.IsBusy = false; _featureSet.InvalidateVertices(); if (_featureSet.FeatureType == FeatureType.Point || _featureSet.FeatureType == FeatureType.MultiPoint) { if (_activeFeature == null) { return; } if (_layer.GetCategory(_activeFeature) != _selectedCategory) { _layer.SetCategory(_activeFeature, _selectedCategory); _layer.SetVisible(_activeFeature, true); } } else { if (_selectedFeature == null) { return; } if (_layer.GetCategory(_selectedFeature) != _selectedCategory) { _layer.SetCategory(_selectedFeature, _selectedCategory); } } } Map.MapFrame.Initialize(); }
/// <summary> /// Handles the Mouse-Up situation. /// </summary> /// <param name="e">The GeoMouseArcs class describes the mouse condition along with geographic coordinates.</param> protected override void OnMouseUp(GeoMouseArgs e) { if (_standBy) { return; } if (_featureSet == null || _featureSet.IsDisposed) { return; } if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right) { // Add the current point to the featureset if (_featureSet.FeatureType == FeatureType.Point) { // Begin snapping changes Coordinate snappedCoord = _coordinateDialog.Coordinate; ComputeSnappedLocation(e, ref snappedCoord); // End snapping changes Topology.Point pt = new Topology.Point(snappedCoord); // Snapping changes Feature f = new Feature(pt); _featureSet.Features.Add(f); _featureSet.ShapeIndices = null; // Reset shape indices _featureSet.UpdateExtent(); _layer.AssignFastDrawnStates(); _featureSet.InvalidateVertices(); return; } if (e.Button == MouseButtons.Right) { _context.Show((Control)Map, e.Location); } else { if (_coordinates == null) { _coordinates = new List <Coordinate>(); } // Begin snapping changes Coordinate snappedCoord = e.GeographicLocation; ComputeSnappedLocation(e, ref snappedCoord); // End snapping changes _coordinates.Add(snappedCoord); // Snapping changes if (_coordinates.Count > 1) { Point p1 = Map.ProjToPixel(_coordinates[_coordinates.Count - 1]); Point p2 = Map.ProjToPixel(_coordinates[_coordinates.Count - 2]); Rectangle invalid = SymbologyGlobal.GetRectangle(p1, p2); invalid.Inflate(20, 20); Map.Invalidate(invalid); } } } base.OnMouseUp(e); }
/// <summary> /// This method occurs as the mouse moves. /// </summary> /// <param name="e">The GeoMouseArcs class describes the mouse condition along with geographic coordinates.</param> protected override void OnMouseMove(GeoMouseArgs e) { if (_standBy) { return; } // Begin snapping changes Coordinate snappedCoord = e.GeographicLocation; bool prevWasSnapped = this.isSnapped; this.isSnapped = ComputeSnappedLocation(e, ref snappedCoord); _coordinateDialog.X = snappedCoord.X; _coordinateDialog.Y = snappedCoord.Y; // End snapping changes if (_coordinates != null && _coordinates.Count > 0) { List <Point> points = _coordinates.Select(coord => Map.ProjToPixel(coord)).ToList(); Rectangle oldRect = SymbologyGlobal.GetRectangle(_mousePosition, points[points.Count - 1]); Rectangle newRect = SymbologyGlobal.GetRectangle(e.Location, points[points.Count - 1]); Rectangle invalid = Rectangle.Union(newRect, oldRect); invalid.Inflate(20, 20); Map.Invalidate(invalid); } // Begin snapping changes _mousePosition = this.isSnapped ? Map.ProjToPixel(snappedCoord) : e.Location; DoMouseMoveForSnapDrawing(prevWasSnapped, _mousePosition); // End snapping changes base.OnMouseMove(e); }
/// <summary> /// updates the auto-filling X and Y coordinates /// </summary> /// <param name="e"></param> protected override void OnMouseMove(GeoMouseArgs e) { if (_standBy) { return; } if (_coordinates == null || _coordinates.Count == 0) { return; } Coordinate c1 = e.GeographicLocation; if (_measureDialog.MeasureMode == MeasureMode.Distance) { double dist = GetDist(c1); _measureDialog.TotalDistance = _previousDistance + _currentDistance + dist; } else { List <Coordinate> tempPolygon = _coordinates.ToList(); tempPolygon.Add(c1); if (tempPolygon.Count < 3) { if (tempPolygon.Count == 2) { Rectangle r = Map.ProjToPixel(new LineString(tempPolygon.ToArray()).EnvelopeInternal.ToExtent()); r.Inflate(20, 20); Map.Invalidate(r); } _mousePosition = e.Location; return; } tempPolygon.Add(_coordinates[0]); Polygon pg = new Polygon(new LinearRing(tempPolygon.ToArray())); if (tempPolygon.Count >= 4) { double area = GetArea(tempPolygon.ToArray()); _measureDialog.TotalArea = area; } Rectangle rr = Map.ProjToPixel(pg.EnvelopeInternal.ToExtent()); rr.Inflate(20, 20); Map.Invalidate(rr); _mousePosition = e.Location; } if (_coordinates.Count > 0) { List <Point> points = _coordinates.Select(coord => Map.ProjToPixel(coord)).ToList(); Rectangle oldRect = SymbologyGlobal.GetRectangle(_mousePosition, points[points.Count - 1]); Rectangle newRect = SymbologyGlobal.GetRectangle(e.Location, points[points.Count - 1]); Rectangle invalid = Rectangle.Union(newRect, oldRect); invalid.Inflate(20, 20); Map.Invalidate(invalid); } _mousePosition = e.Location; base.OnMouseMove(e); }
/// <summary> /// updates the auto-filling X and Y coordinates /// </summary> /// <param name="e"></param> protected override void OnMouseMove(GeoMouseArgs e) { if (_standBy) { return; } if (_coordinates == null || _coordinates.Count == 0) { return; } Coordinate c1 = e.GeographicLocation; if (_measureDialog.MeasureMode == MeasureMode.Distance) { double dist = GetDist(c1); _measureDialog.TotalDistance = _previousDistance + _currentDistance + dist; } else { List <Coordinate> tempPolygon = _coordinates.ToList(); if (!c1.Equals2D(_coordinates[_coordinates.Count - 1])) { tempPolygon.Add(c1); //don't add the current coordinate again if it was added by mouse click } if (tempPolygon.Count < 3) { if (tempPolygon.Count > 1) { Rectangle r = Map.ProjToPixel(new LineString(tempPolygon.ToArray()).EnvelopeInternal.ToExtent()); r.Inflate(20, 20); Map.Invalidate(r); } _mousePosition = e.Location; return; } tempPolygon.Add(_coordinates[0]); //changed by jany_ (2016-06-09) close the polygon, because they must be closed by definition Polygon pg = new Polygon(new LinearRing(tempPolygon.ToArray())); double area = GetArea(tempPolygon.ToArray()); _measureDialog.TotalArea = area; Rectangle rr = Map.ProjToPixel(pg.EnvelopeInternal.ToExtent()); rr.Inflate(20, 20); Map.Invalidate(rr); _mousePosition = e.Location; } if (_coordinates.Count > 0) { List <Point> points = _coordinates.Select(coord => Map.ProjToPixel(coord)).ToList(); Rectangle oldRect = SymbologyGlobal.GetRectangle(_mousePosition, points[points.Count - 1]); Rectangle newRect = SymbologyGlobal.GetRectangle(e.Location, points[points.Count - 1]); Rectangle invalid = Rectangle.Union(newRect, oldRect); invalid.Inflate(20, 20); Map.Invalidate(invalid); } _mousePosition = e.Location; base.OnMouseMove(e); }
void map1_GeoMouseMove(object sender, GeoMouseArgs e) { string locStr = "X:" + e.GeographicLocation.X.ToString("F2") + ", Y:" + e.GeographicLocation.Y.ToString("F2"); statusBarBlocker2.Text = locStr; statusBar1.Width = this.Width - statusBarBlocker2.Width - 100; }
protected override void OnMouseDown(GeoMouseArgs e) { if (_standBy) { return; } base.OnMouseDown(e); }
/// <inheritdoc/> protected override void OnGlpyhClick(GeoMouseArgs e) { using (var form = new ExtensionManagerForm()) { form.App = Manager; form.ShowDialog(); } }
protected override void OnMouseMove(GeoMouseArgs e) { _currentPoint = e.Location; if (_isEnabled == true) { _map.Invalidate(); } base.OnMouseMove(e); }
protected override void OnMouseMove(GeoMouseArgs e) { if (_isEnabled) { _map.Invalidate(); } base.OnMouseMove(e); }
/// <inheritdoc /> protected override void OnMouseMove(GeoMouseArgs e) { _mousePosition = e.Location; if (_dragging) { // Begin snapping changes Coordinate snappedCoord = e.GeographicLocation; if (ComputeSnappedLocation(e, ref snappedCoord)) { _mousePosition = Map.ProjToPixel(snappedCoord); } // End snapping changes UpdateDragCoordinate(snappedCoord); // Snapping changes } else { if (_selectedFeature != null) { VertexHighlight(); } else { // Before a shape is selected it should be possible to highlight shapes to indicate which one // will be selected. bool requiresInvalidate = false; if (_activeFeature != null) { if (ShapeRemoveHighlight(e)) { requiresInvalidate = true; } } if (_activeFeature == null) { if (ShapeHighlight(e)) { requiresInvalidate = true; } } if (requiresInvalidate) { Map.MapFrame.Initialize(); Map.Invalidate(); } } // check to see if the coordinates intersect with a shape in our current featureset. } base.OnMouseMove(e); }
private void MapCtrl_MouseMove(object sender, MouseEventArgs e) { //将地图和坐标函数绑定 GeoMouseArgs args = new GeoMouseArgs(e, mapCtrl); //求X、Y轴坐标 string xpanel = String.Format("X: {0:0.000000}", args.GeographicLocation.X); string ypanel = String.Format("Y: {0:0.000000}", args.GeographicLocation.Y); this._context.Title = xpanel + " " + ypanel + " " + shp.Projection.Name; }
private void map1_GeoMouseMove(object sender, GeoMouseArgs e) { string loacation = "X: " + e.GeographicLocation.X + " "; loacation += "Y: " + e.GeographicLocation.Y.ToString(); toolStripStatusLabel1.Text = loacation; string location = "x: " + e.Location.X + " "; location += "y: " + e.Location.Y + " "; toolStripStatusLabel2.Text = location; }
/// <inheritdoc /> protected override void OnMouseMove(GeoMouseArgs e) { _mousePosition = e.Location; if (_dragging) { // ½º³À ½ÃÀÛ Coordinate snappedCoord = e.GeographicLocation; if (ComputeSnappedLocation(e, ref snappedCoord)) { _mousePosition = Map.ProjToPixel(snappedCoord); } // ½º³À º¯°æ Àû¿ë UpdateDragCoordinate(snappedCoord); // Snapping changes } else { if (_selectedFeature != null) { VertexHighlight(); } else { // µµÇüÀ» ¼±ÅÃÇϱâ Àü¿¡ µµÇüÀ» °Á¶ Ç¥½Ã ÇÒ ¼ö ÀÖ¾î¾ßÇÕ´Ï´Ù. ¾î´À °ÍÀ» ¼±ÅÃÇؾßÇÏ´ÂÁö ³ªÅ¸³À´Ï´Ù. bool requiresInvalidate = false; if (_activeFeature != null) { if (ShapeRemoveHighlight(e)) { requiresInvalidate = true; } } if (_activeFeature == null) { if (ShapeHighlight(e)) { requiresInvalidate = true; } } if (requiresInvalidate) { Map.MapFrame.Initialize(); Map.Invalidate(); } } } base.OnMouseMove(e); }
// Handles the MouseDown protected override void OnMouseDown(GeoMouseArgs e) { if (e.Button == MouseButtons.Left && _isEnabled == true) { _currentPoint = e.Location; System.Drawing.Point point = new System.Drawing.Point(_currentPoint.X, _currentPoint.Y); if (!_points.Contains(point)) { _points.Add(point); } } base.OnMouseDown(e); }
/// <inheritdoc /> protected override void OnMouseUp(GeoMouseArgs e) { // À̵¿Áõ ¸¶¿ì½º¸¦ ³õ¾ÒÀ» ³õ¾ÒÀ»¶§(À§Ä¡À̵¿°áÁ¤½Ã) if (e.Button == MouseButtons.Left && _dragging) { // [20200414] fdragons - add user confirm //if (DialogResult.OK != MessageBox.Show("ÀÌ À§Ä¡·Î À̵¿ ÇϽðڽÀ´Ï±î?", "ÁÂÇ¥À̵¿", MessageBoxButtons.OKCancel)) //{ // // [TODO] À̵¿ Ãë¼Ò󸮸¦ Ãß°¡ÇÏ¿©¾ß ÇÑ´Ù. //} _dragging = false; Map.IsBusy = false; _featureSet.InvalidateVertices(); // Á¡ if (_featureSet.FeatureType == FeatureType.Point || _featureSet.FeatureType == FeatureType.MultiPoint) { if (_activeFeature == null) { return; } OnVertexMoved(new VertexMovedEventArgs(_activeFeature)); if (_layer.GetCategory(_activeFeature) != _selectedCategory) { _layer.SetCategory(_activeFeature, _selectedCategory); _layer.SetVisible(_activeFeature, true); } } else // ¼±, ¸é { if (_selectedFeature == null) { return; } OnVertexMoved(new VertexMovedEventArgs(_selectedFeature)); if (_layer.GetCategory(_selectedFeature) != _selectedCategory) { _layer.SetCategory(_selectedFeature, _selectedCategory); } } } Map.MapFrame.Initialize(); base.OnMouseUp(e); }
/// <summary> /// 鼠标弹起 /// </summary> /// <param name="e"> </param> protected override void OnMouseUp(GeoMouseArgs e) { if (_standBy) { return; } //右键结束此次测量,开始下次测量 if (e.Button == MouseButtons.Right) { if (coordinates.Count > 1) { previousParts.Add(coordinates); currentDistance = 0; } coordinates = new List <Coordinate>(); curDis = new List <double>(); Map.Invalidate(); } else { if (coordinates.Count > 0) { //当前点击点 Coordinate c1 = e.GeographicLocation; //获取和上一个点的距离 double dist = GetDist(c1, null); curDis.Add(dist); //长度叠加 currentDistance += dist; } //添加到序列存储 coordinates.Add(e.GeographicLocation); Map.Invalidate(); } base.OnMouseUp(e); }
protected override void OnMouseMove(GeoMouseArgs e) { int x = Math.Min(Math.Min(_startPoint.X, _currentPoint.X), e.X); int y = Math.Min(Math.Min(_startPoint.Y, _currentPoint.Y), e.Y); int mx = Math.Max(Math.Max(_startPoint.X, _currentPoint.X), e.X); int my = Math.Max(Math.Max(_startPoint.Y, _currentPoint.Y), e.Y); _currentPoint = e.Location; if (_isEnabled) { _map.Invalidate(); } base.OnMouseMove(e); }
/// <summary> /// ¸¶¿ì½º°¡ µµÇüÀ» ¶°³¯ ¶§ »ö»óÀ» ´Ù½Ã Á¤»óÀ¸·Î º¯°æÇÏ´Â °ÍÀ» ó¸®ÇÕ´Ï´Ù. /// </summary> /// <param name="e">GeoMouseArgs ¸Å°³ º¯¼ö´Â ¸¶¿ì½º À§Ä¡ ¹× Áö¸®Àû ÁÂÇ¥¿¡ ´ëÇÑ Á¤º¸¸¦ Æ÷ÇÔÇÕ´Ï´Ù.</param> /// <returns>true,¸Ê ÇÁ·¹ÀÓ ´Ù½Ã±×¸®±â°¡ ÇÊ¿äÇÑ °æ¿ì</returns> private bool ShapeRemoveHighlight(GeoMouseArgs e) { // °Á¶ Ç¥½ÃµÈ ¸ð¾çÀÌ ¾øÀ¸¸é Àǹ̰¡ ¾ø½À´Ï´Ù. if (_oldCategory == null) { return(false); } Rectangle mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6); Extent ext = Map.PixelToProj(mouseRect); bool requiresInvalidate = false; IPolygon env = ext.ToEnvelope().ToPolygon(); if (_layer is MapPointLayer mpl) { int w = 3; int h = 3; if (mpl.GetCategory(_activeFeature) is PointCategory pc) { if (pc.Symbolizer.ScaleMode != ScaleMode.Geographic) { w = (int)pc.Symbolizer.GetSize().Width; h = (int)pc.Symbolizer.GetSize().Height; } } Rectangle rect = new Rectangle(e.Location.X - (w / 2), e.Location.Y - (h / 2), w * 2, h * 2); if (!rect.Contains(Map.ProjToPixel(_activeFeature.Geometry.Coordinates[0]))) { mpl.SetCategory(_activeFeature, _oldCategory); _activeFeature = null; requiresInvalidate = true; } } else { if (!_activeFeature.Geometry.Intersects(env)) { _layer.SetCategory(_activeFeature, _oldCategory); _activeFeature = null; requiresInvalidate = true; } } return(requiresInvalidate); }
private void MapFunctionSelectionZoomOnMouseDown(object sender, GeoMouseArgs geoMouseArgs) { switch (geoMouseArgs.Button) { case MouseButtons.Left: map.Cursor = Cursors.SizeNWSE; break; default: map.Cursor = map.IsBusy ? Cursors.SizeNWSE : defaultCursor; break; } }
/// <summary> /// 鼠标移动 /// </summary> /// <param name="e"></param> protected override void OnMouseMove(GeoMouseArgs e) { //注销后直接跳过 if (_standBy) { return; } //当无坐标时 if (coordinates == null || coordinates.Count == 0) { return; } //鼠标位置点 Coordinate c1 = e.GeographicLocation; //鼠标和最后一个点的距离 double dist = GetDist(c1, null); tempDistance = currentDistance + dist; //当点数量大于0时 if (coordinates.Count > 0) { //将地理坐标转为屏幕坐标 List <Point> points = coordinates.Select(coord => Map.ProjToPixel(coord)).ToList(); //获取鼠标上一个位置和最后一个点的矩形区域 Rectangle oldRect = SymbologyGlobal.GetRectangle(_mousePosition, points[points.Count - 1]); //获取鼠标和左后一个点的矩形区域 Rectangle newRect = SymbologyGlobal.GetRectangle(e.Location, points[points.Count - 1]); //合并区域 Rectangle invalid = Rectangle.Union(newRect, oldRect); //刷新区域 invalid.Inflate(220, 20); Map.Invalidate(invalid); } //设置为鼠标位置 _mousePosition = e.Location; base.OnMouseMove(e); }
protected override void OnMouseDown(GeoMouseArgs e) { if (e.Button == MouseButtons.Left) { _startPoint = e.Location; _currentPoint = _startPoint; //_map.IsBusy = true; if (_points.Count == 1) { _isEnabled = false; _points.Add(e.Location); ////write in coordinate points _coordinatePoints.Add(_map.PixelToProj(new System.Drawing.Point(_points[0].X, _points[0].Y))); _coordinatePoints.Add(_map.PixelToProj(new System.Drawing.Point(_points[0].X, _points[1].Y))); _coordinatePoints.Add(_map.PixelToProj(new System.Drawing.Point(_points[1].X, _points[1].Y))); _coordinatePoints.Add(_map.PixelToProj(new System.Drawing.Point(_points[1].X, _points[0].Y))); _coordinatePoints.Add(_map.PixelToProj(new System.Drawing.Point(_points[0].X, _points[0].Y))); LinearRing _linearRing = new LinearRing(_coordinatePoints.ToArray()); Polygon polygon = new Polygon(_linearRing); IMapPolygonLayer polygonLayer = GetPolygonLayer(); polygonLayer.DataSet.AddFeature(polygon as IGeometry); _points.Clear(); _coordinatePoints.Clear(); _map.Refresh(); } else if (_points.Count == 0) { _isEnabled = true; _points.Add(e.Location); } } else if (e.Button == MouseButtons.Right) { this.Enabled = false; string bufferType = "PolygonBuffer"; GIS.Common.Dialogs.Buffer polygonBuffer = new GIS.Common.Dialogs.Buffer(bufferType); polygonBuffer.ShowDialog(); _map.FunctionMode = FunctionMode.Pan; } base.OnMouseDown(e); }
/// <summary> /// Highlighting shapes with a mouse over is something that also needs to be undone when the /// mouse leaves. This test handles changing the colors back to normal when the mouse leaves a shape. /// </summary> /// <param name="e">The GeoMouseArgs parameter contains information about the mouse location and geographic coordinates.</param> /// <returns>Boolean, true if mapframe initialize (or visual change) is necessary.</returns> private bool ShapeRemoveHighlight(GeoMouseArgs e) { // If no shapes have ever been highlighted, this is meaningless. if (_oldCategory == null) { return(false); } Rectangle mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6); Extent ext = Map.PixelToProj(mouseRect); MapPointLayer mpl = _layer as MapPointLayer; bool requiresInvalidate = false; IPolygon env = ext.ToEnvelope().ToPolygon(); if (mpl != null) { int w = 3; int h = 3; PointCategory pc = mpl.GetCategory(_activeFeature) as PointCategory; if (pc != null) { if (pc.Symbolizer.ScaleMode != ScaleMode.Geographic) { w = (int)pc.Symbolizer.GetSize().Width; h = (int)pc.Symbolizer.GetSize().Height; } } Rectangle rect = new Rectangle(e.Location.X - (w / 2), e.Location.Y - (h / 2), w * 2, h * 2); if (!rect.Contains(Map.ProjToPixel(_activeFeature.Coordinates[0]))) { mpl.SetCategory(_activeFeature, _oldCategory); _activeFeature = null; requiresInvalidate = true; } } else { if (!_activeFeature.Intersects(env)) { _layer.SetCategory(_activeFeature, _oldCategory); _activeFeature = null; requiresInvalidate = true; } } return(requiresInvalidate); }
protected override void OnMouseDown(GeoMouseArgs e) { if (e.Button == MouseButtons.Middle) { mouseButtonMiddleDown = true; } if (e.Button == MouseButtons.Left) { startPoint = e.Location; currentPoint = startPoint; geoStartPoint = e.GeographicLocation; isDragging = true; Map.IsBusy = true; } base.OnMouseDown(e); }
protected override void OnMouseDoubleClick(GeoMouseArgs e) { _isEnabled = false; _coordinatePoints.Clear(); for (int i = 0; i <= (_points.Count - 1); i++) { _coordinatePoints.Add(_map.PixelToProj(new System.Drawing.Point(_points[i].X, _points[i].Y))); } _lineString = new LineString(_coordinatePoints.ToArray()); IMapLineLayer lineLayer = GetLineLayer(); lineLayer.DataSet.AddFeature(_lineString as IGeometry); _points.Clear(); _map.Refresh(); _isEnabled = true; }
protected override void OnMouseMove(GeoMouseArgs e) { if (isDragging) { int x = Math.Min(Math.Min(startPoint.X, currentPoint.X), e.X); int y = Math.Min(Math.Min(startPoint.Y, currentPoint.Y), e.Y); int mx = Math.Max(Math.Max(startPoint.X, currentPoint.X), e.X); int my = Math.Max(Math.Max(startPoint.Y, currentPoint.Y), e.Y); currentPoint = e.Location; Map.Invalidate(new Rectangle(x, y, mx - x, my - y)); } if (mouseButtonMiddleDown) { return; } base.OnMouseMove(e); }
/// <summary> /// Mouse Wheel /// </summary> /// <param name="e"></param> protected override void OnMouseWheel(GeoMouseArgs e) //Fix this { if (_zoomTimer != null) { _zoomTimer.Invalidate (); // if the timer was already started, stop it. _zoomTimer.Dispose (); } if ((e.Map.IsZoomedToMaxExtent == true) && (_direction * e.Delta < 0)) {} else { e.Map.IsZoomedToMaxExtent = false; Rectangle r = e.Map.MapFrame.View; // For multiple zoom steps before redrawing, we actually // want the x coordinate relative to the screen, not // the x coordinate relative to the previously modified view. if (_client == Rectangle.Empty) { _client = r; } int cw = _client.Width; int ch = _client.Height; double w = r.Width; double h = r.Height; if (_direction * e.Delta > 0) { double inFactor = 2.0 * _sensitivity; r.Inflate(Convert.ToInt32(-w / inFactor), Convert.ToInt32(-h / inFactor)); // try to keep the mouse cursor in the same geographic position r.X += Convert.ToInt32((e.X * w / (_sensitivity * cw)) - w / inFactor); r.Y += Convert.ToInt32((e.Y * h / (_sensitivity * ch)) - h / inFactor); } else { double outFactor = 0.5 * _sensitivity; r.Inflate(Convert.ToInt32(w / _sensitivity), Convert.ToInt32(h / _sensitivity)); r.X += Convert.ToInt32(w / _sensitivity - (e.X * w / (outFactor * cw))); r.Y += Convert.ToInt32(h / _sensitivity - (e.Y * h / (outFactor * ch))); } e.Map.MapFrame.View = r; e.Map.Invalidate(); _zoomTimer = NSTimer.CreateScheduledTimer(TimeSpan.FromMilliseconds (_timerInterval), delegate{ZoomTimerTick();}); _mapFrame = e.Map.MapFrame; if (!BusySet) { Map.IsBusy = true; BusySet = true; } base.OnMouseWheel(e); } }
/// <summary> /// Fires the OnMouseWheel event for the active tools /// </summary> /// <param name="e"></param> public override void ScrollWheel(NSEvent theEvent) { var LocationInView = ConvertPointFromView (theEvent.LocationInWindow, null); GeoMouseArgs e = new GeoMouseArgs(new MouseEventArgs(MouseButtons.None, 0, (int)LocationInView.X, (int)(Height - LocationInView.Y), (int)(theEvent.DeltaY*10)), this); foreach (IMapFunction tool in MapFunctions) { if (tool.Enabled) { tool.DoMouseWheel (e); if (e.Handled) break; } } var handler = GeoScrollWheel; if (handler != null) { handler(this, e); } base.ScrollWheel(theEvent); }
/// <summary> /// Fires the OnMouseMove event on the Active Tools /// </summary> /// <param name="e"></param> public override void MouseDragged(NSEvent theEvent) { var LocationInView = ConvertPointFromView (theEvent.LocationInWindow, null); GeoMouseArgs args = new GeoMouseArgs(new MouseEventArgs (MouseButtons.None, 0, (int)LocationInView.X, (int)(Height - LocationInView.Y), 0), this); foreach (IMapFunction tool in MapFunctions) { if (tool.Enabled) { tool.DoMouseMove(args); if (args.Handled) break; } } OnMouseMove(args); base.MouseDragged(theEvent); }
/// <summary> /// Fires the OnMouseDown event on the Active Tools /// </summary> /// <param name="e"></param> public override void MouseDown(NSEvent theEvent) { var LocationInView = ConvertPointFromView (theEvent.LocationInWindow, null); GeoMouseArgs e = new GeoMouseArgs(new MouseEventArgs (MouseButtons.Left, theEvent.ClickCount, (int)LocationInView.X, (int)(Height - LocationInView.Y), 0), this); foreach (IMapFunction tool in MapFunctions) { if (tool.Enabled) { tool.DoMouseDown(e); if (e.Handled) break; } } var handler = GeoMouseDown; if (handler != null) { handler(this, e); } base.MouseDown(theEvent); }
protected void OnMouseMove(GeoMouseArgs args) { var h = GeoMouseMove; if (h != null) h(this, args); }