Reset();
if (ViewState["cursor"] != null)
{
ViewState.Remove("cursor");
}
}
Listing 4-9 presents the complete FancyLabelStyle class.
Listing 4-9. The FancyLabelStyle Class File
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ControlsBook2Lib.Ch04
{
public enum CursorStyle
{
auto,
hand,
crosshair,
help,
move,
text,
wait
}
public class FancyLabelStyle : Style
{
public FancyLabelStyle()
: base()
{
}
public FancyLabelStyle(StateBag ViewState)
: base(ViewState)
{
}
public CursorStyle Cursor
{
get
{
170 CHAPTER 4 ?– T HE WEBCONTROL BASE CLASS AND CONTROL S TYLES
if (ViewState["cursor"] != null)
{
return (CursorStyle)ViewState["cursor"];
}
else
{
return CursorStyle.auto;
}
}
set
{
ViewState["cursor"] = value;
}
}
override public void CopyFrom(Style style)
{
base.CopyFrom(style);
FancyLabelStyle flstyle = style as FancyLabelStyle;
if (flstyle != null)
Cursor = flstyle.Cursor;
}
override public void MergeWith(Style style)
{
base.MergeWith(style);
FancyLabelStyle flstyle = style as FancyLabelStyle;
//Only merge if inbound style is set and current style is not set
if ((flstyle != null) && (!flstyle.IsEmpty) && (IsEmpty))
Cursor = flstyle.Cursor;
}
override public void Reset()
{
base.
Pages:
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265