1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System.Text;
- using Terminal.Gui;
- namespace UICatalog.Scenarios;
- [ScenarioMetadata ("Line View", "Demonstrates drawing lines using the LineView control.")]
- [ScenarioCategory ("Controls")]
- [ScenarioCategory ("LineView")]
- [ScenarioCategory ("Borders")]
- public class LineViewExample : Scenario
- {
- public override void Main ()
- {
- Application.Init ();
- // Setup - Create a top-level application window and configure it.
- Toplevel appWindow = new ();
- var menu = new MenuBar
- {
- Menus =
- [
- new ("_File", new MenuItem [] { new ("_Quit", "", () => Quit ()) })
- ]
- };
- appWindow.Add (menu);
- appWindow.Add (new Label { Y = 1, Text = "Regular Line" });
- // creates a horizontal line
- var line = new LineView { Y = 2 };
- appWindow.Add (line);
- appWindow.Add (new Label { Y = 3, Text = "Double Width Line" });
- // creates a horizontal line
- var doubleLine = new LineView { Y = 4, LineRune = (Rune)'\u2550' };
- appWindow.Add (doubleLine);
- appWindow.Add (new Label { Y = 5, Text = "Short Line" });
- // creates a horizontal line
- var shortLine = new LineView { Y = 5, Width = 10 };
- appWindow.Add (shortLine);
- appWindow.Add (new Label { Y = 7, Text = "Arrow Line" });
- // creates a horizontal line
- var arrowLine = new LineView
- {
- Y = 8, Width = 10, StartingAnchor = CM.Glyphs.LeftTee, EndingAnchor = (Rune)'>'
- };
- appWindow.Add (arrowLine);
- appWindow.Add (new Label { Y = 10, X = 11, Text = "Vertical Line" });
- // creates a horizontal line
- var verticalLine = new LineView (Orientation.Vertical) { X = 25 };
- appWindow.Add (verticalLine);
- appWindow.Add (new Label { Y = 12, X = 28, Text = "Vertical Arrow" });
- // creates a horizontal line
- var verticalArrow = new LineView (Orientation.Vertical)
- {
- X = 27, StartingAnchor = CM.Glyphs.TopTee, EndingAnchor = (Rune)'V'
- };
- appWindow.Add (verticalArrow);
- var statusBar = new StatusBar (
- new Shortcut []
- {
- new (Application.QuitKey, "Quit", Quit)
- }
- );
- appWindow.Add (statusBar);
- // Run - Start the application.
- Application.Run (appWindow);
- appWindow.Dispose ();
- // Shutdown - Calling Application.Shutdown is required.
- Application.Shutdown ();
- }
- private void Quit () { Application.RequestStop (); }
- }
|