527 views
in GUI Development by

Hi,

I have this window below. There are a few things I am trying to do. 

1) As the user enters a numbers I would like to dynamically move the horizontal bar to correspond to the number that was put in (minimum 0, maximum 2000). So if the user puts in the value "1" first then it would calculate 1/2000*100 and the green bar would move accordingly, then user would type "0" and now the value is "10" so it would calculate 10/2000*1000 for the green bar and so on. When the value comes out of the texteditor it is a string, is there a way to convert it to a float and do these calculations? 

2) Once the value is entered and the green checkbox is selected I would like this number to go into the top left square and replace the value "1000". How can this be done? I am finding it challenging to pass variables between dialogs and what is the best way to do this?

Thanks!

 

1 Answer

0 votes
by

Hello,

regarding your first question, the conversion is perfomed by using one of the built-in parse functions.

Regarding the data exchange between dialogs, you can:

option 1: call from dialog A a method of dialog B and so pass a value to it. The method have to be provided in dialog B.

option 2: from dialog A assign a value to a property of dialog B. The property has to be provided in dialog B.

See also the section Implementing component interface.

More sophisticated:

option 3: use a separate global autoobject to maintain all values. The diverse dialogs can access/share this object easily. For example, in the common object you could have an integer property named Voltage. Then you can connect the Horizontal Value Bar to this property directly. It serves as data provider. To trigger the Horizintal Bar upodate, you needs to 'notify' the change of the property. You do this by using the statement notifyobservers. With a Property Observer you can additionally implement methods to react to the alternation of a property.

Best regards

Paul Banach

by
Thank you Paul for your answers. I've got the parse_float working properly. Is there a way when the horizontal bar goes over the max value that it can turn red? Haven't been able to find this property for the HorizontalValueBar.

Also, since there will be many values that will be saved and they will need to be accessed throughout the application I am looking at the option 3 you mentioned with using a separate global autoobject. I am looking at the Menu example that is provided with the Embedded Wizard app, where the picture and sound properties are within the global autoobject Controller. Is this the best example to look at for option 3? If so, can you point me to a detailed description of what needs to be done to make this work?

Thanks.
by

In such case I would recommend you as first to create two configuration objects for your horizontal value bar. The default configuration object is fix preconfigured with the green images so it can't change the colors. Please se the section: Customize your own Horizontal Value Bar.

The idea here: you provide one configuration object for a green slider and a second fro red slider. Then when you change the current value of the value bar you additionally test whether the value is above/below some threshold. Depending on the result of thios test you modify the property Appearance of the horizontal value bar - you assign the right configuration object. For example:

var int32 newValue = ...

HorizontalValueBar.CurrentValue = newValue;

if ( newValue > 50 )
  HorizontalValueBar.Appearance = Your_ConfigurationObject_Red;
else
  HorizontalValueBar.Appearance = Your_ConfigurationObject_Green;

Regarding your second question, please see the documentation:

Implementing component interface

Creating a property and implementing an onset method

Using Property Observer

The last two document links describe the aspects in context of an interface between GUI and the target device. These concepts can however also be used to manage data internally within the GUI application. Just ignore the native sections to exchange the data with the target. Limit to create Device Driver class and add all the desired properties to it.

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...