using DrawGraph; using Newtonsoft.Json; using System; using System.Drawing; using System.IO; namespace DrawGraph { [JsonObject(MemberSerialization.OptOut)] [Serializable] public class ImagePackObj : PackObjBase { [JsonIgnore] private Image img = null; private string fileName = ""; [ClassAttributs(Description = "只能写项目资源目录(Resources)下的图片名称")] public string FileName { get { return this.fileName; } set { this.fileName = value; FileStream fileStream = null; try { fileStream = new FileStream( this.fileName, FileMode.Open, FileAccess.Read); this.img = Image.FromStream(fileStream); } catch (Exception ) { } finally { bool flag = fileStream != null; if (flag) { fileStream.Close(); fileStream.Dispose(); } } } } public ImagePackObj(ZedGraphControl zgc, PackObjManager poManager) : base(zgc, poManager) { this.baseZed = zgc; base.PackText = "图片" + this.index.ToString(); } public override void Draw() { bool flag = this.baseZed == null; if (!flag) { this.Clear(); bool flag2 = this.fileName == ""; if (!flag2) { bool flag3 = this.img == null; if (!flag3) { ZUtil.DrawImage(new ImageObj(this.img, (double)base.RealX, (double)base.RealY, (double)base.RealEndX, (double)base.RealEndY) { IsVisible = true, ZOrder = ZOrder.A_InFront, Tag = base.PackTag, Location = { CoordinateFrame = CoordType.PaneFraction, AlignH = AlignH.Left, AlignV = AlignV.Top }, //IsVisible = true, //ZOrder = ZOrder.A_InFront }, this.baseZed); base.Refresh(); } } } } } }