Generic.cs 940 B

123456789101112131415161718192021222324252627282930313233
  1. #nullable enable
  2. using Terminal.Gui;
  3. namespace UICatalog.Scenarios;
  4. [ScenarioMetadata ("Generic", "Generic sample - A template for creating new Scenarios")]
  5. [ScenarioCategory ("Controls")]
  6. public sealed class Generic : Scenario
  7. {
  8. public override void Main ()
  9. {
  10. // Init
  11. Application.Init ();
  12. // Setup - Create a top-level application window and configure it.
  13. Window appWindow = new ()
  14. {
  15. Title = GetQuitKeyAndName (),
  16. };
  17. var button = new Button { Id = "button", X = Pos.Center (), Y = 1, Text = "_Press me!" };
  18. button.Accepting += (s, e) => MessageBox.ErrorQuery ("Error", "You pressed the button!", "_Ok");
  19. appWindow.Add (button);
  20. // Run - Start the application.
  21. Application.Run (appWindow);
  22. appWindow.Dispose ();
  23. // Shutdown - Calling Application.Shutdown is required.
  24. Application.Shutdown ();
  25. }
  26. }