コード例 #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);
 }