Esempio n. 1
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)
         {
         }
     }
 }
Esempio n. 2
0
        public void onChangeColorTest()
        {
            BMPLogic logic   = new BMPLogic(200, 200);
            TextBox  textBox = new TextBox();

            textBox.Text = "43";
            logic.onChangeRedPart(textBox);
            Assert.Equal(43, logic.getPen().Color.R);
            textBox.Text = "27";
            logic.onChangeGreenPart(textBox);
            Assert.Equal(27, logic.getPen().Color.G);
            textBox.Text = "32";
            logic.onChangeBluePart(textBox);
            Assert.Equal(32, logic.getPen().Color.B);
            textBox.Text = "344";
            logic.onChangeRedPart(textBox);
            Assert.Equal(255, logic.getPen().Color.R);
            textBox.Text = "2337";
            logic.onChangeGreenPart(textBox);
            Assert.Equal(255, logic.getPen().Color.G);
            textBox.Text = "332";
            logic.onChangeBluePart(textBox);
            Assert.Equal(255, logic.getPen().Color.B);
            textBox.Text = "-5";
            logic.onChangeRedPart(textBox);
            Assert.Equal(0, logic.getPen().Color.R);
            textBox.Text = "-12";
            logic.onChangeGreenPart(textBox);
            Assert.Equal(0, logic.getPen().Color.G);
            textBox.Text = "-333";
            logic.onChangeBluePart(textBox);
            Assert.Equal(0, logic.getPen().Color.B);
            textBox.Text = "abc";
            logic.onChangeGreenPart(textBox);
            logic.onChangeRedPart(textBox);
            logic.onChangeBluePart(textBox);
            Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getPen().Color);
        }
Esempio n. 3
0
        public void chooseColorTest()
        {
            BMPLogic logic = new BMPLogic(200, 200);

            logic.chooseColor(new DataGridViewCellMouseEventArgs(0, 0, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)));
            Assert.Equal(Color.Black, logic.getPen().Color);
            logic.chooseColor(new DataGridViewCellMouseEventArgs(1, 0, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)));
            Assert.Equal(Color.Blue, logic.getPen().Color);
            logic.chooseColor(new DataGridViewCellMouseEventArgs(2, 0, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)));
            Assert.Equal(Color.Green, logic.getPen().Color);
            logic.chooseColor(new DataGridViewCellMouseEventArgs(3, 0, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)));
            Assert.Equal(Color.Aqua, logic.getPen().Color);
            logic.chooseColor(new DataGridViewCellMouseEventArgs(0, 1, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)));
            Assert.Equal(Color.Red, logic.getPen().Color);
            logic.chooseColor(new DataGridViewCellMouseEventArgs(1, 1, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)));
            Assert.Equal(Color.Magenta, logic.getPen().Color);
            logic.chooseColor(new DataGridViewCellMouseEventArgs(2, 1, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)));
            Assert.Equal(Color.White, logic.getPen().Color);
            logic.chooseColor(new DataGridViewCellMouseEventArgs(3, 1, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 250, 250, -1)));
            Assert.Equal(Color.Yellow, logic.getPen().Color);
        }