public void getLastPointTest()
        {
            BMPLogic logic = new BMPLogic(200, 200);

            logic.startDrawing(new MouseEventArgs(MouseButtons.Left, 0, 100, 100, -1));
            Assert.Equal(100, logic.getLastPoint().X);
            Assert.Equal(100, logic.getLastPoint().Y);
        }
Exemple #2
0
 /// <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)
         {
         }
     }
 }