123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- 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
- {
- /// <summary>
- /// 基本线类
- /// </summary>
- 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<Color> m_list_colors;
- /// <summary>
- /// 克隆基本线
- /// </summary>
- /// <returns></returns>
- public override object Clone()
- {
- return MemberwiseClone();
- }
- public DisplaySegment()
- {
- m_id = System.Guid.NewGuid();
- }
- /// <summary>
- /// ID
- /// </summary>
- public override Guid guid
- {
- get { return m_id; }
- set { m_id = value; }
- }
- /// <summary>
- /// 画面的大小
- /// </summary>
- public override RectangleF Rect
- {
- get { return m_region; }
- set { m_region = value; }
- }
- /// <summary>
- /// OTSField
- /// </summary>
- public override PointF OTSPointF
- {
- get { return m_OTSPointF; }
- set { m_OTSPointF = value; }
- }
- /// <summary>
- /// 画布是否被选择
- /// </summary>
- public override bool IsSelect
- {
- get { return m_isselect; }
- set { m_isselect = value; }
- }
- /// <summary>
- /// 是否在被拖动
- /// </summary>
- public override bool IsDragging
- {
- get { return m_isdragging; }
- set { m_isdragging = value; }
- }
- /// <summary>
- /// 被拖动到的位置坐标
- /// </summary>
- public override PointF DraggingPoint
- {
- get { return m_dragingpoint; }
- set { m_dragingpoint = value; }
- }
- /// <summary>
- /// 线的颜色
- /// </summary>
- public override Color Color
- {
- get { return m_color; }
- set { m_color = value; }
- }
- /// <summary>
- /// 背景色
- /// </summary>
- public override Color BackColor
- {
- get { return m_backcolor; }
- set { m_backcolor = value; }
- }
- /// <summary>
- /// 多边形的图形路径边缘
- /// </summary>
- public override GraphicsPath GPath
- {
- get { return m_gpath; }
- set { m_gpath = value; }
- }
- /// <summary>
- /// 设置画笔的笔宽度
- /// </summary>
- public float PenWidthAndHeight
- {
- get { return m_PenWidthAndHeight; }
- set { m_PenWidthAndHeight = value; }
- }
- /// <summary>
- /// 设置显示的方式,可以用,绘线显示查看标准库颜色的,也可以用绘点,查看BSE原图颗粒图色的
- /// </summary>
- public SegmentShowMode ShowMode
- {
- get { return show_mode; }
- set { show_mode = value; }
- }
- /// <summary>
- /// 保存BSE标准库文件的颗粒点的颜色信息
- /// </summary>
- public List<Color> List_Colors
- {
- get { return m_list_colors; }
- set { m_list_colors = value; }
- }
- /// <summary>
- /// 绘制函数
- /// </summary>
- /// <param name="e"></param>
- 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);
-
- // }
- //}
- }
- }
- }
|