Click or drag to resize

UI & Options

UI & Options

Scripts can present a configuration UI to the user by defining a class that extends ScriptOptions. Each public property becomes a configurable option in the ReadySuite property grid. Use attributes to control how properties are displayed, grouped, and validated.

Setting Up Options

Define a class that inherits from ScriptOptions, then override LoadOptions() in your script to wire it up:

C#
public class MyOptions : ScriptOptions
{
    public MyOptions()
    {
        // Set default values in the constructor
        Enabled = true;
        MaxItems = 100;
    }

    [Category("Settings")]
    [Description("Enable processing.")]
    public bool Enabled { get; set; }

    [Category("Settings")]
    [Description("Maximum number of items to process.")]
    public int MaxItems { get; set; }
}

public override void LoadOptions()
{
    Options = new MyOptions();
}
Layout and Display Attributes
AttributePurpose
[Category("...")]Groups properties under a collapsible heading in the property grid
[Description("...")]Tooltip text shown when the property is selected
[DisplayName("...")]Overrides the property name shown in the UI
C#
[Category("Output Fields")]
[DisplayName("PDF Portfolio")]
[Description("Field indicating whether the source is a PDF portfolio.")]
public FieldItem IsPdfPortfolioField { get; set; }
Field Pickers

Use FieldItem as a property type to present a field picker. The [FieldItem] attribute controls the picker behavior:

ParameterPurpose
AllowNewAllow the user to create a new field
AllowNullAllow no selection (optional field)
AllowSystemFieldsInclude system fields in the picker
TypesRestrict to specific FieldItemType values
C#
// Required text field picker that allows creating new fields
[Category("Output")]
[Required(ErrorMessage = "Output field is required.")]
[FieldItem(AllowNew = true, AllowSystemFields = false, AllowNull = false, Types = new[] { FieldItemType.Text })]
public FieldItem OutputField { get; set; }

// Optional boolean field picker (read-only selection from existing fields)
[Category("Input")]
[FieldItem(AllowNew = false, AllowNull = true, Types = new[] { FieldItemType.Boolean })]
public FieldItem FlagField { get; set; }

Use List<FieldItem> when the user needs to select multiple fields:

C#
[Category("Input")]
[Description("Fields to include in the export.")]
[NotNullOrEmptyCollection(ErrorMessage = "At least one field is required.")]
[FieldItem(Types = new[] { FieldItemType.Text, FieldItemType.Memo })]
public List<FieldItem> InputFields { get; set; }

Any enum property automatically renders as a dropdown. Use [Description] attributes on enum members for display-friendly names:

C#
public enum OutputMode
{
    [Description("Write to field")] Field,
    [Description("Write to file")] File,
    [Description("Write to field and file")] Both
}

[Category("Settings")]
[Description("Select where the output is written.")]
public OutputMode Mode { get; set; }

For multi-select scenarios, use a [Flags] enum:

C#
[Flags]
public enum ReportTypes
{
    None = 0,
    Summary = 1,
    Details = 2,
    Errors = 4
}
File and Folder Browsers

Use editor attributes to provide browse dialogs for path properties:

C#
// Folder browser
[Category("Output")]
[Description("Folder where files will be saved.")]
[Editor(typeof(FolderPathEditor), typeof(UITypeEditor))]
public string OutputFolder { get; set; }

// File open browser
[Category("Input")]
[Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
public string InputFile { get; set; }

// File save browser
[Category("Output")]
[Editor(typeof(SaveFileNameEditor), typeof(UITypeEditor))]
public string ReportFile { get; set; }

The DateFormatEditor provides a specialized picker for date format strings:

C#
[Category("Settings")]
[Editor("Compiled.EDD.Scripting.UI.DateFormatEditor, Compiled.EDD.Scripting.UI", typeof(System.Drawing.Design.UITypeEditor))]
public string DateTimeFormat { get; set; }
Validation

Use validation attributes to enforce requirements before the script runs:

C#
// Always required
[Required(ErrorMessage = "Body field is required.")]
public FieldItem Body { get; set; }

// Required only when another property has a specific value
[RequiredIf("Mode", OutputMode.File, ErrorMessage = "Output folder is required when writing to file.")]
public string OutputFolder { get; set; }

// Required when a bool is true
[RequiredIf("Truncate", true, ErrorMessage = "Max length must be set when truncation is enabled.")]
public int MaxLength { get; set; }

// Collection must have at least one item
[NotNullOrEmptyCollection(ErrorMessage = "At least one field must be selected.")]
public List<FieldItem> Fields { get; set; }
String Lists

Use List<string> for properties where the user enters multiple string values. These render as a line-based editor:

C#
[Category("Settings")]
[Description("File extensions to include.")]
[NotNullOrEmptyCollection(AllowNullOrWhiteSpaceStrings = false, ErrorMessage = "At least one extension is required.")]
public List<string> Extensions { get; set; }
Supported Property Types
TypeUI Control
boolCheckbox
stringText box
int, long, float, double, decimalNumeric text box
charSingle character text box
DateTimeDate/time picker
FieldItemField picker dropdown
List<FieldItem>Multi-field picker
List<string>Line-based string editor
List<FindAndReplaceItem>Find-and-replace grid editor
enumDropdown selector
[Flags] enumMulti-select dropdown

Other primitive types render with the property grid's default editor. To customize how a property is displayed — file or folder browsers, custom pickers, etc. — apply an [Editor] attribute as shown in File and Folder Browsers.