You are here: Start » Program Examples » WebHmi Handling Events

WebHmi Handling Events

Aim:

The task of this example is to prepare an application that is based on the WebHMI Event Handling mechanism.

Input:

The program uses images acquired by the TestImage filter.

Output:

The program with the WebHmi that uses event handling on controls:

Hints:

In the following articles, you can find information about designing WebHmi and Event Handling mechanism:

Solution (FIS):

  1. To add a WebHMI subsystem, choose Edit » Add Web HMI... and select a WebHMI template that fits the target layout. The template is just a starting point that can be freely modified. The Titled Picture with controls were used:

  2. Choose stackPanel1, click FAB action button, and choose Add Content... option:

  3. From the WebHMI controls menu, choose ComboBox control.

  4. When ComboBox1 is added, go into properties and modify it:

    • In Items replace options with: Baboon, Lena, Peppers, Plane;
    • Set InitialValue and SelectedValue to 1;
    • Create WebHmi Event handler for SelectedValueChanged named "ChangeDisplayedImage".
  5. Choose stackPanel1 and add Border control. Specify in Properties for border1:

    • BorderStyle to Solid;
    • BorderThickness to 2px;
    • CornerRadius to 10px;
    • BorderBrush color by clicking "3 dots" icon.
  6. Choose border1, click FAB action button, and choose Set Content.... From menu, choose StackPanel.

  7. Choose StackPanel3 and add TextBlock control. In textBlock1 control, change in Properties Text to "Rotate image**.

  8. Choose StackPanel3 and add TablePanel control. For tablePanel2 change in Properties ColumnDefinitions to "200px 100px".

  9. Choose tablePanel2 control and add Slider control. Similarly, add TextBlock control to tablePanel2.

  10. Choose slider1 control and in Properties change:

    • Margin to "2px 10px 0px 10px";
    • Maximum to 359;
    • Create WebHmi Event handler for ValueChanged named "SliderRotateImage".
  11. Choose tablePanel1 and modify ColumnDefinitions to "auto 350px".

  12. Choose Switch1 control and in Properties:

    • Change Text to "Image negation";
    • Attach WebHmi Event handler to Click named "ChangeDisplayedImage".
  13. Choose Switch2 control, click FAB action button, and choose Remove.

  14. Prepare the program with the macrofilters attached below.

  15. Connect the program with the created WebHmi:

    • In UpdateAngleControls macrofilter, connect CopyObject::Real filter output outObject to slider1 control inValue input;
    • In UpdateAngleControls macrofilter, connect FormatRealToString filter output outString to textBlock2 control inText input;
    • In GetComboBoxImage macrofilter, connect VariantImageSelection filter input inImageId to comboBox1 control outSelectedIdentifier output;
    • In DisplayNegatedImage macrofilter, connect MakeConditional::Image filter input inCondition to switch1 control outIsChecked output;
    • In DisplayNegatedImage macrofilter, connect MergeDefault::Image filter output outObject to pictureBox1 control inSource input;
    • In SliderRotateImage event handler, connect UpdateAngleControls filter input inValue and RotateImage filter input inAngle to slider1 control outValue output.

Macrofilter Main.

Macrofilter InitWebHMI

Macrofilter UpdateAngleControls

Macrofilter GetComboBoxImage

Macrofilter DisplayNegatedImage

Event handling macrofilter ChangeDisplayedImage

Event handling macrofilter SliderRotateImage