Generate a Color table for all static predefined members of the Color class.
Const long CELLS_PER_LINE = 10; const float MARGIN = 12; const float CELL_WIDTH = 160; const float CELL_HEIGHT = 64; const float COLOR_LEFT_MARGIN = 8; const float COLOR_TOP_MARGIN = 8; const float COLOR_CELL_WIDTH = 48; const float COLOR_CELL_HEIGHT = 32; const float TEXT_TOP_MARGIN = COLOR_TOP_MARGIN + COLOR_CELL_HEIGHT + 2; List <Color> vColors = new List <Color> (); type t = typeof (Color); PropertyInfo [] vProps = t. getProperties (); foreach (PropertyInfo propInfo in vProps) {if (MemberTypes. property = propInfo. memberType & typeof (Color) = propInfo. propertyType) {Color tmpColor = (Color) propInfo. getValue (null, null); vColors. add (tmpColor) ;}} Bitmap BMP color = new Bitmap (int) (CELLS_PER_LINE * CELL_WIDTH + MARGIN * 2), (int) (vColors. count/CELLS_PER_LINE + 1) * CELL_HEIGHT + MARGIN * 2); using (Graphics grp = Graphics. fromImage (BMP color) {grp. clear (Color. black); for (int I = 0; I <vColors. count; I ++) {float nLeftBase = MARGIN + I % CELLS_PER_LINE * CELL_WIDTH; float nTopBase = MARGIN + I/CELLS_PER_LINE * CELL_HEIGHT; grp. drawRectangle (new Pen (Color. white), nLeftBase, nTopBase, CELL_WIDTH, CELL_HEIGHT); grp. fillRectangle (new SolidBrush (vColors [I]), nLeftBase + COLOR_LEFT_MARGIN, nTopBase + COLOR_TOP_MARGIN, COLOR_CELL_WIDTH, COLOR_CELL_HEIGHT); grp. drawString (vColors [I]. name, new Font ("", 9, FontStyle. regular), new SolidBrush (Color. white), nLeftBase + COLOR_LEFT_MARGIN, nTopBase + TEXT_TOP_MARGIN) ;}} BMP color. save (@ "D: \ AllColor.bmp ");
Generate results