/// <summary> /// Обработка Mouse move на picture /// </summary> /// <param name="sender">Отправитель</param> /// <param name="e">Параметры</param> private void pictureBox_MouseMove(object sender, MouseEventArgs e) { if (drawing) { try { if (logic.GetDrawingItem() == DrawingItem.Rectangle || logic.GetDrawingItem() == DrawingItem.Ellipse || logic.GetDrawingItem() == DrawingItem.Triangle) { Point lastPoint = logic.getLastPoint(); int x = Math.Min(lastPoint.X, e.X), y = Math.Min(lastPoint.Y, e.Y); picture.setRectangle( new Rectangle(x, y, Math.Abs(e.X - lastPoint.X), Math.Abs(e.Y - lastPoint.Y)), logic.GetDrawingItem()); picture.setPen(logic.getPen()); picture.Invalidate(); } else { logic.draw(e); picture.Refresh(); } } catch (Exception) { } } }
public void getPreviousTest() { BMPLogic logic = new BMPLogic(400, 400); logic.startDrawing(new MouseEventArgs(MouseButtons.Left, 0, 100, 100, -1)); logic.draw(new MouseEventArgs(MouseButtons.Left, 0, 200, 200, -1)); logic.finishDrawing(new MouseEventArgs(MouseButtons.Left, 0, 200, 200, -1)); Assert.NotNull(logic.getPrevious()); }
public void DrawingTest() { MouseEventArgs args = new MouseEventArgs(MouseButtons.Left, 0, 200, 200, -1); BMPLogic logic = new BMPLogic(400, 400); logic.onWidthChanged(1); logic.startDrawing(args); logic.draw(new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)); Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(200, 200)); Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(250, 250)); logic = new BMPLogic(400, 400); logic.chooseBrush(); logic.startDrawing(args); logic.draw(new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)); Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(200, 200)); Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(250, 250)); logic.chooseEraser(); logic.startDrawing(args); logic.draw(new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)); Assert.Equal(Color.FromArgb(255, 255, 255, 255), logic.getBitmap().GetPixel(200, 200)); Assert.Equal(Color.FromArgb(255, 255, 255, 255), logic.getBitmap().GetPixel(250, 250)); }