#Extremely rough and laggy clock #
Extremely rough and laggy clock
#Extremely rough and laggy clock #
Extremely rough and laggy clock
#Extreamley#Extremely rough and laggy clock #
I purposley made the timer interval less than a second in hopes for making things run smoothley but it even worsened the situation! I thought of making the second's hand run on milliseconds but it still didn't do the job and there was difference between the clock and the label text.
I purposely made the timer interval less than a second in hopes for making things run smoothly but it even worsened the situation! I thought of making the seconds hand run on milliseconds but it still didn't do the job and there was difference between the clock and the label text.
#Extreamley rough and laggy clock #
I purposley made the timer interval less than a second in hopes for making things run smoothley but it even worsened the situation! I thought of making the second's hand run on milliseconds but it still didn't do the job and there was difference between the clock and the label text.
#Extremely rough and laggy clock #
I purposely made the timer interval less than a second in hopes for making things run smoothly but it even worsened the situation! I thought of making the seconds hand run on milliseconds but it still didn't do the job and there was difference between the clock and the label text.
Windows Forms Clock
#Extreamley rough and laggy clock #
I purposley made the timer interval less than a second in hopes for making things run smoothley but it even worsened the situation! I thought of making the second's hand run on milliseconds but it still didn't do the job and there was difference between the clock and the label text.
public Form1()
{
InitializeComponent();
timer1.Interval = 500;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Invalidate();
this.label1.Text = String.Format("{0}:{1}:{2}",clockTime.Hour,clockTime.Minute,clockTime.Second);
}
DateTime clockTime = DateTime.Now;
int cirDia = 200;
public void Form1_Paint(object sender, PaintEventArgs e)
{
clockTime = DateTime.Now;
Pen secHand = new Pen(Color.Green, 1);
Pen minHand = new Pen(Color.Black, 2);
Pen hourHand = new Pen(Color.Red, 3);
Graphics canvas = e.Graphics;
float centerX = this.ClientRectangle.Width / 2;
float centerY = this.ClientRectangle.Height / 2;
canvas.DrawEllipse(Pens.Aqua, centerX - cirDia / 2, centerY - cirDia / 2, cirDia, cirDia);
float secX = 100 * (float)Math.Cos(Math.PI / -2 + (2 * clockTime.Second * Math.PI) / 60) + centerX;
float secY = 100 * (float)Math.Sin(Math.PI / -2 + (2 * clockTime.Second * Math.PI) / 60) + centerY;
float minX = 80 * (float)Math.Cos(Math.PI / -2 + (2 * clockTime.Minute * Math.PI) / 60) + centerX;
float minY = 80 * (float)Math.Sin(Math.PI / -2 + (2 * clockTime.Minute * Math.PI) / 60) + centerY;
float hourX = 70 * (float)Math.Cos(Math.PI / -2 + (2 * clockTime.Hour * Math.PI) / 12) + centerX;
float hourY = 70 * (float)Math.Sin(Math.PI / -2 + (2 * clockTime.Hour * Math.PI) / 12) + centerY;
canvas.DrawLine(secHand, centerX, centerY, secX, secY);
canvas.DrawLine(minHand, centerX, centerY, minX, minY);
canvas.DrawLine(hourHand, centerX, centerY, hourX, hourY);
}