/// <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);
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
        /// <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;
        }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 5
0
        /// <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>
        ///  鼠标移动
        /// </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);
        }
Esempio n. 7
0
        /// <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 (_layoutDialog.MeasureMode == LayoutMode.Distance)
            {
                double dist = GetDist(c1);
                _layoutDialog.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).Envelope.ToExtent());
                        r.Inflate(20, 20);
                        Map.Invalidate(r);
                    }
                    _mousePosition = e.Location;
                    return;
                }
                Polygon pg = new Polygon(new LinearRing(tempPolygon));

                double area = GetArea(tempPolygon);

                _layoutDialog.TotalArea = area;
                Rectangle rr = Map.ProjToPixel(pg.Envelope.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);
            }
            //Point et = pvMap4Draw.ProjToPixel(_coordinates[_coordinates.Count - 1]);
            if (_layoutDialog.chkOrthonality == true)
            {
                Point lastPt = pvMap4Draw.ProjToPixel(_coordinates[_coordinates.Count - 1]);

                if (Math.Abs(lastPt.X - e.X) >= Math.Abs(lastPt.Y - e.Y))
                {
                    et = new Point(e.X, lastPt.Y);
                }
                else
                {
                    et = new Point(lastPt.X, e.Y);
                }

                _mousePosition = et;// e.Location;
            }
            else
            {
                _mousePosition = e.Location;
                base.OnMouseMove(e);
            }
            //
            //
        }