-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathTracker.cs
More file actions
180 lines (161 loc) · 3.78 KB
/
Tracker.cs
File metadata and controls
180 lines (161 loc) · 3.78 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
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
using System;
using System.Collections;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using Netron.GraphLib.UI;
using Netron.GraphLib.Interfaces;
namespace Netron.GraphLib
{
/// <summary>
/// Abstract base class for tracker objects.
/// </summary>
[Serializable]
public abstract class Tracker
{
#region Fields
/// <summary>
/// Reflects the tracker in a rectangle object
/// </summary>
protected RectangleF mRectangle;
/// <summary>
/// the mSite to which the tracker belongs
/// </summary>
[NonSerialized] protected IGraphSite mSite;
/// <summary>
/// Resize state (Default: true).
/// </summary>
protected bool mResizable = true;
/// <summary>
/// Tracking state.
/// </summary>
protected bool mTrack;
/// <summary>
/// Current mCurrentHandle.
/// </summary>
protected Point mCurrentHandle = Point.Empty;
/// <summary>
/// Current mouse location,
/// </summary>
protected PointF mCurrentPoint = PointF.Empty;
/// <summary>
/// Size of handles (Default: 7x7).
/// </summary>
protected Size handleSize = new Size(7,7);
#endregion
#region Constructor
/// <summary>
/// Constructor taking a resizable argument.
/// </summary>
/// <param name="resize">Resizable state</param>
protected Tracker(bool resize)
{
mResizable = resize;
}
/// <summary>
/// Default constructor.
/// </summary>
protected Tracker() {}
#endregion
#region Properties
/// <summary>
/// Gets or sets the rectangle of the tracker
/// </summary>
public RectangleF Rectangle
{
get{return mRectangle;}
set{mRectangle = value;}
}
/// <summary>
/// Gets or sets resizable mode.
/// </summary>
public bool Resizable
{
get { return mResizable; }
set { mResizable = value; }
}
/// <summary>
/// Gets or sets the IGraphSite of the tracker
/// </summary>
public IGraphSite Site
{
get{return mSite;}
set{mSite = value;}
}
/// <summary>
/// Gets the width of a mCurrentHandle
/// </summary>
public int HandleWidth
{
get { return handleSize.Width; }
}
/// <summary>
/// Gets the height of a mCurrentHandle
/// </summary>
public int HandleHeight
{
get { return handleSize.Height; }
}
/// <summary>
/// Gets the tracking mode
/// </summary>
public bool Track
{
get { return mTrack; }
set{mTrack = true;}
}
#endregion
#region Methods
/// <summary>
/// Start tracking
/// </summary>
/// <param name="p"></param>
/// <param name="h"></param>
public virtual void Start(PointF p, Point h)
{
mCurrentHandle = h;
mCurrentPoint = p;
mTrack = true;
}
/// <summary>
/// Ends tracking
/// </summary>
public virtual void End()
{
mTrack = false;
mCurrentHandle = Point.Empty;
}
/// <summary>
/// Hit check. To be overridden.
/// </summary>
/// <param name="p">Current point</param>
/// <returns>Handle</returns>
public abstract Point Hit(PointF p);
/// <summary>
/// Returns the cursor at a given location.
/// </summary>
/// <param name="p">Current location</param>
/// <returns>Cursor</returns>
public abstract Cursor Cursor(PointF p);
/// <summary>
/// Moves a tracker to the given location.
/// </summary>
/// <param name="p">New Location</param>
/// <param name="maxSize"></param>
/// <param name="snap"></param>
/// <param name="snapSize"></param>
public abstract void Move(PointF p,Size maxSize, bool snap, int snapSize);
/// <summary>
/// Paints the tracker
/// </summary>
/// <param name="g">Graphics context</param>
public abstract void Paint(Graphics g);
/// <summary>
/// Returns the grip at given point.
/// </summary>
/// <param name="p">Point</param>
/// <returns>Rectangle of grip</returns>
public abstract RectangleF Grip(Point p);
#endregion
}
}