public class
AControlDesigner : ControlDesigner
{
public
AControlDesigner()
{
}
protected
override void
PreFilterProperties(System.Collections.IDictionary properties)
{
base.PreFilterProperties(properties);
//Remove
the BackColor property from the list of available properties.
properties.Remove("BackColor");
}
protected
override void
PostFilterProperties(System.Collections.IDictionary properties)
{
base.PostFilterProperties
(properties);
//The
properties that would cause the control to cease functioning
//in
the designer must be replaced with harmless copies.
//EnableTimeout
is replaced with the designers harmless one
properties["EnableTimeout"]=TypeDescriptor.CreateProperty(
typeof(AControlDesigner),
(PropertyDescriptor)properties["EnableTimeout"],
new
Attribute[0]);
//UsableTime
is also replaced
properties["UsableTime"]=TypeDescriptor.CreateProperty(
typeof(AControlDesigner),
(PropertyDescriptor)properties["UsableTime"],
new
Attribute[0]);
}
public
TimeSpan UsableTime
{
get
{
return
(TimeSpan)ShadowProperties["UsableTime"];
}
set
{
ShadowProperties["UsableTime"]=value;
}
}
public
bool EnableTimeout
{
get
{
return
(bool)ShadowProperties["EnableTimeout"];
}
set
{
ShadowProperties["EnableTimeout"]=
value;
}
}
public
override void
Initialize(IComponent component)
{
base.Initialize
(component);
AControl
c = component as AControl;
if
(component==null)
throw
new ArgumentException();
ShadowProperties["UsableTime"]=c.UsableTime;
ShadowProperties["EnableTimeout"]=c.EnableTimeout;
c.EnableTimeout=false;
c.UsableTime=new
TimeSpan(0,0,0,0,0);
}
}
Public Class
AControlDesigner
Inherits
ControlDesigner
Public
Sub New()
End
Sub 'New
Protected
Overrides Sub
PreFilterProperties(ByVal properties
As System.Collections.IDictionary)
MyBase.PreFilterProperties(properties)
'Remove
the BackColor property from the list of available properties.
properties.Remove("BackColor")
End
Sub 'PreFilterProperties
Protected
Overrides Sub
PostFilterProperties(ByVal properties
As System.Collections.IDictionary)
MyBase.PostFilterProperties(properties)
'The
properties that would cause the control to cease functioning
'in
the designer must be replaced with harmless copies.
'EnableTimeout
is replaced with the designers harmless one
properties("EnableTimeout")
= TypeDescriptor.CreateProperty(GetType(AControlDesigner),
CType(properties("EnableTimeout"),
PropertyDescriptor), New Attribute(-1) {})
'UsableTime
is also replaced
properties("UsableTime")
= TypeDescriptor.CreateProperty(GetType(AControlDesigner),
CType(properties("UsableTime"),
PropertyDescriptor), New Attribute(-1) {})
End
Sub 'PostFilterProperties
Public
Property UsableTime()
As TimeSpan
Get
Return
CType(ShadowProperties("UsableTime"), TimeSpan)
End
Get
Set(ByVal
Value As TimeSpan)
ShadowProperties("UsableTime")
= Value
End
Set
End
Property
Public
Property EnableTimeout()
As Boolean
Get
Return
CBool(ShadowProperties("EnableTimeout"))
End
Get
Set(ByVal
Value As Boolean)
ShadowProperties("EnableTimeout")
= Value
End
Set
End
Property
Public
Overrides Sub
Initialize(ByVal component
As IComponent)
MyBase.Initialize(component)
If
component Is Nothing
Then
Throw
New ArgumentException
End
If
Dim
c As AControl =
DirectCast(component, AControl) '
ShadowProperties("UsableTime")
= c.UsableTime
ShadowProperties("EnableTimeout")
= c.EnableTimeout
c.EnableTimeout
= False
c.UsableTime
= New TimeSpan(0, 0, 0, 0, 0)
End
Sub 'Initialize
End Class
'AControlDesigner