using System;
using System.Collections.Generic;
using System.Text;
using IReaper.CourseData;
using IReaper.FileData;
using IReaper.Statues;
using System.ComponentModel;
using System.IO;
namespace IReaper.Command{
/// <summary>
///
/// </summary>
class OpenFileCommand:CommandBase
{
#region ICommand
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="paras"></param>
public override void CommandBody(object sender, params object[] paras)
{
if (paras == null || paras.Length != 2)
return;
Course course = paras[0] as Course;
FileType type = (FileType)paras[1];
CourseFileData file = null;
string path;
switch (type)
{
case FileType.Code:
file = course.Code;
break;
case FileType.PPT:
file = course.PPT;
break;
case FileType.QA:
file = course.QA;
break;
case FileType.Video:
file = course.Video;
break;
case FileType.Zune:
file = course.WMV;
break;
case FileType.MP4:
file = course.MP4;
break;
case FileType.MP3:
file = course.MP3;
break;
}
if (file == null)
path = Path.Combine(IReaper.Properties.Settings.Default.RootPath, course.Headline);
else
path = file.FilePath;
if (File.Exists(path))
{
try
{
System.Diagnostics.Process.Start(path);
}
catch (Exception ex)
{
ErrorManager.ReportException(ex);
}
}
}
public override CommandFamily Family
{
get { return CommandFamily.Command_OpenCourseFile; }
}
#endregion
}
}
|