|
|
|
@ -26,13 +26,27 @@ using ICSharpCode.SharpDevelop.Gui;
@@ -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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 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.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class XmlTreeViewControl : ExtTreeView |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
const string ViewStatePropertyName = "XmlTreeViewControl.ViewState"; |
|
|
|
|
|
|
|
|
|
XmlDocument document; |
|
|
|
@ -43,9 +57,9 @@ namespace ICSharpCode.XmlEditor
@@ -43,9 +57,9 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Raised when the delete key is pressed.
|
|
|
|
|
/// Raised when some key in tree view is pressed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public event EventHandler DeleteKeyPressed; |
|
|
|
|
public event EventHandler<XmlTreeViewKeyPressedEventArgs> TreeViewKeyPressed; |
|
|
|
|
|
|
|
|
|
public XmlTreeViewControl() |
|
|
|
|
{ |
|
|
|
@ -98,7 +112,7 @@ namespace ICSharpCode.XmlEditor
@@ -98,7 +112,7 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
/// Gets the selected text node in the tree.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public XmlText SelectedTextNode { |
|
|
|
|
get { |
|
|
|
|
get { |
|
|
|
|
XmlTextTreeNode xmlTextTreeNode = SelectedNode as XmlTextTreeNode; |
|
|
|
|
if (xmlTextTreeNode != null) { |
|
|
|
|
return xmlTextTreeNode.XmlText; |
|
|
|
@ -106,12 +120,12 @@ namespace ICSharpCode.XmlEditor
@@ -106,12 +120,12 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the selected comment node in the tree.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public XmlComment SelectedComment { |
|
|
|
|
get { |
|
|
|
|
get { |
|
|
|
|
XmlCommentTreeNode commentTreeNode = SelectedNode as XmlCommentTreeNode; |
|
|
|
|
if (commentTreeNode != null) { |
|
|
|
|
return commentTreeNode.XmlComment; |
|
|
|
@ -230,7 +244,7 @@ namespace ICSharpCode.XmlEditor
@@ -230,7 +244,7 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the corresponding tree node's text based on
|
|
|
|
|
/// Updates the corresponding tree node's text based on
|
|
|
|
|
/// the textNode's value.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void UpdateTextNode(XmlText textNode) |
|
|
|
@ -240,9 +254,9 @@ namespace ICSharpCode.XmlEditor
@@ -240,9 +254,9 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
node.Update(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the corresponding tree node's text based on
|
|
|
|
|
/// Updates the corresponding tree node's text based on
|
|
|
|
|
/// the comment's value.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void UpdateComment(XmlComment comment) |
|
|
|
@ -314,7 +328,7 @@ namespace ICSharpCode.XmlEditor
@@ -314,7 +328,7 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 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
@@ -332,8 +346,8 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
/// </summary>
|
|
|
|
|
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
@@ -370,7 +384,7 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Inserts a new element node either before or after the
|
|
|
|
|
/// Inserts a new element node either before or after the
|
|
|
|
|
/// currently selected element node.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void InsertElement(XmlElement element, InsertionMode insertionMode) |
|
|
|
@ -388,7 +402,7 @@ namespace ICSharpCode.XmlEditor
@@ -388,7 +402,7 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Inserts a new text node either before or after the
|
|
|
|
|
/// Inserts a new text node either before or after the
|
|
|
|
|
/// currently selected node.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void InsertTextNode(XmlText textNode, InsertionMode insertionMode) |
|
|
|
@ -406,7 +420,7 @@ namespace ICSharpCode.XmlEditor
@@ -406,7 +420,7 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Inserts a new comment node either before or after the
|
|
|
|
|
/// Inserts a new comment node either before or after the
|
|
|
|
|
/// currently selected node.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void InsertComment(XmlComment comment, InsertionMode insertionMode) |
|
|
|
@ -541,7 +555,7 @@ namespace ICSharpCode.XmlEditor
@@ -541,7 +555,7 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Shows the corresponding tree node with the ghosted image
|
|
|
|
|
/// Shows the corresponding tree node with the ghosted image
|
|
|
|
|
/// that indicates it is being cut.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void ShowCutElement(XmlElement element, bool showGhostImage) |
|
|
|
@ -551,7 +565,7 @@ namespace ICSharpCode.XmlEditor
@@ -551,7 +565,7 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Shows the corresponding tree node with the ghosted image
|
|
|
|
|
/// Shows the corresponding tree node with the ghosted image
|
|
|
|
|
/// that indicates it is being cut.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void ShowCutTextNode(XmlText textNode, bool showGhostImage) |
|
|
|
@ -559,9 +573,9 @@ namespace ICSharpCode.XmlEditor
@@ -559,9 +573,9 @@ namespace ICSharpCode.XmlEditor
|
|
|
|
|
XmlTextTreeNode node = FindTextNode(textNode); |
|
|
|
|
node.ShowGhostImage = showGhostImage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Shows the corresponding tree node with the ghosted image
|
|
|
|
|
/// Shows the corresponding tree node with the ghosted image
|
|
|
|
|
/// that indicates it is being cut.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void ShowCutComment(XmlComment comment, bool showGhostImage) |
|
|
|
|