コード例 #1
0
        public ViuDemo()
        {
            var mainContainer = new Parent {
                ClearAreaBeforePrint = true
            };
            var cons = new ConsoleParent(mainContainer);

            cons.SetTitle("Viu/SCFE Demo");
            var switcher = new SwitcherStrategy(mainContainer);

            mainContainer.Strategy = switcher;


            var menu = new Parent(new LineStrategy {
                Centered = true
            });

            mainContainer.AddComponent(menu);
            menu.AddComponent(new TextComponent("~ SCFE Demo ~")
            {
                Foreground = ConsoleColor.Yellow, HAlign = HorizontalAlignment.Centered
            });
            menu.AddComponent(new Separator());
            switcher.SwitchToComponent(menu, null);

            var table = new TableComponent <ViuDemoType> {
                Data = _demos
            };

            menu.AddComponent(table);
            table.AddColumn(new IndicatorColumnType <ViuDemoType>());
            table.AddColumn(
                new BasicColumnType <ViuDemoType>("Choose a demo to get started. Exit a demo with the Escape key.",
                                                  vdt => vdt.Name));
            table.ActionOnListElement += (sender, args) =>
            {
                switcher.SwitchToComponent(args.Item.Parent, args.Graphics);
                mainContainer.Validate();
                mainContainer.Print(args.Graphics);
            };

            foreach (var vdt in _demos)
            {
                mainContainer.AddComponent(vdt.Parent);
            }

            mainContainer.ActionMap.Put(StandardActionNames.CancelAction, (o, args) =>
            {
                mainContainer.SetFocused(false, args.Graphics);
                switcher.SwitchToComponent(menu, args.Graphics);
                mainContainer.Validate();
                mainContainer.SetFocused(true, args.Graphics);
                mainContainer.Print(args.Graphics);
            });

            cons.Validate();
            cons.FocusFirst();
            cons.Print();
        }
コード例 #2
0
        // ReSharper disable once UnusedMember.Local
        private static void LaunchSingleTest(Func <Parent> test)
        {
            var cons = new ConsoleParent(test());

            cons.Validate();
            cons.FocusFirst();
            cons.Print();
        }
コード例 #3
0
ファイル: ScfeApp.cs プロジェクト: yxyfer/SalamandersLab
 public void Show()
 {
     _cons = new ConsoleParent(_main)
     {
         ExceptionHandler = (e, g) => { ShowHelpMessage(e.Message.Replace("\n", " - "), g, ConsoleColor.Red); }
     };
     _cons.Validate();
     // Only once the table is actually added
     _cons.FocusFirst();
     _cons.Print();
     _cons.SetTitle("SCFE - " + CurrentDir.Path);
 }
コード例 #4
0
ファイル: ScfeApp.cs プロジェクト: yxyfer/SalamandersLab
 private void AddMainBindings()
 {
     _main.InputMap.Put(new KeyStroke(ConsoleKey.PageDown, null, null, null), ScfeActions.GoDownFast);
     _main.InputMap.Put(new KeyStroke(ConsoleKey.PageUp, null, null, null), ScfeActions.GoUpFast);
     _main.InputMap.Put(new KeyStroke(ConsoleKey.F10, null, null, null), "RESETALL");
     _main.ActionMap.Put("RESETALL", (o, args) =>
     {
         _cons.Validate();
         var old = _cons.ClearAreaBeforePrint;
         _cons.ClearAreaBeforePrint = true;
         _cons.Print(args.Graphics);
         _cons.ClearAreaBeforePrint = old;
     });
 }