TextAlignment.cs 1.4 KB

1234567891011121314151617181920212223242526
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Terminal.Gui;
  4. namespace UICatalog {
  5. [ScenarioMetadata (Name: "Text Alignment", Description: "Demonstrates text alignment")]
  6. [ScenarioCategory ("Text")]
  7. class TextAlignment : Scenario {
  8. public override void Setup ()
  9. {
  10. int i = 1;
  11. string txt = "Hello world, how are you doing today";
  12. var labelList = new List<Label> ();
  13. labelList.Add (new Label ($"Label:"));
  14. labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Left, Width = Dim.Fill (1), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()) + 1 });
  15. labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Right, Width = Dim.Fill (1), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()) + 1 });
  16. labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Centered, Width = Dim.Fill (1), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()) + 1 });
  17. labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Justified, Width = Dim.Fill (1), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()) + 1 });
  18. txt += "\nSecond line";
  19. labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Left, Width = Dim.Fill (1), Height = 4, X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()) + 1 });
  20. Win.Add (labelList.ToArray ());
  21. Win.LayoutSubviews ();
  22. }
  23. }
  24. }