2012-11-04 01:36:12 +00:00
|
|
|
using System;
|
2012-11-05 04:18:25 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using MonoMac.AppKit;
|
|
|
|
using MonoMac.Foundation;
|
2012-11-04 01:36:12 +00:00
|
|
|
|
|
|
|
namespace NBTExplorer.Mac
|
|
|
|
{
|
2012-11-05 04:18:25 +00:00
|
|
|
public class TreeDataSource : NSOutlineViewDataSource
|
2012-11-04 01:36:12 +00:00
|
|
|
{
|
2012-11-05 04:18:25 +00:00
|
|
|
private List<TreeDataNode> _nodes;
|
|
|
|
|
2012-11-04 01:36:12 +00:00
|
|
|
public TreeDataSource ()
|
|
|
|
{
|
2012-11-05 04:18:25 +00:00
|
|
|
_nodes = new List<TreeDataNode>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<TreeDataNode> Nodes
|
|
|
|
{
|
|
|
|
get { return _nodes; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public override int GetChildrenCount (NSOutlineView outlineView, NSObject item)
|
|
|
|
{
|
|
|
|
if (item is TreeDataNode) {
|
|
|
|
TreeDataNode nodeItem = item as TreeDataNode;
|
|
|
|
return nodeItem.Nodes.Count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _nodes.Count;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override NSObject GetObjectValue (NSOutlineView outlineView, NSTableColumn forTableColumn, NSObject byItem)
|
|
|
|
{
|
|
|
|
TreeDataNode nodeItem = byItem as TreeDataNode;
|
|
|
|
if (nodeItem == null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
return (NSString)nodeItem.CombinedName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override NSObject GetChild (NSOutlineView outlineView, int childIndex, NSObject ofItem)
|
|
|
|
{
|
|
|
|
TreeDataNode nodeItem = ofItem as TreeDataNode;
|
|
|
|
if (nodeItem != null) {
|
|
|
|
return nodeItem.Nodes [childIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
return Nodes[childIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool ItemExpandable (NSOutlineView outlineView, NSObject item)
|
|
|
|
{
|
|
|
|
TreeDataNode nodeItem = item as TreeDataNode;
|
|
|
|
if (nodeItem != null)
|
|
|
|
return nodeItem.HasChildren;
|
|
|
|
|
|
|
|
return false;
|
2012-11-04 01:36:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|