PageRenderTime 590ms CodeModel.GetById 17ms RepoModel.GetById 0ms 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
Possible License(s): CC-BY-SA-3.0
  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. namespace Microsoft.Research.DynamicDataDisplay.Charts.Axes
  8. {
  9. public abstract class LabelProvider<T> : LabelProviderBase<T>
  10. {
  11. public override UIElement[] CreateLabels(ITicksInfo<T> ticksInfo)
  12. {
  13. var ticks = ticksInfo.Ticks;
  14. UIElement[] res = new UIElement[ticks.Length];
  15. LabelTickInfo<T> labelInfo = new LabelTickInfo<T> { Info = ticksInfo.Info };
  16. for (int i = 0; i < res.Length; i++)
  17. {
  18. labelInfo.Tick = ticks[i];
  19. labelInfo.Index = i;
  20. string labelText = GetString(labelInfo);
  21. TextBlock label = (TextBlock)GetResourceFromPool();
  22. if (label == null)
  23. {
  24. label = new TextBlock();
  25. }
  26. label.Text = labelText;
  27. label.ToolTip = ticks[i].ToString();
  28. res[i] = label;
  29. ApplyCustomView(labelInfo, label);
  30. }
  31. return res;
  32. }
  33. }
  34. }