The information tree is on the Details tab page of our user interface. It houses the information treeview control. Depending upon the PSODispType, we will either create a new node or use the one previously created to write out our text:
private void DisplayResult(PSODispType DispType, string Text)
{
switch (DispType)
{
Create a brand-new node in the tree. This is the highest level for a particle in the tree and represents the global best values found, as follows:
case PSODispType.GlobalBest:
Node n1 = new Node();
n1.Text = Text;
lastNode = advTree1.Nodes.Add(n1);
break;
Add details to the previous node. This is an individual particle in the swarm, and its sub details will be plotted in our next function, as follows:
case PSODispType.Swarm:
Node n2 = new Node();
n2.Text = Text;
advTree1?.Nodes?[lastNode]?.Nodes?.Add(n2);
break;
Add details to the previous node. These are the exact details of the particle, and form the bottom-level node for this particle in the swarm, as follows:
case PSODispType.SwarmPosition:
Node n = new Node();
n.Text = Text;
advTree1?.Nodes?[lastNode]?.Nodes?.Add(n);
break;
}
}
And that's it. We now have a fully populated information tree!