3
using System.Globalization;
4
using System.Windows.Controls;
5
using System.Windows.Media;
6
using System.Windows.Media.Animation;
7
using System.Windows.Shapes;
11
public class Display : Canvas {
12
TextBlock hour, minute, ampm;
13
Storyboard to_config, to_clock;
14
DateTime last = DateTime.MinValue;
19
DateTime dt = DateTime.Now;
21
if (dt.Hour == last.Hour && dt.Minute == last.Minute)
24
if (dt.Hour != last.Hour) {
31
hour.Text = h.ToString ("00");
34
minute.Text = dt.Minute.ToString ("00");
38
if (isAm && dt.Hour >= 12) {
41
} else if (!isAm && dt.Hour < 12) {
48
bool in_config = false;
50
void DoConfigTransition ()
61
public void PageLoaded(object o, EventArgs e)
65
UIElement r = FindName ("dotcover") as UIElement;
66
Storyboard sb = FindName ("run") as Storyboard;
67
hour = FindName ("hour") as TextBlock;
68
minute = FindName ("minute") as TextBlock;
69
ampm = FindName ("ampm") as TextBlock;
70
Canvas config = FindName ("configcanvas") as Canvas;
71
Canvas config_button = FindName ("config_button") as Canvas;
72
to_config = FindName ("to_config") as Storyboard;
73
to_clock = FindName ("to_clock") as Storyboard;
77
ampm.Visibility = Visibility.Collapsed;
79
isAm = ampm.Text.ToLower () == "am";
83
if (sb == null || r == null || hour == null || minute == null || config == null ||
84
to_config == null || to_clock == null){
85
Console.WriteLine ("Elements are missing from the xaml file\n");
89
DoubleAnimation timer = new DoubleAnimation ();
90
sb.Children.Add (timer);
91
timer.Duration = new Duration (TimeSpan.FromSeconds (0.5));
93
sb.Completed += delegate {
96
r.Opacity = visible ? 0.0 : 1.0;
101
bool in_config = false;
103
config_button.MouseLeftButtonUp += delegate {
104
DoConfigTransition ();
107
config.MouseLeftButtonUp += delegate {
108
DoConfigTransition ();