All Tutorials / DJ Sures / How To Make An EZ-Builder Plugin

How To Make An EZ-Builder Plugin

4. Create Form

In this step, we will create a graphical screen for your plugin using Windows Forms. This is where we will add the buttons and such which the users will interact with. In this step, we will also show you how to create the override methods necessary to make the Windows Form detected by EZ-Builder as a valid plugin.

1) Right click on your project and select Add -> Windows Form
User-inserted image

2) It does not matter what you call this form, give it any name - however, we will use the name MainForm for simplicity. This form will be your main EZ-Builder Control screen.
User-inserted image

3) Now you should see a blank form on the designer window of Visual Studio.
User-inserted image

4) View the code of the MainForm by expanding it's tree in the Solution Explorer and double clicking the MainForm class as seen in the image below. You may also press F7 to view the code, or right click and select View Code. There's many ways to view the code of the form, use which ever method you feel comfortable with.
User-inserted image

5) The form will inherit the System.Windows.Forms.Form type, which we will change to the EZ-Builder Form type. Notice in the screenshot below that we removed the Form and replaced it with EZ_Builder.UCForms.FormPluginMaster.
User-inserted image

*Note: Only one form in your plugin can inherit the FormPluginMaster. If you create more than one form using the FormPluginMaster, only the first one will be detected and used by EZ-Builder. You can have many forms in your plugin, but only one can be the FormPluginMaster. All other forms must continue to use the default System.Windows.Forms.Form.

6) There are expected methods which your plugin will need to declare for EZ-Builder to properly use the plugin. You can copy the code from here and paste into the project within the MainForm class { and } braces.

Code:


///
/// This method is called by EZ-Builder when it requests the configuration for your plugin.
/// EZ-Builder will request the configuration when the control is created and when the project is saved.
/// The data set in this configuration will be serialized and saved in the EZ-Builder user's project.
/// Custom data may be stored in the STORAGE dictionary.
///
public override EZ_Builder.Config.Sub.PluginV1 GetConfiguration() {

return base.GetConfiguration();
}

///
/// This method is called by EZ-Builder when a project is loaded or when the control is added to a project.
/// Set your default data in here!
/// The configuration from the user's project file will be set using this method.
/// *Note: The plugin must call Base.SetConfiguration(cf) in your override. See the example!
/// Also note that this is a good place to ensure all required configuration data exists.
/// In the case of a newer version of your plugin where different configuration data may be required outside of the users configuration file, set it here.
///
public override void SetConfiguration(EZ_Builder.Config.Sub.PluginV1 cf) {

base.SetConfiguration(cf);
}

///
/// This method is called by EZ-Builder when another control sends a command to this control using the EZ-Script ControlCommand() function.
/// The available ControlCommand() functions for this control should be returned in the GetSupportedControlCommandsMethodsForSlave() override.
///
public override void SendCommand(string windowCommand, params string[] values) {

base.SendCommand(windowCommand, values);
}

///
/// This method is called by EZ-Builder for the Cheat Sheet to receive all available ControlCommand() syntax for this control.
/// When the ControlCommand() is called for this function, see the SendCommand() override.
///
public override object[] GetSupportedControlCommands() {

return base.GetSupportedControlCommands();
}



7) If you have pasted the override code from the previous step into your code, the project should now look like the image below.
User-inserted image

*Note: There are explanation comments for each of the above methods. Reference the open source projects created by DJ Sures by clicking here for more detailed/advanced code examples.