PageRenderTime 41ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/Main/src/DynamicDataDisplay/Charts/DebugMenu.cs

#
C# | 61 lines | 47 code | 8 blank | 6 comment | 1 complexity | fd5d95831848288001a206f06c800ca8 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.Controls;
  6. using System.Windows;
  7. namespace Microsoft.Research.DynamicDataDisplay.Charts
  8. {
  9. /// <summary>
  10. /// Represents a menu that appears in Debug version of DynamicDataDisplay.
  11. /// </summary>
  12. public class DebugMenu : IPlotterElement
  13. {
  14. /// <summary>
  15. /// Initializes a new instance of the <see cref="DebugMenu"/> class.
  16. /// </summary>
  17. public DebugMenu()
  18. {
  19. Panel.SetZIndex(menu, 1);
  20. }
  21. private Plotter plotter;
  22. private readonly Menu menu = new Menu
  23. {
  24. HorizontalAlignment = HorizontalAlignment.Left,
  25. VerticalAlignment = VerticalAlignment.Top,
  26. Margin = new Thickness(3)
  27. };
  28. public Menu Menu
  29. {
  30. get { return menu; }
  31. }
  32. public MenuItem TryFindMenuItem(string itemName)
  33. {
  34. return menu.Items.OfType<MenuItem>().Where(item => (string)item.Header == itemName).FirstOrDefault();
  35. }
  36. #region IPlotterElement Members
  37. public void OnPlotterAttached(Plotter plotter)
  38. {
  39. this.plotter = plotter;
  40. plotter.CentralGrid.Children.Add(menu);
  41. }
  42. public void OnPlotterDetaching(Plotter plotter)
  43. {
  44. plotter.CentralGrid.Children.Remove(menu);
  45. this.plotter = null;
  46. }
  47. public Plotter Plotter
  48. {
  49. get { return plotter; }
  50. }
  51. #endregion
  52. }
  53. }