Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Charts/Axes/GenericLabelProvider.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.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows;
6using System.Windows.Controls;
7
8namespace Microsoft.Research.DynamicDataDisplay.Charts.Axes
9{
10  /// <summary>
11  /// Represents default implementation of label provider for specified type.
12  /// </summary>
13  /// <typeparam name="T">Axis values type.</typeparam>
14  public class GenericLabelProvider<T> : LabelProviderBase<T>
15  {
16    /// <summary>
17    /// Initializes a new instance of the <see cref="GenericLabelProvider&lt;T&gt;"/> class.
18    /// </summary>
19    public GenericLabelProvider() { }
20
21    #region ILabelProvider<T> Members
22
23    /// <summary>
24    /// Creates the labels by given ticks info.
25    /// </summary>
26    /// <param name="ticksInfo">The ticks info.</param>
27    /// <returns>
28    /// Array of <see cref="UIElement"/>s, which are axis labels for specified axis ticks.
29    /// </returns>
30    public override UIElement[] CreateLabels(ITicksInfo<T> ticksInfo)
31    {
32      var ticks = ticksInfo.Ticks;
33      var info = ticksInfo.Info;
34
35      LabelTickInfo<T> tickInfo = new LabelTickInfo<T>();
36      UIElement[] res = new UIElement[ticks.Length];
37      for (int i = 0; i < res.Length; i++)
38      {
39        tickInfo.Tick = ticks[i];
40        tickInfo.Info = info;
41
42        string text = GetString(tickInfo);
43
44        res[i] = new TextBlock
45        {
46          Text = text,
47          ToolTip = ticks[i].ToString()
48        };
49      }
50      return res;
51    }
52
53    #endregion
54  }
55}
Note: See TracBrowser for help on using the repository browser.