Rev | Line | |
---|
[12503] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Windows;
|
---|
| 6 | using System.Windows.Controls;
|
---|
| 7 | using Microsoft.Research.DynamicDataDisplay.Charts.Axes;
|
---|
| 8 | using System.Globalization;
|
---|
| 9 |
|
---|
| 10 | namespace 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.