using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; namespace Eventech.DynPicture.Model { public class PictureLineInfo : IPictureBaseInfo, ICloneable { public PictureLineInfo() { } public PictureLineInfo(PictureLineInfo 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.StartPointF = rhs.StartPointF; this.EndPointF = rhs.EndPointF; #region line this.LineWidth = rhs.LineWidth; this.LineColor = rhs.LineColor; this.LineStyle = rhs.LineStyle; this.LineType = rhs.LineType; #endregion } #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.Line; /// /// 图层 /// public int Level { get; set; } /// /// 描述 /// public virtual string Description { get; set; } /// /// 标签 /// public virtual string Tag { get; set; } #endregion /// /// 开始点 /// public PointF StartPointF { get; set; } /// /// 结束点 /// public PointF EndPointF { get; set; } #region Line /// /// 线宽 /// public float LineWidth { get { return _lineWidth; } set { _lineWidth = value; } } private float _lineWidth = XmlConfigInfo.ConfigInfo.LineWidth; /// /// 线色 /// public Color LineColor { get { return _lineColor; } set { _lineColor = value; } } private Color _lineColor = XmlConfigInfo.ConfigInfo.LineColor; /// /// 线类型 /// public eLineType LineType { get { return _lineType; } set { _lineType = value; } } private eLineType _lineType = eLineType.Line; /// /// 线样式 /// public eLineStyle LineStyle { get { return _lineStyle; } set { _lineStyle = value; } } private eLineStyle _lineStyle = eLineStyle.Solid; #endregion #region Clone /// /// /// /// public PictureLineInfo Clone() { return new PictureLineInfo(this); } object ICloneable.Clone() { return this.Clone(); } #endregion Clone /// /// 获取坐标信息 /// /// /// public ImageInfoCoordinate GetCoordinate(Graphics g) { var angle = (float)this.StartPointF.AngleClockWise(this.EndPointF); var xp = this.StartPointF.GetXPoint(this.EndPointF); var size = new SizeF(xp.X - this.StartPointF.X, 2*XmlConfigInfo.ConfigInfo.LineShadow); return new ImageInfoCoordinate(StartPointF, angle, size, StringAlignment.Near, StringAlignment.Center); } /// /// 绘制信息 /// /// /// public void DrawInfo(Graphics g, ImageInfoCoordinate coordinate) { g.DrawLine(coordinate.Origin, coordinate.Angle, this.LineWidth, coordinate.Size.Width, this.LineColor,this.LineStyle); } /// /// 绘制高亮外观 /// /// /// /// 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.StartPointF = new PointF(this.StartPointF.X + value, this.StartPointF.Y); this.EndPointF = new PointF(this.EndPointF.X + value, this.EndPointF.Y); break; case eAxis.Y: this.StartPointF = new PointF(this.StartPointF.X, this.StartPointF.Y + value); this.EndPointF = new PointF(this.EndPointF.X, this.EndPointF.Y + value); break; default: break; } } public void DrawInfo2(Graphics g, ImageInfoCoordinate coordinate) { g.DrawLine(coordinate.Origin, coordinate.Angle, this.LineWidth, coordinate.Size.Width, this.LineColor, this.LineStyle); } } }