Created
November 24, 2019 20:36
-
-
Save tmacharia/5eb66ab9605a0ed0e401997da7cda788 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Windows.Xaml; | |
namespace uwp.clock.backend | |
{ | |
public sealed partial class UwpClockPage : Page | |
{ | |
private readonly DispatcherTimer _timer; | |
private double PreviousAngle = 0; | |
public UwpClockPage() | |
{ | |
this.InitializeComponent(); | |
_timer = new DispatcherTimer | |
{ | |
Interval = TimeSpan.FromSeconds(1) | |
}; | |
_timer.Tick += (s,e) => OnTick(); | |
} | |
private void OnTick() | |
{ | |
// calculate angle of rotation based on current system time seconds. | |
double angle = DateTime.Now.TimeOfDay.Seconds * 360 / 60; | |
lock (SpinSecHandStoryBoard) | |
{ | |
SpinSecHandAnim.From = PreviousAngle; | |
SpinSecHandAnim.To = angle; | |
SpinSecHandAnim.Duration = new Duration(TimeSpan.FromSeconds(1)); | |
SpinSecHandStoryBoard.Begin(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment