Files
Terminal.Gui/UICatalog/Scenarios/LineViewExample.cs
BDisp 713b2c4725 Fixes #92. Remove dependency on ustring. (#2620)
* Remove NStack and replace ustring to string.

* Add unit test and improving some code.

* Adjust code and fix all unit tests errors.

* Add XML Document and move the Rune folder into the Text folder.

* Improve unit tests with byte array on DecodeRune and DecodeLastRune.

* Fix unit test.

* 😂Code review

* Reduce unit tests code.

* Change StringExtensions.Make to StringExtensions.ToString and added some more unit tests.

* Fix merge errors.

* Remove GetTextWidth and calls replaced with StringExtensions.GetColumns.

* Hack to use UseSystemConsole passed in the command line arguments.

* Revert "Hack to use UseSystemConsole passed in the command line arguments."

This reverts commit b74d11c786.

* Remove Application.UseSystemConsole from the config file.

* Fix errors related by removing UseSystemConsole from the config file.

* Fixes #2633. DecodeEscSeq throw an exception if cki is null.

* Fix an exception if SelectedItem is -1.

* Set SelectedItem to 0 and remove unnecessary ToString.

* Using a unique ToString method for Rune and other for byte.

* Fix a bug where a wider rune is added with only a width of 1.

* Force the SelectedGlyph is the one that was typed after jumpList is executed.

* Added more InlineData to RuneTests.

* Reducing significantly the code by using Theory attribute in the TextFormatterTests.

* Override PositionCursor to handle the CharMap cursor position.

* Fix merge errors.

* Minor tweaks to API docs

---------

Co-authored-by: Tig Kindel <tig@users.noreply.github.com>
2023-05-20 19:35:32 +02:00

103 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terminal.Gui;
using static UICatalog.Scenario;
namespace UICatalog.Scenarios {
[ScenarioMetadata (Name: "Line View", Description: "Demonstrates drawing lines using the LineView control.")]
[ScenarioCategory ("Controls"), ScenarioCategory ("LineView")]
public class LineViewExample : Scenario {
public override void Setup ()
{
Win.Title = this.GetName ();
Win.Y = 1; // menu
Win.Height = Dim.Fill (1); // status bar
Application.Top.LayoutSubviews ();
var menu = new MenuBar (new MenuBarItem [] {
new MenuBarItem ("_File", new MenuItem [] {
new MenuItem ("_Quit", "", () => Quit()),
})
});
Application.Top.Add (menu);
Win.Add (new Label ("Regular Line") { Y = 0 });
// creates a horizontal line
var line = new LineView () {
Y = 1,
};
Win.Add (line);
Win.Add (new Label ("Double Width Line") { Y = 2 });
// creates a horizontal line
var doubleLine = new LineView () {
Y = 3,
LineRune = (Rune)'\u2550'
};
Win.Add (doubleLine);
Win.Add (new Label ("Short Line") { Y = 4 });
// creates a horizontal line
var shortLine = new LineView () {
Y = 5,
Width = 10
};
Win.Add (shortLine);
Win.Add (new Label ("Arrow Line") { Y = 6 });
// creates a horizontal line
var arrowLine = new LineView () {
Y = 7,
Width = 10,
StartingAnchor = CM.Glyphs.LeftTee,
EndingAnchor = (Rune)'>'
};
Win.Add (arrowLine);
Win.Add (new Label ("Vertical Line") { Y = 9,X=11 });
// creates a horizontal line
var verticalLine = new LineView (Orientation.Vertical) {
X = 25,
};
Win.Add (verticalLine);
Win.Add (new Label ("Vertical Arrow") { Y = 11, X = 28 });
// creates a horizontal line
var verticalArrow = new LineView (Orientation.Vertical) {
X = 27,
StartingAnchor = CM.Glyphs.TopTee,
EndingAnchor = (Rune)'V'
};
Win.Add (verticalArrow);
var statusBar = new StatusBar (new StatusItem [] {
new StatusItem(Application.QuitKey, $"{Application.QuitKey} to Quit", () => Quit()),
});
Application.Top.Add (statusBar);
}
private void Quit ()
{
Application.RequestStop ();
}
}
}