using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
namespace OTSCommon.DBOperate.Model
{
[Serializable]
public class Field
{
Bitmap mImage = null;
///
/// FieldID
///
public int FieldID
{
get;
set;
}
///
/// FieldPosX
///
public int FieldPosX
{
get;
set;
}
///
/// FieldPosY
///
public int FieldPosY
{
get;
set;
}
public PointF GetOTSPosition()
{
return new PointF(FieldPosX, FieldPosY);
}
public Bitmap GetFieldImage()
{
if (mImage == null)
{
//mImage = DrawFunction.ReadImageFile(FieldImageName);
if (!File.Exists(FieldImageName))
{
return null;//文件不存在
}
FileStream fs = File.OpenRead(FieldImageName); //OpenRead
int filelength = 0;
filelength = (int)fs.Length; //获得文件长度
Byte[] image = new Byte[filelength]; //建立一个字节数组
fs.Read(image, 0, filelength); //按字节流读取
System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
fs.Close();
mImage = new Bitmap(result);
}
return mImage;
}
///
/// FieldPosY
///
public string FieldImageName
{
get;
set;
}
///
/// ParticleList
///
public List ParticleList
{
get;
set;
}
}
}