LineViewExample.cs 2.3 KB

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