Example #1
0
 public PointLocation ContainsPoint(PointDO p)
 {
     PointLocation loc = PointLocation.Outside;
     if(p.Top > this.Top && p.Top < this.bottom && p.Left > this.Left && p.Left < this.right)
     {
         loc = PointLocation.Inside;
     }
     else if ((p.Top == this.Top && p.Left >= this.Left && p.Left <= this.right)
         || (p.Top == this.bottom && p.Left >= this.Left && p.Left <= this.right)
         || (p.Left == this.Left && p.Top >= this.Top && p.Top <= this.bottom)
         || (p.Left == this.right && p.Top >= this.Top && p.Top <= this.bottom))
     {
         loc = PointLocation.Border;
     }
     return loc;
 }
Example #2
0
 /// <summary>
 /// Given vertices of the passed in rectangle that are within the bound of the current instance, determines
 /// the missing vertices of the intersection
 /// </summary>
 /// <param name="insidePoints">Vertices of the passed in rectangle that are within bounds of the current instance</param>
 /// <param name="other">The other rectangle</param>
 /// <returns>List of all vertices of the intersect region</returns>
 private List<PointDO> FindMissingPoints(List<PointDO> insidePoints, RectangleDO other)
 {
     List<PointDO> complete = new List<PointDO>();
     complete.AddRange(insidePoints);
     if (insidePoints.Count == 2 && insidePoints[0].Left != insidePoints[1].Left && insidePoints[0].Top != insidePoints[1].Top)
     {
         complete.Add(new PointDO(insidePoints[1].Top, insidePoints[0].Left));
         complete.Add(new PointDO(insidePoints[0].Top, insidePoints[1].Left));
     }
     else
     {
         if (other.Right > this.Right)
         {
             foreach(PointDO p in insidePoints)
             {
                 if(p.Left < this.Right)
                 {
                     PointDO missing = new PointDO(p.Top, this.Right);
                     if (!complete.Contains(missing))
                     {
                         complete.Add(missing);
                     }
                 }
             }
         }
         else if (other.Left < this.Left)
         {
             foreach(PointDO p in insidePoints)
             {
                 if(p.Left > this.Left)
                 {
                     PointDO missing = new PointDO(p.Top, this.Left);
                     if (!complete.Contains(missing))
                     {
                         complete.Add(missing);
                     }
                 }
             }
         }
         else if (other.Top < this.Top)
         {
             foreach(PointDO p in insidePoints)
             {
                 if(p.Top > this.Top)
                 {
                     PointDO missing = new PointDO(this.Top, p.Left);
                     if (!complete.Contains(missing))
                     {
                         complete.Add(missing);
                     }
                 }
             }
         }
         else if (other.Bottom > this.Bottom)
         {
             foreach(PointDO p in insidePoints)
             {
                 if(p.Top < this.Bottom)
                 {
                     PointDO missing = new PointDO(this.Bottom, p.Left);
                     if (!complete.Contains(missing))
                     {
                         complete.Add(missing);
                     }
                 }
             }
         }
     }
     return complete;
 }