Generic.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Terminal.Gui;
  2. namespace UICatalog.Scenarios;
  3. [ScenarioMetadata ("Generic", "Generic sample - A template for creating new Scenarios")]
  4. [ScenarioCategory ("Controls")]
  5. public class MyScenario : Scenario
  6. {
  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 is below. This code
  17. // leverages ConfigurationManager to borrow the color scheme settings from UICatalog:
  18. Application.Init ();
  19. ConfigurationManager.Themes.Theme = Theme;
  20. ConfigurationManager.Apply ();
  21. Top = new Toplevel ();
  22. Top.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
  23. }
  24. public override void Setup ()
  25. {
  26. // Put scenario code here (in a real app, this would be the code
  27. // that would setup the app before `Application.Run` is called`).
  28. // With a Scenario, after UI Catalog calls `Scenario.Setup` it calls
  29. // `Scenario.Run` which calls `Application.Run`. Example:
  30. var button = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "Press me!" };
  31. Top.Add (button);
  32. }
  33. }