Esempio n. 1
0
        public void OnModifyEntry(Entry ent, TreeNodeAdv node)
        {
            ModifyEntryDialog diag = new ModifyEntryDialog();

            if (ent != null)
            {
                diag.Edited = ent.Clone();
            }
            diag.ShowDialog();

            if (diag.Confirmed)
            {
                TreePath     path   = node.Tree.GetPath(node);
                SectionEntry parent = (SectionEntry)node.Parent.Tag;

                int nodeIndex = node.Index;
                if (ent != null)
                {//if the entry is different, we need to remove the old one
                    parent.Entries.Remove(ent);
                    this.NodesRemoved(this, new TreeModelEventArgs(path.Up(), new int[] { node.Index }, new object[] { ent }));
                }
                if (diag.Edited != null)
                {//if the new entry exists (this was not just a deletion), we need to add it to the tree
                    parent.Entries.Insert(nodeIndex, diag.Edited);
                    diag.Edited.Parent = parent;
                    this.NodesInserted(this, new TreeModelEventArgs(path.Up(), new int[] { nodeIndex }, new object[] { diag.Edited }));
                }
            }
        }
Esempio n. 2
0
        public void OnModifyEntry(Entry ent, TreeNodeAdv node)
        {
            ModifyEntryDialog diag = new ModifyEntryDialog();
            if (ent != null)
                diag.Edited = ent.Clone();
            diag.ShowDialog();

            if (diag.Confirmed)
            {
                TreePath path = node.Tree.GetPath(node);
                SectionEntry parent = (SectionEntry)node.Parent.Tag;

                int nodeIndex = node.Index;
                if (ent != null)
                {//if the entry is different, we need to remove the old one
                    parent.Entries.Remove(ent);
                    this.NodesRemoved(this, new TreeModelEventArgs(path.Up(), new int[] { node.Index }, new object[] { ent }));
                }
                if (diag.Edited != null)
                {//if the new entry exists (this was not just a deletion), we need to add it to the tree
                    parent.Entries.Insert(nodeIndex, diag.Edited);
                    diag.Edited.Parent = parent;
                    this.NodesInserted(this, new TreeModelEventArgs(path.Up(), new int[] { nodeIndex }, new object[] { diag.Edited }));
                }
            }
        }