Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Charts/Axes/Numeric/ToStringLabelProvider.cs @ 13398

Last change on this file since 13398 was 12503, checked in by aballeit, 10 years ago

#2283 added GUI and charts; fixed MCTS

File size: 1.4 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;
8using System.Globalization;
9
10namespace Microsoft.Research.DynamicDataDisplay.Charts
11{
12  /// <summary>
13  /// Represents a simple label provider for double ticks, which simply returns result of .ToString() method, called for rounded ticks.
14  /// </summary>
15  public class ToStringLabelProvider : NumericLabelProviderBase
16  {
17    /// <summary>
18    /// Initializes a new instance of the <see cref="ToStringLabelProvider"/> class.
19    /// </summary>
20    public ToStringLabelProvider() { }
21
22    public override UIElement[] CreateLabels(ITicksInfo<double> ticksInfo)
23    {
24      var ticks = ticksInfo.Ticks;
25
26      Init(ticks);
27
28      UIElement[] res = new UIElement[ticks.Length];
29      LabelTickInfo<double> tickInfo = new LabelTickInfo<double> { Info = ticksInfo.Info };
30      for (int i = 0; i < res.Length; i++)
31      {
32        tickInfo.Tick = ticks[i];
33        tickInfo.Index = i;
34
35        string labelText = GetString(tickInfo);
36
37        TextBlock label = (TextBlock)GetResourceFromPool();
38        if (label == null)
39        {
40          label = new TextBlock();
41        }
42
43        label.Text = labelText;
44        label.ToolTip = ticks[i].ToString();
45
46        res[i] = label;
47
48        ApplyCustomView(tickInfo, label);
49      }
50      return res;
51    }
52  }
53}
Note: See TracBrowser for help on using the repository browser.