Index: Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs
===================================================================
diff -u -rd03f2b52982110a0f804adfefe73f86551c59e62 -ra0688c8ec20cdc107412deaecf9a38a4c1bd5101
--- Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision d03f2b52982110a0f804adfefe73f86551c59e62)
+++ Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision a0688c8ec20cdc107412deaecf9a38a4c1bd5101)
@@ -70,8 +70,9 @@
///
///
/// The current implementation assumes that the data hierarchy,
- /// defined by the combination of registered objects and the set
- /// , only contains uniquely identifiable data objects.
+ /// defined by the combination of registered objects and the provided
+ /// , only contains uniquely identifiable data objects. Additionally, only one
+ /// object can be registered per .
///
public partial class TreeViewControl : UserControl
{
@@ -172,6 +173,7 @@
/// This method registers a object.
///
/// The to register.
+ /// Only one object can be registered per .
public void RegisterTreeNodeInfo(TreeNodeInfo treeNodeInfo)
{
tagTypeTreeNodeInfoLookup[treeNodeInfo.TagType] = treeNodeInfo;
@@ -182,7 +184,7 @@
/// can be renamed.
///
/// The data object to obtain the corresponding tree node for.
- /// Whether or not the tree node can be renamed.
+ /// Whether or not the tree node can be renamed or false when no corresponding tree node is found.
public bool CanRenameNodeForData(object dataObject)
{
var treeNode = GetNodeByTag(dataObject);
@@ -196,7 +198,8 @@
///
/// The data object to obtain the corresponding tree node for.
///
- /// When the tree node cannot be renamed, a popup is shown for notifying the end user.
+ /// When a tree node is found that cannot be renamed, a popup is shown for notifying the end user.
+ /// The renaming logic will be skipped when no corresponding tree node is found.
///
public void TryRenameNodeForData(object dataObject)
{
@@ -213,7 +216,7 @@
/// can be removed.
///
/// The data object to obtain the corresponding tree node for.
- /// Whether or not the tree node can be removed.
+ /// Whether or not the tree node can be removed or false when no corresponding tree node is found.
public bool CanRemoveNodeForData(object dataObject)
{
var treeNode = GetNodeByTag(dataObject);
@@ -226,8 +229,9 @@
///
/// The data object to obtain the corresponding tree node for.
///
- /// When the tree node can be removed, a popup is shown for confirmation by the end user.
- /// When the tree node cannot be removed, a popup is shown for simply notifying the end user.
+ /// When a tree node is found that can be removed, a popup is shown for confirmation by the end user.
+ /// When a tree node is found that cannot be removed, a popup is shown for notifying the end user.
+ /// The removing logic will be skipped when no corresponding tree node is found.
///
public void TryRemoveNodeForData(object dataObject)
{
@@ -244,7 +248,7 @@
/// can be collapsed/expanded.
///
/// The data object to obtain the corresponding tree node for.
- /// Whether or not the tree node can be collapsed/expanded.
+ /// Whether or not the tree node can be collapsed/expanded or false when no corresponding tree node is found.
public bool CanExpandOrCollapseForData(object dataObject)
{
var treeNode = GetNodeByTag(dataObject);
@@ -256,6 +260,9 @@
/// This method tries to collapse all nodes of the tree node corresponding to the
/// (child nodes are taken into account recursively).
///
+ ///
+ /// The collapsing logic will be skipped when no corresponding tree node is found.
+ ///
public void TryCollapseAllNodesForData(object dataObject)
{
var treeNode = GetNodeByTag(dataObject);
@@ -270,6 +277,9 @@
/// This method tries to expand all nodes of the tree node corresponding to the
/// (child nodes are taken into account recursively).
///
+ ///
+ /// The expanding logic will be skipped when no corresponding tree node is found.
+ ///
public void TryExpandAllNodesForData(object dataObject)
{
var treeNode = GetNodeByTag(dataObject);
@@ -284,6 +294,9 @@
/// This method tries to select the tree node corresponding to the .
///
/// The data object to obtain the corresponding tree node for.
+ ///
+ /// The tree node selection is set to null when no corresponding tree node is found.
+ ///
public void TrySelectNodeForData(object dataObject)
{
treeView.SelectedNode = GetNodeByTag(dataObject);
@@ -293,6 +306,7 @@
/// This method tries to return the path of the tree node corresponding to the .
///
/// The data object to obtain the corresponding tree node for.
+ /// The path of the tree node or null when no corresponding tree node is found.
public string TryGetPathForData(object dataObject)
{
var treeNode = GetNodeByTag(dataObject);
@@ -302,7 +316,7 @@
private bool CanRename(TreeNode treeNode)
{
- var treeNodeInfo = GetTreeNodeInfoForData(treeNode.Tag);
+ var treeNodeInfo = TryGetTreeNodeInfoForData(treeNode.Tag);
var parentTag = GetParentTag(treeNode);
return treeNodeInfo.CanRename != null && treeNodeInfo.CanRename(treeNode.Tag, parentTag);
@@ -321,7 +335,7 @@
private bool CanRemove(TreeNode treeNode)
{
- var treeNodeInfo = GetTreeNodeInfoForData(treeNode.Tag);
+ var treeNodeInfo = TryGetTreeNodeInfoForData(treeNode.Tag);
var parentTag = GetParentTag(treeNode);
return treeNodeInfo.CanRemove != null && treeNodeInfo.CanRemove(treeNode.Tag, parentTag);
@@ -341,7 +355,7 @@
return;
}
- var treeNodeInfo = GetTreeNodeInfoForData(treeNode.Tag);
+ var treeNodeInfo = TryGetTreeNodeInfoForData(treeNode.Tag);
if (treeNodeInfo.OnNodeRemoved != null)
{
@@ -438,10 +452,10 @@
/// This method updates the provided .
///
/// The to update.
- /// Thrown when no corresponding can be found for the provided .
+ /// Thrown when no corresponding can be found for the provided .
private void UpdateNode(TreeNode treeNode)
{
- var treeNodeInfo = GetTreeNodeInfoForData(treeNode.Tag);
+ var treeNodeInfo = TryGetTreeNodeInfoForData(treeNode.Tag);
if (treeNodeInfo == null)
{
throw new InvalidOperationException("No tree node info registered");
@@ -526,7 +540,7 @@
var lastAddedNodeToSetSelectionTo = newTreeNodes.Values.LastOrDefault(node =>
{
var dataObject = node.Tag;
- var info = GetTreeNodeInfoForData(dataObject);
+ var info = TryGetTreeNodeInfoForData(dataObject);
return info.EnsureVisibleOnCreate != null && info.EnsureVisibleOnCreate(dataObject);
});
@@ -565,7 +579,7 @@
///
/// The data to find the corresponding for.
/// The for the provided data or null if no corresponding was found.
- private TreeNodeInfo GetTreeNodeInfoForData(object item)
+ private TreeNodeInfo TryGetTreeNodeInfoForData(object item)
{
if (item == null)
{
@@ -700,7 +714,7 @@
return;
}
- var treeNodeInfo = GetTreeNodeInfoForData(e.Node.Tag);
+ var treeNodeInfo = TryGetTreeNodeInfoForData(e.Node.Tag);
if (treeNodeInfo.OnNodeRenamed != null)
{
treeNodeInfo.OnNodeRenamed(e.Node.Tag, e.Label);
@@ -709,7 +723,7 @@
private void TreeViewAfterCheck(object sender, TreeViewEventArgs e)
{
- var treeNodeInfo = GetTreeNodeInfoForData(e.Node.Tag);
+ var treeNodeInfo = TryGetTreeNodeInfoForData(e.Node.Tag);
if (treeNodeInfo.OnNodeChecked != null)
{
var parentTag = GetParentTag(e.Node);
@@ -728,22 +742,22 @@
switch (keyEventArgs.KeyData)
{
- case Keys.F5: // Refresh the selected node in the tree view
+ case Keys.F5: // Refresh the selected tree node in the tree view
{
if (treeView.SelectedNode != null)
{
UpdateNode(treeView.SelectedNode);
}
break;
}
- case Keys.F2: // Start editing the label of the selected node
+ case Keys.F2: // Start editing the label of the selected tree node
{
Rename(selectedNode);
break;
}
- case Keys.Apps: // If implemented, show the context menu of the selected node
+ case Keys.Apps: // If implemented, show the context menu of the selected tree node
{
- var treeNodeInfo = GetTreeNodeInfoForData(selectedNode.Tag);
+ var treeNodeInfo = TryGetTreeNodeInfoForData(selectedNode.Tag);
var parentTag = GetParentTag(selectedNode);
// Update the context menu (relevant in case of keyboard navigation in the tree view)
@@ -766,15 +780,15 @@
break;
}
- case Keys.Delete: // Try to delete the selected node
+ case Keys.Delete: // Try to delete the selected tree node
{
Remove(selectedNode);
break;
}
- case Keys.Space: // If applicable, change the checked state of the selected node
+ case Keys.Space: // If applicable, change the checked state of the selected tree node
{
- var treeNodeInfo = GetTreeNodeInfoForData(selectedNode.Tag);
+ var treeNodeInfo = TryGetTreeNodeInfoForData(selectedNode.Tag);
if (treeNodeInfo.CanCheck != null && treeNodeInfo.CanCheck(selectedNode.Tag))
{
selectedNode.Checked = !selectedNode.Checked;
@@ -806,7 +820,7 @@
return;
}
- var treeNodeInfo = GetTreeNodeInfoForData(clickedNode.Tag);
+ var treeNodeInfo = TryGetTreeNodeInfoForData(clickedNode.Tag);
if (e.Button.HasFlag(MouseButtons.Right))
{
@@ -849,17 +863,17 @@
private void TreeViewDragDrop(object sender, DragEventArgs e)
{
- dragDropHandler.HandleDragDrop(this, treeView, e, GetTreeNodeInfoForData);
+ dragDropHandler.HandleDragDrop(this, treeView, e, TryGetTreeNodeInfoForData);
}
private void TreeViewDragOver(object sender, DragEventArgs e)
{
- dragDropHandler.HandleDragOver(treeView, e, GetTreeNodeInfoForData);
+ dragDropHandler.HandleDragOver(treeView, e, TryGetTreeNodeInfoForData);
}
private void TreeViewItemDrag(object sender, ItemDragEventArgs e)
{
- dragDropHandler.HandleItemDrag(treeView, e, GetTreeNodeInfoForData);
+ dragDropHandler.HandleItemDrag(treeView, e, TryGetTreeNodeInfoForData);
}
private void TreeViewDragLeave(object sender, EventArgs e)