GetConditions() public method

Returns a list of sub-conditions under this list
public GetConditions ( ) : List
return List
Example #1
0
        /// <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;
                }
            }
        }
Example #2
0
        /// <summary>
        /// This method builds the correct context menu options for the selected node
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ConditionTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            // By default, we want the "New Criteria" item enabled
            CriteriaRootMenu.Items[0].Enabled = true;

            // Get the current selected node
            TreeNode CNode = ConditionTree.SelectedNode;

            if (CNode == null)
            {
                if (ConditionTree.Nodes.Count == 0)
                {
                    return;
                }
                else
                {
                    CNode = ConditionTree.Nodes[0];
                }
            }

            // Are we the parent node?
            if (CNode.Parent == null)
            {
                CNode.ContextMenuStrip = CriteriaRootMenu;
                if (CNode.Tag is ConditionList)
                {
                    ConditionList L     = (ConditionList)CNode.Tag;
                    int           Items = L.GetConditions().Count;
                    if (Items > 1 && L.Type != ConditionType.And && L.Type != ConditionType.Or)
                    {
                        CNode.ContextMenuStrip.Items[0].Enabled = false;
                    }
                }
            }
            else
            {
                CNode.ContextMenuStrip = (CNode.Tag is ConditionList && ((ConditionList)CNode.Tag).Type == ConditionType.And)
                    ? CriteriaRootMenu
                    : CriteriaItemMenu;
            }
        }
Example #3
0
        /// <summary>
        /// Takes a node tree and converts it to a Condition
        /// </summary>
        /// <param name="Node"></param>
        /// <returns></returns>
        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);
            }
        }
Example #4
0
        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;
        }
        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;
        }