private static void Main() { var kernel = new StandardKernel(); LoadModules(kernel); var bundle = new CoreBundle(kernel); var ctx = new Context(kernel); // TODO: introduce a getUserNameCommand Console.WriteLine("Who are you?"); ctx.PlayerName = Console.ReadLine(); Console.Clear(); var engine = new GnomEngine(ctx, bundle); engine.HandleUserInput("field"); var view = GnomViewProvider.GetGnomView(); var app = new GnomApp(view, view["restart"], new ConsoleManipulator(), x => { if (x.PressedKeyInfo.Key == ConsoleKey.Escape) { Console.SetCursorPosition(60, 25); Environment.Exit(42); } else if (x.PressedKeyInfo.Key == ConsoleKey.Enter) { engine.HandleUserInput((x.Target as IElement).Id); } }); app.Start(); }
public static void Main() { Console.CursorVisible = false; var uiDescription = @"root #root .root-element box #container .div field #field .field button #restart .btn1 :restart button #undo .btn2 :undo button #exit .btn3 :exit button #top .btn4 :top"; var styles = @".div width 50 height 20 color blue .root-element color black width 2 height 2 left 2 top 2 .field width 28 height 11 color red .root width 50 height 30 color green .btn1 left 4 top 12 height 4 width 10 color blue .btn2 left 16 top 12 height 4 width 8 color blue .btn3 left 26 top 12 height 4 width 8 color blue .btn4 left 36 top 12 height 4 width 8 color blue"; var graph = @"restart # undo # # undo restart exit # # exit undo top # # top exit # # #"; var gnomBuilder = ParserProvider.GetGnomConstructor(); var result = gnomBuilder.Construct(uiDescription, graph, styles); var drawer = new ConsoleManipulator(); var matrix = new string[,] { { "1", "2", "3" }, { "4", "5", "6" } }; var startingSelection = AddMatrixToGnom(result["field"], matrix); startingSelection.LinkTo(ConsoleKey.DownArrow, result["restart"], true); var app = new GnomApp(result, startingSelection, drawer, x => { }); result["restart"].OnClick = x => Console.BackgroundColor = ConsoleColor.Red; result["undo"].OnClick = x => Console.BackgroundColor = ConsoleColor.Blue; result["exit"].OnClick = x => Environment.Exit(0); app.Start(); }