Generic.cs 917 B

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