Often, a Customizer works as a user-friendly user interface to one or more expert properties. For example, the Easy Chart Customizer modifies the contents of the pens, tagPens, calcPens, axes, and subplot dataset properties. This means you can also use Property Bindings and scripting to modify the values of these expert properties at runtime, giving you the ability to dynamically perform complex manipulations of components.
Configuring the Style Customizer
Some components have styles already set up and others do not. The following example involves a Cylindrical Tank component that already has a styles defined. This example shows you how to change styles using the Style Customizer for the Cylindrical Tank.
- Drag in a Cylindrical tank from the component palette on to your window.
- Right click on the Cylindrical Tank component and scroll down to Customizers > Style Customizer. There are four driving properties that can have styles configured: Capacity, Data Quality, Value, and Visible.
For this example, click on Capacity > Liquid Color and then the Add Property icon. Repeat this step for the Show Value and Tank Color Properties.
Next under Styles, click the Addicon.
Click the Expandicon to see the color palette for the Liquid Color.
- Choose a color from the palette. Repeat this step for the Show Value and Tank Color Properties.
- Then click the OK to save your updates.
In this example, we have a Level Indicator component that is displaying the level in a tank. Let's say that you want to have its appearance change based on the alarm state of the tank's temperature. We'll do this using a custom property.
- In the Vision window, right click on the component and choose Custom Properties.
- Click the Add icon.
- Name the new property Severity and set it to an Integer type. Click OK.
- Right click on the component and choose Style Customizer.
- Choose your Severity property as the driving property, and the Border and Filled Color properties as the styled properties.
- Under Styles, click the Add icon three times
- Now create three styles for the three alarm states you want to show. For the first style, enter a value of -1 (not an alarm) and don't change anything else.
- For the second, enter a value of 2 (medium alarm). Set the filled color to orange.
- For the third style, enter a Value of 4 (high alarm).
- Click the Expand icon.
- Select the Animate checkbox.
- Click the Add icon.
- Set the StepDuration to 500 for both frames.
- For the first frame set the FilledColor to red.
- For the second frame, set the FilledColor to yellow.
- Click OK. Notice that the styled properties you chose are now bold and have the Styles
- In the Property Editor, click on the Binding property.
- Now, when the alarm state for the tank's temperature changes, the color of the appearance of the indicator will change based on the settings in the Style Customizer. In this image, the indicator flashes red and yellow because the high alarm was triggered.
Let's look at another example that uses the Custom Properties and the Styles feature together. For example, the Label component seems pretty plain at first: it just displays a string. You can use its foreground color, background color, and border to make it look interesting.
- Drag a Label component onto a window.
- Rght click on the Label component and choose Custom Properties.
- Click the Add icon.
- Name the new property State and set it to an Integer type. Click OK.
- Bind that property to a discrete state Tag coming out of a PLC.
- Next use the State property to drive its Styles configuration to make the component look different and display different text based on the state being 0, 1, or 2 (maybe for a Hand/Off/Auto indicator).
We could have used the Multi-State Indicator component from the very beginning, but understanding this example will let you create your own types of components by combining the existing components in creative ways.
Some components like the Easy Chart, Table, Power Table, Tab Strip, Multi-State Button, and Multi-State Indicator have default styles already set up, but you can modify them however you like. If you don't like the default styles, change them. They are there to simply help you get started.
You can bind a property that is already being used by a style, but a warning icon will appear on the property, and the property name turns red in the In the Property Editor. This means there is a conflict between the binding on the property, and the style on the component. As a general practice, only the style or binding should write to the property, not both.