public static Menu <T> Always <T>(this Menu <T> menu, MenuItemEventHandler <T> action) { if (action != null) { foreach (MenuItem <T> item in menu.Items) { item.OnSelect(action); } } return(menu); }
private void CreateMenu(string title, int activeItem, MenuItemEventHandler <int> always, params MenuItem <int>[] items) => AddMenu(new Menu("Setup", Palette) { Title = $"{title.ToUpper()}:", TitleColour = 15, ActiveColour = 11, TextColour = 5, DisabledColour = 8, FontId = MenuFont, IndentTitle = 2 } .Items(items) .Always(always) .Center(this) .SetActiveItem(activeItem) );
/// <summary> /// Adds a menu item into menu /// </summary> /// <param name="parent">Parent menu</param> /// <param name="text">Text</param> /// <param name="toggle">Is toggle</param> /// <param name="on">Is on</param> /// <param name="subMenu">Sub menu</param> /// <param name="activateEventHandler">Activated event handler</param> /// <param name="highlightedEventHandler">Highlighted event handler</param> /// <param name="preActivateEventHandler">Pre-activated event handler</param> public static MenuItem AddMenuItem(Menu parent, string text, bool toggle = false, bool on = false, Menu subMenu = null, MenuItemEventHandler activateEventHandler = null, MenuItemEventHandler preActivateEventHandler = null, MenuItemEventHandler highlightedEventHandler = null, object data = null) { MenuItem mi = new MenuItem() { Text = text, IsToggle = toggle, On = on, SubMenu = subMenu }; if (activateEventHandler != null) mi.Activated += activateEventHandler; if (preActivateEventHandler != null) mi.PreActivated += preActivateEventHandler; if (highlightedEventHandler != null) mi.Highlighted += highlightedEventHandler; mi.Data = data; parent.Add(mi); return mi; }
private Menu CreateMenu(int y, string title, MenuItemEventHandler <int> setChoice, params string[] menuTexts) { Menu menu = new Menu(Palette) { Title = title, X = 203, Y = y, MenuWidth = GetMenuWidth(title, menuTexts), TitleColour = 15, ActiveColour = 11, TextColour = 79, DisabledColour = 8, FontId = 0 }; for (int i = 0; i < menuTexts.Length; i++) { menu.Items.Add(menuTexts[i], i).OnSelect(setChoice); } menu.ActiveItem = 1; return(menu); }
private Menu CreateMenu(string title, MenuItemEventHandler <int> setChoice, params string[] menuTexts) { Menu menu = new Menu("NewGameMenu", Palette) { Title = title, X = OffsetX + 163, Y = OffsetY + 39, MenuWidth = 114, TitleColour = 3, ActiveColour = 11, TextColour = 5, DisabledColour = 8, FontId = 6, IndentTitle = 2, RowHeight = 8 }; for (int i = 0; i < menuTexts.Length; i++) { menu.Items.Add(menuTexts[i], i).OnSelect(setChoice); } return(menu); }
private Menu CreateMenu(string title, MenuItemEventHandler <int> setChoice, params string[] menuTexts) { int width = GetMenuWidth(title, menuTexts); int height = GetMenuHeight(title, menuTexts); Menu menu = new Menu("Setup", Palette) { Title = title, X = (Width - width) / 2, Y = (Height - height) / 2, MenuWidth = width, TitleColour = 15, ActiveColour = 11, TextColour = 5, DisabledColour = 8, FontId = MenuFont, IndentTitle = 2 }; for (int i = 0; i < menuTexts.Length; i++) { menu.Items.Add(menuTexts[i], i).OnSelect(setChoice); } return(menu); }
public MenuItem(GetTextHandler getTextCallback, MenuItemEventHandler callback, MenuItemType type = MenuItemType.Button, MenuItemAction action = MenuItemAction.None) : this(getTextCallback, type, action) { Clicked += callback; }
public MenuItem(string text, MenuItemEventHandler callback, MenuItemType type = MenuItemType.Button, MenuItemAction action = MenuItemAction.None) : this(text, type, action) { Clicked += callback; }
public static MenuItem <T> OnHelp <T>(this MenuItem <T> menuItem, MenuItemEventHandler <T> eventMethod) { menuItem.GetHelp += eventMethod; return(menuItem); }
public static MenuItem <T> OnContext <T>(this MenuItem <T> menuItem, MenuItemEventHandler <T> eventMethod) { menuItem.RightClick += eventMethod; return(menuItem); }
public static MenuItem <T> OnSelect <T>(this MenuItem <T> menuItem, MenuItemEventHandler <T> eventMethod) { menuItem.Selected += eventMethod; return(menuItem); }
private void CreateMenu(string title, MenuItemEventHandler <int> always, params MenuItem <int>[] items) => CreateMenu(title, -1, always, items);
public TrackMenuItem(string text, MenuItemEventHandler callback) : base(text, callback) { ShouldRefreshScreenIfTextChanged = false; }