public Hand( ref Graphics GraphicsInterface, HandType TypeOfHand, ClockTime Time, ClockCentreCoordinates Coordinates, Int32 HandLength, Color HandColour, float HandThickness) { // Set specific hand properties. CoordinateStartX = Coordinates.X; CoordinateStartY = Coordinates.Y; Length = HandLength; Colour = HandColour; Thickness = HandThickness; // What type of clock hand to create? switch (TypeOfHand) { case HandType.Milliseconds: { // 1 millisecond = 0.006 degrees. Angle = Time.Milliseconds * 0.006F; break; } case HandType.Seconds: { // 1 second = 6 degrees. Angle = Time.Seconds * 6; break; } case HandType.Minutes: { // 1 minute = 6 degrees. Angle = Time.Minutes * 6; break; } case HandType.Hours: { // 1 hour = 30 degrees + 0.5 degrees for each minute. Angle = Time.Hours * 30 + (Int32)(Time.Minutes * 0.5); break; } default: break; } GetEndCoordinates(Coordinates); DrawHand(ref GraphicsInterface); }
public Clock( ref Graphics GraphicsInterface, Int32 CoordinateCentreX, Int32 CoordinateCentreY) { ClockCentreCoordinates CentreCoordinates = new ClockCentreCoordinates( CoordinateCentreX, CoordinateCentreY); ClockTime Time = new ClockTime(); Hand HandHours = new Hand( ref GraphicsInterface, HandType.Hours, Time, CentreCoordinates, HandLengthHours, HandColourHours, HandThicknessHours); Hand HandMinutes = new Hand( ref GraphicsInterface, HandType.Minutes, Time, CentreCoordinates, HandLengthMinutes, HandColourMinutes, HandThicknessMinutes); Hand HandSeconds = new Hand( ref GraphicsInterface, HandType.Seconds, Time, CentreCoordinates, HandLengthSeconds, HandColourSeconds, HandThicknessSeconds); }
public StopWatch( ref Graphics GraphicsInterface, Int32 CoordinateCentreX, Int32 CoordinateCentreY) : base(ref GraphicsInterface, CoordinateCentreX, CoordinateCentreY) { ClockCentreCoordinates CentreCoordinates = new ClockCentreCoordinates( CoordinateCentreX, CoordinateCentreY); // Take modulus 60000 of milliseconds time. //ClockTime Time = new ClockTime(); //Time.Milliseconds = StopWatch.StopwatchTime.Elapsed.Seconds % 60; // Take modulus 60000 of milliseconds time. ClockTime Time = new ClockTime(); //Time.Milliseconds = StopWatch.StopwatchTime.Elapsed.Milliseconds % 60000; //Time.Milliseconds = // (StopWatch.StopwatchTime.Elapsed.Seconds * 1000) + // (StopWatch.StopwatchTime.Elapsed.Milliseconds); Time.Milliseconds = (float)(StopWatch.StopwatchTime.Elapsed.TotalMilliseconds % 60000); Hand HandMilliseconds = new Hand( ref GraphicsInterface, HandType.Milliseconds, Time, CentreCoordinates, HandLengthMilliseconds, HandColourMilliseconds, HandThicknessMilliseconds); }