NET Standard Color Names (C#) : Color « Development « ASP.Net

ASP.Net
1. ADO.net Database
2. Ajax
3. Asp Control
4. Collections
5. Components
6. Data Binding
7. Development
8. File Directory
9. HTML Control
10. Language Basics
11. Login Security
12. Mobile Control
13. Network
14. Page
15. Request
16. Response
17. Server
18. Session Cookie
19. Sitemap
20. Theme Style
21. User Control and Master Page
22. Validation by Control
23. Validation by Function
24. WebPart
25. WPF
26. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
ASP.Net » Development » Color 
NET Standard Color Names (C#)

<%--
Pro ASP.NET Web Forms Techniques, Second Edition

By Alex Homer
ISBN: 1-59059-317-0
Published: Dec 2003
Publisher: Apress.com

--%>       
       

<%@Page Language="C#" %>
<%@Import Namespace="System.Drawing" %>
<script runat="server">

void Page_Load() {
  Color[] aKnownCols = new Color[168];
  KnownColor eValue;
  for (eValue = 0; eValue <= KnownColor.YellowGreen; eValue++) {
    aKnownCols[(inteValue= Color.FromKnownColor(eValue);
  }

  // create a table containing the .NET colors
  // declare variables, we'll create 5 rows simultaneously
  TableRow oRow1, oRow2, oRow3, oRow4, oRow5;
  TableCell oCell;
  Color oKnown;
  String sDecimalVals, sHexVals, sKnown;
  int iCellCount = 0;

  // to create empty cell with colored background
  String sColorCell = "<font size=5>&nbsp; &nbsp; &nbsp; &nbsp;</font>";

  // create empty Table object and five Row objects
  Table oTable = new Table();
  oRow1 = new TableRow();
  oRow2 = new TableRow();
  oRow3 = new TableRow();
  oRow4 = new TableRow();
  oRow5 = new TableRow();

  // set horizontal alignment for three rows
  oRow2.HorizontalAlign = HorizontalAlign.Center;
  oRow3.HorizontalAlign = HorizontalAlign.Center;
  oRow4.HorizontalAlign = HorizontalAlign.Center;

  // iterate through array of safe colors
  foreach (Color oColor in aKnownCols) {

    iCellCount += 1;   // increment cell counter

    // create the strings showing decimal and hex RGB values
    sDecimalVals = oColor.R.ToString() "," + oColor.G.ToString()
                 "," + oColor.B.ToString();
    sHexVals = "#" + oColor.R.ToString("x2"+ oColor.G.ToString("x2")
             + oColor.B.ToString("x2");
    sKnown = oColor.Name;

    // create a new cell, and add LiteralControl containing value
    oCell = new TableCell();
    oCell.Controls.Add(new LiteralControl(sColorCell));

    // set properties for this cell, and add to row 1
    oCell.BorderColor = Color.Black;
    oCell.BorderStyle = BorderStyle.Solid;
    oCell.BorderWidth = Unit.Pixel(1);
    oCell.BackColor = oColor;
    oRow1.Cells.Add(oCell);

    // repeat for cells containing decimal, hex and color name values
    oCell = new TableCell();
    oCell.Controls.Add(new LiteralControl(sDecimalVals));
    oRow2.Cells.Add(oCell);
    oCell = new TableCell();
    oCell.Controls.Add(new LiteralControl(sHexVals));
    oRow3.Cells.Add(oCell);
    oCell = new TableCell();
    oCell.Controls.Add(new LiteralControl(sKnown));
    oRow4.Cells.Add(oCell);

    // create cell in row 5 to provide space between color rows
    oCell = new TableCell();
    oCell.Controls.Add(new LiteralControl("&nbsp;"));
    oRow5.Cells.Add(oCell);

    // start a new row every eight values
    if ((int)(iCellCount / 8== ((float)iCellCount / 8)) {
      oTable.Rows.Add(oRow1);
      oTable.Rows.Add(oRow2);
      oTable.Rows.Add(oRow3);
      oTable.Rows.Add(oRow4);
      oTable.Rows.Add(oRow5);
      oRow1 = new TableRow();
      oRow2 = new TableRow();
      oRow3 = new TableRow();
      oRow4 = new TableRow();
      oRow5 = new TableRow();
      oRow2.HorizontalAlign = HorizontalAlign.Center;
      oRow3.HorizontalAlign = HorizontalAlign.Center;
      oRow4.HorizontalAlign = HorizontalAlign.Center;
    }

  }
  ctlPlaceholder.Controls.Add(oTable);

}

</script>
<html>
<head>
<title>.NET Standard Color Names</title>
</head>
<body>
<span class="heading">.NET Standard Color Names</span><p />
<asp:PlaceHolder id="ctlPlaceholder" runat="server" />
</body>
</html>

           
       
Related examples in the same category
1. Create Color object from string (VB.net)
2. Color table (C#)
3. ColorTranslator.FromHtml
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.