ChineseUI.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 
  2. namespace UICatalog.Scenarios;
  3. [ScenarioMetadata ("ChineseUI", "Chinese UI")]
  4. [ScenarioCategory ("Text and Formatting")]
  5. public class ChineseUI : Scenario
  6. {
  7. public override void Main ()
  8. {
  9. Application.Init ();
  10. var win = new Window
  11. {
  12. Title = GetQuitKeyAndName (),
  13. X = 0,
  14. Y = 0,
  15. Width = Dim.Fill (),
  16. Height = Dim.Fill ()
  17. };
  18. var buttonPanel = new FrameView
  19. {
  20. Title = "Command",
  21. X = 0,
  22. Y = 1,
  23. Width = Dim.Fill (),
  24. Height = 5
  25. };
  26. win.Add (buttonPanel);
  27. var btn = new Button { X = 1, Y = 1, Text = "你" }; // v1: A
  28. btn.Accepting += (s, e) =>
  29. {
  30. int? result = MessageBox.Query (
  31. (s as View)?.App,
  32. "Confirm",
  33. "Are you sure you want to quit ui?",
  34. 0,
  35. "Yes",
  36. "No"
  37. );
  38. if (result == 0)
  39. {
  40. Application.RequestStop ();
  41. }
  42. };
  43. buttonPanel.Add (
  44. btn,
  45. new Button { X = 12, Y = 1, Text = "好" }, // v1: B
  46. new Button { X = 22, Y = 1, Text = "呀" } // v1: C
  47. );
  48. Application.Run (win);
  49. win.Dispose ();
  50. Application.Shutdown ();
  51. }
  52. }