|Version:||from 2.0 (example project created with 2.3)|
Here you will find information and downloads for graphical elements that are moved or changed by the event processing of the operator station.
Attention: No control elements are changed here, but “normal” graphical elements such as lines or polygons. So this area is not intended for solving standard tasks or even for a beginner in Elvis, but for the Elvis professionals or for programmers who want to bring even more dynamism to the pages.
Download the small dynamic.zip project, open the “blind” page in the configuration and play with the slider (user mode!). The “polygon” page also contains an interesting effect.
A nice touch? You want to know how it works? Read on!
Access to graphic elements
All properties of graphical elements can be changed via the event processing of the operator station – yes, really!
Initially, the difficulty lies only in the access to the element. Unfortunately, the elements do not have a name (such as the control elements). However, all elements have a data point name (DatapointName). [Bitte keine Kommentare dazu – ich kann das auch nicht nachvollziehen.]
We can make good use of the data point name.
Unfortunately, there is no user interface for setting or changing this data point name for the graphical elements (is not included in the properties dialog). Workaround: we use a small macro to give the element a data point name. With that, we have already cleared all the hurdles for access!
Dynamically change the fill type of a polygon
The macro sets the data point name for a selected graphical element (e.g. a polygon). It has a fairly simple structure. The program actually contains only two interesting lines:
Here, the object “Element” is set to the selected element of the drawing:
Set Element = Drawing.ActiveElement
and here the data point name from the dialog is stored in the “DatapointName” property of the element:
Element.DatapointName = dlg.ctlDatapointName
Change the fill type of a polygon using data point values
If you want to set the fill effect of polygons over data point values, there are some events to process. Here you will find a small example that sets the fill effect via data point values and is thus better adapted to the use in a project.
Now let’s change the graphic element. To do this, we must first find it on a page and then modify one or more of its properties. In order for us to be able to find an element, it has been given a data point name (see above).
Finding should be as fast as possible. That’s why it’s good if we don’t have to do the search in the whole document (i.e. in all layers), but can limit ourselves to one layer. Of course, if there are only a few elements in this layer, the search will be even faster.
Conclusion: We use a separate layer for our dynamic elements. We call this layer “dynamics” (of course, any other name can be used – this must of course be taken into account in event processing).
In order to keep the event processing clear, we use a subroutine that we put in the global area of the form. The subroutine should be called “SetFillStyle” because we use it to switch the fill of the element between filled and unfilled. It has two parameters: the data point name and the value. The subroutine finds all elements of the Dynamic layer whose data point name matches the passed name and sets their FillStyle to 1 if the value is not null, otherwise the FillStyle is set to 0.
The program is included in the sample project (polygon page).
Increase: Rotate line
If we have understood the fundamentals of changing properties of graphical elements (polygon), we can venture into a somewhat larger task.
The slat position of blinds can be graphically represented by lines. The coordinates of the lines must be calculated for the respective control value. The mathematical basics are included on the “blind” page.
The peculiarity of the solution is the storage of the coordinates of the center. This is necessary so that the line is always drawn in one and the same place and retains its position even after many calculations. In addition, the length of the line is also saved. Because there are no properties for this data, the coordinates of the center and longitude are stored together in the HistoryName property. That’s a bit of a messy use of this property. However, since the property is meaningless for graphic elements, we shouldn’t have any problems with it.
To make it easy to set the data point name, midpoint, and longitude, I’ve provided a small macro here as well:
For event processing, we again use a subroutine (“blind”). In principle, the program is structured as above (SetFillStyle), but now the data from the HistoryName is also used to calculate and reset the coordinates of the line.
You shouldn’t have any trouble transferring the examples to the use of data point values. If there are any questions here, please contact the webmaster.
Here’s an increase in the whole thing! The macro set_blinds automatically generates the slats (lines) and connects them to the data point.
The result then looks like this, for example: