home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Pages and Transforms / RotatedRectangles / RotatedRectangles.cs next >
Encoding:
Text File  |  2001-01-15  |  1.2 KB  |  39 lines

  1. //------------------------------------------------
  2. // RotatedRectangles.cs ⌐ 2001 by Charles Petzold
  3. //------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8.  
  9. class RotatedRectangles: PrintableForm
  10. {
  11.      public new static void Main()
  12.      {
  13.           Application.Run(new RotatedRectangles());
  14.      }
  15.      public RotatedRectangles()
  16.      {
  17.           Text = "Rotated Rectangles";
  18.      }
  19.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  20.      {
  21.           Pen      pen   = new Pen(clr);
  22.           grfx.PageUnit  = GraphicsUnit.Pixel;
  23.           PointF[] aptf  = { (PointF) grfx.VisibleClipBounds.Size };
  24.           grfx.PageUnit  = GraphicsUnit.Inch;
  25.           grfx.PageScale = 0.01f;
  26.  
  27.           grfx.TransformPoints(CoordinateSpace.Page, 
  28.                                CoordinateSpace.Device, aptf);
  29.  
  30.           grfx.TranslateTransform(aptf[0].X / 2, aptf[0].Y / 2);
  31.           
  32.           for (int i = 0; i < 36; i++)
  33.           {
  34.                grfx.DrawRectangle(pen, 0, 0, 100, 100);
  35.                grfx.RotateTransform(10);
  36.           }
  37.      }
  38. }
  39.