using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using IReaper.FileData;
using IReaper.CourseData;
using IReaper.Properties;
using IReaper.Category;
namespace IReaper.CourseData{
public delegate TreeNode GetTreeNodeEventHandler();
class WebcastRootNodeBuilder
{
#region Instance
TreeNode rootNode;
///
/// </summary>
/// <param name="Node"></param>
private WebcastRootNodeBuilder()
{ }
/// <summary>
/// 7
/// </summary>
void CreateSubNodes(TreeNode Node)
{
if (Node == null)
return;
this.rootNode = Node;
this.rootNode.ImageKey = "Webcast";
this.rootNode.SelectedImageKey = "Webcast";
this.rootNode.Nodes.Clear();
//
TreeNode techNode = new TreeNode(Resources.Technology);//"");
TreeNode seriesNode = new TreeNode(Resources.Series);//"");
TreeNode productNode = new TreeNode(Resources.Product);//"");
TreeNode teacherNode = new TreeNode(Resources.Speaker);//"");
TreeNode levelNode = new TreeNode(Resources.Level);//"");
TreeNode rateNode = new TreeNode(Resources.Rate);//"");
TreeNode timeNode = new TreeNode(Resources.Time);//"");
//
techNode.Name = CourseAttributeTypeEnum.Technology.ToString();
techNode.SelectedImageKey = techNode.ImageKey = CourseAttributeTypeEnum.Technology.ToString();
seriesNode.Name = CourseAttributeTypeEnum.Series.ToString();
seriesNode.SelectedImageKey = seriesNode.ImageKey = CourseAttributeTypeEnum.Series.ToString();
productNode.Name = CourseAttributeTypeEnum.Product.ToString();
productNode.SelectedImageKey = productNode.ImageKey = CourseAttributeTypeEnum.Product.ToString();
teacherNode.Name = CourseAttributeTypeEnum.Speaker.ToString();
teacherNode.SelectedImageKey = teacherNode.ImageKey = CourseAttributeTypeEnum.Speaker.ToString();
levelNode.Name = CourseAttributeTypeEnum.Level.ToString();
levelNode.SelectedImageKey = levelNode.ImageKey = CourseAttributeTypeEnum.Level.ToString();
timeNode.Name = CourseAttributeTypeEnum.Time.ToString();
timeNode.SelectedImageKey = timeNode.ImageKey = CourseAttributeTypeEnum.Time.ToString();
rateNode.Name = CourseAttributeTypeEnum.Rating.ToString();
rateNode.SelectedImageKey = rateNode.ImageKey = CourseAttributeTypeEnum.Rating.ToString();
//i
//root
if (this.rootNode.TreeView != null)
{
this.rootNode.TreeView.BeginInvoke(new System.Threading.ThreadStart(delegate()
{
this.rootNode.Nodes.AddRange(new TreeNode[]{
techNode,
seriesNode,
productNode,
teacherNode,
levelNode,
rateNode,
timeNode
});
}));
}
else
{
this.rootNode.Nodes.AddRange(new TreeNode[]{
techNode,
seriesNode,
productNode,
teacherNode,
levelNode,
rateNode,
timeNode
});
}
}
#endregion
#region static
static WebcastRootNodeBuilder builder;
static CourseCategoryVector allVector;
static WebcastRootNodeBuilder()
{
builder = new WebcastRootNodeBuilder();
}
/// <summary>
/// Node
/// </summary>
/// <param name="Node"></param>
internal static void BuildSubNodes(TreeNode Node)
{
builder.CreateSubNodes(Node);
}
/// <summary>
///
/// </summary>
public static CourseCategoryVector AllVector
{
get { return WebcastRootNodeBuilder.allVector; }
}
public static TreeNode GetAllDataNode()
{
//
WebcastCourseTreeNode<Course> allNode = ((Dictionary<string, TreeNode>)Core.CoreData[CoreDataType.AllCourseTreeNode])["All"] as WebcastCourseTreeNode<Course>;
if (allNode == null)
allNode = new WebcastCourseTreeNode<Course>();
//
BuildSubNodes(allNode);
//
allNode.Name = "All";
allNode.Tag = Resources.AllCourse;
//
allVector = CourseVectorBase.GetCoursVector(CourseDataManager.AllCourses) as CourseCategoryVector;
allNode.SetVector(allVector);
//
return allNode;
}
public static TreeNode GetCompletedDataNode()
{
//
WebcastCourseTreeNode<Course> completedNode = ((Dictionary<string, TreeNode>)Core.CoreData[CoreDataType.AllCourseTreeNode])["Completed"] as WebcastCourseTreeNode<Course>;
if (completedNode == null)
completedNode = new WebcastCourseTreeNode<Course>();
//
BuildSubNodes(completedNode);
//
completedNode.Name = "Completed";
completedNode.Tag = Resources.Completed;// "";
//
completedNode.SetVector(CourseVectorBase.GetCoursVector(CourseDataManager.CompletedCourses));
return completedNode;
}
public static TreeNode GetNewDataNode()
{
//
WebcastCourseTreeNode<Course> newNode = ((Dictionary<string, TreeNode>)Core.CoreData[CoreDataType.AllCourseTreeNode])["New"] as WebcastCourseTreeNode<Course>;
if (newNode == null)
newNode = new WebcastCourseTreeNode<Course>();
//
BuildSubNodes(newNode);
//
newNode.Name = "New";
newNode.Tag = Resources.New;// "";
//
newNode.SetVector(CourseVectorBase.GetCoursVector(CourseDataManager.NewCourses));
return newNode;
}
public static TreeNode GetLatestDataNode()
{
//
WebcastCourseTreeNode<Course> lastNode = ((Dictionary<string, TreeNode>)Core.CoreData[CoreDataType.AllCourseTreeNode])["Last"] as WebcastCourseTreeNode<Course>;
if (lastNode == null)
lastNode = new WebcastCourseTreeNode<Course>();
//
BuildSubNodes(lastNode);
//
lastNode.Name = "Last";
lastNode.Tag = Resources.Lastest;// "";
//
lastNode.SetVector(CourseVectorBase.GetCoursVector(CourseDataManager.LatestCourses));
return lastNode;
}
#endregion
}
}
|