using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using IReaper.Command;
using IReaper.Category;
using IReaper.CommonGui;
namespace IReaper.CourseData{
public partial class CourseItemTreePanel : iReaperDockContent
{
public CourseItemTreePanel()
{
InitializeComponent();
Core.CoreData.PropertyChanged += new PropertyChangedEventHandler(CoreData_PropertyChanged);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
//set treenode
this.SetCurrentViewedTreeNode();
}
/// <summary>
/// CoreGUIComponentCurrentViewedTreeNodeTreeNode
/// </summary>
private void SetCurrentViewedTreeNode()
{
TreeNode node = (TreeNode)Core.CoreData[CoreDataType.CurrentViewedCourseTreeNode];
if (node != null)
{
if (this.taskItemTree.Nodes.Count == 0 || this.taskItemTree.Nodes[0] != node)
{
//
//
node.Remove();
this.taskItemTree.BeginUpdate();
this.taskItemTree.Nodes.Clear();
node.Text = IReaper.Properties.Resources.MSDNCourse;
node.Name = "MSDN Root";
this.taskItemTree.Nodes.Add(node);
this.taskItemTree.EndUpdate();
node.Expand();
this.taskItemTree.SelectedNode = node;
}
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void contextMenuStripTreeView_Opening(object sender, CancelEventArgs e)
{
ButtonStatuMonitor.DataType = CoreDataType.CurrentViewedCourses;
this.toolStripMenuItemDownload.Enabled = ButtonStatuMonitor.CanDownload;
this.toolStripMenuItemRemoveFile.Enabled = ButtonStatuMonitor.CanRemove;
}
protected override void OnClosing(CancelEventArgs e)
{
taskItemTree.Nodes.Clear();
base.OnClosing(e);
}
/* Command
* Core
*/
private void CoreData_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == CoreDataType.CurrentViewedCourseTreeNode.ToString())
{
this.SetCurrentViewedTreeNode();
}
}
}
}
|