Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Charts/PopupTip.cs @ 13401

Last change on this file since 13401 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 1.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows.Controls.Primitives;
6using System.Threading;
7
8namespace 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.