Extend the base form

Procedure

  1. In Visual Studio, create a new VB project form using the WPF User Control Library or Class Library project templates.
    Note: If you are creating a form based on WinForms, use the "User Windows Forms Control Library" (which is called "Windows Control Library" in Visual Studio 2005) or "Class Library" project templates.
  2. Delete the Class1.vb file from the project.
  3. Add a new WPF user control to the project using the "User Control (WPF)" file template.
    Note: If you are creating a form based on WinForms, use the "User Control" file template.
  4. In the References section of the project, browse to the Program folder of the Workflow installation directory and add references to the following:
    • Proficy.Platform.Core.DisplayFramework.dll
    • Proficy.Platform.Core.ProficySystem.dll
    • Proficy.Platform.Samples.Forms.Baseform.dll
    If you are using WPF, add the following .NET references if they are not already added to your project:
    • PresentationCore
    • PresentationFramework
    • WindowsBase
    If you are using WinForms, add the following .NET reference if it is not already added to your project:
    • System.Windows.Forms
  5. Add the following imports to include these classes in your project.
    • System
    • System.Collections.Generic
    • System.Windows
    • System.Windows.Controls
    • Proficy.Platform.Samples.Forms.Base
    These imports are required in order to resolve the types used by BaseForm.
    Note: If you are creating a form based on WinForms rather than WPF, you should import System.Windows.Controls instead of System.Windows.Forms. The other imports mentioned above remain the same.
  6. Change the class to inherit from the BaseForm; that is, change the .vb file to contain the following Inherits statement:
    Public Class UserControl1

    Inherits Proficy.Platform.Samples.Forms.Base.BaseForm

    You must also modify the .xaml.vb file to derive from that class, as well, by adding the namespace of the BaseForm and changing the beginning and ending tags to use it. When you are finished, the .xaml file should look as follows:
    <base:BaseForm x:Class="UserControl1"
    xmlns:base="clr-namespace:Proficy.Platform.Samples.Forms.Base;assembly=Proficy.Platform.Samples.Forms.BaseForm"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="300" Height="300">
        <Grid>        
        </Grid>
    </base:BaseForm>
    
    Note: If you are creating a form based on WinForms, then your form should inherit from BaseFormVB.Proficy.Platform.Samples.Forms.Base.VB.BaseFormVB.
    An error displays because the other partial class does not have the same Inherits line.

    Press Shift+Alt+PF10, click the red underscore below BaseFormVB, and then select the Change class "UserControl1" to inherit from "BaseFormVB.Proficy.Platform.Samples.Forms.Base.VB.BaseFormVB" link. The Inherits line is added to the partial class.

    Note: Do not give your class a namespace.
  7. Switch to the Designer View and create the user interface elements for the form, such as text boxes, labels, and list boxes.
    Note: If you are creating a form based on WinForms, set the Autosize property on the user control to True. This allows the form to automatically size to the window pane size in the Task List.
  8. Switch to the Code View and paste in Regions code for Private Variables, InputParameters, OutputParameters, and Overrides. There are three functions in the Overrides region:
    • TransferDataIn: This function gets called prior to displaying the form. It allows for the transfer of data from the input parameters into the display components.
    • ValidateForm: This function gets called to validate the form prior to attempting to return parameters. This function gets called before TransferDataOut.
    • TransferDataOut: This function gets called prior to returning the outputs from the form. It allows for the transfer of data from the display components and the setting the output fields.
    For more information, see Overriding the Base Form Methods and Declaring Parameters.
  9. Build the project.
  10. When the project builds successfully into a DLL, add it to Workflow as a new form. See Add pre-existing forms and user displays to Workflow.