using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using IReaper.Properties;
namespace IReaper.FileData{
public partial class CourseFileProperty : UserControl
{
CourseFileData file;
string shadowPath;
public CourseFileProperty(CourseFileData File)
{
this.file = File;
}
public CourseFileProperty()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.file == null)
{
this.ShowNoSuchFile();
}
else
{
this.labelFileType.Text = this.file.FileType.ToString();
this.openFileDialog.InitialDirectory = this.file.RootPath;
this.openFileDialog.FileName = this.file.FileName;
switch (this.file.RunState)
{
case RunningStatue.Created:
this.ShowEmpty();
return;
case RunningStatue.Finished:
this.ShowCompleted();
break;
case RunningStatue.Stopped:
case RunningStatue.Error:
this.ShowInCompletedAndPause();
break;
default:
this.ShowInCompletedAndRunning();
break;
}
this.textBoxFilePath.Text = this.file.FilePath;
}
}
#region Statue Definition
/// <summary>
///
/// </summary>
private void ShowNoSuchFile()
{
//
this.Visible = false;
this.Enabled = false;
}
/// <summary>
///
/// </summary>
private void ShowEmpty()
{
this.labelStatue.ForeColor = Color.Gainsboro;
this.labelStatue.Text = Resources.Created;
this.buttonAttach.Enabled = true;
}
/// <summary>
/// ,
/// </summary>
private void ShowInCompletedAndPause()
{
this.labelStatue.ForeColor = Color.Red;
this.labelStatue.Text = Resources.Pause;
this.buttonAttach.Enabled = false;
}
/// <summary>
///
/// </summary>
private void ShowInCompletedAndRunning()
{
this.labelStatue.ForeColor = Color.Yellow;
this.labelStatue.Text = Resources.Running;
this.buttonAttach.Enabled = false;
}
/// <summary>
///
/// </summary>
private void ShowCompleted()
{
this.labelStatue.ForeColor = Color.Green;
this.labelStatue.Text = Resources.Completed;
this.buttonAttach.Enabled = true;
}
#endregion
private void ChangeFile(object sender, EventArgs e)
{
if (this.file == null)
return;
if (this.openFileDialog.ShowDialog() == DialogResult.OK)
{
this.shadowPath = this.openFileDialog.FileName;
this.textBoxFilePath.Text = this.shadowPath;
}
}
/// <summary>
///
/// </summary>
public void CommiteChange()
{
if (string.IsNullOrEmpty(this.shadowPath))
return;
//
try
{
FileUtils.FileTransferManager.ImportCourseFileDataFromSingleFile(this.file, this.shadowPath);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
public CourseFileData File
{
get { return file; }
set { file = value; }
}
}
}
|