Author: spouliot
Date: 2006-08-27 19:43:01 -0400 (Sun, 27 Aug 2006)
New Revision: 64454

Modified:
   trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
   trunk/mcs/class/System.Drawing/System.Drawing/ColorConverter.cs
   trunk/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs
Log:
2006-08-27  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * ColorConverter.cs: Catch the case where the integer part of the 
        color doesn't fit into a 32bit integer.
        * ColorTranslator.cs: Fixed Gendarme's UseStringEmptyRule on ToHtml 
        method. Fixed string handling on FromHtml method. Fixed all parameter
        names to match FX.



Modified: trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog     2006-08-27 
22:56:29 UTC (rev 64453)
+++ trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog     2006-08-27 
23:43:01 UTC (rev 64454)
@@ -1,3 +1,11 @@
+2006-08-27  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * ColorConverter.cs: Catch the case where the integer part of the 
+       color doesn't fit into a 32bit integer.
+       * ColorTranslator.cs: Fixed Gendarme's UseStringEmptyRule on ToHtml 
+       method. Fixed string handling on FromHtml method. Fixed all parameter
+       names to match FX.
+
 2006-08-25  Sebastien Pouliot  <[EMAIL PROTECTED]> 
 
        * gdipFunctions.cs: Change ColorMatrix to IntPtr in method 

Modified: trunk/mcs/class/System.Drawing/System.Drawing/ColorConverter.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/ColorConverter.cs     
2006-08-27 22:56:29 UTC (rev 64453)
+++ trunk/mcs/class/System.Drawing/System.Drawing/ColorConverter.cs     
2006-08-27 23:43:01 UTC (rev 64454)
@@ -6,12 +6,8 @@
 //     Ravindra ([EMAIL PROTECTED])
 //
 // Copyright (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
 //
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // "Software"), to deal in the Software without restriction, including
@@ -32,7 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.Collections;
 using System.ComponentModel;
 using System.Globalization;
@@ -106,6 +101,8 @@
                                                ((i & 0xf0) << 8) | ((i & 0xf0) 
<< 4) |
                                                ((i & 0xf) << 4) | (i & 0xf);
                                        result = Color.FromArgb ( -16777216 | i 
);
+                               } else if (s.StartsWith ("#") && (s.Length > 9) 
&& !s.StartsWith ("#0x")) {
+                                       throw new Exception (Locale.GetText 
("{0} isn't a valid color (integer too large).", s));
                                }
                        }
 

Modified: trunk/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs    
2006-08-27 22:56:29 UTC (rev 64453)
+++ trunk/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs    
2006-08-27 23:43:01 UTC (rev 64454)
@@ -1,18 +1,14 @@
 //
 // System.Drawing.ColorTranslator.cs
 //
-// Copyright (C) 2001 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004 Novell, Inc.  http://www.novell.com
-//
 // Authors:
 //     Dennis Hayes ([EMAIL PROTECTED])
 //     Ravindra ([EMAIL PROTECTED])
+//     Sebastien Pouliot  <[EMAIL PROTECTED]>
 //
+// Copyright (C) 2001 Ximian, Inc.  http://www.ximian.com
+// Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
 //
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // "Software"), to deal in the Software without restriction, including
@@ -33,18 +29,22 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
  
-using System;
 using System.ComponentModel;
 
-namespace System.Drawing
-{
-       public sealed class ColorTranslator
-       {
-               private ColorTranslator () { }
+namespace System.Drawing {
 
-               public static Color FromHtml (string HtmlFromColor)
+       public sealed class ColorTranslator {
+
+               private ColorTranslator ()
                {
-                       switch (HtmlFromColor.ToLower()) {
+               }
+
+               public static Color FromHtml (string htmlColor)
+               {
+                       if ((htmlColor == null) || (htmlColor.Length == 0))
+                               return Color.FromArgb (0, 0, 0, 0);
+
+                       switch (htmlColor.ToLower ()) {
                        case "buttonface":
                                return SystemColors.Control;
                        case "captiontext":
@@ -59,15 +59,15 @@
                                return SystemColors.Info;
                        }
                        TypeConverter converter = TypeDescriptor.GetConverter 
(typeof (Color));
-                       return (Color) converter.ConvertFromString 
(HtmlFromColor);
+                       return (Color) converter.ConvertFromString (htmlColor);
                }
 
-               public static Color FromOle (int OleFromColor)
+               public static Color FromOle (int oleColor)
                {
                        // OleColor format is BGR
-                       int R = OleFromColor & 0xFF;
-                       int G = (OleFromColor >> 8) & 0xFF;
-                       int B = (OleFromColor >> 16) & 0xFF;
+                       int R = oleColor & 0xFF;
+                       int G = (oleColor >> 8) & 0xFF;
+                       int B = (oleColor >> 16) & 0xFF;
 
                        Color retcolor = Color.FromArgb (255, R, G, B);
                        foreach (Color c in Color.NamedColors.Values) {
@@ -83,12 +83,12 @@
                        return retcolor;
                }
 
-               public static Color FromWin32 (int Win32FromColor)
+               public static Color FromWin32 (int win32Color)
                {
                        // Win32Color format is BGR
-                       int R = Win32FromColor & 0xFF;
-                       int G = (Win32FromColor >> 8) & 0xFF;
-                       int B = (Win32FromColor >> 16) & 0xFF;
+                       int R = win32Color & 0xFF;
+                       int G = (win32Color >> 8) & 0xFF;
+                       int B = (win32Color >> 16) & 0xFF;
 
                        Color retcolor = Color.FromArgb (255, R, G, B);
                        foreach (Color c in Color.NamedColors.Values) {
@@ -108,7 +108,7 @@
                {
                        KnownColor kc;
                        if (c.IsEmpty)
-                               return "";
+                               return String.Empty;
 
                        string result;
                        if(c.IsSystemColor) {
@@ -183,18 +183,18 @@
                        return result;
                }
 
-               public static int ToOle (Color color)
+               public static int ToOle (Color c)
                {
                        // OleColor format is BGR, same as Win32
 
-                       return  ((color.B << 16) | (color.G << 8) | color.R);
+                       return  ((c.B << 16) | (c.G << 8) | c.R);
                }
 
-               public static int ToWin32 (Color color)
+               public static int ToWin32 (Color c)
                {
                        // Win32Color format is BGR, Same as OleColor
 
-                       return  ((color.B << 16) | (color.G << 8) | color.R);
+                       return  ((c.B << 16) | (c.G << 8) | c.R);
                }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to