12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.IO;
- namespace OTSCommon.DBOperate.Model
- {
- [Serializable]
- public class Field
- {
- Bitmap mImage = null;
- /// <summary>
- /// FieldID
- /// </summary>
- public int FieldID
- {
- get;
- set;
- }
- /// <summary>
- /// FieldPosX
- /// </summary>
- public int FieldPosX
- {
- get;
- set;
- }
- /// <summary>
- /// FieldPosY
- /// </summary>
- 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;
- }
- /// <summary>
- /// FieldPosY
- /// </summary>
- public string FieldImageName
- {
- get;
- set;
- }
- /// <summary>
- /// ParticleList
- /// </summary>
- public List<Particle> ParticleList
- {
- get;
- set;
- }
- }
- }
|