1 | using System.Drawing;
|
---|
2 |
|
---|
3 | namespace HeuristicLab.Visualization {
|
---|
4 | /// <summary>
|
---|
5 | /// Helper class for different OnMouseMove and OnMouseUp implementations.
|
---|
6 | /// </summary>
|
---|
7 | public class MouseEventListener {
|
---|
8 | /// <summary>
|
---|
9 | /// Fired when the MouseMove method was called.
|
---|
10 | /// </summary>
|
---|
11 | public event MouseEventListenerHandler OnMouseMove;
|
---|
12 |
|
---|
13 | /// <summary>
|
---|
14 | /// Fired when the MouseUp method was called.
|
---|
15 | /// </summary>
|
---|
16 | public event MouseEventListenerHandler OnMouseUp;
|
---|
17 |
|
---|
18 | private Point startPoint;
|
---|
19 |
|
---|
20 | /// <summary>
|
---|
21 | /// Call this method to fire the OnMouseMove event.
|
---|
22 | /// </summary>
|
---|
23 | /// <param name="actualPoint"></param>
|
---|
24 | public void MouseMove(Point actualPoint) {
|
---|
25 | if (OnMouseMove != null) {
|
---|
26 | OnMouseMove(startPoint, actualPoint);
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | /// <summary>
|
---|
31 | /// Call this method to fire the OnMouseUp event.
|
---|
32 | /// </summary>
|
---|
33 | /// <param name="actualPoint">Actual point of the mouse</param>
|
---|
34 | public void MouseUp(Point actualPoint) {
|
---|
35 | if (OnMouseUp != null) {
|
---|
36 | OnMouseUp(startPoint, actualPoint);
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 | /// <summary>
|
---|
41 | /// Gets or sets the starting point of the mouse.
|
---|
42 | /// </summary>
|
---|
43 | public Point StartPoint {
|
---|
44 | get { return startPoint; }
|
---|
45 | set { startPoint = value; }
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | /// <summary>
|
---|
50 | /// Handler for the MouseEventListener events.
|
---|
51 | /// </summary>
|
---|
52 | /// <param name="startPoint">Starting point of the mouse.</param>
|
---|
53 | /// <param name="actualPoint">Actual point of the mouse.</param>
|
---|
54 | public delegate void MouseEventListenerHandler(Point startPoint, Point actualPoint);
|
---|
55 | } |
---|