Exemple #1
0
 private void DrawSquare()
 {
     using (Pen pen = new Pen(Color.Black))
     {
         rect.Rotate(1);
         rect.Move((float)(moveKx * xStep), (float)(moveKy * Math.Abs(kPerp) * xStep));
         if (line.Contains(rect.P1) || line.Contains(rect.P2) || line.Contains(rect.P3) || line.Contains(rect.P4))
         {
             t?.Dispose();
         }
         alpha = (alpha + 1) % 360;
         rect?.Draw(graphics, pen);
     }
 }
Exemple #2
0
        public void RotateTest()
        {
            var rectangle = new Rectangle(
                new Point(20, 20),
                new Point(30, 20),
                new Point(30, 30),
                new Point(20, 30));

            rectangle.Rotate(90);
            Assert.AreEqual(30, rectangle.Points[0].X);
            Assert.AreEqual(20, rectangle.Points[0].Y);

            Assert.AreEqual(30, rectangle.Points[1].X);
            Assert.AreEqual(30, rectangle.Points[1].Y);

            Assert.AreEqual(20, rectangle.Points[2].X);
            Assert.AreEqual(30, rectangle.Points[2].Y);

            Assert.AreEqual(20, rectangle.Points[3].X);
            Assert.AreEqual(20, rectangle.Points[3].Y);
        }