{
[Serializable]
[ComVisible (true)]
+#if !MONOTOUCH && !MONOMAC
+ [TypeConverter (typeof (SizeFConverter))]
+#endif
public struct SizeF
{
// Private height and width fields.
- private float wd, ht;
+ private float width, height;
// -----------------------
// Public Shared Members
/// properties of the two Sizes.
/// </remarks>
- public static bool operator == (SizeF sz_a, SizeF sz_b)
+ public static bool operator == (SizeF sz1, SizeF sz2)
{
- return ((sz_a.Width == sz_b.Width) &&
- (sz_a.Height == sz_b.Height));
+ return ((sz1.Width == sz2.Width) &&
+ (sz1.Height == sz2.Height));
}
/// <summary>
/// properties of the two Sizes.
/// </remarks>
- public static bool operator != (SizeF sz_a, SizeF sz_b)
+ public static bool operator != (SizeF sz1, SizeF sz2)
{
- return ((sz_a.Width != sz_b.Width) ||
- (sz_a.Height != sz_b.Height));
+ return ((sz1.Width != sz2.Width) ||
+ (sz1.Height != sz2.Height));
}
/// <summary>
/// SizeF. Requires explicit cast.
/// </remarks>
- public static explicit operator PointF (SizeF sz)
+ public static explicit operator PointF (SizeF size)
{
- return new PointF (sz.Width, sz.Height);
+ return new PointF (size.Width, size.Height);
}
public SizeF (PointF pt)
{
- wd = pt.X;
- ht = pt.Y;
+ width = pt.X;
+ height = pt.Y;
}
/// <summary>
/// Creates a SizeF from an existing SizeF value.
/// </remarks>
- public SizeF (SizeF sz)
+ public SizeF (SizeF size)
{
- wd = sz.Width;
- ht = sz.Height;
+ width = size.Width;
+ height = size.Height;
}
/// <summary>
public SizeF (float width, float height)
{
- wd = width;
- ht = height;
+ this.width = width;
+ this.height = height;
}
// -----------------------
[Browsable (false)]
public bool IsEmpty {
get {
- return ((wd == 0.0) && (ht == 0.0));
+ return ((width == 0.0) && (height == 0.0));
}
}
public float Width {
get {
- return wd;
+ return width;
}
set {
- wd = value;
+ width = value;
}
}
public float Height {
get {
- return ht;
+ return height;
}
set {
- ht = value;
+ height = value;
}
}
/// Checks equivalence of this SizeF and another object.
/// </remarks>
- public override bool Equals (object o)
+ public override bool Equals (object obj)
{
- if (!(o is SizeF))
+ if (!(obj is SizeF))
return false;
- return (this == (SizeF) o);
+ return (this == (SizeF) obj);
}
/// <summary>
public override int GetHashCode ()
{
- return (int) wd ^ (int) ht;
+ return (int) width ^ (int) height;
}
public PointF ToPointF ()
{
- return new PointF (wd, ht);
+ return new PointF (width, height);
}
public Size ToSize ()
{
int w, h;
checked {
- w = (int) wd;
- h = (int) ht;
+ w = (int) width;
+ h = (int) height;
}
return new Size (w, h);
public override string ToString ()
{
- return string.Format ("{{Width={0}, Height={1}}}", wd.ToString (CultureInfo.CurrentCulture),
- ht.ToString (CultureInfo.CurrentCulture));
+ return string.Format ("{{Width={0}, Height={1}}}", width.ToString (CultureInfo.CurrentCulture),
+ height.ToString (CultureInfo.CurrentCulture));
+ }
+
+ public static SizeF Add (SizeF sz1, SizeF sz2)
+ {
+ return new SizeF (sz1.Width + sz2.Width,
+ sz1.Height + sz2.Height);
+ }
+
+ public static SizeF Subtract (SizeF sz1, SizeF sz2)
+ {
+ return new SizeF (sz1.Width - sz2.Width,
+ sz1.Height - sz2.Height);
}
}
}