BF2Statistics.MedalData.MedalDataParser.ParseNodeConditions C# (CSharp) Method

ParseNodeConditions() public static method

Takes a node tree and converts it to a Condition
public static ParseNodeConditions ( TreeNode Node ) : Condition
Node System.Windows.Forms.TreeNode
return Condition
        public static Condition ParseNodeConditions(TreeNode Node)
        {
            if (Node.Tag == null)
                return null;

            if (Node.Tag is ConditionList)
            {
                ConditionList C = (ConditionList)Node.Tag;
                List<Condition> Cs = C.GetConditions();

                // If a Plus / Div list has 3rd param, add the node
                if (Cs.Count == 3 && (C.Type == ConditionType.Plus || C.Type == ConditionType.Div))
                    Node.Nodes.Add(Cs[2].ToTree());

                // Remove old conditions
                C.Clear();

                foreach (TreeNode Sub in Node.Nodes)
                {
                    Condition SC = ParseNodeConditions(Sub);
                    if (SC == null)
                        continue;

                    C.Add(SC);
                }
                return C;
            }
            else
                return (Node.Tag is ConditionValue) ? (ConditionValue) Node.Tag : (Condition)Node.Tag;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Brings up the Criteria Editor for an Award
        /// </summary>
        public void EditCriteria()
        {
            // Grab the selected treenode
            TreeNode SelectedNode = ConditionTree.SelectedNode;

            // Make sure we have a node selected
            if (SelectedNode == null)
            {
                MessageBox.Show("Please select a criteria to edit.");
                return;
            }

            // Make sure its a child node, and not the topmost
            if (SelectedNode.Parent == null) // && SelectedNode.Nodes.Count != 0)
            {
                return;
            }

            // Open correct condition editor form
            if (SelectedNode.Tag is ObjectStat)
            {
                Child = new ObjectStatForm(SelectedNode);
            }
            else if (SelectedNode.Tag is PlayerStat)
            {
                Child = new ScoreStatForm(SelectedNode);
            }
            else if (SelectedNode.Tag is MedalOrRankCondition)
            {
                Child = new MedalConditionForm(SelectedNode);
            }
            else if (SelectedNode.Tag is GlobalStatMultTimes)
            {
                Child = new GlobalStatMultTimesForm(SelectedNode);
            }
            else if (SelectedNode.Tag is ConditionList)
            {
                Child = new ConditionListForm(SelectedNode);
            }
            else
            {
                return;
            }

            if (Child.ShowDialog() == DialogResult.OK)
            {
                ConditionList NN = new ConditionList(List.Type);
                NN = (ConditionList)MedalDataParser.ParseNodeConditions(ConditionTree.Nodes[0]);

                ConditionTree.Nodes.Clear();
                ConditionTree.Nodes.Add(NN.ToTree());
                ConditionTree.Refresh();
                ConditionTree.ExpandAll();
            }
        }
All Usage Examples Of BF2Statistics.MedalData.MedalDataParser::ParseNodeConditions