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()); } }
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()); } }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView1.SelectedNode == null) { return; } if (!(treeView1.SelectedNode.Tag is ClassChecker)) { return; } try { using (ConditionInputForm f = new ConditionInputForm()) { ClassChecker node = (ClassChecker)treeView1.SelectedNode.Tag; f.textBox_cond.Text = node.TakeCondition; f.textBox_unit.Text = node.RequiredAmount.ToString(); f.textBox_name.Text = node.Name; f.ShowDialog(); node.TakeCondition = f.textBox_cond.Text; node.RequiredAmount = float.Parse(f.textBox_unit.Text); node.Name = f.textBox_name.Text; treeView1.SelectedNode.Text = node.ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }