The following procedure contains the required work flow for the creation of a customized common properties form in Microsoft Visual Studio.
-
In Microsoft Visual Studio, create a C# Windows Form Application project.
You must use Microsoft .NET Framework 4.6.2.
-
Add any required references to SPELControls.dll and SpelCustomUIInf.dll
-
Inside the Form1.cs file, add Namespaces, Ingr.Spel.SPELControls, and SpelCustomInf.
-
Set Form1.cs to implement ISPLCustomForm interface.
-
Add required controls to the form.
A Combo box must be of type SPELCombobox.
-
Define a tag for each control with the appropriate name.
The tag name must be the same as the Smart Electrical property name in the Data Dictionary.
-
Set Class Library as an Output type.
-
Build the project.
-
Place the project output .dll in the application bin folder with the SPELCustomForms.xml and SPELCustomForms.xsd files.
Example Code for Creating a Custom Motor Form.
public partial class MotorForm : Form, ISPELCustomForm
{
IFormEngine _formEngine;
public MotorForm()
{
InitializeComponent();
}
public Form CreateForm(string strFormName, IFormEngine objFormEngine)
{
this._formEngine = objFormEngine;
this.Name = strFormName;
return this;
}
// method must be added to a DropDown event for fill the combo
private void comboBox1_DropDown(object sender, EventArgs e)
{
_formEngine.OnDropDown(sender as SPELComboBox);
}
// must be added to SelectedIndexChanged event for select value
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
_formEngine.ValueChange(sender as SPELComboBox);
}
private void comboBox2_DropDown(object sender, EventArgs e)
{
_formEngine.OnDropDown(sender as SPELComboBox);
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
_formEngine.ValueChange(sender as SPELComboBox);
}
// method for textbox value change
private void textBox2_TextChanged(object sender, EventArgs e)
{
_formEngine.ValueChange(sender as TextBox);
}
private void comboBox3_DropDown(object sender, EventArgs e)
{
_formEngine.OnDropDown(sender as SPELComboBox);
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
_formEngine.ValueChange(sender as SPELComboBox);
}
// to save changes to a database
private void button1_Select(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
_formEngine.SaveChanges();
this.Close();
}
// to close the form
private void button2_Select(object sender, EventArgs e)
{
this.Close();
}
}