BF2Statistics.MedalData.MedalDataEditor.AddNewCriteria C# (CSharp) Method

AddNewCriteria() private method

Adds a new criteria to an award from the Add Critera Dialog
private AddNewCriteria ( object sender, FormClosingEventArgs e ) : void
sender object
e System.Windows.Forms.FormClosingEventArgs
return void
        private void AddNewCriteria(object sender, FormClosingEventArgs e)
        {
            // If there is a node referenced.
            if (ConditionNode != null && ConditionNode.Tag is ConditionList)
            {
                Condition Add = Child.GetCondition();
                ConditionList List = (ConditionList)ConditionNode.Tag;
                List.Add(Add);
            }
            else
            {
                // No Node referenced... Use top most
                ConditionList A = new ConditionList(ConditionType.And);
                Condition B = SelectedAward.GetCondition();
                if (B is ConditionList)
                {
                    ConditionList C = (ConditionList)B;
                    if (C.Type == ConditionType.And)
                        A = C;
                    else
                        A.Add(B);
                }
                else
                {
                    // Add existing conditions into the condition list
                    A.Add(B);
                }

                // Add the new condition
                A.Add(Child.GetCondition());

                // Parse award conditions into tree view
                SelectedAward.SetCondition(A);
            }

            // Update the tree view
            AwardConditionsTree.BeginUpdate();
            AwardConditionsTree.Nodes.Clear();
            AwardConditionsTree.Nodes.Add(SelectedAward.ToTree());
            ValidateConditions(SelectedAwardNode, SelectedAward.GetCondition());
            AwardConditionsTree.ExpandAll();
            AwardConditionsTree.EndUpdate();
        }