Ejemplo n.º 1
0
        private void filesList_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            filesList.LabelEdit = false;
            EntryListViewItem entryItem = (filesList.Items[e.Item] as EntryListViewItem);

            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.Parent.RenameEntry(entryItem.Entry, e.Label);
            }
            if (!e.CancelEdit)
            {
                entryItem.Update();
                filesList.Sort();
                e.CancelEdit = true;
            }
        }
Ejemplo n.º 2
0
        private void UpdateGUIEntries()
        {
            // Update tree
            UpdateGUIEntiresNodes(filesTree.Nodes[0] as EntryTreeNode, "");
            filesTree.Nodes[0].Text = this.File.Filename;

            foreach (TreeNode node in filesTree.Nodes)
            {
                EntryTreeNode enode = node as EntryTreeNode;
                if (enode.Parent == null)
                {
                    // root entry
                    enode.Entry         = this.File.Root;
                    this.File.Root.Node = enode;
                }
                else
                {
                    string        path        = enode.Text;
                    EntryTreeNode currentNode = enode;
                    while ((currentNode = currentNode.Parent as EntryTreeNode).Parent != null)
                    {
                        path = currentNode.Text + "/" + path;
                    }
                }
            }

            if (filesTree.SelectedNode != null)
            {
                EntryTreeNode enode = filesTree.SelectedNode as EntryTreeNode;

                // Update list
                foreach (ListViewItem item in filesList.Items)
                {
                    EntryListViewItem eitem = item as EntryListViewItem;

                    eitem.Entry = enode.Entry.GetEntry(eitem.Text) as FileEntry;
                    if (eitem.Entry == null)
                    {
                        throw new Exception("Failed to update GUI with new file");
                    }
                    eitem.Entry.ViewItem = eitem;
                }
            }
        }