[System.Drawing] Add ifdefs to source code used by Xamarin.iOS/Mac to make it compile...
[mono.git] / mcs / class / System.Drawing / System.Drawing / SizeF.cs
index bd673a29d9b00f94d72e79b715a0f966f2559a4d..38714d1c9968f30ae18e363a4c811a82dc38de99 100644 (file)
@@ -40,10 +40,13 @@ namespace System.Drawing
 {
        [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
@@ -83,10 +86,10 @@ namespace System.Drawing
                ///     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>
@@ -99,10 +102,10 @@ namespace System.Drawing
                ///     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>
@@ -128,9 +131,9 @@ namespace System.Drawing
                ///     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);
                }
 
 
@@ -148,8 +151,8 @@ namespace System.Drawing
                
                public SizeF (PointF pt)
                {
-                       wd = pt.X;
-                       ht = pt.Y;
+                       width = pt.X;
+                       height = pt.Y;
                }
 
                /// <summary>
@@ -160,10 +163,10 @@ namespace System.Drawing
                ///     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>
@@ -176,8 +179,8 @@ namespace System.Drawing
                
                public SizeF (float width, float height)
                {
-                       wd = width;
-                       ht = height;
+                       this.width = width;
+                       this.height = height;
                }
 
                // -----------------------
@@ -195,7 +198,7 @@ namespace System.Drawing
                [Browsable (false)]
                public bool IsEmpty {
                        get {
-                               return ((wd == 0.0) && (ht == 0.0));
+                               return ((width == 0.0) && (height == 0.0));
                        }
                }
 
@@ -209,10 +212,10 @@ namespace System.Drawing
                
                public float Width {
                        get {
-                               return wd;
+                               return width;
                        }
                        set {
-                               wd = value;
+                               width = value;
                        }
                }
 
@@ -226,10 +229,10 @@ namespace System.Drawing
                
                public float Height {
                        get {
-                               return ht;
+                               return height;
                        }
                        set {
-                               ht = value;
+                               height = value;
                        }
                }
 
@@ -241,12 +244,12 @@ namespace System.Drawing
                ///     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>
@@ -259,20 +262,20 @@ namespace System.Drawing
                
                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);
@@ -288,8 +291,20 @@ namespace System.Drawing
                
                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);
                }
        }
 }