Changeset 725 for trunk/sources
- Timestamp:
- 11/09/08 16:30:24 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.Test/MainForm.Designer.cs
r724 r725 36 36 this.canvasUI.TabIndex = 3; 37 37 this.canvasUI.Text = "canvasUI"; 38 this.canvasUI.MouseDown += new System.Windows.Forms.MouseEventHandler(this.canvasUI_MouseDown); 38 39 // 39 40 // label2 -
trunk/sources/HeuristicLab.Visualization.Test/MainForm.cs
r636 r725 1 1 using System.Drawing; 2 2 using System.Windows.Forms; 3 using HeuristicLab.Visualization;4 3 5 4 namespace HeuristicLab.Visualization.Test { 6 5 public partial class MainForm : Form { 6 private MouseEventListener dragDropListener; 7 7 8 public MainForm() { 8 9 InitializeComponent(); 10 11 CreateMouseEventListeners(); 9 12 10 13 canvasUI.MainCanvas.WorldShape = new WorldShape(new RectangleD(0, 0, 800, 600), new RectangleD(0, 0, 800, 600)); … … 16 19 17 20 canvasUI.Invalidate(); 21 } 22 23 private void CreateMouseEventListeners() { 24 dragDropListener = new MouseEventListener(); 25 dragDropListener.OnMouseMove += DragDrop_OnMouseMove; 26 dragDropListener.OnMouseUp += DragDrop_OnMouseUp; 18 27 } 19 28 … … 34 43 35 44 for (int i = 0; i < 10000; i++) { 36 RectangleShape rect = new RectangleShape(x1, y1, x1+0.3, y1+0.3, 0, Color.Maroon); 37 x1 += 0.4; y1 += 0.4; 45 RectangleShape rect = new RectangleShape(x1, y1, x1 + 0.3, y1 + 0.3, 0, Color.Maroon); 46 x1 += 0.4; 47 y1 += 0.4; 38 48 rightWorld.AddShape(rect); 39 49 } … … 81 91 mainWorld.AddShape(leftWorld); 82 92 } 93 94 private void canvasUI_MouseDown(object sender, MouseEventArgs e) { 95 mouseEventDemonstrationGraphics = canvasUI.CreateGraphics(); 96 97 dragDropListener.StartPoint = e.Location; 98 lastActualPoint = e.Location; 99 100 canvasUI.MouseEventListener = dragDropListener; 101 } 102 103 private Point lastActualPoint; 104 private Graphics mouseEventDemonstrationGraphics; 105 106 private void DragDrop_OnMouseUp(Point startPoint, Point actualPoint) { 107 canvasUI.MouseEventListener = null; 108 109 canvasUI.Invalidate(); 110 mouseEventDemonstrationGraphics.Dispose(); 111 } 112 113 private void DragDrop_OnMouseMove(Point startPoint, Point actualPoint) { 114 mouseEventDemonstrationGraphics.DrawLine(Pens.Blue, lastActualPoint, actualPoint); 115 lastActualPoint = actualPoint; 116 } 83 117 } 84 118 } -
trunk/sources/HeuristicLab.Visualization/CanvasUI.cs
r724 r725 39 39 40 40 private void CanvasUI_MouseMove(object sender, MouseEventArgs e) { 41 if (mouseEventListener != null) {} 41 if (mouseEventListener != null) { 42 mouseEventListener.MouseMove(e.Location); 43 } 42 44 } 43 45 44 46 private void CanvasUI_MouseUp(object sender, MouseEventArgs e) { 45 if (mouseEventListener != null) {} 47 if (mouseEventListener != null) { 48 mouseEventListener.MouseUp(e.Location); 49 } 46 50 } 47 51 } -
trunk/sources/HeuristicLab.Visualization/MouseEventListener.cs
r724 r725 1 namespace HeuristicLab.Visualization { 2 public class MouseEventListener {} 1 using System.Drawing; 2 3 namespace HeuristicLab.Visualization { 4 public class MouseEventListener { 5 public event MouseEventListenerHandler OnMouseMove; 6 public event MouseEventListenerHandler OnMouseUp; 7 8 private Point startPoint; 9 10 public void MouseMove(Point actualPoint) { 11 if (OnMouseMove != null) { 12 OnMouseMove(startPoint, actualPoint); 13 } 14 } 15 16 public void MouseUp(Point actualPoint) { 17 if (OnMouseUp != null) { 18 OnMouseUp(startPoint, actualPoint); 19 } 20 } 21 22 public Point StartPoint { 23 get { return startPoint; } 24 set { startPoint = value; } 25 } 26 } 27 28 public delegate void MouseEventListenerHandler(Point startPoint, Point actualPoint); 3 29 }
Note: See TracChangeset
for help on using the changeset viewer.