Rev | Line | |
---|
[12503] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Windows.Controls.Primitives;
|
---|
| 6 | using System.Threading;
|
---|
| 7 |
|
---|
| 8 | namespace Microsoft.Research.DynamicDataDisplay
|
---|
| 9 | {
|
---|
| 10 | public class PopupTip : Popup
|
---|
| 11 | {
|
---|
| 12 | private TimeSpan showDurationInerval = new TimeSpan(0, 0, 10);
|
---|
| 13 | private Timer timer;
|
---|
| 14 |
|
---|
| 15 | public void ShowDelayed(TimeSpan delay)
|
---|
| 16 | {
|
---|
| 17 | if (timer != null)
|
---|
| 18 | timer.Change((int)delay.TotalMilliseconds, System.Threading.Timeout.Infinite);
|
---|
| 19 | else
|
---|
| 20 | timer = new Timer(OnTimerFinished, null, (int)delay.TotalMilliseconds, System.Threading.Timeout.Infinite);
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | public void HideDelayed(TimeSpan delay)
|
---|
| 24 | {
|
---|
| 25 | if (timer != null)
|
---|
| 26 | {
|
---|
| 27 | timer.Change((int)delay.TotalMilliseconds, System.Threading.Timeout.Infinite);
|
---|
| 28 | }
|
---|
| 29 | else
|
---|
| 30 | timer = new Timer(OnTimerFinished, null, (int)delay.TotalMilliseconds, System.Threading.Timeout.Infinite);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | public void Hide()
|
---|
| 34 | {
|
---|
| 35 | if (timer != null)
|
---|
| 36 | {
|
---|
| 37 | timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
|
---|
| 38 | }
|
---|
| 39 | this.IsOpen = false;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | private void OnTimerFinished(object state)
|
---|
| 43 | {
|
---|
| 44 | this.Dispatcher.BeginInvoke(new Action(() =>
|
---|
| 45 | {
|
---|
| 46 | bool show = !this.IsOpen;
|
---|
| 47 | this.IsOpen = show;
|
---|
| 48 | if (show)
|
---|
| 49 | HideDelayed(showDurationInerval);
|
---|
| 50 | }));
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.