Unicode.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. const int margin = 1;
  13. var menu = new MenuBar (new MenuBarItem [] {
  14. new MenuBarItem ("_Файл", new MenuItem [] {
  15. new MenuItem ("_Создать", "Creates new file", null),
  16. new MenuItem ("_Открыть", "", null),
  17. new MenuItem ("Со_хранить", "", null),
  18. new MenuItem ("_Выход", "", () => Application.RequestStop() )
  19. }),
  20. new MenuBarItem ("_Edit", new MenuItem [] {
  21. new MenuItem ("_Copy", "", null),
  22. new MenuItem ("C_ut", "", null),
  23. new MenuItem ("_Paste", "", null)
  24. })
  25. });
  26. Top.Add (menu);
  27. var label = new Label ("Button:") { X = margin, Y = margin };
  28. Win.Add (label);
  29. var button = new Button (" ~  s  gui.cs   master ↑10") { X = 15, Y = Pos.Y (label) };
  30. Win.Add (button);
  31. label = new Label ("Button:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
  32. Win.Add (label);
  33. var button2 = new Button ("Со_хранить") { X = 15, Y = Pos.Y (label), Width = Dim.Percent (50) };
  34. Win.Add (button2);
  35. label = new Label ("CheckBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
  36. Win.Add (label);
  37. var checkBox = new CheckBox (" ~  s  gui.cs   master ↑10") { X = 15, Y = Pos.Y (label), Width = Dim.Percent (50) };
  38. Win.Add (checkBox);
  39. label = new Label ("ComboBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
  40. Win.Add (label);
  41. var comboBox = new ComboBox (1, 1, 30, 5, new List<string> () { "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить" }) {
  42. X = 15,
  43. Y = Pos.Y (label),
  44. Width = 30,
  45. ColorScheme = Colors.Error
  46. };
  47. Win.Add (comboBox);
  48. comboBox.Text = " ~  s  gui.cs   master ↑10";
  49. label = new Label ("HexView:") { X = Pos.X (label), Y = Pos.Bottom (label) + 2 };
  50. Win.Add (label);
  51. var hexView = new HexView (new System.IO.MemoryStream (Encoding.ASCII.GetBytes (" ~  s  gui.cs   master ↑10 Со_хранить"))) {
  52. X = 15,
  53. Y = Pos.Y (label),
  54. Width = Dim.Percent (60),
  55. Height = 5
  56. };
  57. Win.Add (hexView);
  58. label = new Label ("ListView:") { X = Pos.X (label), Y = Pos.Bottom (hexView) + 1 };
  59. Win.Add (label);
  60. var listView = new ListView (new List<string> () { "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить" }) {
  61. X = 15,
  62. Y = Pos.Y (label),
  63. Width = Dim.Percent (60),
  64. Height = 3,
  65. ColorScheme = Colors.Menu
  66. };
  67. Win.Add (listView);
  68. label = new Label ("RadioGroup:") { X = Pos.X (label), Y = Pos.Bottom (listView) + 1 };
  69. Win.Add (label);
  70. var radioGroup = new RadioGroup (new [] { "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить" }, selected: 0) {
  71. X = 15,
  72. Y = Pos.Y (label),
  73. Width = Dim.Percent (60),
  74. ColorScheme = Colors.Menu
  75. };
  76. Win.Add (radioGroup);
  77. label = new Label ("TextField:") { X = Pos.X (label), Y = Pos.Bottom (radioGroup) + 1 };
  78. Win.Add (label);
  79. var textField = new TextField (" ~  s  gui.cs   master ↑10 = Со_хранить") { X = 15, Y = Pos.Y (label), Width = Dim.Percent (60) };
  80. Win.Add (textField);
  81. label = new Label ("TextView:") { X = Pos.X (label), Y = Pos.Bottom (textField) + 1 };
  82. Win.Add (label);
  83. var textView = new TextView () {
  84. X = 15,
  85. Y = Pos.Y (label),
  86. Width = Dim.Percent (60),
  87. Height = 3,
  88. ColorScheme = Colors.Menu,
  89. Text = " ~  s  gui.cs   master ↑10\nСо_хранить",
  90. };
  91. Win.Add (textView);
  92. //label = new Label ("Charset:") {
  93. // X = Pos.Percent(75) + 1,
  94. // Y = 0,
  95. //};
  96. //Win.Add (label);
  97. //var charset = new Label ("") {
  98. // X = Pos.Percent(75) + 1,
  99. // Y = Pos.Y (label) + 1,
  100. // Width = Dim.Fill (1),
  101. // Height = Dim.Fill (),
  102. // ColorScheme = Colors.Dialog
  103. //};
  104. //Win.Add (charset);
  105. // Move Win down to row 1, below menu
  106. Win.Y = 1;
  107. Top.LayoutSubviews ();
  108. }
  109. }
  110. }