Share via


Requirements for Plug-in Data View Objects (Windows Embedded CE 6.0)

1/6/2010

When designing a plug-in based on the Remote Tools Framework, you can choose to display the associated data in either the default two-column list view that the framework supplies or in a custom view that you implement.

Generic View

The default view is called Generic View. It is a list view that contains two columns, Description and Value. When this view is implemented, the contents are populated by using the OnRenderGeneric method of the plug-in data object. For more information about Generic View, see Remote Tools Framework Native API.

Custom View

To display the plug-in data in other ways, you can design and implement a custom view. You must base your custom view on the PluginDataView class, and build an instance of that class in the OnInit method of your plug-in object.

The following list shows the minimum requirements for a class derived from the PluginDataView class, which is in turn derived from the UserControl class.

  • Ensure that the constructor calls the base class constructor.
  • Create the controls for the view by using the Visual Studio Windows form designer or through code.
    Building controls in the constructor of the view can slow down load time.
    If you want the controls to build as the view is populated with data, override the OnBuildControls method, and place your control-building code there. As an alternative, you can call the InitializeComponent method in the OnBuildControls method if you used the designer.
  • Implement the OnPopulateControls method to fill any child controls with data, such as list views, or to cache data values for later rendering.

Ee503839.collapse(en-US,WinEmbedded.60).gifConstructor

The base constructor must be called with the data object, as shown in the following code example.

public MyView( MyData data) 
    : base ( data )
{
}

Ee503839.collapse(en-US,WinEmbedded.60).gifOnBuildControls

When a control is about to be displayed for the first time, the OnBuildControls method is called on the fly. This method is called once, on the primary UI thread.

This is where you can build any child controls and add them to the view.

The following code example from the SimplePlugin project uses OnBuildControls to create a full-frame list box.

protected override void OnBuildControls()
{
    this.lbStrings = new System.Windows.Forms.ListBox();
    this.lbStrings.Dock = System.Windows.Forms.DockStyle.Fill;
    this.Controls.Add(this.lbStrings);
}

Ee503839.collapse(en-US,WinEmbedded.60).gifOnPopulateControls

When the data changes, the Remote Tools Framework calls the OnPopulateControls method to refresh the view. In addition, you can call OnPopulateControls at any time in the lifetime of the plug-in.

In the sample plug-in, after the list box is filled with the strings in the array from the data object, OnPopulateControls is called on the primary UI thread.

The following code example from the SimplePlugin project casts the Data field to the data type that this view is displaying. The hint parameter is null when the method is called. Your data object can specify a hint when it calls the RenderViews method.

protected override void OnPopulateControls(object hint)
{
    MyData myData = (MyData)this.Data;
    lbStrings.Items.Clear();
    for (int i = 0; i < myData.Strings.Count; i++)
    {
        lbStrings.Items.Add(myData.Strings[i].ToString());
    }
}

See Also

Concepts

General Plug-in Design Requirements