Generic.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 ()
  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 Theme & the ColorScheme property of `this.Win` to `colorScheme`.
  14. // To override this, implement an override of `Init`.
  15. base.Init ();
  16. // A common, alternate, implementation where `this.Win` is not used:
  17. //Application.Init ();
  18. //ConfigurationManager.Themes.Theme = Theme;
  19. //ConfigurationManager.Apply ();
  20. //Application.Top.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
  21. }
  22. public override void Setup ()
  23. {
  24. // Put scenario code here (in a real app, this would be the code
  25. // that would setup the app before `Application.Run` is called`).
  26. // With a Scenario, after UI Catalog calls `Scenario.Setup` it calls
  27. // `Scenario.Run` which calls `Application.Run`.
  28. // Example:
  29. var button = new Button ("Press me!") {
  30. AutoSize = false,
  31. X = Pos.Center (),
  32. Y = Pos.Center (),
  33. };
  34. button.Clicked += () => MessageBox.Query (20, 7, "Hi", "Neat?", "Yes", "No");
  35. Win.Add (button);
  36. }
  37. }
  38. }