It also does a cast
to ensure that we are dealing with the correct Style type before copying:
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;
}
The IsEmpty property follows the pattern of the base Style class. Here is the signature of
our version:
protected internal new bool IsEmpty
{
get
{ //Call base class version to get default behavior
return base.IsEmpty && (ViewState["cursor"] == null);
}
}
Note that we don??™t use the override keyword. The base class Style implements this property
with the internal keyword, which prevents us from overriding this property. Instead, we
use the keyword new to provide our custom replacement. We still call the base version of this
method internally, but we also implement custom logic to handle our additional style setting.
The final method we implement is Reset(). This method simply calls the base class version
of Reset and removes the cursor value from ViewState:
CHAPTER 4 ?– THE WEBCONTROL BASE C LASS AND CONTROL STYLES 169
override public void Reset()
{
base.
Pages:
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264