Beispiel #1
0
        private void filesTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            filesTree.LabelEdit = false;
            EntryTreeNode entryItem = e.Node as EntryTreeNode;

            // copy-paste sadly
            if (e.Label == null || e.Label == "")
            {
                // invalid name, don't create message box
                e.CancelEdit = true;
                //entryItem.Update();
            }
            else if (e.Label == entryItem.Entry.Name)
            {
                // do nothing
            }
            else if (entryItem.Entry.Parent.GetEntries().Any(entry => entry.Name == e.Label))
            {
                MessageBox.Show("Name already used.");
                e.CancelEdit = true;
            }
            else
            {
                entryItem.Entry.Name = e.Label;
            }
            if (!e.CancelEdit)
            {
                e.Node.Text = e.Label;
                filesTree.Sort();
                e.CancelEdit = true;
            }
        }
Beispiel #2
0
 public EntryTreeNode(DirectoryEntry entry, EntryTreeNode[] children)
     : base(entry.Name, children)
 {
     this.Entry = entry;
     entry.Node = this;
 }