protected override void OnMouseMove(MouseEventArgs e) { int x = (int)((e.X - ClientRectangle.Left) / Image.ZoomScale); int y = (int)((e.Y - ClientRectangle.Top) / Image.ZoomScale); if (myMovingSelected) { if (myMovingLayer && myTempLayer == null && (x != myAnchorPos.X || y != myAnchorPos.Y)) { myTempLayer = new Layer(Image); bool noSelection = mySelectedArea == 0; for (int px = 0; px < Image.Width; ++px) { for (int py = 0; py < Image.Height; ++py) { if (noSelection || mySelectedPixels[px, py]) { PixelSelect(px, py, CurrentLayer.Pixels[px, py] == Pixel.Empty); myTempLayer.SetPixel(px, py, CurrentLayer.Pixels[px, py]); if (!ModifierKeys.HasFlag(Keys.Control)) { CurrentLayer.SetPixel(px, py, Pixel.Empty); } } } } } UpdateMovedRect(x, y); } if (myDrawingPencil) { if (MouseButtons.HasFlag(MouseButtons.Left)) { DrawPencil(x, y, Image.CurrentPixel); } else { DrawPencil(x, y, Pixel.Empty); } } if (mySelectingPixels || myDrawingBox) { UpdateBoxPreview(x, y); } }
protected override void OnMouseMove( MouseEventArgs e ) { int x = (int) ( ( e.X - ClientRectangle.Left ) / Image.ZoomScale ); int y = (int) ( ( e.Y - ClientRectangle.Top ) / Image.ZoomScale ); if ( myMovingSelected ) { if ( myMovingLayer && myTempLayer == null && ( x != myAnchorPos.X || y != myAnchorPos.Y ) ) { myTempLayer = new Layer( Image ); bool noSelection = mySelectedArea == 0; for ( int px = 0; px < Image.Width; ++px ) { for ( int py = 0; py < Image.Height; ++py ) { if ( noSelection || mySelectedPixels[ px, py ] ) { PixelSelect( px, py, CurrentLayer.Pixels[ px, py ] == Pixel.Empty ); myTempLayer.SetPixel( px, py, CurrentLayer.Pixels[ px, py ] ); if( !ModifierKeys.HasFlag( Keys.Control ) ) CurrentLayer.SetPixel( px, py, Pixel.Empty ); } } } } UpdateMovedRect( x, y ); } if ( myDrawingPencil ) { if ( MouseButtons.HasFlag( MouseButtons.Left ) ) DrawPencil( x, y, Image.CurrentPixel ); else DrawPencil( x, y, Pixel.Empty ); } if ( mySelectingPixels || myDrawingBox ) UpdateBoxPreview( x, y ); }