using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CommonMethods
{
[Serializable]
public class IToolInfo
{
///
/// 工具是否启用
///
public bool enable { get; set; }
///
/// 工具名称
///
public string toolName { get; set; }
///
/// 工具类型
///
public ToolType toolType { get; set; }
///
/// 工具对象
///
public object tool { get; set; }
///
/// 工具窗体,由于无法对Form进行序列化,所以作为静态变量
///
[NonSerialized]
public Form FormTool = new Form();
///
/// 工具窗体名
///
public string FormToolName { get; set; }
///
/// 工具描述信息
///
public string toolTipInfo { get; set; }
///
/// 工具输入字典集合
///
public List toolInput { get; set; }
///
/// 工具输出字典集合
///
public List toolOutput { get; set; }
///
/// 工具作用描述
///
public string toolDescription { get; set; }
///
/// 工具运行结果
///
public ToolRunStatu toolRunStatu { get; set; }
///
/// 绑定的JOB名称
///
public string bingingJobName { get; set; }
public IToolInfo()
{
enable = true;
toolType = ToolType.None;
toolName = string.Empty;
bingingJobName = string.Empty;
tool = new object();
toolInput = new List();
toolOutput = new List();
}
///
/// 以IO名获取IO对象
///
///
///
public ToolIO GetInput(string IOName)
{
for (int i = 0; i < toolInput.Count; i++)
{
if (toolInput[i].IOName == IOName)
return toolInput[i];
}
return new ToolIO();
}
///
/// 以IO名获取IO对象
///
///
///
public ToolIO GetOutput(string IOName)
{
for (int i = 0; i < toolOutput.Count; i++)
{
if (toolOutput[i].IOName == IOName)
return toolOutput[i];
}
return new ToolIO();
}
///
/// 移除工具输入项
///
///
public void RemoveInputIO(string IOName)
{
for (int i = 0; i < toolInput.Count; i++)
{
if (toolInput[i].IOName == toolName)
toolInput.RemoveAt(i);
}
}
///
/// 移除工具输出项
///
///
public void RemoveOutputIO(string IOName)
{
for (int i = 0; i < toolOutput.Count; i++)
{
if (toolOutput[i].IOName == toolName)
toolOutput.RemoveAt(i);
}
}
public Form GetFormTool()
{
return FormTool;
}
public void SetFormTool(Form myForm)
{
FormTool = myForm;
}
}
///
/// 工具的输入输出类
///
[Serializable]
public class ToolIO
{
public string IOName;
public object value;
public DataType ioType;
public ToolIO() { }
public ToolIO(string IOName1, object value1, DataType ioType1)
{
this.IOName = IOName1;
this.value = value1;
this.ioType = ioType1;
}
}
}