Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Charts/Axes/DateTime/DateTimeLabelProvider.cs @ 13847

Last change on this file since 13847 was 12503, checked in by aballeit, 10 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;
6using System.Windows.Controls;
7using Microsoft.Research.DynamicDataDisplay.Charts.Axes;
8
9namespace Microsoft.Research.DynamicDataDisplay.Charts
10{
11  /// <summary>
12  /// Represents a label provider for <see cref="System.DateTime"/> ticks.
13  /// </summary>
14  public class DateTimeLabelProvider : DateTimeLabelProviderBase
15  {
16    /// <summary>
17    /// Initializes a new instance of the <see cref="DateTimeLabelProvider"/> class.
18    /// </summary>
19    public DateTimeLabelProvider() { }
20
21    public override UIElement[] CreateLabels(ITicksInfo<DateTime> ticksInfo)
22    {
23      object info = ticksInfo.Info;
24      var ticks = ticksInfo.Ticks;
25
26      if (info is DifferenceIn)
27      {
28        DifferenceIn diff = (DifferenceIn)info;
29        DateFormat = GetDateFormat(diff);
30      }
31
32      LabelTickInfo<DateTime> tickInfo = new LabelTickInfo<DateTime> { Info = info };
33
34      UIElement[] res = new UIElement[ticks.Length];
35      for (int i = 0; i < ticks.Length; i++)
36      {
37        tickInfo.Tick = ticks[i];
38
39        string tickText = GetString(tickInfo);
40        UIElement label = new TextBlock { Text = tickText, ToolTip = ticks[i] };
41        ApplyCustomView(tickInfo, label);
42        res[i] = label;
43      }
44
45      return res;
46    }
47  }
48}
Note: See TracBrowser for help on using the repository browser.