using OTSCommon.Model; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace OTSIncAReportGraph { /// /// 基本线类 /// public class DisplaySegment : BaseObject, ICloneable { private Guid m_id; private RectangleF m_region; private PointF m_OTSPointF; private bool m_isselect; private bool m_isdragging; private PointF m_dragingpoint; private Color m_color; private Color m_backcolor; private GraphicsPath m_gpath; private float m_PenWidthAndHeight = 1; private SegmentShowMode show_mode = SegmentShowMode.DRAWPOINT;//绘线,绘点,默认绘点,意思为默认显示BSE原图像 private List m_list_colors; /// /// 克隆基本线 /// /// public override object Clone() { return MemberwiseClone(); } public DisplaySegment() { m_id = System.Guid.NewGuid(); } /// /// ID /// public override Guid guid { get { return m_id; } set { m_id = value; } } /// /// 画面的大小 /// public override RectangleF Rect { get { return m_region; } set { m_region = value; } } /// /// OTSField /// public override PointF OTSPointF { get { return m_OTSPointF; } set { m_OTSPointF = value; } } /// /// 画布是否被选择 /// public override bool IsSelect { get { return m_isselect; } set { m_isselect = value; } } /// /// 是否在被拖动 /// public override bool IsDragging { get { return m_isdragging; } set { m_isdragging = value; } } /// /// 被拖动到的位置坐标 /// public override PointF DraggingPoint { get { return m_dragingpoint; } set { m_dragingpoint = value; } } /// /// 线的颜色 /// public override Color Color { get { return m_color; } set { m_color = value; } } /// /// 背景色 /// public override Color BackColor { get { return m_backcolor; } set { m_backcolor = value; } } /// /// 多边形的图形路径边缘 /// public override GraphicsPath GPath { get { return m_gpath; } set { m_gpath = value; } } /// /// 设置画笔的笔宽度 /// public float PenWidthAndHeight { get { return m_PenWidthAndHeight; } set { m_PenWidthAndHeight = value; } } /// /// 设置显示的方式,可以用,绘线显示查看标准库颜色的,也可以用绘点,查看BSE原图颗粒图色的 /// public SegmentShowMode ShowMode { get { return show_mode; } set { show_mode = value; } } /// /// 保存BSE标准库文件的颗粒点的颜色信息 /// public List List_Colors { get { return m_list_colors; } set { m_list_colors = value; } } /// /// 绘制函数 /// /// public override void OnPaint(PaintEventArgs e) { //两种绘制模式的选择,绘线还是缓点 if (show_mode == SegmentShowMode.DRAWLINE) { //表示显示的是带有标准库的图像 Pen p = new Pen(m_color, m_PenWidthAndHeight + 1f);//这里加1f的宽度后,用线组成多边形不会分散,效果正常,原因不知,但目前没有遇到问题 e.Graphics.DrawLine(p, Rect.X, Rect.Y, Rect.X + Rect.Width, Rect.Y); } //else if (show_mode == SegmentShowMode.DRAWPOINT) //{ // //根据color的序列,显示绘制的原像素的图像。 // for (int i = 0; i < m_list_colors.Count(); i++) // { // e.Graphics.FillRectangle(new SolidBrush(m_list_colors[i]), // this.Rect.X + (i * m_PenWidthAndHeight) + 1f, // this.Rect.Y, // m_PenWidthAndHeight, // m_PenWidthAndHeight); // } //} } } }