示例#1
0
 private void addNodeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode == null)
     {
         return;
     }
     if (!(treeView1.SelectedNode.Tag is ClassCheckerNode))
     {
         return;
     }
     try
     {
         using (ConditionInputForm f = new ConditionInputForm())
         {
             f.ShowDialog();
             ClassCheckerNode node    = (ClassCheckerNode)treeView1.SelectedNode.Tag;
             ClassCheckerNode newnode = new ClassCheckerNode(f.textBox_cond.Text, float.Parse(f.textBox_unit.Text), f.textBox_name.Text);
             treeView1.SelectedNode.Nodes.Add(newnode.ToString()).Tag = newnode;
             node.Children.Add(newnode);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#2
0
 private void addLeafToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode == null)
     {
         return;
     }
     if (!(treeView1.SelectedNode.Tag is ClassCheckerNode))
     {
         return;
     }
     try
     {
         while (true)
         {
             using (ConditionInputForm f = new ConditionInputForm())
             {
                 f.ShowDialog();
                 if (string.IsNullOrEmpty(f.textBox_cond.Text + f.textBox_name.Text + f.textBox_unit))
                 {
                     break;
                 }
                 ClassCheckerNode node = (ClassCheckerNode)treeView1.SelectedNode.Tag;
                 ClassCheckerLeaf leaf = new ClassCheckerLeaf(f.textBox_cond.Text, float.Parse(f.textBox_unit.Text), f.textBox_name.Text);
                 treeView1.SelectedNode.Nodes.Add(leaf.ToString()).Tag = leaf;
                 node.Children.Add(leaf);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#3
0
        public Form1()
        {
            this.rootNode = new ClassCheckerNode(".*", 0, "Root");

            InitializeComponent();

            var root = this.treeView1.Nodes.Add(rootNode.ToString());

            root.Tag = rootNode;
        }
示例#4
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (System.IO.FileStream stream = new System.IO.FileStream("grad.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                ClassCheckerNode root = (ClassCheckerNode)serializer.Deserialize(stream);

                treeView1.Nodes[0].Nodes.Clear();

                this.rootNode = root;
                AddNodes(root, treeView1.Nodes[0]);
                treeView1.Nodes[0].Text = rootNode.ToString();
            }
            MessageBox.Show("OK");
        }
示例#5
0
        private void AddNodes(ClassCheckerNode parentC, TreeNode parentT)
        {
            foreach (var item in parentC.Children)
            {
                switch (item)
                {
                case ClassCheckerLeaf leaf:
                    TreeNode tnode = parentT.Nodes.Add(leaf.ToString());
                    tnode.Tag = leaf;
                    foreach (var cls in leaf.Classes)
                    {
                        tnode.Nodes.Add(cls.ToString()).Tag = cls;
                    }
                    break;

                case ClassCheckerNode node:
                    AddNodes(node, parentT.Nodes.Add(node.ToString()));
                    break;
                }
            }
            parentT.Tag = parentC;
        }