Browse Source

Add support for recursively expanding tree nodes to SharpTreeView.

pull/170/merge
Daniel Grunwald 14 years ago
parent
commit
0e648ef19b
  1. 4
      ILSpy/TreeNodes/AssemblyTreeNode.cs
  2. 4
      ILSpy/TreeNodes/TypeTreeNode.cs
  3. 14
      SharpTreeView/SharpTreeNode.cs
  4. 17
      SharpTreeView/SharpTreeView.cs

4
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -135,6 +135,10 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
} }
public override bool CanExpandRecursively {
get { return true; }
}
public TypeTreeNode FindTypeNode(TypeDefinition def) public TypeTreeNode FindTypeNode(TypeDefinition def)
{ {
if (def == null) if (def == null)

4
ILSpy/TreeNodes/TypeTreeNode.cs

@ -117,6 +117,10 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
} }
public override bool CanExpandRecursively {
get { return true; }
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{ {
language.DecompileType(type, output, options); language.DecompileType(type, output, options);

14
SharpTreeView/SharpTreeNode.cs

@ -267,12 +267,26 @@ namespace ICSharpCode.TreeView
lazyLoading = value; lazyLoading = value;
if (lazyLoading) { if (lazyLoading) {
IsExpanded = false; IsExpanded = false;
if (canExpandRecursively) {
canExpandRecursively = false;
RaisePropertyChanged("CanExpandRecursively");
}
} }
RaisePropertyChanged("LazyLoading"); RaisePropertyChanged("LazyLoading");
RaisePropertyChanged("ShowExpander"); RaisePropertyChanged("ShowExpander");
} }
} }
bool canExpandRecursively = true;
/// <summary>
/// Gets whether this node can be expanded recursively.
/// If not overridden, this property returns false if the node is using lazy-loading, and true otherwise.
/// </summary>
public virtual bool CanExpandRecursively {
get { return canExpandRecursively; }
}
public virtual bool ShowIcon public virtual bool ShowIcon
{ {
get { return Icon != null; } get { return Icon != null; }

17
SharpTreeView/SharpTreeView.cs

@ -227,11 +227,28 @@ namespace ICSharpCode.TreeView
e.Handled = true; e.Handled = true;
} }
break; break;
case Key.Multiply:
if (container != null && ItemsControl.ItemsControlFromItemContainer(container) == this) {
container.Node.IsExpanded = true;
ExpandRecursively(container.Node);
e.Handled = true;
}
break;
} }
if (!e.Handled) if (!e.Handled)
base.OnKeyDown(e); base.OnKeyDown(e);
} }
void ExpandRecursively(SharpTreeNode node)
{
if (node.CanExpandRecursively) {
node.IsExpanded = true;
foreach (SharpTreeNode child in node.Children) {
ExpandRecursively(child);
}
}
}
/// <summary> /// <summary>
/// Scrolls the specified node in view and sets keyboard focus on it. /// Scrolls the specified node in view and sets keyboard focus on it.
/// </summary> /// </summary>

Loading…
Cancel
Save