Exemplo n.º 1
0
 /// <summary>
 /// Constructor which sets the initial values to bound the (0,0) point and the point
 /// that results from (0,0) + size.
 /// </summary>
 public Rect(Size size)
 {
     if (size.IsEmpty)
     {
         this = s_empty;
     }
     else
     {
         _x = _y = 0;
         _width = size.Width;
         _height = size.Height;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor which sets the initial values to the values of the parameters
 /// </summary>
 public Rect(Point location, Size size)
 {
     if (size.IsEmpty)
     {
         this = s_empty;
     }
     else
     {
         _x = location._x;
         _y = location._y;
         _width = size._width;
         _height = size._height;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Inflate - return the result of inflating rect by the size provided, in all directions
 /// If this is Empty, this method is illegal.
 /// </summary>
 public static Rect Inflate(Rect rect, Size size)
 {
     rect.Inflate(size._width, size._height);
     return rect;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Inflate - inflate the bounds by the size provided, in all directions
 /// If this is Empty, this method is illegal.
 /// </summary>
 public void Inflate(Size size)
 {
     Inflate(size._width, size._height);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Equals - compares this Size with the passed in object.  In this equality
 /// Double.NaN is equal to itself, unlike in numeric equality.
 /// Note that double values can acquire error when operated upon, such that
 /// an exact comparison between two values which
 /// are logically equal may fail.
 /// </summary>
 /// <returns>
 /// bool - true if "value" is equal to "this".
 /// </returns>
 /// <param name='value'>The Size to compare to "this"</param>
 public bool Equals(Size value)
 {
     return Size.Equals(this, value);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Compares two Size instances for object equality.  In this equality
 /// Double.NaN is equal to itself, unlike in numeric equality.
 /// Note that double values can acquire error when operated upon, such that
 /// an exact comparison between two values which
 /// are logically equal may fail.
 /// </summary>
 /// <returns>
 /// bool - true if the two Size instances are exactly equal, false otherwise
 /// </returns>
 /// <param name='size1'>The first Size to compare</param>
 /// <param name='size2'>The second Size to compare</param>
 public static bool Equals(Size size1, Size size2)
 {
     if (size1.IsEmpty)
     {
         return size2.IsEmpty;
     }
     else
     {
         return size1.Width.Equals(size2.Width) &&
         size1.Height.Equals(size2.Height);
     }
 }
Exemplo n.º 7
0
 static private Size CreateEmptySize()
 {
     Size size = new Size();
     // We can't set these via the property setters because negatives widths
     // are rejected in those APIs.
     size._width = Double.NegativeInfinity;
     size._height = Double.NegativeInfinity;
     return size;
 }
Exemplo n.º 8
0
 // Normalizes the point in the given size to the range [-1, 1].
 internal static Point GetNormalizedPoint(Point point, Size size)
 {
     return new Point(
         ((2 * point.X) / size.Width) - 1,
         -(((2 * point.Y) / size.Height) - 1));
 }
Exemplo n.º 9
0
 // Returns the aspect ratio of the given size.
 internal static double GetAspectRatio(Size viewSize)
 {
     return viewSize.Width / viewSize.Height;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Compares two Size instances for fuzzy equality.  This function
 /// helps compensate for the fact that double values can
 /// acquire error when operated upon
 /// </summary>
 /// <param name='size1'>The first size to compare</param>
 /// <param name='size2'>The second size to compare</param>
 /// <returns>Whether or not the two Size instances are equal</returns>
 public static bool AreClose(Size size1, Size size2)
 {
     return DoubleUtil.AreClose(size1.Width, size2.Width) &&
     DoubleUtil.AreClose(size1.Height, size2.Height);
 }