Unicode.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. using System.Collections.ObjectModel;
  2. using System.IO;
  3. using System.Text;
  4. namespace UICatalog.Scenarios;
  5. [ScenarioMetadata ("Unicode", "Tries to test Unicode in all controls (#204)")]
  6. [ScenarioCategory ("Text and Formatting")]
  7. [ScenarioCategory ("Controls")]
  8. public class UnicodeInMenu : Scenario
  9. {
  10. public override void Main ()
  11. {
  12. var unicode =
  13. "Τὴ γλῶσσα μοῦ ἔδωσαν ἑλληνικὴ\nτὸ σπίτι φτωχικὸ στὶς ἀμμουδιὲς τοῦ Ὁμήρου.\nΜονάχη ἔγνοια ἡ γλῶσσα μου στὶς ἀμμουδιὲς τοῦ Ὁμήρου.";
  14. var gitString =
  15. $"gui.cs 糊 (hú) {
  16. Glyphs.IdenticalTo
  17. } {
  18. Glyphs.DownArrow
  19. }18 {
  20. Glyphs.UpArrow
  21. }10 {
  22. Glyphs.VerticalFourDots
  23. }1 {
  24. Glyphs.HorizontalEllipsis
  25. }";
  26. // Init
  27. Application.Init ();
  28. // Setup - Create a top-level application window and configure it.
  29. Window appWindow = new ()
  30. {
  31. Title = GetQuitKeyAndName ()
  32. };
  33. var menu = new MenuBar
  34. {
  35. Menus =
  36. [
  37. new (
  38. "_Файл",
  39. new MenuItem []
  40. {
  41. new (
  42. "_Создать",
  43. "Creates new file",
  44. null
  45. ),
  46. new ("_Открыть", "", null),
  47. new ("Со_хранить", "", null),
  48. new (
  49. "_Выход",
  50. "",
  51. () => Application.RequestStop ()
  52. )
  53. }
  54. ),
  55. new (
  56. "_Edit",
  57. new MenuItem []
  58. {
  59. new ("_Copy", "", null), new ("C_ut", "", null),
  60. new ("_糊", "hú (Paste)", null)
  61. }
  62. )
  63. ]
  64. };
  65. appWindow.Add (menu);
  66. var statusBar = new StatusBar (
  67. [
  68. new (
  69. Application.QuitKey,
  70. "Выход",
  71. () => Application.RequestStop ()
  72. ),
  73. new (Key.F2, "Создать", null),
  74. new (Key.F3, "Со_хранить", null)
  75. ]
  76. );
  77. appWindow.Add (statusBar);
  78. var label = new Label { X = 0, Y = 1, Text = "Label:" };
  79. appWindow.Add (label);
  80. var testlabel = new Label
  81. {
  82. X = 20,
  83. Y = Pos.Y (label),
  84. Width = Dim.Percent (50),
  85. Text = gitString
  86. };
  87. appWindow.Add (testlabel);
  88. label = new () { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "Label (CanFocus):" };
  89. appWindow.Add (label);
  90. var sb = new StringBuilder ();
  91. sb.Append ('e');
  92. sb.Append ('\u0301');
  93. sb.Append ('\u0301');
  94. testlabel = new ()
  95. {
  96. X = 20,
  97. Y = Pos.Y (label),
  98. Width = Dim.Percent (50),
  99. CanFocus = true,
  100. HotKeySpecifier = new ('&'),
  101. Text = $"Should be [e with two accents, but isn't due to #2616]: [{sb}]"
  102. };
  103. appWindow.Add (testlabel);
  104. label = new () { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "Button:" };
  105. appWindow.Add (label);
  106. var button = new Button { X = 20, Y = Pos.Y (label), Text = "A123456789♥♦♣♠JQK" };
  107. appWindow.Add (button);
  108. label = new () { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "CheckBox:" };
  109. appWindow.Add (label);
  110. var checkBox = new CheckBox
  111. {
  112. X = 20,
  113. Y = Pos.Y (label),
  114. Width = Dim.Percent (50),
  115. Height = 1,
  116. Text = gitString
  117. };
  118. var checkBoxRight = new CheckBox
  119. {
  120. X = 20,
  121. Y = Pos.Bottom (checkBox),
  122. Width = Dim.Percent (50),
  123. Height = 1,
  124. TextAlignment = Alignment.End,
  125. Text = $"End - {gitString}"
  126. };
  127. appWindow.Add (checkBox, checkBoxRight);
  128. //label = new () { X = Pos.X (label), Y = Pos.Bottom (checkBoxRight) + 1, Text = "ComboBox:" };
  129. //appWindow.Add (label);
  130. //var comboBox = new ComboBox { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50) };
  131. //comboBox.SetSource (new ObservableCollection<string> { gitString, "Со_хранить" });
  132. //appWindow.Add (comboBox);
  133. //comboBox.Text = gitString;
  134. label = new () { X = Pos.X (label), Y = Pos.Bottom (label) + 2, Text = "HexView:" };
  135. appWindow.Add (label);
  136. var hexView = new HexView (new MemoryStream (Encoding.ASCII.GetBytes (gitString + " Со_хранить")))
  137. {
  138. X = 20, Y = Pos.Y (label), Width = Dim.Percent (60), Height = 5
  139. };
  140. appWindow.Add (hexView);
  141. label = new () { X = Pos.X (label), Y = Pos.Bottom (hexView) + 1, Text = "ListView:" };
  142. appWindow.Add (label);
  143. var listView = new ListView
  144. {
  145. X = 20,
  146. Y = Pos.Y (label),
  147. Width = Dim.Percent (60),
  148. Height = 3,
  149. Source = new ListWrapper<string> (
  150. ["item #1", gitString, "Со_хранить", unicode]
  151. )
  152. };
  153. appWindow.Add (listView);
  154. label = new () { X = Pos.X (label), Y = Pos.Bottom (listView) + 1, Text = "RadioGroup:" };
  155. appWindow.Add (label);
  156. var radioGroup = new RadioGroup
  157. {
  158. X = 20,
  159. Y = Pos.Y (label),
  160. Width = Dim.Percent (60),
  161. RadioLabels = ["item #1", gitString, "Со_хранить", "𝔽𝕆𝕆𝔹𝔸ℝ"]
  162. };
  163. appWindow.Add (radioGroup);
  164. label = new () { X = Pos.X (label), Y = Pos.Bottom (radioGroup) + 1, Text = "TextField:" };
  165. appWindow.Add (label);
  166. var textField = new TextField
  167. {
  168. X = 20, Y = Pos.Y (label), Width = Dim.Percent (60), Text = gitString + " = Со_хранить"
  169. };
  170. appWindow.Add (textField);
  171. label = new () { X = Pos.X (label), Y = Pos.Bottom (textField) + 1, Text = "TextView:" };
  172. appWindow.Add (label);
  173. var textView = new TextView
  174. {
  175. X = 20,
  176. Y = Pos.Y (label),
  177. Width = Dim.Percent (60),
  178. Height = 5,
  179. Text = unicode
  180. };
  181. appWindow.Add (textView);
  182. // Run - Start the application.
  183. Application.Run (appWindow);
  184. appWindow.Dispose ();
  185. // Shutdown - Calling Application.Shutdown is required.
  186. Application.Shutdown ();
  187. }
  188. }