ViewExperiments.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Terminal.Gui;
  2. namespace UICatalog.Scenarios;
  3. [ScenarioMetadata ("View Experiments", "v2 View Experiments")]
  4. [ScenarioCategory ("Controls")]
  5. [ScenarioCategory ("Borders")]
  6. [ScenarioCategory ("Layout")]
  7. [ScenarioCategory ("Proof of Concept")]
  8. public class ViewExperiments : Scenario
  9. {
  10. public override void Main ()
  11. {
  12. Application.Init ();
  13. Window app = new ()
  14. {
  15. Title = GetQuitKeyAndName ()
  16. };
  17. var view = new View
  18. {
  19. X = 2,
  20. Y = 2,
  21. Height = Dim.Auto (),
  22. Width = Dim.Auto (),
  23. Title = "View1",
  24. ColorScheme = Colors.ColorSchemes ["Base"],
  25. Id = "View1",
  26. ShadowStyle = ShadowStyle.Transparent,
  27. BorderStyle = LineStyle.Double,
  28. CanFocus = true, // Can't drag without this? BUGBUG
  29. Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped
  30. };
  31. Button button = new ()
  32. {
  33. Title = "Button_1",
  34. };
  35. view.Add (button);
  36. button = new ()
  37. {
  38. Y = Pos.Bottom (button),
  39. Title = "Button_2",
  40. };
  41. view.Add (button);
  42. //app.Add (view);
  43. view.BorderStyle = LineStyle.Double;
  44. var view2 = new View
  45. {
  46. X = Pos.Right (view),
  47. Y = Pos.Bottom (view),
  48. Height = Dim.Auto (),
  49. Width = Dim.Auto (),
  50. Title = "View2",
  51. ColorScheme = Colors.ColorSchemes ["Base"],
  52. Id = "View2",
  53. ShadowStyle = ShadowStyle.Transparent,
  54. BorderStyle = LineStyle.Double,
  55. CanFocus = true, // Can't drag without this? BUGBUG
  56. Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped
  57. };
  58. button = new ()
  59. {
  60. Title = "Button_3",
  61. };
  62. view2.Add (button);
  63. button = new ()
  64. {
  65. Y = Pos.Bottom (button),
  66. Title = "Button_4",
  67. };
  68. view2.Add (button);
  69. view2.Add (button);
  70. var editor = new AdornmentsEditor
  71. {
  72. X = 0,
  73. Y = 0,
  74. AutoSelectViewToEdit = true
  75. };
  76. app.Add (editor);
  77. button = new ()
  78. {
  79. Y = 0,
  80. X = Pos.X (view),
  81. Title = "Button_0",
  82. };
  83. app.Add (button);
  84. button = new ()
  85. {
  86. X = Pos.AnchorEnd (),
  87. Y = Pos.AnchorEnd (),
  88. Title = "Button_5",
  89. };
  90. view.X = 34;
  91. view.Y = 4;
  92. app.Add (view);
  93. app.Add (view2);
  94. app.Add (button);
  95. Application.Run (app);
  96. app.Dispose ();
  97. Application.Shutdown ();
  98. }
  99. }