using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
|
namespace Eventech.DynPicture.Model
|
{
|
/// <summary>
|
/// 箭头信息
|
/// </summary>
|
public class PictureArrowInfo : IPictureBaseInfo, ICloneable
|
{
|
public PictureArrowInfo() { }
|
public PictureArrowInfo(PictureArrowInfo 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;
|
|
this.ArrowLength = rhs.ArrowLength;
|
this.ArrowWidth = rhs.ArrowWidth;
|
this.ArrowColor = rhs.ArrowColor;
|
|
this.LineColor = rhs.LineColor;
|
this.LineWidth = rhs.LineWidth;
|
}
|
|
#region 图片信息基础属性
|
|
/// <summary>
|
/// 唯一标识
|
/// </summary>
|
public long ID { get; set; }
|
|
/// <summary>
|
/// 名称
|
/// </summary>
|
public string Name { get; set; }
|
|
/// <summary>
|
/// 是否允许修改
|
/// </summary>
|
public bool AllowEdit { get; set; }
|
|
/// <summary>
|
/// 获取图片信息类型
|
/// </summary>
|
public ePictureInfoType InfoType
|
{
|
get { return _infoType; }
|
private set { _infoType = value; }
|
}
|
private ePictureInfoType _infoType = ePictureInfoType.Arrow;
|
|
/// <summary>
|
/// 图层
|
/// </summary>
|
public int Level { get; set; }
|
|
/// <summary>
|
/// 描述
|
/// </summary>
|
public virtual string Description { get; set; }
|
|
/// <summary>
|
/// 标签
|
/// </summary>
|
public virtual string Tag { get; set; }
|
|
#endregion
|
|
/// <summary>
|
/// 开始点
|
/// </summary>
|
public PointF StartPointF { get; set; }
|
|
/// <summary>
|
/// 结束点
|
/// </summary>
|
public PointF EndPointF { get; set; }
|
|
#region Arrow
|
|
/// <summary>
|
/// 箭头长度
|
/// </summary>
|
public float ArrowLength
|
{
|
get { return _arrowLength; }
|
set { _arrowLength = value; }
|
}
|
private float _arrowLength = XmlConfigInfo.ConfigInfo.ArrowLength;
|
|
/// <summary>
|
/// 箭头宽度
|
/// </summary>
|
public float ArrowWidth
|
{
|
get { return _arrowWidth; }
|
set { _arrowWidth = value; }
|
}
|
private float _arrowWidth = XmlConfigInfo.ConfigInfo.ArrowWidth;
|
|
/// <summary>
|
/// 箭头颜色
|
/// </summary>
|
public Color ArrowColor
|
{
|
get { return _arrowColor; }
|
set { _arrowColor = value; }
|
}
|
private Color _arrowColor = XmlConfigInfo.ConfigInfo.ArrowColor;
|
|
#endregion
|
|
#region Line
|
/// <summary>
|
/// 线宽
|
/// </summary>
|
public float LineWidth
|
{
|
get { return _lineWidth; }
|
set { _lineWidth = value; }
|
}
|
private float _lineWidth = XmlConfigInfo.ConfigInfo.LineWidth;
|
|
/// <summary>
|
/// 线色
|
/// </summary>
|
public Color LineColor
|
{
|
get { return _lineColor; }
|
set { _lineColor = value; }
|
}
|
|
private Color _lineColor = XmlConfigInfo.ConfigInfo.LineColor;
|
#endregion
|
|
#region Clone
|
|
public PictureArrowInfo Clone()
|
{
|
return new PictureArrowInfo(this);
|
}
|
object ICloneable.Clone()
|
{
|
return this.Clone();
|
}
|
|
#endregion Clone
|
|
/// <summary>
|
/// 获取坐标信息
|
/// </summary>
|
/// <param name="g"></param>
|
/// <returns></returns>
|
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);
|
}
|
|
/// <summary>
|
/// 绘制信息
|
/// </summary>
|
/// <param name="g"></param>
|
/// <param name="coordinate"></param>
|
public void DrawInfo(Graphics g, ImageInfoCoordinate coordinate)
|
{
|
g.DrawArrow(coordinate.Origin,coordinate.Angle,this.LineWidth, coordinate.Size.Width, this.LineColor, this.ArrowWidth,this.ArrowLength,this.ArrowColor);
|
}
|
|
/// <summary>
|
/// 绘制高亮外观
|
/// </summary>
|
/// <param name="g"></param>
|
/// <param name="coordinate"></param>
|
/// <param name="func"></param>
|
public void DrawHighlightAppearance(Graphics g, ImageInfoCoordinate coordinate, Func<PointF, PointF> 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.DrawArrow(coordinate.Origin, coordinate.Angle, this.LineWidth, coordinate.Size.Width, this.LineColor, this.ArrowWidth, this.ArrowLength, this.ArrowColor);
|
}
|
}
|
}
|