?? colorchain.cs
字號(hào):
using System;
using System.Collections ;
using System.Drawing ;
using System.Windows.Forms ;
namespace Chain
{
/// <summary>
/// receives color names in chain
/// </summary>
public class ColorChain : Chain {
private Hashtable colHash; //color list kept here
private Panel panel; //color goes here
//-----
public ColorChain(Panel pnl) {
panel = pnl; //save reference
//create Hash table to correlate color names
//with actual Color objects
colHash = new Hashtable ();
colHash.Add ("red", Color.Red);
colHash.Add ("green", Color.Green);
colHash.Add ("blue", Color.Blue);
}
//-----
public override void sendToChain(string mesg) {
mesg = mesg.ToLower ();
try {
Color c = (Color)colHash[mesg];
//if this is a color, put it in the panel
panel.BackColor =c;
}
catch (NullReferenceException e) {
//send on if this doesn't work
sendChain(mesg);
}
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -