using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using IReaper;
namespace IReaper.CourseData{
public partial class CourseDetailViewer : iReaperDockContent
{
Course currentCourse;
public CourseDetailViewer()
{
InitializeComponent();
Core.CoreData.PropertyChanged += new PropertyChangedEventHandler(CoreData_PropertyChanged);
}
private void CoreData_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == CoreDataType.CurrentSelectedCourses.ToString())
{
CourseCollection courses = Core.CoreData[CoreDataType.CurrentSelectedCourses] as CourseCollection;
if (courses == null || courses.Count == 0)
{
return;
}
this.currentCourse = courses[0];
if (this.InvokeRequired)
{
this.BeginInvoke(new ThreadStart(this.ShowCourse));
}
else
{
this.ShowCourse();
}
}
}
private void ShowCourse()
{
//set text
this.labelID.Text = this.currentCourse.Id;
this.labelHeadline.Text = this.currentCourse.Headline;
this.labelDescription.Text = this.currentCourse.Description;
this.labelSpeaker.Text = this.currentCourse.Speaker;
this.linkLabelUrl.Text = this.currentCourse.CourseUrl;
this.labelRating.Text = this.currentCourse.Rate.ToString();
}
private void OpenWebsite(object sender, LinkLabelLinkClickedEventArgs e)
{
Uri uri;
if (Uri.TryCreate(this.linkLabelUrl.Text, UriKind.Absolute, out uri))
{
Browser.BrowserManager.OpenWebsite(uri);
}
}
private void labelDescription_MouseHover(object sender, EventArgs e)
{
this.toolTip.SetToolTip(this.labelDescription, this.labelDescription.Text);
}
private void labelSpeaker_MouseHover(object sender, EventArgs e)
{
this.toolTip.SetToolTip(this.labelSpeaker, this.currentCourse.Resume);
}
}
}
|