private void SaveBtn_Click(object sender, EventArgs e)
{
if (List.Type == ConditionType.Not)
{
if (ConditionTree.Nodes[0].Nodes.Count == 0)
{
MessageBox.Show("You must define a criteria.");
return;
}
}
else
{
if (ConditionTree.Nodes[0].Nodes.Count < 2)
{
MessageBox.Show("You must define 2 criteria's.");
return;
}
}
// Generate a new list, and store it in the Node.Tag
List = (ConditionList)MedalDataParser.ParseNodeConditions(ConditionTree.Nodes[0]);
Node.Tag = List;
// For AND (and) OR lists, since we can add and remove elements (thus losing references),
// we must clear the condition nodes, and rebuild them from scratch
if (List.Type == ConditionType.And || List.Type == ConditionType.Or)
{
Node.Nodes.Clear();
foreach (var something in List.GetConditions())
Node.Nodes.Add(something.ToTree());
}
// Signal to the DataEditor that we made changes
MedalDataEditor.ChangesMade = true;
this.DialogResult = DialogResult.OK;
}