using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
namespace MS.SDKMSDNKeywordIndex
{
public class TocNodeViewModel : TreeViewItemViewModel
{
readonly TocNode _tocNode;
private HelpApiShim api = new HelpApiShim();
public TocNodeViewModel(TocNode node)
: base(null, true)
{
_tocNode = node;
}
public TocNodeViewModel(TocNode tocNode, TocNodeViewModel parentNode)
: base(parentNode, true)
{
_tocNode = tocNode;
}
public string Title
{
get { return _tocNode.Title; }
}
public string Url
{
get { return _tocNode.Url; }
}
public string Id
{
get { return _tocNode.Id; }
}
protected override void LoadChildren()
{
if (_tocNode.hasChildren)
{
try
{
foreach (TocNode node in api.GetTocNodes(_tocNode))
{
base.Children.Add(new TocNodeViewModel(node, this));
}
}
catch (WebException )
{
//retart the agent, get a new API instance due to PID change
api = new HelpApiShim();
LoadChildren();
}
}
}
}
}