/// <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(); } }
/// <summary> /// Intializes the condition tree /// </summary> private void Initialize() { // Add Conditions to tree view ConditionTree.BeginUpdate(); ConditionTree.Nodes.Clear(); ConditionTree.Nodes.Add(List.ToTree()); ConditionTree.EndUpdate(); ConditionTree.ExpandAll(); // Get the list name ListTypeBox.Text = ConditionList.Names[(int)List.Type]; // Proccess list descritpion if (List.Type == ConditionType.And || List.Type == ConditionType.Or) { ConditionDescBox.Text = "Can contain unlimited number of sub criteria's"; } else { ConditionDescBox.Text = "Must contain "; ConditionDescBox.Text += (List.Type == ConditionType.Not) ? "1 Sub Criteria." : "2 Sub Criteria's. An optinal 3rd \"Value\" Criteria can be applied."; } // Hide value box's for unsupporting condition lists if (List.Type != ConditionType.Plus && List.Type != ConditionType.Div) { EnableValue.Visible = false; ValueBox.Visible = false; } else { // Get our condition value, and add its value to the valuebox List <Condition> CL = List.GetConditions(); if (CL.Count == 3) { EnableValue.Checked = true; ValueBox.Value = Int32.Parse(CL[2].ToString()); } else { EnableValue.Checked = false; } } }
private void UpdateRoot() { ConditionList NList = new ConditionList(List.Type); // Add existing nodes to the new list foreach (TreeNode E in ConditionTree.Nodes[0].Nodes) { NList.Add((Condition)E.Tag); } // Add condition value if enabled if (ValueBox.Enabled) { NList.Add(new ConditionValue(ValueBox.Value.ToString())); } // update tree ConditionTree.BeginUpdate(); ConditionTree.Nodes.Clear(); ConditionTree.Nodes.Add(NList.ToTree()); ConditionTree.ExpandAll(); ConditionTree.EndUpdate(); }