private void PictureBox_Paint(object sender, PaintEventArgs e) { foreach (Shape sh in shapes) { sh.Draw(e.Graphics); } switch (Mode) { case Mode.DrawLine: Line line = new Line(X, Y, Color.Black, 2, X1, Y1); line.Draw(e.Graphics); //e.Graphics.DrawLine(new Pen(buttonColor.BackColor, 2), X, Y, X1, Y1); break; case Mode.DrawCircle: Circle circle = new Circle(X, Y, Color.Black, 2, Rad); circle.Draw(e.Graphics); //e.Graphics.DrawEllipse(new Pen(buttonColor.BackColor, 2), X - Rad/2, Y - Rad/2, Rad, Rad); break; case Mode.DrawRectangle: ShapeLibrary.Rectangle rectangle = new ShapeLibrary.Rectangle(X, Y, Color.Black, 2, X1, Y1); rectangle.Draw(e.Graphics); break; case Mode.DrawEllipse: ShapeLibrary.Elipse elipse = new ShapeLibrary.Elipse(X, Y, Color.Black, 2, Rad, Width); elipse.Draw(e.Graphics); break; } }
private void PictureBox_MouseUp(object sender, MouseEventArgs e) { switch (Mode) { case Mode.DrawLine: Line line = new Line(X, Y, buttonColor.BackColor, size, X1, Y1); AddShape(line); X = 0; Y = 0; X1 = 0; Y1 = 0; pictureBox.Refresh(); break; case Mode.DrawCircle: Circle circle = new Circle(X, Y, buttonColor.BackColor, size, Rad); AddShape(circle); X = 0; Y = 0; Rad = 0; pictureBox.Refresh(); break; case Mode.DrawRectangle: ShapeLibrary.Rectangle rectangle = new ShapeLibrary.Rectangle(X, Y, buttonColor.BackColor, size, X1, Y1); AddShape(rectangle); X = 0; Y = 0; X1 = 0; Y1 = 0; pictureBox.Refresh(); break; case Mode.DrawEllipse: ShapeLibrary.Elipse elipse = new Elipse(X, Y, buttonColor.BackColor, size, Rad, Width); AddShape(elipse); X = 0; Y = 0; Rad = 0; Width = 0; pictureBox.Refresh(); break; } }
private void pictureBoxMain_MouseUp(object sender, MouseEventArgs e) { switch (Mode) { case Mode.DrawLine: Shape line = new Line(MouseX, MouseY, e.X, e.Y, new Pen(buttonColor.BackColor, 2)); AddShapes(line); break; case Mode.DrawCircle: Shape circle = new Circle((e.X + MouseX) / 2, (e.Y + MouseY) / 2, (int)Math.Sqrt(Math.Pow((e.X - MouseX), 2) + Math.Pow((e.Y - MouseY), 2)), new Pen(buttonColor.BackColor, 2)); AddShapes(circle); break; case Mode.DrawRectangle: Shape rectangle = new ShapeLibrary.Rectangle(MouseX, MouseY, e.X - MouseX, e.Y - MouseY, new Pen(buttonColor.BackColor, 2)); AddShapes(rectangle); break; case Mode.DrawEllipse: Shape ellipse = new Ellipse((e.X + MouseX) / 2, (e.Y + MouseY) / 2, e.X - MouseX, e.Y - MouseY, new Pen(buttonColor.BackColor, 2)); AddShapes(ellipse); break; } }
public void AreaTest() { Rectangle target = new Rectangle(0, 0); target.Length = double.Epsilon; target.Width = double.Epsilon; Assert.AreEqual(double.Epsilon * double.Epsilon, target.Area); target.Length = 0; target.Width = 0; Assert.AreEqual(0, target.Area); target.Length = 1; target.Width = 0; Assert.AreEqual(0, target.Area); target.Length = 0; target.Width = 1; Assert.AreEqual(0, target.Area); target.Length = 1; target.Width = 1; Assert.AreEqual(1, target.Area); target.Length = 2; target.Width = 3; Assert.AreEqual(6, target.Area); target.Length = double.MaxValue; target.Width = 2; Assert.AreEqual(double.PositiveInfinity, target.Area); target.Length = double.MaxValue; target.Width = 1; Assert.AreEqual(double.MaxValue, target.Area); target.Length = double.NaN; target.Width = 1; Assert.AreEqual(double.NaN, target.Area); target.Length = 1; target.Width = double.NaN; Assert.IsTrue(double.IsNaN(target.Area)); }
public void WidthTest() { double expected = 10; double actual; Rectangle target = new Rectangle(0, 0); target.Width = expected; actual = target.Width; Assert.AreEqual(expected, actual); }
public void UpdateTest() { double length = 10; double width = 10; Rectangle target = new Rectangle(0, 0); target.Update(length, width); Assert.AreEqual(length, target.Length); Assert.AreEqual(width, target.Width); }
public void ConstructorWidthTestException() { Rectangle target = new Rectangle(0, -1); }
public void ConstructorTest() { double length = 0; double width = 0; Rectangle target = new Rectangle(length, width); Assert.AreEqual(length, target.Length); Assert.AreEqual(width, target.Width); }
public void ConstructorLengthTestException() { Rectangle target = new Rectangle(-1, 0); }