public MenuItem(Menu owner, MenuItem parent, string caption, string intro, ConsoleKey shortCutKey, Action<MenuItem> action, VisibleChecker visibleChecker) { this._owner = owner; this._parent = parent; this._caption = caption; this._intro = intro; this._shortCutKey = shortCutKey; this.Action = action; this.VisibleChecker = visibleChecker; }
public static void Main(string[] args) { // Create the dictionary that will be used to hold the generators generators = new Dictionary<string, TreasureGenerator.TreasureGenerator>(files.Length); // Get the files and make generators for them for( int i = 0; i < files.Length; i++) generators.Add(stripFileName(files[i]), new TreasureGenerator.TreasureGenerator(files[i])); coinGen = new CoinGenerator.CoinGenerator(); // Create the menu items for the treasure menu List<MenuItem> menuItems = new List<MenuItem>(); int menuOrder = 0; menuItems.Add(new MenuItem(menuOrder++, "Generate a gem", generateGem)); menuItems.Add(new MenuItem(menuOrder++, "Generate a treasure", generateArt)); menuItems.Add(new MenuItem(menuOrder++, "Generate coins", generateCoins)); // Create the generator menu Menu generatorMenu = new Menu(menuItems, "What would you like to generate?", "Return to main menu"); // Create the menu items for the main menu menuItems.Clear(); menuOrder = 0; menuItems.Add(new MenuItem(menuOrder++, "Treasure Generator", generatorMenu.RunMenu)); // Create the main menu Menu mainMenu = new Menu(menuItems); // Run the main menu mainMenu.RunMenu(wait:false); }
public MenuItem(Menu owner, string caption) : this(owner, null, caption, null, ConsoleKey.Escape, null, null) { }