SimpleDialog.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #nullable enable
  2. using Terminal.Gui;
  3. namespace UICatalog.Scenarios;
  4. [ScenarioMetadata ("SimpleDialog", "SimpleDialog ")]
  5. public sealed class SimpleDialog : Scenario
  6. {
  7. public override void Main ()
  8. {
  9. // Init
  10. Application.Init ();
  11. // Setup - Create a top-level application window and configure it.
  12. Window appWindow = new ()
  13. {
  14. Title = GetQuitKeyAndName (),
  15. BorderStyle = LineStyle.None
  16. };
  17. appWindow.DrawingText += (s, e) =>
  18. {
  19. appWindow!.FillRect (appWindow!.Viewport, Glyphs.Dot);
  20. e.Cancel = true;
  21. };
  22. Dialog dialog = new () { Id = "dialog", Width = 20, Height = 4, Title = "Dialog" };
  23. dialog.Arrangement |= ViewArrangement.Resizable;
  24. var button = new Button
  25. {
  26. Id = "button",
  27. X = 0,
  28. Y = 0,
  29. NoDecorations = true,
  30. NoPadding = true,
  31. Text = "A",
  32. //WantContinuousButtonPressed = false,
  33. HighlightStyle = HighlightStyle.None,
  34. ShadowStyle = ShadowStyle.Transparent,
  35. };
  36. button.Accepting += (s, e) =>
  37. {
  38. Application.Run (dialog);
  39. e.Cancel = true;
  40. };
  41. appWindow.Add (button);
  42. // Run - Start the application.
  43. Application.Run (appWindow);
  44. dialog.Dispose ();
  45. appWindow.Dispose ();
  46. // Shutdown - Calling Application.Shutdown is required.
  47. Application.Shutdown ();
  48. }
  49. }