Adding Designer Support
Deprecated
This feature is deprecated and will be removed in a future version.
If your custom metadata requires a complex user interface (anything beyond the simple text edit control provided by the property grid) to edit, you'll need to add designer support. Otherwise, there won't be any way for the user to enter values for properties that make use of your metadata type. To add designer support, you'll need to build an editor for your type or use an existing UITypeEditor. An editor is simply a class that subclasses the .NET System.Drawing.Design.UITypeEditor class.
For example, DropDownEditorProperty is a class that wraps up a string and a boolean value together into a single piece of metadata. To edit this data, it provides a class, DropDownEditorPropertyEditor, which derives from UITypeEditor. The declaration of DropDownEditorProperty is decorated to indicate that this is the editor class that CodeSmith Generator should use in the property grid:
[Editor(typeof(CodeSmith.Samples.DropDownEditorPropertyEditor), typeof(System.Drawing.Design.UITypeEditor))] public class DropDownEditorProperty
In a template, you can use this metadata type just like any other (although you need to remember to reference its assembly, because CodeSmith Generator doesn't know about this type by default):
<%@ Property Name="DropDownEditorProperty" Type="CodeSmith.Samples.DropDownEditorProperty" Category="Options" Description="This property uses a custom dropdown editor." %> <%@ Assembly Name="SampleCustomProperties" %>
When the user wants to edit the DropDownEditProperty and clicks in the property sheet, CodeSmith Generator will display the custom designer:
Using an predefined UITypeEditor
Here is a compiled list of all UITypeEditors that CodeSmith Generator ships with.
Name | Assembly | Obsolete | Description |
---|---|---|---|
CodeSmith.Engine.CodeFileParserPicker | CodeSmith.Engine | Allows you to browse for a CSharp or VisualBasic class file. | |
CodeSmith.Engine.XmlPropertyFilePicker | CodeSmith.Engine | This type editor can be used on a class that supports XML serialization to allow the user to pick an XML file and have that XML file deserialized into the target class. | |
CodeSmith.Engine.XmlSchemaFilePicker | CodeSmith.Engine | Allows you to browse for an XSD Schema. | |
CodeSmith.CustomProperties.AssemblyFilePicker | CodeSmith.CustomProperties | Allows you to browse for an assembly. | |
CodeSmith.CustomProperties.FileNameEditor | CodeSmith.CustomProperties | Allows you to browse for a file. | |
CodeSmith.CustomProperties.NameValueCollectionEditor | CodeSmith.CustomProperties | YES | Allows you to quickly edit an NameValueCollection. |
CodeSmith.CustomProperties.StringCollectionEditor | CodeSmith.CustomProperties | YES | Allows you quickly edit a string collection. |
CodeSmith.CustomProperties.XmlSerializedFilePicker | CodeSmith.CustomProperties | Allows you to browse for an Xml file. |
Please note that you will need to add the following Assembly Directive for any UITypeEditor listed above that is defined in the CodeSmith.CustomProperties assembly.
<%@ Assembly Name="CodeSmith.CustomProperties" %>