MessageBoxes.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Terminal.Gui;
  5. namespace UICatalog {
  6. [ScenarioMetadata (Name: "MessageBoxes", Description: "Demonstrates how to use MessageBoxes")]
  7. [ScenarioCategory ("Controls")]
  8. [ScenarioCategory ("Dialogs")]
  9. [ScenarioCategory ("Bug Repro")]
  10. class MessageBoxes : Scenario {
  11. public override void Setup ()
  12. {
  13. Top = new Toplevel ();
  14. var menu = new MenuBar (new MenuBarItem [] {
  15. new MenuBarItem ("_File", new MenuItem [] {
  16. new MenuItem ("_Quit", "", () => Application.RequestStop() )
  17. }),
  18. new MenuBarItem ("_Simple Query...", "A simple query message box", () => MessageBox.Query (0, 6, "MessageBox.Query", "Minimum size was specified", "Ok")),
  19. new MenuBarItem ("_Error Query...", "A error query message box", () => MessageBox.ErrorQuery (0, 6, "MessageBox.Query", "Minimum size was specified", "Ok")),
  20. // BUGBUG: Illustrates MessageBoxes do not deal with long text gracefully. Issue #432
  21. new MenuBarItem ("_Long Text...", "Demo long text", () => MessageBox.Query (0, 6, "About UI Catalog", "This is a very long title. It is longer than the width of the screen. Will it Wrap? I bet it will not wrap", "Ok")),
  22. });
  23. Top.Add (menu);
  24. Win = new Window ($"Scenario: {GetName ()}") {
  25. X = 0,
  26. Y = 1,
  27. Width = Dim.Fill (),
  28. Height = Dim.Fill ()
  29. };
  30. Top.Add (Win);
  31. }
  32. public override void Run ()
  33. {
  34. Application.Run (Top);
  35. }
  36. }
  37. }