AIMS/DrawGraph/BoardPack/ImagePackObj.cs
2022-12-29 21:57:18 +08:00

90 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
}
}
}
}
}
}