using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using IReaper.Command;
using IReaper.CourseData;
using IReaper.Notify;
namespace IReaper{
public partial class MainForm : Form
{
static string configFile = Path.Combine(Program.LocalAppFolder,"Layout.config");
#region DockContents
Browser.iReaperBrowserForm welcome;
DockContent tree;
DockContent course;
DockContent download;
//DockContent videoPlayList;
DockContent courseDetail;
#endregion
DeserializeDockContent deserializeDockContent;
public MainForm()
{
InitializeComponent();
CreateMDIForm();
iReaperNotifyManager.InitSysIcon(this.components);
Application.Idle += new EventHandler(Application_Idle);
Core.CoreData[CoreDataType.ApplicationForm] = this;
this.deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
}
private void CreateMDIForm()
{
welcome = new Browser.iReaperBrowserForm();
tree = new CourseItemTreePanel();
course = new CourseData.CoursesPanel();
download = new FileData.FilePanel();
courseDetail = new CourseDetailViewer();
//videoPlayList = new PlayListForm();
}
private void LoadMDIForm()
{
Core.CoreData[CoreDataType.ActiveDockPanel] = this.dockPanel;
tree.Show();
course.Show();
download.Show();
courseDetail.Show();
}
//
private void Application_Idle(object sender, EventArgs e)
{
LoadReminder();
Application.Idle -= new EventHandler(Application_Idle);
}
private void LoadReminder()
{
//IReaper.Statues.LoadReminderWork load = new IReaper.Statues.LoadReminderWork();
//load.RunWorkerAsync();
}
private void ShowClassic(object sender, EventArgs e)
{
tree.Show();
}
private void ShowDownload(object sender, EventArgs e)
{
download.Show();
}
private void ShowCourse(object sender, EventArgs e)
{
course.Show();
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnClosing(CancelEventArgs e)
{
//
this.dockPanel.SaveAsXml(configFile);
CommandBase command = CommandManager.GetCommand(CommandFamily.Command_CloseSystem);
command.ExecuteAsync(this,null);
e.Cancel = true;
}
private void ShowConfig(object sender, EventArgs e)
{
IReaper.Configurations.Perferences perferences = new IReaper.Configurations.Perferences();
perferences.ShowDialog();
}
private void ShowCourseDetails(object sender, EventArgs e)
{
this.courseDetail.Show();
}
/// <summary>
/// iReaper
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OpenWebsite(object sender, EventArgs e)
{
Browser.BrowserManager.OpenWebsite("http://www.ireaper.net");
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnActiveContentChanged(object sender, EventArgs e)
{
Core.CoreData[CoreDataType.ActiveDockContent] = this.dockPanel.ActiveContent;
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnResize(EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Hide();
}
base.OnResize(e);
}
private void OpenAboutForm(object sender, EventArgs e)
{
AboutForm about = new AboutForm();
about.ShowDialog();
}
private IDockContent GetContentFromPersistString(string persistString)
{
if (persistString == typeof(CourseItemTreePanel).ToString())
return this.tree;
else if (persistString == typeof(CourseData.CoursesPanel).ToString())
return this.course;
else if (persistString == typeof(FileData.FilePanel).ToString())
return this.download;
else if (persistString == typeof(CourseDetailViewer).ToString())
return this.courseDetail;
return null;
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnLoad(EventArgs e)
{
if (File.Exists(configFile))
{
try
{
this.dockPanel.LoadFromXml(configFile, this.deserializeDockContent);
Core.CoreData[CoreDataType.ActiveDockPanel] = this.dockPanel;
}
catch
{
LoadMDIForm();
}
}
else
{
LoadMDIForm();
}
welcome.LoadWelcomeWeb();
base.OnLoad(e);
}
}
}
|