Unicode.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using NStack;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Terminal.Gui;
  5. namespace UICatalog {
  6. [ScenarioMetadata (Name: "Unicode", Description: "Tries to test Unicode in all controls (#204)")]
  7. [ScenarioCategory ("Text")]
  8. [ScenarioCategory ("Controls")]
  9. class UnicodeInMenu : Scenario {
  10. public override void Setup ()
  11. {
  12. //string text = "Hello world, how are you today? Pretty neat!\nSecond line\n\nFourth Line.";
  13. string unicode = "Τὴ γλῶσσα μοῦ ἔδωσαν ἑλληνικὴ\nτὸ σπίτι φτωχικὸ στὶς ἀμμουδιὲς τοῦ Ὁμήρου.\nΜονάχη ἔγνοια ἡ γλῶσσα μου στὶς ἀμμουδιὲς τοῦ Ὁμήρου.";
  14. var menu = new MenuBar (new MenuBarItem [] {
  15. new MenuBarItem ("_Файл", new MenuItem [] {
  16. new MenuItem ("_Создать", "Creates new file", null),
  17. new MenuItem ("_Открыть", "", null),
  18. new MenuItem ("Со_хранить", "", null),
  19. new MenuItem ("_Выход", "", () => Application.RequestStop() )
  20. }),
  21. new MenuBarItem ("_Edit", new MenuItem [] {
  22. new MenuItem ("_Copy", "", null),
  23. new MenuItem ("C_ut", "", null),
  24. new MenuItem ("_Paste", "", null)
  25. })
  26. });
  27. Top.Add (menu);
  28. var label = new Label ("Label:") { X = 0, Y = 1 };
  29. Win.Add (label);
  30. var testlabel = new Label ("Стоял _он, дум великих полн") { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50), };
  31. Win.Add (testlabel);
  32. label = new Label ("Label (CanFocus):") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
  33. Win.Add (label);
  34. testlabel = new Label ("Стоял &он, дум великих полн") { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50), CanFocus = true, HotKeySpecifier = new System.Rune('&') };
  35. Win.Add (testlabel);
  36. label = new Label ("Button:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
  37. Win.Add (label);
  38. var button = new Button ("A123456789♥♦♣♠JQK") { X = 20, Y = Pos.Y (label) };
  39. Win.Add (button);
  40. label = new Label ("CheckBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
  41. Win.Add (label);
  42. var checkBox = new CheckBox (" ~  s  gui.cs   master ↑10") { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50) };
  43. Win.Add (checkBox);
  44. label = new Label ("ComboBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
  45. Win.Add (label);
  46. var comboBox = new ComboBox () {
  47. X = 20,
  48. Y = Pos.Y (label),
  49. Width = Dim.Percent (50),
  50. };
  51. comboBox.SetSource (new List<string> () { "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить" });
  52. Win.Add (comboBox);
  53. comboBox.Text = " ~  s  gui.cs   master ↑10";
  54. label = new Label ("HexView:") { X = Pos.X (label), Y = Pos.Bottom (label) + 2 };
  55. Win.Add (label);
  56. var hexView = new HexView (new System.IO.MemoryStream (Encoding.ASCII.GetBytes (" ~  s  gui.cs   master ↑10 Со_хранить"))) {
  57. X = 20,
  58. Y = Pos.Y (label),
  59. Width = Dim.Percent (60),
  60. Height = 5
  61. };
  62. Win.Add (hexView);
  63. label = new Label ("ListView:") { X = Pos.X (label), Y = Pos.Bottom (hexView) + 1 };
  64. Win.Add (label);
  65. var listView = new ListView (new List<string> () { "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить", unicode }) {
  66. X = 20,
  67. Y = Pos.Y (label),
  68. Width = Dim.Percent (60),
  69. Height = 3,
  70. };
  71. Win.Add (listView);
  72. label = new Label ("RadioGroup:") { X = Pos.X (label), Y = Pos.Bottom (listView) + 1 };
  73. Win.Add (label);
  74. var radioGroup = new RadioGroup (new ustring [] { "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить" }, selected: 0) {
  75. X = 20,
  76. Y = Pos.Y (label),
  77. Width = Dim.Percent (60),
  78. };
  79. Win.Add (radioGroup);
  80. label = new Label ("TextField:") { X = Pos.X (label), Y = Pos.Bottom (radioGroup) + 1 };
  81. Win.Add (label);
  82. var textField = new TextField (" ~  s  gui.cs   master ↑10 = Со_хранить") { X = 20, Y = Pos.Y (label), Width = Dim.Percent (60) };
  83. Win.Add (textField);
  84. label = new Label ("TextView:") { X = Pos.X (label), Y = Pos.Bottom (textField) + 1 };
  85. Win.Add (label);
  86. var textView = new TextView () {
  87. X = 20,
  88. Y = Pos.Y (label),
  89. Width = Dim.Percent (60),
  90. Height = 5,
  91. Text = unicode,
  92. };
  93. Win.Add (textView);
  94. // Move Win down to row 1, below menu
  95. Win.Y = 1;
  96. Top.LayoutSubviews ();
  97. }
  98. }
  99. }