BF2Statistics.MedalData.ConditionListForm.ConditionTree_AfterSelect C# (CSharp) Method

ConditionTree_AfterSelect() private method

This method builds the correct context menu options for the selected node
private ConditionTree_AfterSelect ( object sender, TreeViewEventArgs e ) : void
sender object
e TreeViewEventArgs
return void
        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;
        }