📄 dotnet-color-list.aspx
字号:
<%@Page Language="C#" %>
<%@Import Namespace="System.Drawing" %>
<script runat="server">
void Page_Load() {
// array to hold list of 168 "known" colors
Color[] aKnownCols = new Color[168];
KnownColor eValue;
for (eValue = 0; eValue <= KnownColor.YellowGreen; eValue++) {
aKnownCols[(int) eValue] = 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> </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(" "));
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;
}
}
// table complete, so insert into page within PlaceHolder control
ctlPlaceholder.Controls.Add(oTable);
}
</script>
<!doctype html public "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<style type="text/css">
body, td, tr, th {font-family:Tahoma,Arial,sans-serif; font-size:10pt}
input, select {font-family:Tahoma,Arial,sans-serif; font-size:9pt}
.heading {font-family:Tahoma,Arial,sans-serif; font-size:14pt; font-weight:bold}
.subhead {font-family:Tahoma,Arial,sans-serif; font-size:12pt; font-weight:bold; padding-bottom:5px}
.cite {font-family:Tahoma,Arial,sans-serif; font-size:8pt}
</style>
<title>.NET Standard Color Names</title>
</head>
<body>
<span class="heading">.NET Standard Color Names</span><p />
<!-- placeholder to hold table of results -->
<asp:PlaceHolder id="ctlPlaceholder" runat="server" />
<hr /><span class="cite">©2002 <a class="cite" href="http://www.daveandal.net/">Dave And Al</a></span>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -