using System;
using System.Threading;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using IReaper.CourseData;
using IReaper.FileData;
using IReaper.Command;
namespace IReaper.CommonGui{
public partial class CourseViewToolStrip : ToolStrip
{
public CourseViewToolStrip()
{
InitializeComponent();
Core.CoreData.PropertyChanged += new PropertyChangedEventHandler(CoreComponent_PropertyChanged);
}
public CourseViewToolStrip(IContainer container)
{
container.Add(this);
InitializeComponent();
Core.CoreData.PropertyChanged += new PropertyChangedEventHandler(CoreComponent_PropertyChanged);
}
private void CoreComponent_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == CoreDataType.CurrentSelectedCourses.ToString())
{
UpdateButtonStatue();
}
}
/// <summary>
/// CoreGUIComponent
/// </summary>
private void UpdateButtonStatue()
{
bool forceRemind = Properties.Settings.Default.RemindAllNewCourse;
ButtonStatuMonitor.DataType = CoreDataType.CurrentSelectedCourses;
this.toolStripSBDownload.Enabled = ButtonStatuMonitor.CanDownload;
this.toolStripSBOpen.Enabled = ButtonStatuMonitor.CanOpen;
this.toolStripSBRemove.Enabled = ButtonStatuMonitor.CanRemove;
this.toolStripSBExport.Enabled = ButtonStatuMonitor.CanExport;
}
private void UpdateViewTreeView(object sender, EventArgs e)
{
int index = this.toolStripCBCourseFilter.SelectedIndex;
string key = null;
switch (index)
{
case 0:
key = "Last";
break;
case 1:
key = "New";
break;
case 2:
key = "All";
break;
case 3:
key = "Completed";
break;
default:
return;
}
IReaper.Core.CoreData[CoreDataType.CurrentViewedCourseTreeNode] = ((Dictionary<string, TreeNode>)Core.CoreData[CoreDataType.AllCourseTreeNode])[key];
}
protected override void OnCreateControl()
{
if (this.toolStripCBCourseFilter.Items.Count > 0)
{
this.toolStripCBCourseFilter.SelectedIndex = 0;
}
base.OnCreateControl();
}
private void SynData(object sender, EventArgs e)
{
CommandBase command = CommandManager.GetCommand(CommandFamily.Command_SynchorizeCourseData);
command.Execute(null, null);
}
}
}
|