?? 16.9.txt
字號:
Listing 16.9 Gauge Custom Web Control
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using System.Drawing;
namespace _14_CustomWebControl
{
[DefaultProperty(“Text”),
ToolboxData(“<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>”)]
public class WebCustomControl1 : System.Web.UI.WebControls.WebControl
{
private string text;
private int level = 50;
private Color gaugeColor = Color.Red;
public WebCustomControl1()
{
this.Height = 100;
this.Width = 50;
}
[Bindable(true),
Category(“Appearance”),
DefaultValue(“”)]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
public int Percentage
{
get
{
return this.level;
}
set
{
if( value < 0 )
this.level = 0;
else if( value > 100 )
this.level = 100;
else
this.level = value;
}
}
public Color GaugeColor
{
get
{
return gaugeColor;
}
set
{
gaugeColor = value;
}
}
protected override void Render(HtmlTextWriter output)
{
output.Write( “<TABLE cellspacing=’0’ cellpadding=’0’ height=’” +
Height + “‘ width=’” + Width + “‘>” );
output.Write( “<TR height=’” + (100-level).ToString() +
“‘ bgcolor=’” + ColorTranslator.ToHtml( Color.LightGray ) +
“‘><TD/></TR>” );
output.Write( “<TR height=’” + level + “‘ bgcolor=’”
+ ColorTranslator.ToHtml( gaugeColor ) + “‘><TD/></TR>” );
output.Write( “</TABLE>” );
output.Write( text );
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -