Product: | Elvis |
Version: | 2.x |
Booth: | 2006-09-04 |
Summary
This article presents a solution to the following problem:
A display is to be implemented that changes the font and background color of a control element (e.g. Analog Output) depending on the ActualValue of a data point. Likewise, the ActualValue of another data point is intended to show or hide the control element.
Details
For the example, an Elvis Analog Output Controls is used (can be linked to any data point). It’s very simple:
- Create the two control data points with the names “ON/OFF” (for color control) and “Visible/Invisible” (for visibility) of the type EIB switch.
- In the example, these two data points are each connected to a state button for testing, but of course the values can also come from the bus.
- Enter the following code in Form Load (“replace AnalogOutput” with the name of the control element to be influenced):
//CODE:vb:' Farben setzen If Database.Datapoint("Ein/Aus").ActualValue = True Then Form.Item("AnalogOutput").Forecolor = 255 Form.Item("AnalogOutput").Backcolor = 655336 Else Form.Item("AnalogOutput").Forecolor = 655336 Form.Item("AnalogOutput").Backcolor = 255 End If ' Sichtbarkeit setzen Form.Item("AnalogOutput").Visible = Database.Datapoint("Sichtbar/Unsichtbar").ActualValue //CODE
- In the Form DatapointChanged, type the following code:
//CODE:vb:If Dp.Name = "Ein/Aus" And prop = "ActualValue" Then ' Farben setzen If DP.ActualValue = True Then Form.Item("AnalogOutput").Forecolor = 255 Form.Item("AnalogOutput").Backcolor = 655336 Else Form.Item("AnalogOutput").Forecolor = 655336 Form.Item("AnalogOutput").Backcolor = 255 End If End If If Dp.Name = "Sichtbar/Unsichtbar" And prop = "ActualValue" Then ' Sichtbarkeit ändern Form.Item("AnalogOutput").Visible = DP.ActualValue ' Bedienseite neu zeichnen Form.Document.Redraw End If//CODE
You have to handle both events so that the correct display is ensured at the beginning (Form_Load) and also after each relevant data point change.
Download the sample project kb050134.zip.