StraightLine.cs
2.0 KB
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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace zhouchen.chart.chart
{
// 直线类
public class StraightLine : LinerChart
{
private Point _ptStart = new Point(0,0);
private Point ptStart
{
get { return _ptStart; }
set {
_ptStart = value;
NotifyPropertyChanged("ptStart");
}
}
private Point _ptEnd = new Point(0,0);
public Point ptEnd
{
get { return _ptEnd; }
set
{
_ptEnd = value;
NotifyPropertyChanged("ptEnd");
}
}
public StraightLine()
{
_chartType = ChartType.Chart_Straight;
}
public StraightLine(Point ptStart, Point ptEnd) : this()
{
_ptStart = ptStart;
_ptEnd = ptEnd;
}
public override void DrawChart(Graphics graph, Matrix matrix)
{
Point[] pts = new Point[] { _ptStart, _ptEnd };
matrix.TransformPoints(pts);
Pen pen = new Pen(this._ColorLine, this._nLineWidth);
graph.DrawLine(pen, pts[0], pts[1]);
if (!IsSelect)
{
return;
}
Pen pen_select_line = new Pen(COLOR_SELECT_LINE, 1);
Brush brush_select_fill = new SolidBrush(COLOR_SELECT_FILL);
Rectangle[] rcpt = new Rectangle[pts.Length];
int nIndex = 0;
foreach (Point pt in pts)
{
rcpt[nIndex++] = new Rectangle(pt.X - SPACE_HALF, pt.Y - SPACE_HALF, SPACE_FULL, SPACE_FULL);
}
graph.DrawLine(pen_select_line, pts[0], pts[1]);
foreach (Rectangle rc in rcpt)
{
graph.FillEllipse(brush_select_fill, rc);
graph.DrawEllipse(pen_select_line, rc);
}
}
}
}