/// <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);
        }
예제 #2
0
        /// <summary>
        /// Returns true if the element intersect the rectangle from the parent class
        /// </summary>
        /// <param name="rect">The rectangle to test must be in the virtual modeling coordinant plane</param>
        /// <returns></returns>
        public override bool ElementInRectangle(Rectangle rect)
        {
            IGeometry rectanglePoly;

            if ((rect.Height == 0) && (rect.Width == 0))
            {
                rectanglePoly = new Topology.Point(rect.X, rect.Y);
            }
            else if (rect.Width == 0)
            {
                Topology.Point[] rectanglePoints = new Topology.Point[2];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X, rect.Y + rect.Height);
                rectanglePoly      = new LineString(rectanglePoints);
            }
            else if (rect.Height == 0)
            {
                Topology.Point[] rectanglePoints = new Topology.Point[2];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X + rect.Width, rect.Y);
                rectanglePoly      = new LineString(rectanglePoints);
            }
            else
            {
                Topology.Point[] rectanglePoints = new Topology.Point[5];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X, rect.Y + rect.Height);
                rectanglePoints[2] = new Topology.Point(rect.X + rect.Width, rect.Y + rect.Height);
                rectanglePoints[3] = new Topology.Point(rect.X + rect.Width, rect.Y);
                rectanglePoints[4] = new Topology.Point(rect.X, rect.Y);
                rectanglePoly      = new Polygon(new LinearRing(rectanglePoints));
            }

            if (Shape == ModelShape.Arrow)
            {
                Topology.Point[] arrowPoints = new Topology.Point[_arrowPath.PointCount];
                for (int i = 0; i < _arrowPath.PointCount; i++)
                {
                    arrowPoints[i] = new Topology.Point(_arrowPath.PathPoints[i].X + Location.X, _arrowPath.PathPoints[i].Y + Location.Y);
                }
                LineString arrowLine = new LineString(arrowPoints);
                return(arrowLine.Intersects(rectanglePoly));
            }
            return(false);
        }
예제 #3
0
        /// <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; }

            // 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.UpdateExtent();
                _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);
        }
예제 #4
0
        /// <summary>
        /// Returns true if the element intersect the rectangle from the parent class
        /// </summary>
        /// <param name="rect">The rectangle to test must be in the virtual modeling coordinant plane</param>
        /// <returns></returns>
        public override bool ElementInRectangle(Rectangle rect)
        {
            IGeometry rectanglePoly;
            if ((rect.Height == 0) && (rect.Width == 0))
            {
                rectanglePoly = new Topology.Point(rect.X, rect.Y);
            }
            else if (rect.Width == 0)
            {
                Topology.Point[] rectanglePoints = new Topology.Point[2];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X, rect.Y + rect.Height);
                rectanglePoly = new LineString(rectanglePoints);
            }
            else if (rect.Height == 0)
            {
                Topology.Point[] rectanglePoints = new Topology.Point[2];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X + rect.Width, rect.Y);
                rectanglePoly = new LineString(rectanglePoints);
            }
            else
            {
                Topology.Point[] rectanglePoints = new Topology.Point[5];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X, rect.Y + rect.Height);
                rectanglePoints[2] = new Topology.Point(rect.X + rect.Width, rect.Y + rect.Height);
                rectanglePoints[3] = new Topology.Point(rect.X + rect.Width, rect.Y);
                rectanglePoints[4] = new Topology.Point(rect.X, rect.Y);
                rectanglePoly = new Polygon(new LinearRing(rectanglePoints));
            }

            if (Shape == ModelShape.Arrow)
            {
                Topology.Point[] arrowPoints = new Topology.Point[_arrowPath.PointCount];
                for (int i = 0; i < _arrowPath.PointCount; i++)
                {
                    arrowPoints[i] = new Topology.Point(_arrowPath.PathPoints[i].X + Location.X, _arrowPath.PathPoints[i].Y + Location.Y);
                }
                LineString arrowLine = new LineString(arrowPoints);
                return (arrowLine.Intersects(rectanglePoly));
            }
            return false;
        }
예제 #5
0
        /// <summary>
        /// Returns true if the element intersect the rectangle from the parent class
        /// </summary>
        /// <param name="rect">The rectangle to test must be in the virtual modeling coordinant plane</param>
        /// <returns></returns>
        public virtual bool ElementInRectangle(Rectangle rect)
        {
            IGeometry rectanglePoly;

            if ((rect.Height == 0) && (rect.Width == 0))
            {
                rectanglePoly = new Topology.Point(rect.X, rect.Y);
            }
            else if (rect.Width == 0)
            {
                Topology.Point[] rectanglePoints = new Topology.Point[2];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X, rect.Y + rect.Height);
                rectanglePoly      = new LineString(rectanglePoints);
            }
            else if (rect.Height == 0)
            {
                Topology.Point[] rectanglePoints = new Topology.Point[2];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X + rect.Width, rect.Y);
                rectanglePoly      = new LineString(rectanglePoints);
            }
            else
            {
                Topology.Point[] rectanglePoints = new Topology.Point[5];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X, rect.Y + rect.Height);
                rectanglePoints[2] = new Topology.Point(rect.X + rect.Width, rect.Y + rect.Height);
                rectanglePoints[3] = new Topology.Point(rect.X + rect.Width, rect.Y);
                rectanglePoints[4] = new Topology.Point(rect.X, rect.Y);
                rectanglePoly      = new Polygon(new LinearRing(rectanglePoints));
            }

            switch (Shape)
            {
            case ModelShape.Rectangle:
                return(rect.IntersectsWith(Rectangle));

            case ModelShape.Ellipse:
                int b = Height / 2;
                int a = Width / 2;
                Topology.Point[] ellipsePoints = new Topology.Point[(4 * a) + 1];
                for (int x = -a; x <= a; x++)
                {
                    if (x == 0)
                    {
                        ellipsePoints[x + a]     = new Topology.Point(Location.X + x + a, Location.Y);
                        ellipsePoints[3 * a - x] = new Topology.Point(Location.X + x + a, Location.Y + Height);
                    }
                    else
                    {
                        ellipsePoints[x + a]     = new Topology.Point(Location.X + x + a, Location.Y + b - Math.Sqrt(Math.Abs(((b * b * x * x) / (a * a)) - (b * b))));
                        ellipsePoints[3 * a - x] = new Topology.Point(Location.X + x + a, Location.Y + b + Math.Sqrt(Math.Abs(((b * b * x * x) / (a * a)) - (b * b))));
                    }
                }

                Polygon ellipsePoly = new Polygon(new LinearRing(ellipsePoints));
                return(ellipsePoly.Intersects(rectanglePoly));

            case ModelShape.Triangle:
                Topology.Point[] trianglePoints = new Topology.Point[4];
                trianglePoints[0] = new Topology.Point(Location.X, Location.Y);
                trianglePoints[1] = new Topology.Point(Location.X, Location.Y + Height);
                trianglePoints[2] = new Topology.Point(Location.X + Width - 5, Location.Y + ((Height - 5) / 2));
                trianglePoints[3] = new Topology.Point(Location.X, Location.Y);
                Polygon trianglePoly = new Polygon(new LinearRing(trianglePoints));
                return(trianglePoly.Intersects(rectanglePoly));

            default:
                return(false);
            }
        }
예제 #6
0
        /// <summary>
        /// Returns true if the element intersect the rectangle from the parent class
        /// </summary>
        /// <param name="rect">The rectangle to test must be in the virtual modeling coordinant plane</param>
        /// <returns></returns>
        public virtual bool ElementInRectangle(Rectangle rect)
        {
            IGeometry rectanglePoly;
            if ((rect.Height == 0) && (rect.Width == 0))
            {
                rectanglePoly = new Topology.Point(rect.X, rect.Y);
            }
            else if (rect.Width == 0)
            {
                Topology.Point[] rectanglePoints = new Topology.Point[2];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X, rect.Y + rect.Height);
                rectanglePoly = new LineString(rectanglePoints);
            }
            else if (rect.Height == 0)
            {
                Topology.Point[] rectanglePoints = new Topology.Point[2];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X + rect.Width, rect.Y);
                rectanglePoly = new LineString(rectanglePoints);
            }
            else
            {
                Topology.Point[] rectanglePoints = new Topology.Point[5];
                rectanglePoints[0] = new Topology.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Topology.Point(rect.X, rect.Y + rect.Height);
                rectanglePoints[2] = new Topology.Point(rect.X + rect.Width, rect.Y + rect.Height);
                rectanglePoints[3] = new Topology.Point(rect.X + rect.Width, rect.Y);
                rectanglePoints[4] = new Topology.Point(rect.X, rect.Y);
                rectanglePoly = new Polygon(new LinearRing(rectanglePoints));
            }

            switch (Shape)
            {
                case ModelShape.Rectangle:
                    return (rect.IntersectsWith(Rectangle));

                case ModelShape.Ellipse:
                    int b = Height / 2;
                    int a = Width / 2;
                    Topology.Point[] ellipsePoints = new Topology.Point[(4 * a) + 1];
                    for (int x = -a; x <= a; x++)
                    {
                        if (x == 0)
                        {
                            ellipsePoints[x + a] = new Topology.Point(Location.X + x + a, Location.Y);
                            ellipsePoints[3 * a - x] = new Topology.Point(Location.X + x + a, Location.Y + Height);
                        }
                        else
                        {
                            ellipsePoints[x + a] = new Topology.Point(Location.X + x + a, Location.Y + b - Math.Sqrt(Math.Abs(((b * b * x * x) / (a * a)) - (b * b))));
                            ellipsePoints[3 * a - x] = new Topology.Point(Location.X + x + a, Location.Y + b + Math.Sqrt(Math.Abs(((b * b * x * x) / (a * a)) - (b * b))));
                        }
                    }

                    Polygon ellipsePoly = new Polygon(new LinearRing(ellipsePoints));
                    return (ellipsePoly.Intersects(rectanglePoly));

                case ModelShape.Triangle:
                    Topology.Point[] trianglePoints = new Topology.Point[4];
                    trianglePoints[0] = new Topology.Point(Location.X, Location.Y);
                    trianglePoints[1] = new Topology.Point(Location.X, Location.Y + Height);
                    trianglePoints[2] = new Topology.Point(Location.X + Width - 5, Location.Y + ((Height - 5) / 2));
                    trianglePoints[3] = new Topology.Point(Location.X, Location.Y);
                    Polygon trianglePoly = new Polygon(new LinearRing(trianglePoints));
                    return (trianglePoly.Intersects(rectanglePoly));

                default:
                    return false;
            }
        }