Exemple #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();
            }
        }
Exemple #2
0
        /// <summary>
        /// Deletes the selected criteria node
        /// </summary>
        public void DeleteCriteria()
        {
            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 we can't delete the parent node
            // Mostly because we need to keep references intact
            if (SelectedNode.Parent == null)
            {
                return;
            }

            // Dont delete on Plus / Div Trees
            if (!(SelectedNode.Tag is ConditionList))
            {
                TreeNode Parent = SelectedNode.Parent;
                if (Parent == null)
                {
                    return;
                }

                // If we are in the root condition list
                if (Parent.Parent == null || Parent.Parent.Tag == null)
                {
                    ConditionTree.Nodes.Remove(SelectedNode);
                    return;
                }

                // Get the parents condition list
                ConditionList C = (ConditionList)Parent.Tag;

                // Remove the whole tree if its a not statement
                if (C.Type == ConditionType.Not)
                {
                    ConditionTree.Nodes.Remove(Parent);
                }

                // We donot handle nested condition lists in this form
                else if (C.Type == ConditionType.Plus || C.Type == ConditionType.Div)
                {
                    ConditionTree.SelectedNode = Parent;
                    EditCriteria();
                }
                else
                {
                    ConditionTree.Nodes.Remove(SelectedNode);
                }
            }
            else
            {
                ConditionTree.Nodes.Remove(SelectedNode);
            }

            ConditionTree.Refresh();
        }