Picker controller of numerical type

Section 4

In the "RGA" view, section 4 (1) consists of a picker controller that allows you to dial in a numerical number from 0 to 9.9. To change the value of a picker, tap the row labeled "Tap me to unlock setting." (2) This stops the entire view from scrolling while you are trying to dial in a value. When you are done dialing, tap the same row again to set the value and at the same time, to enable you to scroll the view again.

This particular picker controller has two dials: The left one has a range from 0-9 and the right on has a range from .0 to .9. We will recreate this controller in our "myRGA" iPhone view.

(Note: you can have as many dials as will fit for a numerical dial)

Add a new section

Right click the "view" node then select "add section." Right click the "title" node of the new "section" node and enter "Electron Voltage" in the pop-up.

Select a controller type

Find the "row" node under the new section and right click the "controller" node. Select "add picker" from the selection. The default has only one dial. This is OK. We will add the second dial later. To set the height of this picker, right click the "height" node (1) and enter 240 (in terms of pixels on iPhone). Next, right click the "width" node (2) and enter 120. Right click the "title" node and enter 0; 1; 2; 3; 4; 5; 6; 7; 8; 9. These are the numbers that will appear on the dial. Separate each number with a semicolon.

Add a new dial

Now let's work on the second dial. Right click the "picker" node (4) and select "add dial" from the selection. Right click the "width" node of the new "dial" node, Enter 80. Right click the "title" node and enter ".0; .1; .2; .3; ...; .9". Do not include the quotation mark. Separate each number with a semicolon.

Connect the picker controller (of iPhone view) to the RGA example.exe (Windows app)

Right click the "source.dataName" and select "electronVoltage" from the selection.

Save, reload and test

Now dial in a number from 0.0 to 9.9 on your iPhone and watch the value changes on the RGA Example.exe.

Again, to change the value of a picker, tap the row "Tap me to unlock setting." This stops the entire view from scrolling while you trying to dial. When you are done dialing, tap the same row again to freeze the setting and enable you to scroll the view again.

How the "Electron Voltage" textBox variable is exposed for MONITORING?

Open Form1.cs in the RGA Example VS project and double click the textBox (1, figure above). It should jump to the following code:
private void textBox_electronVoltage_TextChanged(object sender, EventArgs e)
{

if (textBox_electronVoltage.Text.Length > 0)
{

bool hasError = false;
try
{
//******************************************************************************
//**************** Client Get (Retrieve Information) *************************
float kv = float.Parse(textBox_electronVoltage.Text); //given a data type so the client will know how to handle the data.
INFOMATO.WCF.DataExchangeService.servicePostData("RGA", "electronVoltage", kv);
//******************************************************************************
//******************************************************************************
}
catch
{
hasError = true;
}
if(hasError) MessageBox.Show("Entry must be a number between 0.0 to 9.9");
}
}

Every time the textBox(named textBox_electronVoltage) value changes, the above function is called. Since the value for this picker is a float type, we need to convert the textBox text string to a float numeric data by calling the float.Parse function. We then call the function INFOMATO.WCF.DataExchangeService.servicePostData to inform iQuipment PC an update value for the "RGA" view, dataName of "electronVoltage."

How the "Electron Voltage" textBox variable is exposed for REMOTE-CONTROL?

Similar to what was done for the Segments control. When you tap the picker on your iPhone, it will trigger the event. INFOMATO.WCF.DataExchangeService.clientSetDataEvent, which in tern calls DataExchangeService_clientSetDataEvent for event handling.

void DataExchangeService_clientSetDataEvent(string viewName, string dataName, object dataValue)
{
if (viewName.ToLower() == "RGA".ToLower())
{
switch (dataName.ToLower())
{
...
case "electronvoltage":
this.UpdateTextGUIObject(this.textBox_electronVoltage, dataValue.ToString());
break;
...
}
}
}

In the UpdateTextGUIObject(this.checkBox_power, (bool)dataValue) function call, we took care of UI Thread safe issue when updating the textBox. More details about Windows's UI thread safe coding have been discussed in the "segment" controller.

Previous Lesson: Slider controller Table of Contents Next Lesson: Picker controller of text type