123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using Terminal.Gui;
- namespace UICatalog.Scenarios;
- [ScenarioMetadata ("HotKeys", "Demonstrates how HotKeys work.")]
- [ScenarioCategory ("Controls")]
- [ScenarioCategory ("Mouse and Keyboard")]
- public class HotKeys : Scenario
- {
- public override void Main ()
- {
- Application.Init ();
- Window app = new ()
- {
- Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}"
- };
- var textViewLabel = new Label { Text = "_TextView:", X = 0, Y = 0 };
- app.Add (textViewLabel);
- var textField = new TextField { X = Pos.Right (textViewLabel) + 1, Y = 0, Width = 10 };
- app.Add (textField);
- var viewLabel = new Label { Text = "_View:", X = 0, Y = Pos.Bottom (textField) + 1 };
- app.Add (viewLabel);
- var view = new View
- {
- Title = "View (_focusable)",
- Text = "Text renders _Underscore",
- CanFocus = true,
- X = Pos.Right (viewLabel) + 1, Y = Pos.Top (viewLabel), Width = 30, Height = 3,
- BorderStyle = LineStyle.Dashed
- };
- app.Add (view);
- viewLabel = new() { Text = "Vi_ew:", X = 0, Y = Pos.Bottom (view) + 1 };
- app.Add (viewLabel);
- view = new()
- {
- Title = "View (n_ot focusable)",
- Text = "Text renders _Underscore",
- X = Pos.Right (viewLabel) + 1, Y = Pos.Top (viewLabel), Width = 30, Height = 3,
- BorderStyle = LineStyle.Dashed
- };
- app.Add (view);
- var labelWithFrameLabel = new Label { Text = "_Label with Frame:", X = 0, Y = Pos.Bottom (view) + 1 };
- app.Add (labelWithFrameLabel);
- var labelWithFrameFocusable = new Label
- {
- AutoSize = false,
- Title = "Label _with Frame (focusable)",
- CanFocus = true,
- X = Pos.Right (labelWithFrameLabel) + 1, Y = Pos.Top (labelWithFrameLabel), Width = 40, Height = 3,
- BorderStyle = LineStyle.Dashed
- };
- app.Add (labelWithFrameFocusable);
- labelWithFrameLabel = new() { Text = "L_abel with Frame:", X = 0, Y = Pos.Bottom (labelWithFrameFocusable) + 1 };
- app.Add (labelWithFrameLabel);
- var labelWithFrame = new Label
- {
- AutoSize = false,
- Title = "Label with Frame (_not focusable)",
- X = Pos.Right (labelWithFrameLabel) + 1, Y = Pos.Top (labelWithFrameLabel), Width = 40, Height = 3,
- BorderStyle = LineStyle.Dashed
- };
- app.Add (labelWithFrame);
- var buttonWithFrameLabel = new Label { Text = "_Button with Frame:", X = 0, Y = Pos.Bottom (labelWithFrame) + 1 };
- app.Add (buttonWithFrameLabel);
- var buttonWithFrameFocusable = new Button
- {
- AutoSize = false,
- Title = "B_utton with Frame (focusable)",
- CanFocus = true,
- X = Pos.Right (buttonWithFrameLabel) + 1, Y = Pos.Top (buttonWithFrameLabel), Width = 40, Height = 3,
- BorderStyle = LineStyle.Dashed
- };
- app.Add (buttonWithFrameFocusable);
- buttonWithFrameLabel = new() { Text = "Butt_on with Frame:", X = 0, Y = Pos.Bottom (buttonWithFrameFocusable) + 1 };
- app.Add (buttonWithFrameLabel);
- var buttonWithFrame = new Button
- {
- AutoSize = false,
- Title = "Button with Frame (not focusab_le)",
- X = Pos.Right (buttonWithFrameLabel) + 1, Y = Pos.Top (buttonWithFrameLabel), Width = 40, Height = 3,
- CanFocus = false,
- BorderStyle = LineStyle.Dashed
- };
- app.Add (buttonWithFrame);
- var checkboxWithFrameLabel = new Label { Text = "_Checkbox with Frame:", X = 0, Y = Pos.Bottom (buttonWithFrame) + 1 };
- app.Add (checkboxWithFrameLabel);
- var checkboxWithFrameFocusable = new CheckBox
- {
- AutoSize = false,
- Title = "C_heckbox with Frame (focusable)",
- CanFocus = true,
- X = Pos.Right (checkboxWithFrameLabel) + 1, Y = Pos.Top (checkboxWithFrameLabel), Width = 40, Height = 3,
- BorderStyle = LineStyle.Dashed
- };
- app.Add (checkboxWithFrameFocusable);
- checkboxWithFrameLabel = new() { Text = "Checkb_ox with Frame:", X = 0, Y = Pos.Bottom (checkboxWithFrameFocusable) + 1 };
- app.Add (checkboxWithFrameLabel);
- var checkboxWithFrame = new CheckBox
- {
- AutoSize = false,
- Title = "Checkbox with Frame (not focusable)",
- X = Pos.Right (checkboxWithFrameLabel) + 1, Y = Pos.Top (checkboxWithFrameLabel), Width = 40, Height = 3,
- CanFocus = false,
- BorderStyle = LineStyle.Dashed
- };
- app.Add (checkboxWithFrame);
- var button = new Button { X = Pos.Center (), Y = Pos.AnchorEnd (), Text = "_Press me!" };
- app.Add (button);
- Application.Run (app);
- app.Dispose ();
- }
- }
|