void tsbc_SelectedIndexChanged(object sender, EventArgs e)
{
// Did this to stop populating data twice on load (NOTE said stops external reflexives from loading data?)
if (!((ToolStripItem)sender).Enabled)
return;
#region Determine which comboBox was changed and modify related Reflexive Data accordingly
ToolStripComboBox tscb = (ToolStripComboBox)sender;
int tsGroupNumber = (tsNavigation.Items.IndexOf(tscb) - 2) / 3;
TreeNode tn = treeViewTagReflexives.SelectedNode;
List<TreeNode> tns = new List<TreeNode>();
tns.Add(tn);
for (int ii = tsGroupNumber; ii < ((tsNavigation.Items.Count - 2) / 3); ii++)
{
tn = tn.Parent;
tns.Insert(0, tn);
}
reflexiveData rd = (reflexiveData)tn.Tag;
rd.chunkSelected = tscb.SelectedIndex;
#endregion
// tn = TreeNode that was changed
// tns = all nodes from selected node to changed node
// tsGroupNumber = ComboBox # that was changed (from Left->Right)
// Update sub-Combo Box listings for lead Combo Boxes that were changed
//refreshTreeListing(treeViewTagReflexives.Nodes[0]); // Slow to always refresh all!
// Trial area for reflexives(sub-nodes) that have a 0 count in reflexive[0], but not later on
/*
reflexiveData rd2 = (reflexiveData)tn.Tag;
TreeNode mn = (TreeNode)tn.Clone();
TreeNode[] tn2 = loadTreeReflexives(rd2.baseOffset, rd2.reflexive.items, false);
foreach (TreeNode ttn in tn.Nodes)
{
tn.Nodes.Remove(ttn);
mn.Nodes.Add(ttn);
}
tn.Nodes.AddRange(tn2);
*/
refreshReflexiveList(rd);
treeViewTagReflexives.SuspendLayout();
refreshTreeListing(rd);
treeViewTagReflexives.ResumeLayout();
// Update tree listings counters
int levelsUp = treeViewTagReflexives.SelectedNode.Level - rd.node.Level;
for (int j = tsGroupNumber; j <= tsGroupNumber + levelsUp; j++)
{
rd = (reflexiveData)tns[j - tsGroupNumber].Tag;
if (rd.chunkCount > 70000) // Some very large number
throw new Exception( "\"" + tsNavigation.Items[j * 3 + 1].Name + "\" appears to contain " + rd.chunkCount + "chunks!\n"
+ "Try reloading tag. If problem persists, you likely have a corrupt map!" );
tsNavigation.Items[j * 3 + 1].Text = tsNavigation.Items[j * 3 + 1].Name + " [" + rd.chunkCount + "]";
int selection = ((ToolStripComboBox)tsNavigation.Items[j * 3 + 2]).SelectedIndex;
int count = ((ToolStripComboBox)tsNavigation.Items[j * 3 + 2]).Items.Count;
#region check Combo Box and make sure it contains the proper amount of numbers
if (rd.chunkCount > count)
{
for (int ii = count; ii < rd.chunkCount; ii++)
((ToolStripComboBox)tsNavigation.Items[j * 3 + 2]).Items.Add(ii);
}
else if (rd.chunkCount < count && rd.chunkCount > 0)
{
for (int ii = count - 1; ii > rd.chunkCount - 1; ii--)
((ToolStripComboBox)tsNavigation.Items[j * 3 + 2]).Items.RemoveAt(ii);
if (((ToolStripComboBox)tsNavigation.Items[j * 3 + 2]).SelectedIndex == -1)
{
((ToolStripComboBox)tsNavigation.Items[j * 3 + 2]).Enabled = false;
((ToolStripComboBox)tsNavigation.Items[j * 3 + 2]).SelectedIndex = rd.chunkCount - 1;
((ToolStripComboBox)tsNavigation.Items[j * 3 + 2]).Enabled = true;
}
}
else if (rd.chunkCount == 0)
{
((ToolStripComboBox)tsNavigation.Items[j * 3 + 2]).Items.Clear();
}
#endregion
// Update label listings on combobox
string[] s = loadLabels(rd);
ToolStripComboBox tcb = ((ToolStripComboBox)tsNavigation.Items[j * 3 + 2]);
// We need to disable update for this or it endless loops when changing selected index
tcb.SelectedIndexChanged -= tsbc_SelectedIndexChanged;
for (int ii = 0; ii < tcb.Items.Count; ii++)
{
tcb.Items[ii] = ii + " : \"" + s[ii] + "\"";
}
// ...and re-enable afterwards
tcb.SelectedIndexChanged += tsbc_SelectedIndexChanged;
}
tn = treeViewTagReflexives.SelectedNode;
if ((((reflexiveData)tn.Tag).chunkCount) > 0)
ReloadMetaForSameReflexive(((reflexiveData)tn.Tag).baseOffset);
// Update status bar to reflect listings
this.MapForm.statusBarText = string.Empty;
int i = 0;
foreach (ToolStripItem tsi in tsNavigation.Items)
{
if (++i % 3 == 0)
this.MapForm.statusBarText += tsi.Text + " \\ ";
}
}