LineViewExample.cs 2.1 KB

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