home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / The Timer and Time / AnalogClock / AnalogClock.cs next >
Encoding:
Text File  |  2001-01-15  |  1.1 KB  |  40 lines

  1. //-------------------------------------------
  2. // AnalogClock.cs ⌐ 2001 by Charles Petzold
  3. //-------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. using Petzold.ProgrammingWindowsWithCSharp;
  8.  
  9. class AnalogClock: Form
  10. {
  11.      ClockControl clkctl;
  12.  
  13.      public static void Main()
  14.      {
  15.           Application.Run(new AnalogClock());
  16.      }
  17.      public AnalogClock()
  18.      {
  19.           Text = "Analog Clock";
  20.           BackColor = SystemColors.Window;
  21.           ForeColor = SystemColors.WindowText;
  22.  
  23.           clkctl = new ClockControl();
  24.           clkctl.Parent    = this;
  25.           clkctl.Time      = DateTime.Now;
  26.           clkctl.Dock      = DockStyle.Fill;
  27.           clkctl.BackColor = Color.Black;
  28.           clkctl.ForeColor = Color.White;
  29.  
  30.           Timer timer    = new Timer();
  31.           timer.Interval = 100;
  32.           timer.Tick    += new EventHandler(TimerOnTick);
  33.           timer.Start();
  34.      }
  35.      void TimerOnTick(object obj, EventArgs ea)
  36.      {
  37.           clkctl.Time = DateTime.Now;
  38.      }
  39. }
  40.