using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; namespace Eventech.DynPicture.Model { /// /// 图片信息 /// public class PictureImageInfo : IPictureBaseInfo, ICloneable { public PictureImageInfo() { } public PictureImageInfo(PictureImageInfo rhs) { #region base this.ID = rhs.ID; this.Name = rhs.Name; this.AllowEdit = rhs.AllowEdit; this.InfoType = rhs.InfoType; this.Level = rhs.Level; this.Description = rhs.Description; this.Tag = rhs.Tag; #endregion this.Point = rhs.Point; this.Image = rhs.Image; this.Angle = rhs.Angle; } #region 图片信息基础属性 /// /// 唯一标识 /// public long ID { get; set; } /// /// 名称 /// public string Name { get; set; } /// /// 是否允许修改 /// public bool AllowEdit { get; set; } /// /// 获取图片信息类型 /// public ePictureInfoType InfoType { get { return _infoType; } private set { _infoType = value; } } private ePictureInfoType _infoType = ePictureInfoType.Image; /// /// 图层 /// public int Level { get; set; } /// /// 描述信息 /// public virtual string Description { get; set; } /// /// 标签 /// public virtual string Tag { get; set; } #endregion /// /// 位置信息 /// public PointF Point { get; set; } /// /// 图片 /// public Bitmap Image { get; set; } /// /// 旋转角度 /// public float Angle { get { return _angle; } set { _angle = value; } } private float _angle = 0; #region Clone /// /// /// /// public PictureImageInfo Clone() { return new PictureImageInfo(this); } object ICloneable.Clone() { return this.Clone(); } #endregion Clone /// /// 获取坐标信息 /// /// /// public ImageInfoCoordinate GetCoordinate(Graphics g) { if (Image == null) return null; return new ImageInfoCoordinate(this.Point, this.Angle, this.Image.Size, StringAlignment.Center, StringAlignment.Center); } /// /// 绘制信息 /// /// /// public void DrawInfo(Graphics g, ImageInfoCoordinate coordinate) { if (this.Image == null) return; g.DrawImage(this.Image, this.Point, this.Angle, StringAlignment.Center, StringAlignment.Center); } /// /// 绘制高亮外观 /// /// /// /// public void DrawHighlightAppearance(Graphics g, ImageInfoCoordinate coordinate, Func func) { var points = new PointF[5]; points[0] = func(coordinate.AfterLeftTop); points[1] = func(coordinate.AfterRightTop); points[2] = func(coordinate.AfterRightBottom); points[3] = func(coordinate.AfterLeftBottom); points[4] = points[0]; using (var pen = new Pen(XmlConfigInfo.ConfigInfo.HighlightBorderColor, XmlConfigInfo.ConfigInfo.HighlightBorderWidth)) { g.DrawLines(pen, points); } } public void IncreaseAxisValue(eAxis axis, float value) { switch (axis) { case eAxis.X: this.Point = new PointF(this.Point.X + value, this.Point.Y); break; case eAxis.Y: this.Point = new PointF(this.Point.X, this.Point.Y + value); break; default: break; } } public void DrawInfo2(Graphics g, ImageInfoCoordinate coordinate) { if (this.Image == null) return; g.DrawImage(this.Image, this.Point, this.Angle, StringAlignment.Center, StringAlignment.Center); } } }