System.Drawing.Point.Equals C# (CSharp) Method

Equals() public method

Specifies whether this contains the same coordinates as the specified .

public Equals ( object obj ) : bool
obj object
return bool
        public override bool Equals(object obj)
        {
            if (!(obj is Point)) return false;
            Point comp = (Point)obj;

            return comp.X == X && comp.Y == Y;
        }

Usage Example

Exemplo n.º 1
0
		/// <summary>
		/// 目标点是否在线段上 (y2-y1)(x-x1) = (y-y1)(x2-x1)
		/// </summary>		
		public bool Contains(Point pt)
		{
			if((pt.Equals(this.pt1)) ||(pt.Equals(this.pt2)))
			{
				return true ;
			}

			float left  = (this.pt2.Y - this.pt1.Y) * (pt.X       - this.pt1.X) ;
			float right = (pt.Y       - this.pt1.Y) * (this.pt2.X - this.pt1.X) ;

			if(Math.Abs(left - right) < GeometryHelper.ToleranceForFloat)
			{
				return false ;
			}

			if(! GeometryHelper.IsInRegion(pt.X ,this.pt1.X ,this.pt2.X))
			{
				return false ;
			}

			if(! GeometryHelper.IsInRegion(pt.Y ,this.pt1.Y ,this.pt2.Y))
			{
				return false ;
			}

			return true ;
		}
All Usage Examples Of System.Drawing.Point::Equals