Mercurial > silverbladetech
annotate MetroWpf/FxRates.UI/Controls/TimerTextBlock.cs @ 44:382813d76dde Test
Removal of pdf project
author | Steven Hollidge <stevenhollidge@hotmail.com> |
---|---|
date | Wed, 04 Apr 2012 19:21:31 +0100 |
parents | a8b50a087544 |
children |
rev | line source |
---|---|
24
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
1 using System; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
2 using System.Threading; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
3 using System.Windows; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
4 using System.Windows.Controls; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
5 using System.Windows.Data; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
6 using System.Windows.Documents; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
7 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
8 namespace FxRates.UI.Controls |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
9 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
10 public delegate void Invoker(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
11 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
12 public class TimerTextBlock : TextBlock |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
13 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
14 //private static Timer _UpdateTimer = new Timer(UpdateTimer, null, 1000, 1000); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
15 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
16 public static readonly DependencyProperty TimeSpanProperty = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
17 DependencyProperty.Register("TimeSpan", typeof (TimeSpan), typeof (TimerTextBlock), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
18 new UIPropertyMetadata(TimeSpan.Zero)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
19 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
20 public static readonly DependencyProperty IsStartedProperty = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
21 DependencyProperty.Register("IsStarted", typeof (bool), typeof (TimerTextBlock), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
22 new UIPropertyMetadata(false)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
23 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
24 public static readonly DependencyProperty TimeFormatProperty = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
25 DependencyProperty.Register("TimeFormat", typeof (string), typeof (TimerTextBlock), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
26 new UIPropertyMetadata(null)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
27 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
28 public static readonly DependencyProperty IsCountDownProperty = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
29 DependencyProperty.Register("IsCountDown", typeof (bool), typeof (TimerTextBlock), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
30 new UIPropertyMetadata(false)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
31 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
32 private Invoker _UpdateTimeInvoker; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
33 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
34 public TimerTextBlock() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
35 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
36 Init(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
37 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
38 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
39 public TimerTextBlock(Inline inline) : base(inline) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
40 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
41 Init(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
42 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
43 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
44 /// <summary> |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
45 /// Represents the time remaining for the count down to complete if |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
46 /// the control is initialized as a count down timer otherwise, it |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
47 /// represents the time elapsed since the timer has started. |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
48 /// </summary> |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
49 /// <exception cref="System.ArgumentException"> |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
50 /// </exception> |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
51 public TimeSpan TimeSpan |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
52 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
53 get { return (TimeSpan) GetValue(TimeSpanProperty); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
54 set |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
55 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
56 if (value < TimeSpan.Zero) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
57 throw new ArgumentException(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
58 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
59 SetValue(TimeSpanProperty, value); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
60 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
61 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
62 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
63 // Using a DependencyProperty as the backing store for TimeSpan. This enables animation, styling, binding, etc... |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
64 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
65 public bool IsStarted |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
66 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
67 get { return (bool) GetValue(IsStartedProperty); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
68 set { SetValue(IsStartedProperty, value); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
69 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
70 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
71 // Using a DependencyProperty as the backing store for IsStarted. This enables animation, styling, binding, etc... |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
72 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
73 /// <summary> |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
74 /// Format string for displaying the time span value. |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
75 /// </summary> |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
76 public string TimeFormat |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
77 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
78 get { return (string) GetValue(TimeFormatProperty); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
79 set { SetValue(TimeFormatProperty, value); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
80 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
81 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
82 // Using a DependencyProperty as the backing store for TimeFormat. This enables animation, styling, binding, etc... |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
83 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
84 /// <summary> |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
85 /// Represents whether the control is a CountDown or regular timer. |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
86 /// </summary> |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
87 public bool IsCountDown |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
88 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
89 get { return (bool) GetValue(IsCountDownProperty); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
90 set { SetValue(IsCountDownProperty, value); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
91 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
92 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
93 public event EventHandler OnCountDownComplete; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
94 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
95 private static event EventHandler OnTick; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
96 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
97 private void Init() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
98 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
99 Loaded += TimerTextBlock_Loaded; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
100 Unloaded += TimerTextBlock_Unloaded; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
101 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
102 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
103 ~TimerTextBlock() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
104 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
105 Dispose(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
106 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
107 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
108 public void Dispose() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
109 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
110 OnTick -= TimerTextBlock_OnTick; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
111 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
112 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
113 // Using a DependencyProperty as the backing store for IsCountDown. This enables animation, styling, binding, etc... |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
114 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
115 /// <summary> |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
116 /// Sets the time span to zero and stops the timer. |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
117 /// </summary> |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
118 public void Reset() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
119 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
120 IsStarted = false; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
121 TimeSpan = TimeSpan.Zero; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
122 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
123 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
124 private static void UpdateTimer(object state) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
125 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
126 EventHandler onTick = OnTick; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
127 if (onTick != null) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
128 onTick(null, EventArgs.Empty); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
129 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
130 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
131 private void TimerTextBlock_Loaded(object sender, RoutedEventArgs e) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
132 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
133 var binding = new Binding("TimeSpan"); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
134 binding.Source = this; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
135 binding.Mode = BindingMode.OneWay; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
136 binding.StringFormat = TimeFormat; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
137 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
138 SetBinding(TextProperty, binding); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
139 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
140 _UpdateTimeInvoker = UpdateTime; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
141 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
142 OnTick += TimerTextBlock_OnTick; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
143 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
144 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
145 private void TimerTextBlock_Unloaded(object sender, RoutedEventArgs e) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
146 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
147 OnTick -= TimerTextBlock_OnTick; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
148 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
149 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
150 private void TimerTextBlock_OnTick(object sender, EventArgs e) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
151 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
152 Dispatcher.Invoke(_UpdateTimeInvoker); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
153 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
154 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
155 private void UpdateTime() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
156 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
157 if (IsStarted) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
158 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
159 TimeSpan step = TimeSpan.FromSeconds(1); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
160 if (IsCountDown) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
161 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
162 if (TimeSpan >= TimeSpan.FromSeconds(1)) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
163 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
164 TimeSpan -= step; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
165 if (TimeSpan.TotalSeconds <= 0) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
166 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
167 TimeSpan = TimeSpan.Zero; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
168 IsStarted = false; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
169 NotifyCountDownComplete(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
170 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
171 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
172 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
173 else |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
174 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
175 TimeSpan += step; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
176 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
177 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
178 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
179 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
180 private void NotifyCountDownComplete() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
181 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
182 EventHandler handler = OnCountDownComplete; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
183 if (handler != null) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
184 handler(this, EventArgs.Empty); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
185 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
186 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
187 } |