public Cursor onMouseMove(MouseEventArgs e) { //Mode: ziehen in eine Richtung oder Rahmen verschieben oder nix //schauen ob maus über was drüber ist -> Cursor wechseln if (_mode.Equals(GrabMode.NONE)) { Console.WriteLine("_mode.Equals(GrabMode.NONE)"); Cursor c = checkForActiveRegionChangeCursor(e.Location); if (_activeGrabSquare == null && !c.Equals(_insideCursor)) //nix { _color = doNothingColor; return(c); } else //mode change { //_color = activeColor; return(c); //next move for dragging, moving... } } else if (_mode.Equals(GrabMode.DRAG)) { Console.WriteLine("_mode.Equals(GrabMode.DRAG)" + e.Location + " " + e.X + " " + e.Y); _color = activeColor; switch (_activeGrabSquare._direction) { case GrabSquare.Direction.HORIZONTAL: if (_activeGrabSquare._location.Equals(GrabSquare.Location.MIDDLELEFT)) { _rectangle.Width = Math.Max(0, _rectangle.Right - Math.Max(0, e.X)); if (_rectangle.Width > 0) { _rectangle.X = Math.Max(0, e.X); } } else { _rectangle.Width = Math.Max(0, e.X - _rectangle.X); if (_rectangle.Right >= _maxSize.Width) { _rectangle.Width = _maxSize.Width - _rectangle.X; } } break; case GrabSquare.Direction.VERTICAL: if (_activeGrabSquare._location.Equals(GrabSquare.Location.TOPMIDDLE)) { _rectangle.Height = Math.Max(0, _rectangle.Bottom - Math.Max(0, e.Y)); if (_rectangle.Height > 0) { _rectangle.Y = Math.Max(0, e.Y); } } else { _rectangle.Height = Math.Max(0, e.Y - _rectangle.Y); if (_rectangle.Bottom > _maxSize.Height) { _rectangle.Height = _maxSize.Height - _rectangle.Y; } } break; case GrabSquare.Direction.DIAGONALNESW: if (_activeGrabSquare._location.Equals(GrabSquare.Location.TOPRIGHT)) { _rectangle.Width = Math.Max(0, Math.Min(_maxSize.Width, e.X) - _rectangle.X); _rectangle.Height = Math.Max(0, _rectangle.Y + _rectangle.Height - Math.Max(0, e.Y)); if (_rectangle.Height > 0) { _rectangle.Y = Math.Max(0, e.Y); } } else { _rectangle.Width = Math.Max(0, _rectangle.X + _rectangle.Width - Math.Max(0, e.X)); _rectangle.Height = Math.Max(0, Math.Min(_maxSize.Height, e.Y) - _rectangle.Y); if (_rectangle.Bottom > _maxSize.Height) { _rectangle.Height = _maxSize.Height - _rectangle.Y; } if (_rectangle.Left < 0) { _rectangle.X = 0; } if (_rectangle.Width > 0) { _rectangle.X = Math.Max(0, e.X); } } break; case GrabSquare.Direction.DIAGONALNWSE: if (_activeGrabSquare._location.Equals(GrabSquare.Location.TOPLEFT)) { _rectangle.Width = Math.Max(0, _rectangle.Right - Math.Max(0, e.X)); _rectangle.Height = Math.Max(0, _rectangle.Bottom - Math.Max(0, e.Y)); if (_rectangle.Width > 0) { _rectangle.X = Math.Max(0, e.X); } if (_rectangle.Height > 0) { _rectangle.Y = Math.Max(0, e.Y); } } else { _rectangle.Width = Math.Max(0, e.X - _rectangle.X); if (_rectangle.Right > _maxSize.Width) { _rectangle.Width = _maxSize.Width - _rectangle.X; } _rectangle.Height = Math.Max(0, e.Y - _rectangle.Y); if (_rectangle.Bottom > _maxSize.Height) { _rectangle.Height = _maxSize.Height - _rectangle.Y; } } break; } _parent.needRepaint(); return(_activeGrabSquare._cursor); } else if (_mode.Equals(GrabMode.MOVE)) { Console.WriteLine("_mode.Equals(GrabMode.MOVE)"); if (e.X > _maxSize.Width || e.X < 0 || e.Y < 0 || e.Y > _maxSize.Height) { // _mode = GrabMode.NONE; _color = doNothingColor; _parent.needRepaint(); return(_insideCursor); } _color = activeColor; int x = _rectangle.X; int y = _rectangle.Y; int eX = Math.Max(0, e.X); eX = Math.Min(eX, _maxSize.Width); int eY = Math.Max(0, e.Y); eY = Math.Min(eY, _maxSize.Height); _rectangle.X = Math.Max(0, _rectangle.X + (eX - _lastMovePosition.X)); _rectangle.Y = Math.Max(0, _rectangle.Y + (eY - _lastMovePosition.Y)); if (_rectangle.Right > _maxSize.Width) { _rectangle.X = x; } if (_rectangle.Bottom > _maxSize.Height) { _rectangle.Y = y; } _lastMovePosition = e.Location; _parent.needRepaint(); return(_insideCursor); } else { throw new Exception(_mode + " unhandled"); //we test... } }