Generic.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Terminal.Gui;
  2. namespace UICatalog.Scenarios {
  3. [ScenarioMetadata (Name: "Generic", Description: "Generic sample - A template for creating new Scenarios")]
  4. [ScenarioCategory ("Controls")]
  5. public class MyScenario : Scenario {
  6. public override void Init ()
  7. {
  8. // The base `Scenario.Init` implementation:
  9. // - Calls `Application.Init ()`
  10. // - Adds a full-screen Window to Application.Top with a title
  11. // that reads "Press <hotkey> to Quit". Access this Window with `this.Win`.
  12. // - Sets the Theme & the ColorScheme property of `this.Win` to `colorScheme`.
  13. // To override this, implement an override of `Init`.
  14. //base.Init ();
  15. // A common, alternate, implementation where `this.Win` is not used is below. This code
  16. // leverages ConfigurationManager to borrow the color scheme settings from UICatalog:
  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`. Example:
  28. var button = new Button ("Press me!") {
  29. AutoSize = false,
  30. X = Pos.Center (),
  31. Y = Pos.Center (),
  32. };
  33. Application.Top.Add (button);
  34. }
  35. }
  36. }