Share via


How to: Implement a Template Class Factory

To add your wizard to the appropriate template selection dialog box in PerformancePoint Dashboard Designer, your class must follow the design pattern of a template class factory from the Microsoft.PerformancePoint.Scorecards.ModelerPlugins DLL. Your class can inherit from the TemplateFactory class or from the template class factory that is associated with the type of object that your extension creates.

Note

Custom filters must inherit from the ParameterTemplateFactory class, not TemplateFactory.

The following table lists each type of dashboard object and its associated template class factory. You can use each template class factory to create multiple custom templates. For example, use ReportViewTemplateFactory to create templates for multiple custom report view types.

Type of Dashboard Object Template Class Factory

Dashboard

DashboardTemplateFactory

Data Source

DataSourceTemplateFactory

Filter

ParameterTemplateFactory

Indicator

IndicatorTemplateFactory

KPI

KpiTemplateFactory

Report

ReportViewTemplateFactory

Scorecard

ScorecardTemplateFactory

Key methods in a template class factory

When you implement a template class factory, you must override the following methods.

Method Description

CreateTemplateItem

Creates an object by using the specified template. (For an example, see Implementing CreateTemplateItem.)

To create a filter template, use the CreateParameter method in the ParameterTemplateFactory class instead of CreateTemplateItem.

GetTemplateItems

Gets available templates for the wizard. (For an example, see Implementing GetTemplateItems.)

GetTemplateType

Gets the class type for the template.

GetTemplateTypeId

Gets the identifier for the factory class.

The code examples that follow show the use of the Implementing CreateTemplateItem method and Implementing GetTemplateItems method.

Implementing CreateTemplateItem

The following code example opens a wizard that creates a data source and then adds the new data source to the workspace.

// Open the type of wizard template specified by the "item" parameter.
// Users invoke the CreateTemplateItem method by selecting
// the template type in a template selection dialog box.
public override void CreateTemplateItem(TemplateItem item)
{
    if (item.TemplateId == "CustomDataSource")
    {

        WizardForm form = new WizardForm();
        form.Title = "Create the custom data source";
        form.Icon = MainForm.GetInstance().Icon;
        CreateElementWizardPage pageElement = new CreateElementWizardPage(form, typeof(DataSource));

        // Change the image name to reference your custom image.
        pageElement.Logo = Properties.Resources.ImageCustomDataSource;
        pageElement.Headline = "Create the custom data source";
        pageElement.StepTitle = "Name the data source";

        // Add a WizardPage to your wizard form.
        form.AddPage(pageElement);
        form.Start(MainForm.GetInstance());
        if (form.DialogResult == DialogResult.OK)
        {
            DataSource dataSource = new DataSource();
            dataSource.Guid = Guid.NewGuid();
            dataSource.CreatedDate = DateTime.Now;
            dataSource.SourceName = "CustomDataSourceName";
            pageElement.SetElement(dataSource);

            // Add the template item (data source) to the workspace.
            GeneralUtilities.AddToWorkspace(dataSource, true);
        }
        form.Dispose();
    }

Implementing GetTemplateItems

The GetTemplateItems method returns the list of template items to display in the template selection dialog box. The following code example creates a list that contains one available template item.

public override List<TemplateItem> GetTemplateItems()
{
    List<TemplateItem> items = new List<TemplateItem>();
    TemplateItem item1 = new TemplateItem();

    // Set the display name and category for the template item.
    item1.Name = "Custom Data Source";
    item1.Folder = @"All\Internal";

    // Set the description and image to display in the template selection dialog box. 
    // Change the image name to reference your custom image.
    item1.Description = "Load data from a custom data source.";
    item1.Image = Properties.Resources.ImageCustomDataSource;

    // Get the ID string that identifies the template.
    item1.TemplateTypeId = GetTemplateTypeId();
    items.Add(item1);
    return items;
}

See Also

Tasks

How to: Implement the DataSourceTemplateFactory Class
How to: Install a Wizard Template

Other Resources

Wizard Templates