PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Main/src/DynamicDataDisplay/Charts/Axes/LabelProvider.cs

#
C# | 43 lines | 34 code | 9 blank | 0 comment | 3 complexity | 9506cd8c62fe1a1ccb8113ccd3d6995b MD5 | raw file
 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	public abstract class LabelProvider<T> : LabelProviderBase<T>
11	{
12		public override UIElement[] CreateLabels(ITicksInfo<T> ticksInfo)
13		{
14			var ticks = ticksInfo.Ticks;
15
16			UIElement[] res = new UIElement[ticks.Length];
17			LabelTickInfo<T> labelInfo = new LabelTickInfo<T> { Info = ticksInfo.Info };
18
19			for (int i = 0; i < res.Length; i++)
20			{
21				labelInfo.Tick = ticks[i];
22				labelInfo.Index = i;
23
24				string labelText = GetString(labelInfo);
25
26				TextBlock label = (TextBlock)GetResourceFromPool();
27				if (label == null)
28				{
29					label = new TextBlock();
30				}
31
32				label.Text = labelText;
33				label.ToolTip = ticks[i].ToString();
34
35				res[i] = label;
36
37				ApplyCustomView(labelInfo, label);
38			}
39			
40			return res;
41		}
42	}
43}