Exemplo n.º 1
0
        public void startDrawingTest()
        {
            MouseEventArgs args  = new MouseEventArgs(MouseButtons.Left, 0, 200, 200, -1);
            BMPLogic       logic = new BMPLogic(400, 400);

            logic.startDrawing(args);
            Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(200, 200));
            logic.chooseEllipse();
            logic.startDrawing(new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1));
            Assert.Equal(Color.FromArgb(255, 255, 255, 255), logic.getBitmap().GetPixel(250, 250));
        }
Exemplo n.º 2
0
        public void finishDrawingTest()
        {
            MouseEventArgs args  = new MouseEventArgs(MouseButtons.Left, 0, 200, 200, -1);
            BMPLogic       logic = new BMPLogic(400, 400);

            logic.startDrawing(args);
            logic.finishDrawing(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.finishDrawing(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.finishDrawing(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));
            logic = new BMPLogic(400, 400);
            logic.chooseRectangle();
            logic.startDrawing(args);
            logic.finishDrawing(new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1));
            for (int i = 200; i < 251; i++)
            {
                int j = 200;
                Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(i, j));
            }
            for (int i = 200; i < 251; i++)
            {
                int j = 250;
                Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(i, j));
            }
            logic = new BMPLogic(400, 400);
            logic.chooseTriangle();
            logic.startDrawing(args);
            logic.finishDrawing(new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1));
            Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(200, 250));
            Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(250, 250));
            Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(224, 200));
            logic = new BMPLogic(400, 400);
            logic.chooseEllipse();
            logic.startDrawing(args);
            logic.finishDrawing(new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1));
            Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(200, (250 + 200) / 2));
            Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel(250, (250 + 200) / 2));
            Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel((250 + 200) / 2, 200));
            Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getBitmap().GetPixel((250 + 200) / 2, 250));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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());
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
 /// <summary>
 /// Обработка Mouse down на picture
 /// </summary>
 /// <param name="sender">Отправитель</param>
 /// <param name="e">Параметры</param>
 private void pictureBox_MouseDown(object sender, MouseEventArgs e)
 {
     drawing       = true;
     picture.Image = logic.startDrawing(e);
 }