private void buttonCreate_Click(object sender, EventArgs e)
 {
     // open a dialog to create
     KeysetDialog ksd = new KeysetDialog();
     DialogResult result = ksd.ShowDialog();
     if (result == DialogResult.OK)
     {
         // get the new ring from the dialog.
         KeyRing ring = ksd.ring;
         objects.keyrings.Add(ring);
         ring.Save();
         // now create the node in the ui
         bool isOdd = treeViewRings.Nodes.Count % 2 == 0;
         TreeNode newNode = treeViewRings.Nodes.Add(ring.Name);
         newNode.Tag = ring;
         newNode.BackColor = isOdd ? lightBlue : Color.White;
     }
     ksd.Dispose();
 }
 private void buttonRename_Click(object sender, EventArgs e)
 {
     // open a dialog to rename
     TreeNode node = treeViewRings.SelectedNode;
     KeyRing ring = (KeyRing)node.Tag;
     KeysetDialog ksd = new KeysetDialog(ring);
     DialogResult result = ksd.ShowDialog();
     if (result == DialogResult.OK)
     {
         // ring modified in place, just save.
         ring.Save();
         node.Text = ring.Name;
     }
     ksd.Dispose();
 }