Browse Source

Changes to OutlineTreeView to Work With IOutlineNode

pull/315/head
tbulle 12 years ago
parent
commit
f4f0f39cb7
  1. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs

@ -13,30 +13,30 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
protected override bool CanInsert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy) protected override bool CanInsert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
{ {
UpdateCustomNodes(items); UpdateCustomNodes(items);
return (target.DataContext as OutlineNode).CanInsert(_customOutlineNodes, return (target.DataContext as IOutlineNode).CanInsert(_customOutlineNodes,
after == null ? null : after.DataContext as OutlineNode, copy); after == null ? null : after.DataContext as IOutlineNode, copy);
} }
protected override void Insert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy) protected override void Insert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
{ {
UpdateCustomNodes(items); UpdateCustomNodes(items);
(target.DataContext as OutlineNode).Insert(_customOutlineNodes, (target.DataContext as IOutlineNode).Insert(_customOutlineNodes,
after == null ? null : after.DataContext as OutlineNode, copy); after == null ? null : after.DataContext as IOutlineNode, copy);
} }
// Need to do this through a seperate List since previously LINQ queries apparently disconnected DataContext;bug in .NET 4.0 // Need to do this through a seperate List since previously LINQ queries apparently disconnected DataContext;bug in .NET 4.0
private List<OutlineNode> _customOutlineNodes; private List<IOutlineNode> _customOutlineNodes;
void UpdateCustomNodes(IEnumerable<DragTreeViewItem> items) void UpdateCustomNodes(IEnumerable<DragTreeViewItem> items)
{ {
_customOutlineNodes = new List<OutlineNode>(); _customOutlineNodes = new List<IOutlineNode>();
foreach (var item in items) foreach (var item in items)
_customOutlineNodes.Add(item.DataContext as OutlineNode); _customOutlineNodes.Add(item.DataContext as IOutlineNode);
} }
public override bool ShouldItemBeVisible(DragTreeViewItem dragTreeViewitem) public override bool ShouldItemBeVisible(DragTreeViewItem dragTreeViewitem)
{ {
var node = dragTreeViewitem.DataContext as OutlineNode; var node = dragTreeViewitem.DataContext as IOutlineNode;
return string.IsNullOrEmpty(Filter) || node.Name.ToLower().Contains(Filter.ToLower()); return string.IsNullOrEmpty(Filter) || node.Name.ToLower().Contains(Filter.ToLower());
} }
@ -45,7 +45,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{ {
base.SelectOnly(item); base.SelectOnly(item);
var node = item.DataContext as OutlineNode; var node = item.DataContext as IOutlineNode;
var surface = node.DesignItem.View.TryFindParent<DesignSurface>(); var surface = node.DesignItem.View.TryFindParent<DesignSurface>();
if (surface != null) if (surface != null)

Loading…
Cancel
Save