This example (demoPrograms\engine\VC#\inter or demoPrograms\engine\VB\inter) demonstrates the use of a WiT interactive operator (getData in this case).

Running an Interactive Operator
The Form Load and Form Closing sections are standard.
Most of the work is done in the outputCallback/dataChanged procedure. First, readObj is called to read in an image. Then, getData is called. Because the name ‘getData’ has been mapped to the Picture Box control, the image appears inside the Picture Box control and the user can enter graphical data in this window. When the user has finished entering data, he can bring up the pop-up menu on the image (by pressing the right mouse button) and select OK. At this point, the getData operator returns execution to WiT Engine. Then, dataChanged is used to retrieve data from the output of getData (‘data’). In this example, the data is simply displayed in the ‘statusWin’ control. WiT returns multi-line data with only a line-feed character between lines. Because a .Net Edit control requires both a line-feed and carriage return character for each new line, the carriage return characters are added to the text before it is displayed.
[C#]
public void dataChanged(string name, string buf, IntPtr rawData)
{
statusWin.Text = "";
string delimStr = " ";
char [] delimiter = delimStr.ToCharArray();
string [] split = null;
split = buf.Split(delimiter);
if (split.Length < 6 || split[0] != "OBJ_B" || split[1] != "T" ||
split[2] != "CorVector" || split[3] != "CorGraphic")
{
statusWin.Text = "Wrong data";
}
else
{
int elemCnt = Convert.ToInt32(split[4]), idx = 5;
for (int i = 0;i < elemCnt;i++)
{
if (Convert.ToInt32(split[idx++]) != 4)
{
statusWin.Text += "\r\nNot rectangle data.\r\n";
return;
}
if (split[idx++] != "CorFpoint")
{
statusWin.Text += "\r\nNot correct rectangle data.\r\n";
return;
}
idx++; // skip 2
statusWin.Text += "Box #: " + i + "\r\n" +
split[idx++] + "," + split[idx++] + "\r\n" +
split[idx++] + "," + split[idx++] + "\r\n\r\n";
idx += 12; // skip rest of the rectangle data
}
statusWin.SelectionStart = statusWin.Text.Length;
statusWin.ScrollToCaret();
}
}
[Visual Basic]
Public Sub dataChanged(ByVal name As String, ByVal buf As String, _
ByVal rawData As IntPtr)
outText.Text = ""
Dim delimStr As String = " "
Dim delimiter() As Char = delimStr.ToCharArray()
Dim split() As String = Nothing
split = buf.Split(delimiter)
If split.Length < 6 Or split(0) <> "OBJ_B" Or split(1) <> "T" Or _
split(2) <> "CorVector" Or split(3) <> "CorGraphic" Then
outText.Text = "Wrong data"
Else
Dim elemCnt As Integer = Convert.ToInt32(split(4)), _
idx As Integer = 5
Dim i As Integer
For i = 0 To elemCnt - 1 Step i + 1
If Convert.ToInt32(split(idx)) <> 4 Then
outText.Text += vbNewLine + "Not rectangle data." + _
vbNewLine
Return
End If
idx += 1
If split(idx) <> "CorFpoint" Then
outText.Text += vbNewLine + _
"Not correct rectangle data." + _
vbNewLine
Return
End If
idx += 2 ' Skip 2
outText.Text += "Box #: " + i.ToString() + vbNewLine + _
split(idx) + "," + split(idx + 1) + vbNewLine + _
split(idx + 2) + "," + split(idx + 3) + _
vbNewLine + vbNewLine
idx += 16 ' Skip rest of the rectangle data
Next
outText.SelectionStart = outText.Text.Length
outText.ScrollToCaret()
End If
End Sub