2
0

LineViewExample.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Terminal.Gui;
  7. using Terminal.Gui.Views;
  8. using static UICatalog.Scenario;
  9. namespace UICatalog.Scenarios {
  10. [ScenarioMetadata (Name: "Line View", Description: "Demonstrates the LineView control")]
  11. [ScenarioCategory ("Controls"), ScenarioCategory ("Lines")]
  12. public class LineViewExample : Scenario {
  13. public override void Setup ()
  14. {
  15. Win.Title = this.GetName ();
  16. Win.Y = 1; // menu
  17. Win.Height = Dim.Fill (1); // status bar
  18. Top.LayoutSubviews ();
  19. var menu = new MenuBar (new MenuBarItem [] {
  20. new MenuBarItem ("_File", new MenuItem [] {
  21. new MenuItem ("_Quit", "", () => Quit()),
  22. })
  23. });
  24. Top.Add (menu);
  25. Win.Add (new Label ("Regular Line") { Y = 0 });
  26. // creates a horizontal line
  27. var line = new LineView () {
  28. Y = 1,
  29. };
  30. Win.Add (line);
  31. Win.Add (new Label ("Double Width Line") { Y = 2 });
  32. // creates a horizontal line
  33. var doubleLine = new LineView () {
  34. Y = 3,
  35. LineRune = '\u2550'
  36. };
  37. Win.Add (doubleLine);
  38. Win.Add (new Label ("Short Line") { Y = 4 });
  39. // creates a horizontal line
  40. var shortLine = new LineView () {
  41. Y = 5,
  42. Width = 10
  43. };
  44. Win.Add (shortLine);
  45. Win.Add (new Label ("Arrow Line") { Y = 6 });
  46. // creates a horizontal line
  47. var arrowLine = new LineView () {
  48. Y = 7,
  49. Width = 10,
  50. StartingAnchor = Application.Driver.LeftTee,
  51. EndingAnchor = '>'
  52. };
  53. Win.Add (arrowLine);
  54. Win.Add (new Label ("Vertical Line") { Y = 9,X=11 });
  55. // creates a horizontal line
  56. var verticalLine = new LineView (Terminal.Gui.Graphs.Orientation.Vertical) {
  57. X = 25,
  58. };
  59. Win.Add (verticalLine);
  60. Win.Add (new Label ("Vertical Arrow") { Y = 11, X = 28 });
  61. // creates a horizontal line
  62. var verticalArrow = new LineView (Terminal.Gui.Graphs.Orientation.Vertical) {
  63. X = 27,
  64. StartingAnchor = Application.Driver.TopTee,
  65. EndingAnchor = 'V'
  66. };
  67. Win.Add (verticalArrow);
  68. var statusBar = new StatusBar (new StatusItem [] {
  69. new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit())
  70. });
  71. Top.Add (statusBar);
  72. }
  73. private void Quit ()
  74. {
  75. Application.RequestStop ();
  76. }
  77. }
  78. }