public void ReplaceNode(EventCommand esc)
 {
     try
     {
         TreeNode node = editedNode;
         if (node == null)
         {
             return;
         }
         this.treeView.BeginUpdate();
         // Get index to insert at
         int index = editedNode.Index;
         selectedNode = new TreeNode(esc.ToString());
         // EvenScript Command
         if (IsRootNode(node))
         {
             // Insert into treeview
             this.treeView.Nodes.RemoveAt(index);
             this.treeView.Nodes.Insert(index, esc.ToString());
             // Insert into script at same index
             this.script.RemoveAt(index);
             this.script.Insert(index, esc);
             treeView.SelectedNode = this.treeView.Nodes[index];
         }
     }
     finally
     {
         // Update offsets and descriptions
         RefreshScript();
         this.treeView.EndUpdate();
     }
 }