using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D ;
using System.Drawing.Imaging;namespace VirtualClock
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.IContainer components;
private MinuteHand MyMinuteHand;
private HourHand MyHourHand;
private System.Windows.Forms.Timer timer1;
private SecondHand MySecondHand;
private ClockFace TheClockFace;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private bool FirstTick = false; public Form1()
{
 MyMinuteHand = new MinuteHand(this);
 MyHourHand = new HourHand(this);
 MySecondHand = new SecondHand(this);
//
// Required for Windows Form Designer support
//
InitializeComponent();
TheClockFace = new ClockFace(ClientRectangle); timer1.Start();
// draw minute hand

// draw hour hand //
// TODO: Add any constructor code after InitializeComponent call
//
} /// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
} base.Dispose( disposing ); timer1.Stop();
} #region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
// 
// timer1
// 
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
// 
// mainMenu1
// 
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  this.menuItem1});
// 
// menuItem1
// 
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  this.menuItem2,
  this.menuItem3,
  this.menuItem4});
this.menuItem1.Text = "&Icirc;&Auml;&frac14;&thorn;";
// 
// menuItem2
// 
this.menuItem2.Index = 0;
this.menuItem2.Text = "&sup1;&Oslash;&Oacute;&Uacute;";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
// 
// menuItem3
// 
this.menuItem3.Index = 1;
this.menuItem3.Text = "-";
// 
// menuItem4
// 
this.menuItem4.Index = 2;
this.menuItem4.Text = "&Iacute;&Euml;&sup3;&ouml;";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
// 
// Form1
// 
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(328, 333);
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.MinimizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Virtual Clock";
this.Resize += new System.EventHandler(this.Form1_Resize);
this.Load += new System.EventHandler(this.Form1_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint); }
#endregion /// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() 
{
Application.Run(new Form1());
} private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if (FirstTick == false)
return; Graphics g = e.Graphics;
TheClockFace.Draw(g);
MyHourHand.Draw(g);
MyMinuteHand.Draw(g);
MySecondHand.Draw(g);
TheClockFace.DrawPin(g); // redraw the pin to cover the hands
} private void Form1_Resize(object sender, System.EventArgs e)
{
TheClockFace.UpdateRectangle(ClientRectangle);
Invalidate();
} private void timer1_Tick(object sender, System.EventArgs e)
{
MySecondHand.Transform(DateTime.Now);
MyHourHand.Transform(DateTime.Now);
MyMinuteHand.Transform(DateTime.Now);
FirstTick = true;
Invalidate();
} private void menuItem2_Click(object sender, System.EventArgs e)
{
(new chinanetboy()).ShowDialog();
} private void menuItem4_Click(object sender, System.EventArgs e)
{
Close();
} private void Form1_Load(object sender, System.EventArgs e)
{

}
}
}