public Menu(MenuMethod backspaceMethod, params MenuMethod[] methods) { BackSpaceMethod = backspaceMethod; Methods = new List <MenuMethod>(); Methods.AddRange(methods); ItemColor = ConsoleColor.White; SelectionColor = ConsoleColor.Yellow; }
public int lastAwardWeight = 1; // Przy dodawaniu nagrody w polu waga znajduje się ostatnio używana wartość #endregion public MainWindow() { InitializeComponent(); // Przekazanie obecnej instancji do obiektów: randMetods = new RandMethod(this); listManager = new ListManager(this); menuMethods = new MenuMethod(this); }
public MenuItem(string displayText, MenuMethod method, bool isAsync, string subMenuFullName, int displayOrder, string hotKey) { _displayText = displayText; _method = method; _isAsync = isAsync; _subMenuFullName = subMenuFullName; _displayOrder = displayOrder; _key = hotKey; }
/// <summary> /// Gets the common menu items that appear in every menu. /// </summary> /// <returns></returns> private static List <MenuItem> GetCommonMenuItems() { List <MenuItem> menuItems = new List <MenuItem>(); MenuMethod menuMethod = null; bool runAsynchronously = false; string subMenuFullName = null; int displayOrder = 0; menuItems.Add(new MenuItem("Exit application", menuMethod, runAsynchronously, subMenuFullName, displayOrder, MenuItemKey.ExitApp)); displayOrder = 1; menuItems.Add(new MenuItem("Clear screen", menuMethod, runAsynchronously, subMenuFullName, displayOrder, MenuItemKey.ClearScreen)); menuItems.Sort(); return(menuItems); }
/// <summary> /// Gets the menu items to display in this menu. /// </summary> /// <remarks>These are only the menu items that execute methods. The menu items that open /// sub-menus are built in the static method BuildMenuHierarchy.</remarks> private List <MenuItem> GetMenuItems() { List <MenuItem> menuItems = new List <MenuItem>(); Type menuMethodAttributeType = typeof(MenuMethodAttribute); foreach (Type menuClass in this.MenuClasses) { // Methods that appear in the menu must be both public and static. foreach (MethodInfo method in menuClass.GetMethods(BindingFlags.Public | BindingFlags.Static)) { if (method.IsDefined(menuMethodAttributeType, false)) { object[] methodAttributes = method.GetCustomAttributes(menuMethodAttributeType, false); // Method should be decorated with only one MenuMethodAttribute. MenuMethodAttribute menuMethodAttribute = (MenuMethodAttribute)methodAttributes[0]; string menuDisplayText = menuMethodAttribute.Description; bool runAsynchronously = menuMethodAttribute.RunAsynchronously; MenuMethod menuMethod = (MenuMethod)Delegate.CreateDelegate(typeof(MenuMethod), method); int displayOrder = menuMethodAttribute.DisplayOrder; menuItems.Add(new MenuItem(menuDisplayText, menuMethod, runAsynchronously, null, displayOrder)); } } } this.SetMenuItemsKeys(ref menuItems); return(menuItems); }
public object Menu(MenuMethod method, params object[] options) { return(null); }
public object Menu(MenuMethod method, params object[] options) { return null; }
public MenuItem(string displayText, MenuMethod method, bool isAsync, string subMenuFullName, int displayOrder) : this(displayText, method, isAsync, subMenuFullName, displayOrder, null) { }