Changeset 1249 for trunk/sources/HeuristicLab.Visualization/ZoomListener.cs
- Timestamp:
- 03/04/09 21:35:43 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/ZoomListener.cs
r1058 r1249 6 6 private readonly Point startPoint; 7 7 8 public event DrawRectangleHandler DrawRectangle; 8 public event RectangleHandler DrawRectangle; 9 public event RectangleHandler SetClippingArea; 9 10 10 11 public ZoomListener(Point startPoint) { … … 14 15 #region IMouseEventListener Members 15 16 16 public event MouseEventHandler OnMouseMove;17 public event MouseEventHandler OnMouseUp;18 19 17 public void MouseMove(object sender, MouseEventArgs e) { 20 Rectangle r = new Rectangle();21 Point actualPoint = e.Location;22 23 if (startPoint.X < actualPoint.X) {24 r.X = startPoint.X;25 r.Width = actualPoint.X - startPoint.X;26 } else {27 r.X = actualPoint.X;28 r.Width = startPoint.X - actualPoint.X;29 }30 31 if (startPoint.Y < actualPoint.Y) {32 r.Y = startPoint.Y;33 r.Height = actualPoint.Y - startPoint.Y;34 } else {35 r.Y = actualPoint.Y;36 r.Height = startPoint.Y - actualPoint.Y;37 }38 39 18 if(DrawRectangle != null) { 40 DrawRectangle(r); 41 } 42 43 if (OnMouseMove != null) { 44 OnMouseMove(sender, e); 19 DrawRectangle(CalcRectangle(e.Location)); 45 20 } 46 21 } 47 22 48 23 public void MouseUp(object sender, MouseEventArgs e) { 49 if (OnMouseUp!= null) {50 OnMouseUp(sender, e);51 24 if(SetClippingArea != null) { 25 SetClippingArea(CalcRectangle(e.Location)); 26 } 52 27 } 53 28 54 29 #endregion 30 31 private Rectangle CalcRectangle(Point actualPoint) { 32 Rectangle rectangle = new Rectangle(); 33 34 if (startPoint.X < actualPoint.X) { 35 rectangle.X = startPoint.X; 36 rectangle.Width = actualPoint.X - startPoint.X; 37 } else { 38 rectangle.X = actualPoint.X; 39 rectangle.Width = startPoint.X - actualPoint.X; 40 } 41 42 if (startPoint.Y < actualPoint.Y) { 43 rectangle.Y = startPoint.Y; 44 rectangle.Height = actualPoint.Y - startPoint.Y; 45 } else { 46 rectangle.Y = actualPoint.Y; 47 rectangle.Height = startPoint.Y - actualPoint.Y; 48 } 49 50 return rectangle; 51 } 55 52 56 53 public static RectangleD ZoomClippingArea(RectangleD clippingArea, double zoomFactor) {
Note: See TracChangeset
for help on using the changeset viewer.