Index: /trunk/sources/HeuristicLab.Visualization.Test/LegendForm.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization.Test/LegendForm.Designer.cs	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization.Test/LegendForm.Designer.cs	(revision 1249)
@@ -30,5 +30,4 @@
       // 
       this.canvasUI.Location = new System.Drawing.Point(12, 12);
-      this.canvasUI.MouseEventListener = null;
       this.canvasUI.Name = "canvasUI";
       this.canvasUI.Size = new System.Drawing.Size(260, 240);
Index: /trunk/sources/HeuristicLab.Visualization.Test/LineChartTestForm.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization.Test/LineChartTestForm.cs	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization.Test/LineChartTestForm.cs	(revision 1249)
@@ -25,5 +25,5 @@
       if (view != null) {
         LineChart lineChart = (LineChart)view;
-        lineChart.ResetView();
+        lineChart.ZoomToFullView();
       }
     }
Index: /trunk/sources/HeuristicLab.Visualization.Test/MainForm.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization.Test/MainForm.Designer.cs	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization.Test/MainForm.Designer.cs	(revision 1249)
@@ -32,5 +32,4 @@
       // 
       this.canvasUI.Location = new System.Drawing.Point(12, 29);
-      this.canvasUI.MouseEventListener = null;
       this.canvasUI.Name = "canvasUI";
       this.canvasUI.Size = new System.Drawing.Size(800, 571);
Index: /trunk/sources/HeuristicLab.Visualization/CanvasUI.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization/CanvasUI.Designer.cs	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization/CanvasUI.Designer.cs	(revision 1249)
@@ -33,6 +33,4 @@
           // CanvasUI
           // 
-          this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.CanvasUI_MouseMove);
-          this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.CanvasUI_MouseUp);
           this.ResumeLayout(false);
 
Index: /trunk/sources/HeuristicLab.Visualization/CanvasUI.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization/CanvasUI.cs	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization/CanvasUI.cs	(revision 1249)
@@ -7,5 +7,4 @@
   public partial class CanvasUI : Control {
     private readonly Canvas canvas = new Canvas();
-    private IMouseEventListener mouseEventListener;
 
     public CanvasUI() {
@@ -17,9 +16,4 @@
     public Canvas Canvas {
       get { return canvas; }
-    }
-
-    public IMouseEventListener MouseEventListener {
-      get { return mouseEventListener; }
-      set { mouseEventListener = value; }
     }
 
@@ -44,16 +38,4 @@
       base.OnResize(e);
     }
-
-    private void CanvasUI_MouseMove(object sender, MouseEventArgs e) {
-      if (mouseEventListener != null) {
-        mouseEventListener.MouseMove(sender, e);
-      }
-    }
-
-    private void CanvasUI_MouseUp(object sender, MouseEventArgs e) {
-      if (mouseEventListener != null) {
-        mouseEventListener.MouseUp(sender, e);
-      }
-    }
   }
 }
Index: /trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj	(revision 1249)
@@ -120,4 +120,5 @@
     <Compile Include="SizeD.cs" />
     <Compile Include="Transform.cs" />
+    <Compile Include="Translate.cs" />
     <Compile Include="WorldShape.cs" />
     <Compile Include="XAxis.cs" />
Index: /trunk/sources/HeuristicLab.Visualization/IMouseEventListener.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization/IMouseEventListener.cs	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization/IMouseEventListener.cs	(revision 1249)
@@ -6,10 +6,7 @@
     void MouseMove(object sender, MouseEventArgs e);
     void MouseUp(object sender, MouseEventArgs e);
-
-    event MouseEventHandler OnMouseMove;
-    event MouseEventHandler OnMouseUp;
   }
 
-  public delegate void SetNewClippingAreaHandler(RectangleD newClippingArea);
-  public delegate void DrawRectangleHandler(Rectangle rectangle);
+  public delegate void MoveHandler(Point startPoint, Point endPoint);
+  public delegate void RectangleHandler(Rectangle rectangle);
 }
Index: /trunk/sources/HeuristicLab.Visualization/LineChart.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization/LineChart.Designer.cs	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization/LineChart.Designer.cs	(revision 1249)
@@ -42,5 +42,4 @@
           this.canvasUI.Dock = System.Windows.Forms.DockStyle.Fill;
           this.canvasUI.Location = new System.Drawing.Point(0, 0);
-          this.canvasUI.MouseEventListener = null;
           this.canvasUI.Name = "canvasUI";
           this.canvasUI.Size = new System.Drawing.Size(551, 373);
@@ -48,7 +47,8 @@
           this.canvasUI.Text = "canvas";
           this.canvasUI.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseWheel);
-          this.canvasUI.MouseMove += new System.Windows.Forms.MouseEventHandler(this.canvas_MouseMove);
+          this.canvasUI.MouseMove += new System.Windows.Forms.MouseEventHandler(this.canvasUI_MouseMove);
           this.canvasUI.ContextMenuStripChanged += new System.EventHandler(this.optionsToolStripMenuItem_Click);
           this.canvasUI.MouseDown += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseDown);
+          this.canvasUI.MouseUp += new System.Windows.Forms.MouseEventHandler(this.canvasUI_MouseUp);
           this.canvasUI.KeyDown += new System.Windows.Forms.KeyEventHandler(this.canvasUI1_KeyDown);
           // 
Index: /trunk/sources/HeuristicLab.Visualization/LineChart.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization/LineChart.cs	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization/LineChart.cs	(revision 1249)
@@ -1,5 +1,4 @@
 ﻿using System;
 using System.Collections.Generic;
-using System.Diagnostics;
 using System.Drawing;
 using System.Windows.Forms;
@@ -10,13 +9,10 @@
 namespace HeuristicLab.Visualization {
   public partial class LineChart : ViewBase {
-    internal class LinesShape : WorldShape {}
     private readonly IChartDataRowsModel model;
     private readonly Canvas canvas;
 
     private int maxDataRowCount;
-    private Boolean zoomFullView;
     private double minDataValue;
     private double maxDataValue;
-  
 
     private readonly TextShape titleShape;
@@ -28,6 +24,9 @@
     private readonly Grid grid;
 
-    private readonly WorldShape berni;
-    private readonly RectangleShape mousePointer;
+    private readonly Stack<RectangleD> clippingAreaHistory = new Stack<RectangleD>();
+    private readonly WorldShape userInteractionShape;
+    private readonly RectangleShape rectangleShape;
+    private IMouseEventListener mouseEventListener;
+    private bool zoomToFullView;
 
     /// <summary>
@@ -47,5 +46,4 @@
       }
 
-    
       canvas = canvasUI.Canvas;
 
@@ -71,9 +69,9 @@
       canvas.AddShape(legendShape);
 
-      berni = new WorldShape();
-      canvas.AddShape(berni);
-
-      mousePointer = new RectangleShape(10, 10, 20, 20, Color.Black);
-      berni.AddShape(mousePointer);
+      userInteractionShape = new WorldShape();
+      canvas.AddShape(userInteractionShape);
+
+      rectangleShape = new RectangleShape(0, 0, 0, 0, Color.Blue);
+      rectangleShape.Opacity = 50;
 
       maxDataRowCount = 0;
@@ -85,5 +83,5 @@
 
       //The whole data rows are shown per default
-      ResetView();
+      ZoomToFullView();
     }
 
@@ -103,6 +101,6 @@
                                               canvasUI.Height);
 
-      berni.BoundingBox = linesShape.BoundingBox;
-      berni.ClippingArea = new RectangleD(0, 0, berni.BoundingBox.Width, berni.BoundingBox.Height);
+      userInteractionShape.BoundingBox = linesShape.BoundingBox;
+      userInteractionShape.ClippingArea = new RectangleD(0, 0, userInteractionShape.BoundingBox.Width, userInteractionShape.BoundingBox.Height);
 
       grid.BoundingBox = linesShape.BoundingBox;
@@ -122,11 +120,4 @@
       legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width,
                                                 legendShape.BoundingBox.Height);
-    }
-
-    public void ResetView() {
-      zoomFullView = true;
-      ZoomToFullView();
-
-      canvasUI.Invalidate();
     }
 
@@ -193,15 +184,13 @@
     #endregion
 
-    private void ZoomToFullView() {
-      if (!zoomFullView) {
-        return;
-      }
-      var newClippingArea = new RectangleD(-0.1,
-                                           minDataValue - ((maxDataValue - minDataValue)*0.05),
-                                           maxDataRowCount - 0.9,
-                                           maxDataValue + ((maxDataValue - minDataValue)*0.05));
-
-      SetLineClippingArea(newClippingArea);
-      historyStack.Push(newClippingArea);
+    public void ZoomToFullView() {
+      RectangleD newClippingArea = new RectangleD(-0.1,
+                                                  minDataValue - ((maxDataValue - minDataValue)*0.05),
+                                                  maxDataRowCount - 0.9,
+                                                  maxDataValue + ((maxDataValue - minDataValue)*0.05));
+
+      SetLineClippingArea(newClippingArea, true);
+
+      zoomToFullView = true;
     }
 
@@ -210,5 +199,23 @@
     /// </summary>
     /// <param name="clippingArea"></param>
-    private void SetLineClippingArea(RectangleD clippingArea) {
+    /// <param name="pushToHistoryStack"></param>
+    private void SetLineClippingArea(RectangleD clippingArea, bool pushToHistoryStack) {
+      zoomToFullView = false;
+
+      if (pushToHistoryStack) {
+        int count = clippingAreaHistory.Count;
+
+        if (count > 40) {
+          RectangleD[] clippingAreas = clippingAreaHistory.ToArray();
+          clippingAreaHistory.Clear();
+
+          for (int i = count - 20; i < count; i++) {
+            clippingAreaHistory.Push(clippingAreas[i]);
+          }
+        }
+
+        clippingAreaHistory.Push(clippingArea);
+      }
+
       linesShape.ClippingArea = clippingArea;
 
@@ -227,4 +234,6 @@
                                           yAxis.BoundingBox.X2,
                                           linesShape.ClippingArea.Y2);
+
+      canvasUI.Invalidate();
     }
 
@@ -247,6 +256,5 @@
           linesShape.AddShape(lineShape);
         }
-      }
-      else {
+      } else {
         for (int i = 1; i < row.Count; i++) {
           var lineShape = new LineShape(i - 1, row[i - 1], i, row[i], row.Color, row.Thickness, row.Style);
@@ -260,7 +268,6 @@
       //horizontalLineShape.YVal = maxDataValue;
       rowToLineShapes[row] = lineShapes;
+
       ZoomToFullView();
-
-      canvasUI.Invalidate();
     }
 
@@ -277,12 +284,10 @@
           // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently.
           linesShape.AddShape(lineShape);
-        }
-        else {
+        } else {
           // lineShapes[0].X2 = maxDataRowCount;
           lineShapes[0].Y1 = value;
           lineShapes[0].Y2 = value;
         }
-      }
-      else {
+      } else {
         //  horizontalLineShape.YVal = maxDataValue;
         if (index > lineShapes.Count + 1) {
@@ -315,5 +320,4 @@
 
       ZoomToFullView();
-      canvasUI.Invalidate();
     }
 
@@ -337,5 +341,4 @@
     }
 
-  
     #region Begin-/EndUpdate
 
@@ -362,15 +365,37 @@
     #region Zooming / Panning
 
-    private readonly Stack<RectangleD> historyStack = new Stack<RectangleD>();
-    private RectangleShape rectangleShape;
+    private void Pan(Point startPoint, Point endPoint) {
+      RectangleD clippingArea = CalcPanClippingArea(startPoint, endPoint);
+      SetLineClippingArea(clippingArea, false);
+    }
+
+    private void PanEnd(Point startPoint, Point endPoint) {
+      RectangleD clippingArea = CalcPanClippingArea(startPoint, endPoint);
+      SetLineClippingArea(clippingArea, true);
+    }
+
+    private RectangleD CalcPanClippingArea(Point startPoint, Point endPoint) {
+      return Translate.ClippingArea(startPoint, endPoint, linesShape.ClippingArea, linesShape.Viewport);
+    }
+
+    private void SetClippingArea(Rectangle rectangle) {
+      RectangleD clippingArea = Transform.ToWorld(rectangle, linesShape.Viewport, linesShape.ClippingArea);
+
+      SetLineClippingArea(clippingArea, true);
+      userInteractionShape.RemoveShape(rectangleShape);
+    }
+
+    private void DrawRectangle(Rectangle rectangle) {
+      rectangleShape.Rectangle = Transform.ToWorld(rectangle, userInteractionShape.Viewport, userInteractionShape.ClippingArea);
+      canvasUI.Invalidate();
+    }
 
     private void canvasUI1_KeyDown(object sender, KeyEventArgs e) {
-      if (e.KeyCode == Keys.Back && historyStack.Count > 1) {
-        historyStack.Pop();
-
-        RectangleD clippingArea = historyStack.Peek();
-
-        SetNewClippingArea(clippingArea);
-        canvasUI.Invalidate();
+      if (e.KeyCode == Keys.Back && clippingAreaHistory.Count > 1) {
+        clippingAreaHistory.Pop();
+
+        RectangleD clippingArea = clippingAreaHistory.Peek();
+
+        SetLineClippingArea(clippingArea, false);
       }
     }
@@ -378,29 +403,39 @@
     private void canvasUI1_MouseDown(object sender, MouseEventArgs e) {
       Focus();
+
       if (e.Button == MouseButtons.Right) {
         contextMenuStrip1.Show(PointToScreen(e.Location));
-      }
-      else {
-        if (ModifierKeys == Keys.Control) {
-          CreateZoomListener(e);
-        }
-        else {
-          CreatePanListener(e);
-        }
-      }
-    }
-
-    private Point prevMousePosition = Point.Empty;
-
-    private void canvas_MouseMove(object sender, MouseEventArgs e) {
-      if (prevMousePosition != e.Location) {
-        prevMousePosition = e.Location;
-
-        double x = Transform.ToWorldX(e.X, berni.Viewport, berni.ClippingArea);
-        double y = Transform.ToWorldY(e.Y, berni.Viewport, berni.ClippingArea);
-
-        mousePointer.Rectangle = new RectangleD(x - 1, y - 1, x + 1, y + 1);
-        canvasUI.Invalidate();
-      }
+      } else if (e.Button == MouseButtons.Left) {
+        if (ModifierKeys == Keys.None) {
+          PanListener panListener = new PanListener(e.Location);
+          panListener.Pan += Pan;
+          panListener.PanEnd += PanEnd;
+
+          mouseEventListener = panListener;
+        } else if (ModifierKeys == Keys.Control) {
+          ZoomListener zoomListener = new ZoomListener(e.Location);
+          zoomListener.DrawRectangle += DrawRectangle;
+          zoomListener.SetClippingArea += SetClippingArea;
+
+          rectangleShape.Rectangle = RectangleD.Empty;
+          userInteractionShape.AddShape(rectangleShape);
+
+          mouseEventListener = zoomListener;
+        }
+      }
+    }
+
+    private void canvasUI_MouseMove(object sender, MouseEventArgs e) {
+      if (mouseEventListener != null) {
+        mouseEventListener.MouseMove(sender, e);
+      }
+    }
+
+    private void canvasUI_MouseUp(object sender, MouseEventArgs e) {
+      if (mouseEventListener != null) {
+        mouseEventListener.MouseUp(sender, e);
+      }
+
+      mouseEventListener = null;
     }
 
@@ -411,64 +446,15 @@
         RectangleD clippingArea = ZoomListener.ZoomClippingArea(linesShape.ClippingArea, zoomFactor);
 
-        SetLineClippingArea(clippingArea);
-        canvasUI.Invalidate();
-      }
-    }
-
-    private void CreateZoomListener(MouseEventArgs e) {
-      var zoomListener = new ZoomListener(e.Location);
-      zoomListener.DrawRectangle += DrawRectangle;
-      zoomListener.OnMouseUp += OnZoom_MouseUp;
-
-      canvasUI.MouseEventListener = zoomListener;
-
-      rectangleShape = new RectangleShape(e.X, e.Y, e.X, e.Y, Color.Blue);
-      rectangleShape.Opacity = 50;
-
-      linesShape.AddShape(rectangleShape);
-    }
-
-    private void OnZoom_MouseUp(object sender, MouseEventArgs e) {
-      canvasUI.MouseEventListener = null;
-
-      RectangleD clippingArea = rectangleShape.Rectangle;
-
-      SetLineClippingArea(clippingArea);
-      historyStack.Push(clippingArea);
-
-      linesShape.RemoveShape(rectangleShape);
-
-      zoomFullView = false; //user wants to zoom => no full view
-
-      canvasUI.Invalidate();
-    }
-
-    private void DrawRectangle(Rectangle rectangle) {
-      rectangleShape.Rectangle = Transform.ToWorld(rectangle, canvasUI.ClientRectangle, linesShape.ClippingArea);
-      canvasUI.Invalidate();
-    }
-
-    private void CreatePanListener(MouseEventArgs e) {
-      PanListener panListener = new PanListener(canvasUI.ClientRectangle, linesShape.ClippingArea, e.Location);
-
-      panListener.SetNewClippingArea += SetNewClippingArea;
-      panListener.OnMouseUp += delegate {
-                                 historyStack.Push(linesShape.ClippingArea);
-                                 canvasUI.MouseEventListener = null;
-                               };
-
-      canvasUI.MouseEventListener = panListener;
-    }
-
-    private void SetNewClippingArea(RectangleD newClippingArea) {
-      SetLineClippingArea(newClippingArea);
-
-      zoomFullView = false;
-      canvasUI.Invalidate();
+        SetLineClippingArea(clippingArea, true);
+      }
     }
 
     #endregion
 
-   
+    #region Nested type: LinesShape
+
+    internal class LinesShape : WorldShape {}
+
+    #endregion
   }
 }
Index: /trunk/sources/HeuristicLab.Visualization/PanListener.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization/PanListener.cs	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization/PanListener.cs	(revision 1249)
@@ -4,11 +4,10 @@
 namespace HeuristicLab.Visualization {
   public class PanListener : IMouseEventListener {
-    private readonly Rectangle viewPort;
-    private readonly RectangleD clippingArea;
-    private readonly Point startPoint;
+    private Point startPoint;
 
-    public PanListener(Rectangle viewPort, RectangleD clippingArea, Point startPoint) {
-      this.viewPort = viewPort;
-      this.clippingArea = clippingArea;
+    public event MoveHandler Pan;
+    public event MoveHandler PanEnd;
+
+    public PanListener(Point startPoint) {
       this.startPoint = startPoint;
     }
@@ -16,33 +15,15 @@
     #region IMouseEventListener Members
 
-    public event SetNewClippingAreaHandler SetNewClippingArea;
-    public event MouseEventHandler OnMouseMove;
-    public event MouseEventHandler OnMouseUp;
-
     public void MouseMove(object sender, MouseEventArgs e) {
-      PointD worldStartPoint = Transform.ToWorld(startPoint, viewPort, clippingArea);
-      PointD worldActualPoint = Transform.ToWorld(e.Location, viewPort, clippingArea);
-
-      double xDiff = worldActualPoint.X - worldStartPoint.X;
-      double yDiff = worldActualPoint.Y - worldStartPoint.Y;
-
-      RectangleD newClippingArea = new RectangleD();
-      newClippingArea.X1 = clippingArea.X1 - xDiff;
-      newClippingArea.X2 = clippingArea.X2 - xDiff;
-      newClippingArea.Y1 = clippingArea.Y1 - yDiff;
-      newClippingArea.Y2 = clippingArea.Y2 - yDiff;
-
-      if (SetNewClippingArea != null) {
-        SetNewClippingArea(newClippingArea);
+      if (Pan != null) {
+        Pan(startPoint, e.Location);
       }
 
-      if (OnMouseMove != null) {
-        OnMouseMove(sender, e);
-      }
+      startPoint = e.Location;  
     }
 
     public void MouseUp(object sender, MouseEventArgs e) {
-      if (OnMouseUp != null) {
-        OnMouseUp(sender, e);
+      if(PanEnd != null) {
+        PanEnd(startPoint, e.Location);
       }
     }
Index: /trunk/sources/HeuristicLab.Visualization/Translate.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization/Translate.cs	(revision 1249)
+++ /trunk/sources/HeuristicLab.Visualization/Translate.cs	(revision 1249)
@@ -0,0 +1,26 @@
+using System.Drawing;
+
+namespace HeuristicLab.Visualization {
+  public static class Translate {
+    public static RectangleD ClippingArea(Point startPoint, Point endPoint, RectangleD clippingArea, Rectangle viewPort) {
+      PointD worldStartPoint = Transform.ToWorld(startPoint, viewPort, clippingArea);
+      PointD worldEndPoint = Transform.ToWorld(endPoint, viewPort, clippingArea);
+
+      double xDiff = worldEndPoint.X - worldStartPoint.X;
+      double yDiff = worldEndPoint.Y - worldStartPoint.Y;
+
+      return RectangleD(xDiff, yDiff, clippingArea);
+    }
+
+    public static RectangleD RectangleD(double x, double y, RectangleD rectangle) {
+      RectangleD rect = new RectangleD();
+
+      rect.X1 = rectangle.X1 - x;
+      rect.X2 = rectangle.X2 - x;
+      rect.Y1 = rectangle.Y1 - y;
+      rect.Y2 = rectangle.Y2 - y;
+
+      return rect;
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.Visualization/ZoomListener.cs
===================================================================
--- /trunk/sources/HeuristicLab.Visualization/ZoomListener.cs	(revision 1248)
+++ /trunk/sources/HeuristicLab.Visualization/ZoomListener.cs	(revision 1249)
@@ -6,5 +6,6 @@
     private readonly Point startPoint;
 
-    public event DrawRectangleHandler DrawRectangle;
+    public event RectangleHandler DrawRectangle;
+    public event RectangleHandler SetClippingArea;
 
     public ZoomListener(Point startPoint) {
@@ -14,43 +15,39 @@
     #region IMouseEventListener Members
 
-    public event MouseEventHandler OnMouseMove;
-    public event MouseEventHandler OnMouseUp;
-
     public void MouseMove(object sender, MouseEventArgs e) {
-      Rectangle r = new Rectangle();
-      Point actualPoint = e.Location;
-
-      if (startPoint.X < actualPoint.X) {
-        r.X = startPoint.X;
-        r.Width = actualPoint.X - startPoint.X;
-      } else {
-        r.X = actualPoint.X;
-        r.Width = startPoint.X - actualPoint.X;
-      }
-
-      if (startPoint.Y < actualPoint.Y) {
-        r.Y = startPoint.Y;
-        r.Height = actualPoint.Y - startPoint.Y;
-      } else {
-        r.Y = actualPoint.Y;
-        r.Height = startPoint.Y - actualPoint.Y;
-      }
-
       if(DrawRectangle != null) {
-        DrawRectangle(r);
-      }
-
-      if (OnMouseMove != null) {
-        OnMouseMove(sender, e);
+        DrawRectangle(CalcRectangle(e.Location));
       }
     }
 
     public void MouseUp(object sender, MouseEventArgs e) {
-      if (OnMouseUp != null) {
-        OnMouseUp(sender, e);
-      }
+     if(SetClippingArea != null) {
+       SetClippingArea(CalcRectangle(e.Location));
+     }
     }
 
     #endregion
+
+    private Rectangle CalcRectangle(Point actualPoint) {
+      Rectangle rectangle = new Rectangle();
+
+      if (startPoint.X < actualPoint.X) {
+        rectangle.X = startPoint.X;
+        rectangle.Width = actualPoint.X - startPoint.X;
+      } else {
+        rectangle.X = actualPoint.X;
+        rectangle.Width = startPoint.X - actualPoint.X;
+      }
+
+      if (startPoint.Y < actualPoint.Y) {
+        rectangle.Y = startPoint.Y;
+        rectangle.Height = actualPoint.Y - startPoint.Y;
+      } else {
+        rectangle.Y = actualPoint.Y;
+        rectangle.Height = startPoint.Y - actualPoint.Y;
+      }
+
+      return rectangle;
+    }
 
     public static RectangleD ZoomClippingArea(RectangleD clippingArea, double zoomFactor) {
