using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using IReaper.FileData;
using IReaper.Properties;
namespace IReaper.CourseData{
public class DataGridViewDownloadStatueCell : DataGridViewTextBoxCell
{
/// <summary>
///
/// </summary>
public DataGridViewDownloadStatueCell()
{
this.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
}
protected override object
GetFormattedValue(object value,
int rowIndex,
ref DataGridViewCellStyle cellStyle,
System.ComponentModel.TypeConverter valueTypeConverter,
System.ComponentModel.TypeConverter formattedValueTypeConverter,
DataGridViewDataErrorContexts context)
{
//get data
FileDataStatueWrapper data = value as FileDataStatueWrapper;
if (data == null)
return "";
//
switch (data.runstatue)
{
case RunningStatue.Created:
cellStyle.ForeColor = Color.Black;
return Resources.Created;// "";
case RunningStatue.Error:
cellStyle.ForeColor = Color.Red;
this.ToolTipText = (string)this.DataGridView["Message", rowIndex].Value;
return Resources.Error;// "";
case RunningStatue.Finished:
cellStyle.ForeColor = Color.Green;
return Resources.Completed;// "";
case RunningStatue.Running:
cellStyle.ForeColor = Color.Blue;
return this.GetRunningLifeTime(data.position);
case RunningStatue.RunRequest:
cellStyle.ForeColor = Color.LightBlue;
return Resources.Queueing;// "";
case RunningStatue.RunQueued:
cellStyle.ForeColor = Color.LightBlue;
return Resources.Queueing;// "";
case RunningStatue.Stopped:
cellStyle.ForeColor = Color.Black;
return Resources.Pause;// "";
case RunningStatue.StopRequest:
cellStyle.ForeColor = Color.DarkBlue;
return Resources.Stopping;// "";
}
return "";
}
private string GetRunningLifeTime(LifetimePosition position)
{
switch (position)
{
case LifetimePosition.DownloadCreated:
return Resources.Queueing;// "";
case LifetimePosition.DownloadFinished:
return Resources.DownloadFinished;// "";
case LifetimePosition.Downloading:
return Resources.Downloading;// "";
case LifetimePosition.DownloadProcessed:
return Resources.TaskDone;// "";
case LifetimePosition.ExtensionChange:
return Resources.Renamed;// "";
case LifetimePosition.LocalFileCreated:
return Resources.TempFileCreated;// "";
case LifetimePosition.TaskCreated:
return Resources.TaskCreated;// "";
case LifetimePosition.UnCompressing:
return Resources.Extracting;// "";
}
return "";
}
}
}
|