private void InitMenu() { var menuStack = layout.Add(new StackPanel() { Orientation = Orientation.Vertical }, 0, 0); menuStack.Add(new Label() { Text = "Samples Menu".ToYellow(underlined: true) }); menuStack.Add(new Label() { Text = ConsoleString.Empty }); var overviewButton = menuStack.Add(new Button() { Tag = MenuTag, Shortcut = new KeyboardShortcut(ConsoleKey.O, null), Text = "Overview".ToWhite() }); SetupMenuItem(overviewButton, () => { var panel = new ConsolePanel(); var label = panel.Add(new Label() { Text = "Welcome to the PowerArgs sample app.".ToGreen() }).CenterBoth(); return(panel); }); var calculatorButton = menuStack.Add(new Button() { Tag = MenuTag, Shortcut = new KeyboardShortcut(ConsoleKey.C, null), Text = "Calculator program".ToWhite() }); SetupMenuItem(calculatorButton, () => { var panel = new ConsolePanel(); var console = panel.Add(new SampleConsole(() => new CommandLineArgumentsDefinition(typeof(CalculatorProgram)))).Fill(); return(panel); }); var args = new PerfTestArgs() { Test = TestCase.FallingChars }; var perfButton = menuStack.Add(new Button() { Tag = MenuTag, Shortcut = new KeyboardShortcut(ConsoleKey.P, null), Text = "Perf Test".ToWhite() }); SetupMenuItem(perfButton, () => { var panel = new StackPanel() { Height = 3, Orientation = Orientation.Vertical }; panel.Add(new Form(FormOptions.FromObject(args)) { Height = 2 }).FillHorizontally(); var runButton = panel.Add(new Button() { Text = "Run".ToWhite(), Shortcut = new KeyboardShortcut(ConsoleKey.R) }); runButton.Pressed.SubscribeOnce(() => { panel.Controls.Clear(); var console = panel.Add(new PerfTest(args)).Fill(); }); QueueAction(() => panel.Descendents.Where(d => d.CanFocus).FirstOrDefault()?.TryFocus()); return(panel); }); var colorArgs = new ColorTestArgs { From = ConsoleColor.Black, To = ConsoleColor.Green, Mode = ConsoleMode.VirtualTerminal }; var colorButton = menuStack.Add(new Button() { Tag = MenuTag, Shortcut = new KeyboardShortcut(ConsoleKey.R, null), Text = "RGB Test".ToWhite() }); SetupMenuItem(colorButton, () => { var panel = new ConsolePanel() { Height = 4 }; panel.Add(new Form(FormOptions.FromObject(colorArgs)) { Height = 3 }).FillHorizontally(); var runButton = panel.Add(new Button() { Y = 3, Text = "Run".ToWhite(), Shortcut = new KeyboardShortcut(ConsoleKey.R) }); runButton.Pressed.SubscribeOnce(() => { panel.Controls.Clear(); if (colorArgs.Mode == ConsoleMode.VirtualTerminal) { ConsoleProvider.Fancy = true; } if (colorArgs.Mode == ConsoleMode.Console) { ConsoleProvider.Fancy = false; } var toColor = panel.Add(new ConsolePanel() { Width = 20, Height = 3, Background = colorArgs.From }).CenterBoth(); var label = toColor.Add(new Label() { Text = toColor.Background.ToRGBString().ToWhite(toColor.Background, underlined: true) }).CenterBoth(); RGB.AnimateAsync(new RGBAnimationOptions() { Transitions = new System.Collections.Generic.List <System.Collections.Generic.KeyValuePair <RGB, RGB> >() { new System.Collections.Generic.KeyValuePair <RGB, RGB>(colorArgs.From, colorArgs.To), } , Duration = 1500, EasingFunction = Animator.EaseInOut, AutoReverse = true, Loop = this, AutoReverseDelay = 500, OnColorsChanged = (c) => { toColor.Background = c[0]; label.Text = toColor.Background.ToRGBString().ToWhite(toColor.Background, underlined: true); } }); }); QueueAction(() => panel.Descendents.Where(d => d.CanFocus).FirstOrDefault()?.TryFocus()); return(panel); }); overviewButton.Pressed.Fire(); }