omron — Controlling the User Interface through Scripts

Controlling the User Interface through Scripts Controlling the User Interface through Scripts As you are creating your custom UI, you can customize various elements, for example, change the back- ground color on the base form, through a C# client-side script. The UI Form designer provides a built-in C# code editor for creating and editing the client-side scripts. NOTE: This feature requires a special license. For details, see Licensing Requirements on page 28. The UI Form designer code editor is similar in look and function to the ACE C# program editor.

However, the scripts created in the UI Form designer code editor are client-side scripts; the scripts created in the C# program editor are server-side scripts. For more details on the C# program editor, see C# Language Pro- gramming on page 750. All of the tools in the UI Form designer Toolbox are available to C# scripts in the UI Form designer code editor. The properties available to scripts will vary, depending on the particular tool. For details: l Use the IntelliSense information in the script editor, and l Refer to the System.Windows.Forms namespace in the MSDN library:

http://msdn.microsoft.com/en-us/library/system.windows.forms.aspx The following example describes how to change the background color of the base form through a C# client- side script. 1. Create a User Interface Form object in your ACE workspace. For details, see Controlling the User Interface through Scripts on page 1087. 2. In the Designer view, double-click the base form to open the Source code editor and position the cursor at the UIBuilderForm1_Load method (the event handler for the load event of the base form). For more details, see Viewing the Events for a Tool on page 1013. 3. In the C# code editor, add the following C# snippet:

// Set the background color of the base form to red this.BackColor = System.Drawing.Color.Red; The completed code on the Source page will look like the following: NOTES : l Line numbers are added for reference; do not type them into your script. l Line 15 is an optional comment. l Line 16 is the code that changes the background color. 1. using Ace.Core.Server; 2. using System; 3. using System.Collections.Generic; 4. using System.Diagnostics; 5. using System.Windows.Forms; 6. 7. namespace Ace.Custom { 8. ACE User's Guide, 3.6.x, 18316-000 Rev A Page 1087