private void menuItemAddPattern_Click(object sender, EventArgs e)
 {
     ClapNodeOptions dialog = new ClapNodeOptions();
     DialogResult result = dialog.ShowDialog();
     if (result == DialogResult.OK) {
         ActionGroup group = dialog.actionGroup;
         TreeNode newNode = new TreeNode(group.name);
         newNode.Tag = group;
         treeView.Nodes[0].Nodes.Add(newNode);
         treeView.Nodes[0].Expand();
     }
     dialog.Dispose();
 }
 private void editNode(TreeNode node)
 {
     DialogResult result;
     switch (node.Level) {
         case 1:
             ActionGroup group = (ActionGroup)node.Tag;
             ClapNodeOptions dialogPattern = new ClapNodeOptions(group);
             result = dialogPattern.ShowDialog();
             if (result == DialogResult.OK) {
                 group = dialogPattern.actionGroup;
                 node.Text = group.name;
                 node.Tag = group;
             }
             dialogPattern.Dispose();
             break;
         case 2:
             ActionSetting action = (ActionSetting)node.Tag;
             ClapActionOptions actionDialog = new ClapActionOptions(action);
             result = actionDialog.ShowDialog();
             if (result == DialogResult.OK) {
                 action = actionDialog.action;
                 node.Text = action.action;
                 node.Tag = action;
             }
             actionDialog.Dispose();
             break;
         default: break;
     }
 }