In Depth Banner
Skip Navigation Links

Select your preferred language

The designer in its entirety.

  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);

    }

  }

 

Return to the article. 

Copyright © Bob Powell 2003-2009. All rights reserved