Generic.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Data;
  2. using Terminal.Gui;
  3. namespace UICatalog.Scenarios {
  4. [ScenarioMetadata (Name: "Generic", Description: "Generic sample - A template for creating new Scenarios")]
  5. [ScenarioCategory ("Controls")]
  6. public class MyScenario : Scenario {
  7. public override void Init (ColorScheme colorScheme)
  8. {
  9. // The base `Scenario.Init` implementation:
  10. // - Calls `Application.Init ()`
  11. // - Adds a full-screen Window to Application.Top with a title
  12. // that reads "Press <hotkey> to Quit". Access this Window with `this.Win`.
  13. // - Sets the ColorScheme property of `this.Win` to `colorScheme`.
  14. // To overrride this, implement an override of `Init`.
  15. base.Init (colorScheme);
  16. // A common, alternate, implementation where `this.Win` is not used:
  17. // Application.Init ();
  18. // Application.Top.ColorScheme = colorScheme;
  19. }
  20. public override void Setup ()
  21. {
  22. // Put scenario code here (in a real app, this would be the code
  23. // that would setup the app before `Application.Run` is called`).
  24. // With a Scenario, after UI Catalog calls `Scenario.Setup` it calls
  25. // `Scenario.Run` which calls `Application.Run`.
  26. // Example:
  27. var button = new Button ("Press me!") {
  28. AutoSize = false,
  29. X = Pos.Center (),
  30. Y = Pos.Center (),
  31. };
  32. button.Clicked += () => MessageBox.Query (20, 7, "Hi", "Neat?", "Yes", "No");
  33. Win.Add (button);
  34. }
  35. }
  36. }