Hello guys,
When the caller pressed a number key on the keypad, the method tries to get the actual node's child that is attached to that DTMF signal. If there is no such child, the message will go on without any jumping in the tree structure. If the incoming DTMF signal refers to a valid child, the program will jump in the tree structure to the specified child and its message will be started. The GUI will be also refreshed for showing the latest selected node.
Code for incoming DTMF signal handling:
private void call_DtmfReceived(object sender, VoIPEventArgs<DtmfInfo> e)
{
DtmfInfo dtmfInfo = e.Item;
InvokeGUIThread(() =>
{
label1.Text = String.Format("DTMF signal received: {0} ", dtmfInfo.Signal.Signal);
});
//you can restart the actual message by pressing star
if (dtmfInfo.Signal.Signal == 10)
{
ivrReader.StopStreaming();
ivrReader.AddAndStartText(selectedNode.message);
}
//pressing hash gets you back to the main menu
if (dtmfInfo.Signal.Signal == 11 && !atRoot)
{
atRoot = true;
selectedNode = root;
selectedTreeNode = root.treeNode;
InvokeGUIThread(() =>
{
treeView1.SelectedNode.ForeColor = Color.Black;
treeView1.SelectedNode = selectedTreeNode;
treeView1.SelectedNode.ForeColor = Color.Red;
});
ivrReader.StopStreaming();
ivrReader.AddAndStartText(selectedNode.message);
}
//stepping into a submenu if exists
if (selectedNode.getChild(dtmfInfo.Signal.Signal) != null)
{
atRoot = false;
ivrReader.StopStreaming();
selectedNode = selectedNode.getChild(dtmfInfo.Signal.Signal);
selectedTreeNode = selectedNode.treeNode;
InvokeGUIThread(() =>
{
treeView1.SelectedNode.ForeColor = Color.Black;
treeView1.SelectedNode = selectedTreeNode;
treeView1.SelectedNode.ForeColor = Color.Red;
});
ivrReader.AddAndStartText(selectedNode.message);
}
}
Cheers,
Niklas