
IDesignerFilter Interface for Component Metadata Filtering
The IDesignerFilter interface defines a set of methods that can be overridden and implemented in a designer to alter the properties, events, or attributes exposed by the component managed by the designer at design time.
Each method of the IDesignerFilter interface is prefixed with either "Pre" or "Post". Each method is suffixed with either "Attributes", "Events", or "Properties", depending on which type of member it allows you to add, change, or remove. To add any attributes, events, or properties, use the relevant method whose name begins with "Pre". To change or remove any attributes, events, or properties, use the relevant method whose name begins with "Post". The methods whose names begin with "Pre" are called immediately before the methods whose names begin with "Post".
If you want to add an attribute or attributes, implement an override of the PreFilterAttributes method that adds the new System..::.Attribute to the IDictionary passed to the method. The keys in the dictionary are the type IDs of the attributes. To change or remove an attribute or attributes, implement an override of the PostFilterAttributes method.
If you want to add an event or events, implement an override of the PreFilterEvents method that adds the new EventDescriptor to the IDictionary passed to the method. The keys in the dictionary are the names of the events. To change or remove an event or events, implement an override of the PostFilterEvents method.
If you want to add a property or properties, implement an override of the PreFilterProperties method that adds the new PropertyDescriptor to the IDictionary passed to the method. The keys in the dictionary are the names of the properties. To change or remove a property or properties, implement an override of the PostFilterProperties method.
Note: |
|---|
When a class extends a designer that implements
IDesignerFilter, each PostMethodName method should call the corresponding PostMethodName method of the base class after changing its own attributes, and each PreMethodName method should call the corresponding PreMethodName method of the base class before changing its own attributes.
|
The following code example block shows the method signatures of the IDesignerFilter interface.
Public Interface IDesignerFilter
Sub PostFilterAttributes(attributes As IDictionary)
Sub PostFilterEvents(events As IDictionary)
Sub PostFilterProperties(properties As IDictionary)
Sub PreFilterAttributes(attributes As IDictionary)
Sub PreFilterEvents(events As IDictionary)
Sub PreFilterProperties(properties As IDictionary)
End Interface
public interface IDesignerFilter {
void PostFilterAttributes(IDictionary attributes);
void PostFilterEvents(IDictionary events);
void PostFilterProperties(IDictionary properties);
void PreFilterAttributes(IDictionary attributes);
void PreFilterEvents(IDictionary events);
void PreFilterProperties(IDictionary properties);
}
The following code example demonstrates an implementation of IDesignerFilter that adds a Color property of the designer to the associated component.
Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
Namespace IDesignerFilterSample
_
Public Class DesignerFilterDesigner
Inherits ComponentDesigner
' Designer color property to add to component.
Public Property TestColor() As Color
Get
Return Me.intcolor
End Get
Set(ByVal Value As Color)
Me.intcolor = Value
End Set
End Property
' Color for TestColor property.
Private intcolor As Color = Color.Azure
Public Function DesignerFilterDesigner()
End Function 'DesignerFilterDesigner
' Adds a color property of this designer to the component.
Protected Overrides Sub PreFilterProperties(ByVal properties As System.Collections.IDictionary)
MyBase.PreFilterProperties(properties)
' Adds a test property to the component.
properties.Add("TestColor", TypeDescriptor.CreateProperty(GetType(DesignerFilterDesigner), "TestColor", GetType(System.Drawing.Color), Nothing))
End Sub 'PreFilterProperties
End Class 'DesignerFilterDesigner
' Component with which the DesignerFilterDesigner is associated.
<Designer(GetType(DesignerFilterDesigner))> _
Public Class TestComponent
Inherits Component
Public Function TestComponent()
End Function 'TestComponent
End Class 'TestComponent
End Namespace
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace IDesignerFilterSample
{
public class DesignerFilterDesigner : ComponentDesigner, IDesignerFilter
{
// Designer color property to add to component.
public Color TestColor
{
get
{ return this.intcolor; }
set
{ this.intcolor = value; }
}
// Color for TestColor property.
private Color intcolor = Color.Azure;
public DesignerFilterDesigner()
{}
// Adds a color property of this designer to the component.
protected override void PreFilterProperties(System.Collections.IDictionary properties)
{
base.PreFilterProperties(properties);
// Adds a test property to the component.
properties.Add("TestColor", TypeDescriptor.CreateProperty(typeof(DesignerFilterDesigner), "TestColor", typeof(System.Drawing.Color), null));
}
}
// Component with which the DesignerFilterDesigner is associated.
[Designer(typeof(DesignerFilterDesigner))]
public class TestComponent : Component
{
public TestComponent()
{}
}
}
For an example of a Windows Forms control designer that implements property filtering using the IDesignerFilter interface, see the Windows Forms Designer Sample.