Generic.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #nullable enable
  2. namespace UICatalog.Scenarios;
  3. [ScenarioMetadata ("Generic", "Generic sample - A template for creating new Scenarios")]
  4. [ScenarioCategory ("Controls")]
  5. public sealed class Generic : 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. BorderStyle = LineStyle.None
  16. };
  17. var button = new Button ()
  18. {
  19. X = Pos.Center (),
  20. Y = 1,
  21. Title = "_Button",
  22. };
  23. button.Accepting += (s, e) =>
  24. {
  25. // When Accepting is handled, set e.Handled to true to prevent further processing.
  26. e.Handled = true;
  27. MessageBox.ErrorQuery (Application.Instance, "Error", "You pressed the button!", "_Ok");
  28. };
  29. appWindow.Add (button);
  30. // Run - Start the application.
  31. Application.Run (appWindow);
  32. appWindow.Dispose ();
  33. // Shutdown - Calling Application.Shutdown is required.
  34. Application.Shutdown ();
  35. }
  36. }