LineViewExample.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Globalization;
  2. using System.Text;
  3. using Terminal.Gui;
  4. namespace UICatalog.Scenarios;
  5. [ScenarioMetadata ("Line View", "Demonstrates drawing lines using the LineView control.")]
  6. [ScenarioCategory ("Controls")]
  7. [ScenarioCategory ("LineView")]
  8. [ScenarioCategory ("Adornments")]
  9. public class LineViewExample : Scenario
  10. {
  11. public override void Main ()
  12. {
  13. Application.Init ();
  14. var appWindow = new Window()
  15. {
  16. Title = GetQuitKeyAndName (),
  17. };
  18. appWindow.Add (new Label { Y = 1, Text = "Regular Line" });
  19. // creates a horizontal line
  20. var line = new LineView { Y = 2 };
  21. appWindow.Add (line);
  22. appWindow.Add (new Label { Y = 3, Text = "Double Width Line" });
  23. // creates a horizontal line
  24. var doubleLine = new LineView { Y = 4, LineRune = (Rune)'\u2550' };
  25. appWindow.Add (doubleLine);
  26. appWindow.Add (new Label { Y = 5, Text = "Short Line" });
  27. // creates a horizontal line
  28. var shortLine = new LineView { Y = 5, Width = 10 };
  29. appWindow.Add (shortLine);
  30. appWindow.Add (new Label { Y = 7, Text = "Arrow Line" });
  31. // creates a horizontal line
  32. var arrowLine = new LineView
  33. {
  34. Y = 8, Width = 10, StartingAnchor = CM.Glyphs.LeftTee, EndingAnchor = (Rune)'>'
  35. };
  36. appWindow.Add (arrowLine);
  37. appWindow.Add (new Label { Y = 10, X = 11, Text = "Vertical Line" });
  38. // creates a horizontal line
  39. var verticalLine = new LineView (Orientation.Vertical) { X = 25 };
  40. appWindow.Add (verticalLine);
  41. appWindow.Add (new Label { Y = 12, X = 28, Text = "Vertical Arrow" });
  42. // creates a horizontal line
  43. var verticalArrow = new LineView (Orientation.Vertical)
  44. {
  45. X = 27, StartingAnchor = CM.Glyphs.TopTee, EndingAnchor = (Rune)'V'
  46. };
  47. appWindow.Add (verticalArrow);
  48. // Run - Start the application.
  49. Application.Run (appWindow);
  50. appWindow.Dispose ();
  51. // Shutdown - Calling Application.Shutdown is required.
  52. Application.Shutdown ();
  53. }
  54. }