lixiaojun
2024-08-15 11bfb11f3f352315fe64104509adda13d9f870d0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
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 图片信息基础属性
 
        /// <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.Line;
 
        /// <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 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;
 
        /// <summary>
        /// 线类型
        /// </summary>
        public eLineType LineType
        {
            get { return _lineType; }
            set { _lineType = value; }
        }
        private eLineType _lineType = eLineType.Line;
 
        /// <summary>
        /// 线样式
        /// </summary>
        public eLineStyle LineStyle
        {
            get { return _lineStyle; }
            set { _lineStyle = value; }
        }
        private eLineStyle _lineStyle = eLineStyle.Solid;
     
        #endregion
 
        #region Clone
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public PictureLineInfo Clone()
        {
            return new PictureLineInfo(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.DrawLine(coordinate.Origin, coordinate.Angle, this.LineWidth, coordinate.Size.Width, this.LineColor,this.LineStyle);
        }
 
 
        /// <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.DrawLine(coordinate.Origin, coordinate.Angle, this.LineWidth, coordinate.Size.Width, this.LineColor, this.LineStyle);
        }
    }
}