Summary

Add this dll to your project and find "Johnny.AltColorConverter" to use. Use it just the way like System.Drawing.ColorConverter.

Purpose

AltColorConverter is a very simple component that directly inherits System.Drawing.ColorConverter. The only difference between AltColorConverter and ColorConverter is that AltColorConverter rewrites the original ConvertFromString(String) method, which is actually TypeConverter.ConvertFromString(String), to support more string formats, including:
  1. "a, r, g, b" (decimal integer) ex. "255, 0, 0, 0", "127, 44, 88, 132", "255, 255, 255, 255" or "127, 50%, 50%, 50% (V1.1)
  2. "r, g, b" (decimal integer) ex. "0, 0, 0", "44, 88, 132", "255, 255, 255" or "127, 50%, 50% (V1.1) (after conversion, the "a" part will be always set to 255)
  3. "#rrggbb" (hexadecimal) ex. "#000000", "#4488CC", "#FFFFFF" (after conversion, the "a" part will be always set to FF)
  4. "#rgb" (hexadecimal) ex. "#000" (same to "#000000"), "#48C" (same to "#4488CC", "#FFF" (same to "#FFFFFF") (after conversion, the "a" part will be always set to FF)
  5. All other formats (like known colors) that the original method supports

How To Use

(Assume you are using Visual Studio 2010)
  1. Create a C# or VB project
  2. Add AltColorConverter.dll to your project as reference
  3. Use Johnny.AltColorConverter like how you use System.Drawing.ColorConverter

Last edited Mar 10, 2012 at 3:27 PM by johnnykhlee, version 9

Comments

No comments yet.