Unicode.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 () {
  37. X = 15,
  38. Y = Pos.Y (label),
  39. Width = Dim.Percent (50),
  40. ColorScheme = Colors.Error
  41. };
  42. comboBox.SetSource (new List<string> () { "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить" });
  43. Win.Add (comboBox);
  44. comboBox.Text = " ~  s  gui.cs   master ↑10";
  45. label = new Label ("HexView:") { X = Pos.X (label), Y = Pos.Bottom (label) + 2 };
  46. Win.Add (label);
  47. var hexView = new HexView (new System.IO.MemoryStream (Encoding.ASCII.GetBytes (" ~  s  gui.cs   master ↑10 Со_хранить"))) {
  48. X = 15,
  49. Y = Pos.Y (label),
  50. Width = Dim.Percent (60),
  51. Height = 5
  52. };
  53. Win.Add (hexView);
  54. label = new Label ("ListView:") { X = Pos.X (label), Y = Pos.Bottom (hexView) + 1 };
  55. Win.Add (label);
  56. var listView = new ListView (new List<string> () { "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить" }) {
  57. X = 15,
  58. Y = Pos.Y (label),
  59. Width = Dim.Percent (60),
  60. Height = 3,
  61. ColorScheme = Colors.Menu
  62. };
  63. Win.Add (listView);
  64. label = new Label ("RadioGroup:") { X = Pos.X (label), Y = Pos.Bottom (listView) + 1 };
  65. Win.Add (label);
  66. var radioGroup = new RadioGroup (new [] { "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить" }, selected: 0) {
  67. X = 15,
  68. Y = Pos.Y (label),
  69. Width = Dim.Percent (60),
  70. ColorScheme = Colors.Menu
  71. };
  72. Win.Add (radioGroup);
  73. label = new Label ("TextField:") { X = Pos.X (label), Y = Pos.Bottom (radioGroup) + 1 };
  74. Win.Add (label);
  75. var textField = new TextField (" ~  s  gui.cs   master ↑10 = Со_хранить") { X = 15, Y = Pos.Y (label), Width = Dim.Percent (60) };
  76. Win.Add (textField);
  77. label = new Label ("TextView:") { X = Pos.X (label), Y = Pos.Bottom (textField) + 1 };
  78. Win.Add (label);
  79. var textView = new TextView () {
  80. X = 15,
  81. Y = Pos.Y (label),
  82. Width = Dim.Percent (60),
  83. Height = 3,
  84. ColorScheme = Colors.Menu,
  85. Text = " ~  s  gui.cs   master ↑10\nСо_хранить",
  86. };
  87. Win.Add (textView);
  88. //label = new Label ("Charset:") {
  89. // X = Pos.Percent(75) + 1,
  90. // Y = 0,
  91. //};
  92. //Win.Add (label);
  93. //var charset = new Label ("") {
  94. // X = Pos.Percent(75) + 1,
  95. // Y = Pos.Y (label) + 1,
  96. // Width = Dim.Fill (1),
  97. // Height = Dim.Fill (),
  98. // ColorScheme = Colors.Dialog
  99. //};
  100. //Win.Add (charset);
  101. // Move Win down to row 1, below menu
  102. Win.Y = 1;
  103. Top.LayoutSubviews ();
  104. }
  105. }
  106. }