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

  1. //-----------------------------------------------
  2. // SysInfoEfficient.cs ⌐ 2001 by Charles Petzold
  3. //-----------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class SysInfoEfficient: SysInfoUpdate
  9. {
  10.      public new static void Main()
  11.      {
  12.           Application.Run(new SysInfoEfficient());
  13.      }
  14.      public SysInfoEfficient()
  15.      {
  16.           Text = "System Information: Efficient";
  17.      }
  18.      protected override void OnPaint(PaintEventArgs pea)
  19.      {
  20.           Graphics grfx  = pea.Graphics;
  21.           Brush    brush = new SolidBrush(ForeColor);
  22.           Point    pt    = AutoScrollPosition;
  23.  
  24.           int iFirst = (int)((pea.ClipRectangle.Top    - pt.Y) / cySpace);
  25.           int iLast  = (int)((pea.ClipRectangle.Bottom - pt.Y) / cySpace);
  26.  
  27.           iLast = Math.Min(iCount - 1, iLast);
  28.  
  29.           for (int i = iFirst; i <= iLast; i++)
  30.           {
  31.                grfx.DrawString(astrLabels[i], Font, brush, 
  32.                                pt.X, pt.Y + i * cySpace);
  33.  
  34.                grfx.DrawString(astrValues[i], Font, brush, 
  35.                                pt.X + cxCol, pt.Y + i * cySpace); 
  36.           }
  37.      }
  38. }
  39.