private void tmr_Tick(object sender, EventArgs e) { float convToAngle = (float)((2 * Math.PI) / 60000f); foreach (SubCircle c in clock.SubCircles) { UpdateSubCircle(convToAngle, c); } foreach (SubCircle c in clock.OuterSubCircles) { UpdateSubCircle(convToAngle, c); } //clock.MinHandle.AnglePosition += 0.04f * 10; //clock.HourHandle.AnglePosition += 0.04f; clock.MinHandle.AnglePosition = ClockDrawing.ToRad(-90 + ((float)((DateTime.Now - DateTime.Now.Date).TotalMinutes / 60f) * 360)); clock.HourHandle.AnglePosition = ClockDrawing.ToRad(-90 + ((float)((DateTime.Now - DateTime.Now.Date).TotalHours / 12f) * 360)); Invalidate(); }
public static Clock GetDefaultClock() { Random rnd = new Random(); Clock clock = new Clock(); clock.SubCircles = new List <SubCircle>() { new SubCircle() { AnglePosition = ClockDrawing.ToRad(-90 + 120), BigHandles = new List <Handle>() { new Handle() { AnglePosition = ClockDrawing.ToRad(rnd.Next(360)) } }, SmallHandles = new List <Handle>() { new Handle() { AnglePosition = ClockDrawing.ToRad(rnd.Next(360)) } }, }, new SubCircle() { AnglePosition = ClockDrawing.ToRad(-90 + 210), BigHandles = new List <Handle>() { new Handle() { AnglePosition = ClockDrawing.ToRad(rnd.Next(360)) } }, SmallHandles = new List <Handle>() { new Handle() { AnglePosition = ClockDrawing.ToRad(rnd.Next(360)) } }, } }; clock.OuterSubCircles = new List <SubCircle>() { new SubCircle() { AnglePosition = ClockDrawing.ToRad(-90 + 330), BigHandles = new List <Handle>() { new Handle() { AnglePosition = ClockDrawing.ToRad(rnd.Next(360)) } }, SmallHandles = new List <Handle>() { new Handle() { AnglePosition = ClockDrawing.ToRad(rnd.Next(360)) } }, } }; clock.HourHandle = new MainHandle(); clock.MinHandle = new MainHandle(); return(clock); }