Unicode.cs 3.9 KB

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