diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
index 9ccb6a1eac..202464e075 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
@@ -667,11 +667,20 @@ namespace ICSharpCode.XmlEditor
}
///
- /// Deletes the selected node.
+ /// Handles a keyboard press event in tree view.
///
- protected void XmlElementTreeViewDeleteKeyPressed(object source, EventArgs e)
+ protected void XmlElementTreeViewKeyPressed(object source, XmlTreeViewKeyPressedEventArgs e)
{
- Delete();
+ if (e.KeyData == Keys.Delete)
+ Delete();
+ else if (e.KeyData == (Keys.Control | Keys.C))
+ Copy();
+ else if (e.KeyData == (Keys.Control | Keys.X))
+ Cut();
+ else if (e.KeyData == (Keys.Control | Keys.V))
+ Paste();
+ else if (e.KeyData == (Keys.Control | Keys.A))
+ SelectAll();
}
#region Forms Designer generated code
@@ -738,7 +747,7 @@ namespace ICSharpCode.XmlEditor
this.xmlElementTreeView.Size = new System.Drawing.Size(185, 326);
this.xmlElementTreeView.TabIndex = 0;
this.xmlElementTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.XmlElementTreeViewAfterSelect);
- this.xmlElementTreeView.DeleteKeyPressed += new System.EventHandler(this.XmlElementTreeViewDeleteKeyPressed);
+ this.xmlElementTreeView.TreeViewKeyPressed += this.XmlElementTreeViewKeyPressed;
//
// attributesGrid
//
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewControl.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewControl.cs
index 0cf244fad8..2f9840ec4b 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewControl.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewControl.cs
@@ -26,13 +26,27 @@ using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.XmlEditor
{
+ public class XmlTreeViewKeyPressedEventArgs : EventArgs
+ {
+ public XmlTreeViewKeyPressedEventArgs(Keys keyData)
+ {
+ KeyData = keyData;
+ }
+
+ public Keys KeyData
+ {
+ get;
+ private set;
+ }
+ }
+
///
/// Displays a tree of XML elements. This is a separate control so it can
/// be unit tested. It has no SharpDevelop specific parts, for example,
/// the context menus are defined in the XmlTreeViewContainerControl.
///
public class XmlTreeViewControl : ExtTreeView
- {
+ {
const string ViewStatePropertyName = "XmlTreeViewControl.ViewState";
XmlDocument document;
@@ -43,9 +57,9 @@ namespace ICSharpCode.XmlEditor
}
///
- /// Raised when the delete key is pressed.
+ /// Raised when some key in tree view is pressed.
///
- public event EventHandler DeleteKeyPressed;
+ public event EventHandler TreeViewKeyPressed;
public XmlTreeViewControl()
{
@@ -98,7 +112,7 @@ namespace ICSharpCode.XmlEditor
/// Gets the selected text node in the tree.
///
public XmlText SelectedTextNode {
- get {
+ get {
XmlTextTreeNode xmlTextTreeNode = SelectedNode as XmlTextTreeNode;
if (xmlTextTreeNode != null) {
return xmlTextTreeNode.XmlText;
@@ -106,12 +120,12 @@ namespace ICSharpCode.XmlEditor
return null;
}
}
-
+
///
/// Gets the selected comment node in the tree.
///
public XmlComment SelectedComment {
- get {
+ get {
XmlCommentTreeNode commentTreeNode = SelectedNode as XmlCommentTreeNode;
if (commentTreeNode != null) {
return commentTreeNode.XmlComment;
@@ -230,7 +244,7 @@ namespace ICSharpCode.XmlEditor
}
///
- /// Updates the corresponding tree node's text based on
+ /// Updates the corresponding tree node's text based on
/// the textNode's value.
///
public void UpdateTextNode(XmlText textNode)
@@ -240,9 +254,9 @@ namespace ICSharpCode.XmlEditor
node.Update();
}
}
-
+
///
- /// Updates the corresponding tree node's text based on
+ /// Updates the corresponding tree node's text based on
/// the comment's value.
///
public void UpdateComment(XmlComment comment)
@@ -314,7 +328,7 @@ namespace ICSharpCode.XmlEditor
}
///
- /// If no node is selected after a mouse click then we make
+ /// If no node is selected after a mouse click then we make
/// sure the AfterSelect event is fired. Standard behaviour is
/// for the AfterSelect event not to be fired when the user
/// deselects all tree nodes.
@@ -332,8 +346,8 @@ namespace ICSharpCode.XmlEditor
///
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
- if (keyData == Keys.Delete && DeleteKeyPressed != null) {
- DeleteKeyPressed(this, new EventArgs());
+ if (/*keyData == Keys.Delete && */TreeViewKeyPressed != null) {
+ TreeViewKeyPressed(this, new XmlTreeViewKeyPressedEventArgs(keyData));
}
return base.ProcessCmdKey(ref msg, keyData);
}
@@ -370,7 +384,7 @@ namespace ICSharpCode.XmlEditor
}
///
- /// Inserts a new element node either before or after the
+ /// Inserts a new element node either before or after the
/// currently selected element node.
///
void InsertElement(XmlElement element, InsertionMode insertionMode)
@@ -388,7 +402,7 @@ namespace ICSharpCode.XmlEditor
}
///
- /// Inserts a new text node either before or after the
+ /// Inserts a new text node either before or after the
/// currently selected node.
///
void InsertTextNode(XmlText textNode, InsertionMode insertionMode)
@@ -406,7 +420,7 @@ namespace ICSharpCode.XmlEditor
}
///
- /// Inserts a new comment node either before or after the
+ /// Inserts a new comment node either before or after the
/// currently selected node.
///
void InsertComment(XmlComment comment, InsertionMode insertionMode)
@@ -541,7 +555,7 @@ namespace ICSharpCode.XmlEditor
}
///
- /// Shows the corresponding tree node with the ghosted image
+ /// Shows the corresponding tree node with the ghosted image
/// that indicates it is being cut.
///
void ShowCutElement(XmlElement element, bool showGhostImage)
@@ -551,7 +565,7 @@ namespace ICSharpCode.XmlEditor
}
///
- /// Shows the corresponding tree node with the ghosted image
+ /// Shows the corresponding tree node with the ghosted image
/// that indicates it is being cut.
///
void ShowCutTextNode(XmlText textNode, bool showGhostImage)
@@ -559,9 +573,9 @@ namespace ICSharpCode.XmlEditor
XmlTextTreeNode node = FindTextNode(textNode);
node.ShowGhostImage = showGhostImage;
}
-
+
///
- /// Shows the corresponding tree node with the ghosted image
+ /// Shows the corresponding tree node with the ghosted image
/// that indicates it is being cut.
///
void ShowCutComment(XmlComment comment, bool showGhostImage)