- private static Hashtable GetColorHashtableFromType (Type type)
- {
- Hashtable colorHash = new Hashtable (CaseInsensitiveHashCodeProvider.Default,
- CaseInsensitiveComparer.Default);
-
- PropertyInfo [] props = type.GetProperties ();
- foreach (PropertyInfo prop in props){
- if (prop.PropertyType != typeof (Color))
- continue;
-
- MethodInfo getget = prop.GetGetMethod ();
- if (getget == null || getget.IsStatic == false)
- continue;
-
- object o = prop.GetValue (null, null);
- colorHash.Add (prop.Name, o);
-
- Color c = (Color) o;
- knownColors [(int) c.knownColor] = c;
- }
- return colorHash;
- }
-
- private static void FillColorNames ()
- {
- lock (creatingColorNames) {
- if (systemColors != null)
- return;
-
-#if NET_2_0
- knownColors = new Color [(int)KnownColor.MenuHighlight + 1];
-#else
- knownColors = new Color [(int)KnownColor.YellowGreen + 1];
-#endif
- Hashtable colorHash = GetColorHashtableFromType (typeof (Color));
- namedColors = colorHash;
-
- colorHash = GetColorHashtableFromType (typeof (SystemColors));
- systemColors = colorHash;
- }
- }
-
- internal static void UpdateKnownColor (int alpha, int red, int green, int blue, string name, KnownColor known_color) {
- FillColorNames ();
- knownColors[(int)known_color] = Color.FromArgbSystem(alpha, red, green, blue, name, known_color);
- }
-