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