Generic.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using NStack;
  2. using System;
  3. using System.Reflection.Emit;
  4. using Terminal.Gui;
  5. using Terminal.Gui.Configuration;
  6. using Label = Terminal.Gui.Label;
  7. namespace UICatalog.Scenarios {
  8. [ScenarioMetadata (Name: "Generic", Description: "Generic sample - A template for creating new Scenarios")]
  9. [ScenarioCategory ("Controls")]
  10. public class MyScenario : Scenario {
  11. public override void Init ()
  12. {
  13. // The base `Scenario.Init` implementation:
  14. // - Calls `Application.Init ()`
  15. // - Adds a full-screen Window to Application.Top with a title
  16. // that reads "Press <hotkey> to Quit". Access this Window with `this.Win`.
  17. // - Sets the Theme & the ColorScheme property of `this.Win` to `colorScheme`.
  18. // To override this, implement an override of `Init`.
  19. //base.Init ();
  20. // A common, alternate, implementation where `this.Win` is not used is below. This code
  21. // leverages ConfigurationManager to borrow the color scheme settings from UICatalog:
  22. Application.Init ();
  23. ConfigurationManager.Themes.Theme = Theme;
  24. ConfigurationManager.Apply ();
  25. Application.Top.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
  26. }
  27. public override void Setup ()
  28. {
  29. // Put scenario code here (in a real app, this would be the code
  30. // that would setup the app before `Application.Run` is called`).
  31. // With a Scenario, after UI Catalog calls `Scenario.Setup` it calls
  32. // `Scenario.Run` which calls `Application.Run`. Example:
  33. var button = new Button ("Press me!") {
  34. AutoSize = false,
  35. X = Pos.Center (),
  36. Y = Pos.Center (),
  37. };
  38. Application.Top.Add (button);
  39. }
  40. }
  41. }