diff --git a/Terminal.Gui/Drawing/Aligner.cs b/Terminal.Gui/Drawing/Aligner.cs
new file mode 100644
index 000000000..75c981455
--- /dev/null
+++ b/Terminal.Gui/Drawing/Aligner.cs
@@ -0,0 +1,338 @@
+using System.ComponentModel;
+
+namespace Terminal.Gui;
+
+///
+/// Aligns items within a container based on the specified . Both horizontal and vertical
+/// alignments are supported.
+///
+public class Aligner : INotifyPropertyChanged
+{
+ private Alignment _alignment;
+
+ ///
+ /// Gets or sets how the aligns items within a container.
+ ///
+ ///
+ ///
+ /// provides additional options for aligning items in a container.
+ ///
+ ///
+ public Alignment Alignment
+ {
+ get => _alignment;
+ set
+ {
+ _alignment = value;
+ PropertyChanged?.Invoke (this, new (nameof (Alignment)));
+ }
+ }
+
+ private AlignmentModes _alignmentMode = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems;
+
+ ///
+ /// Gets or sets the modes controlling .
+ ///
+ public AlignmentModes AlignmentModes
+ {
+ get => _alignmentMode;
+ set
+ {
+ _alignmentMode = value;
+ PropertyChanged?.Invoke (this, new (nameof (AlignmentModes)));
+ }
+ }
+
+ private int _containerSize;
+
+ ///
+ /// The size of the container.
+ ///
+ public int ContainerSize
+ {
+ get => _containerSize;
+ set
+ {
+ _containerSize = value;
+ PropertyChanged?.Invoke (this, new (nameof (ContainerSize)));
+ }
+ }
+
+ ///
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ ///
+ /// Takes a list of item sizes and returns a list of the positions of those items when aligned within
+ ///
+ /// using the and settings.
+ ///
+ /// The sizes of the items to align.
+ /// The locations of the items, from left/top to right/bottom.
+ public int [] Align (int [] sizes) { return Align (Alignment, AlignmentModes, ContainerSize, sizes); }
+
+ ///
+ /// Takes a list of item sizes and returns a list of the positions of those items when aligned within
+ ///
+ /// using specified parameters.
+ ///
+ /// Specifies how the items will be aligned.
+ ///
+ /// The size of the container.
+ /// The sizes of the items to align.
+ /// The positions of the items, from left/top to right/bottom.
+ public static int [] Align (in Alignment alignment, in AlignmentModes alignmentMode, in int containerSize, in int [] sizes)
+ {
+ if (alignmentMode.HasFlag (AlignmentModes.EndToStart))
+ {
+ throw new NotImplementedException ("EndToStart is not implemented.");
+ }
+
+ if (sizes.Length == 0)
+ {
+ return [];
+ }
+
+ int maxSpaceBetweenItems = alignmentMode.HasFlag (AlignmentModes.AddSpaceBetweenItems) ? 1 : 0;
+ int totalItemsSize = sizes.Sum ();
+ int totalGaps = sizes.Length - 1; // total gaps between items
+ int totalItemsAndSpaces = totalItemsSize + totalGaps * maxSpaceBetweenItems; // total size of items and spacesToGive if we had enough room
+ int spacesToGive = totalGaps * maxSpaceBetweenItems; // We'll decrement this below to place one space between each item until we run out
+
+ if (totalItemsSize >= containerSize)
+ {
+ spacesToGive = 0;
+ }
+ else if (totalItemsAndSpaces > containerSize)
+ {
+ spacesToGive = containerSize - totalItemsSize;
+ }
+
+ switch (alignment)
+ {
+ case Alignment.Start:
+ switch (alignmentMode & ~AlignmentModes.AddSpaceBetweenItems)
+ {
+ case AlignmentModes.StartToEnd:
+ return Start (in sizes, maxSpaceBetweenItems, spacesToGive);
+
+ case AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast:
+ return IgnoreLast (in sizes, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive);
+ }
+
+ break;
+
+ case Alignment.End:
+ switch (alignmentMode & ~AlignmentModes.AddSpaceBetweenItems)
+ {
+ case AlignmentModes.StartToEnd:
+ return End (in sizes, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive);
+
+ case AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast:
+ return IgnoreFirst (in sizes, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive);
+ }
+
+ break;
+
+ case Alignment.Center:
+ return Center (in sizes, containerSize, totalItemsSize, maxSpaceBetweenItems, spacesToGive);
+
+ case Alignment.Fill:
+ return Fill (in sizes, containerSize, totalItemsSize);
+
+ default:
+ throw new ArgumentOutOfRangeException (nameof (alignment), alignment, null);
+ }
+
+ return [];
+ }
+
+ internal static int [] Start (ref readonly int [] sizes, int maxSpaceBetweenItems, int spacesToGive)
+ {
+ var positions = new int [sizes.Length]; // positions of the items. the return value.
+
+ for (var i = 0; i < sizes.Length; i++)
+ {
+ CheckSizeCannotBeNegative (i, in sizes);
+
+ if (i == 0)
+ {
+ positions [0] = 0; // first item position
+
+ continue;
+ }
+
+ int spaceBefore = spacesToGive-- > 0 ? maxSpaceBetweenItems : 0;
+
+ // subsequent items are placed one space after the previous item
+ positions [i] = positions [i - 1] + sizes [i - 1] + spaceBefore;
+ }
+
+ return positions;
+ }
+
+ internal static int [] IgnoreFirst (
+ ref readonly int [] sizes,
+ int containerSize,
+ int totalItemsSize,
+ int maxSpaceBetweenItems,
+ int spacesToGive
+ )
+ {
+ var positions = new int [sizes.Length]; // positions of the items. the return value.
+
+ if (sizes.Length > 1)
+ {
+ var currentPosition = 0;
+ positions [0] = currentPosition; // first item is flush left
+
+ for (int i = sizes.Length - 1; i >= 0; i--)
+ {
+ CheckSizeCannotBeNegative (i, in sizes);
+
+ if (i == sizes.Length - 1)
+ {
+ // start at right
+ currentPosition = Math.Max (totalItemsSize, containerSize) - sizes [i];
+ positions [i] = currentPosition;
+ }
+
+ if (i < sizes.Length - 1 && i > 0)
+ {
+ int spaceBefore = spacesToGive-- > 0 ? maxSpaceBetweenItems : 0;
+
+ positions [i] = currentPosition - sizes [i] - spaceBefore;
+ currentPosition = positions [i];
+ }
+ }
+ }
+ else if (sizes.Length == 1)
+ {
+ CheckSizeCannotBeNegative (0, in sizes);
+ positions [0] = 0; // single item is flush left
+ }
+
+ return positions;
+ }
+
+ internal static int [] IgnoreLast (
+ ref readonly int [] sizes,
+ int containerSize,
+ int totalItemsSize,
+ int maxSpaceBetweenItems,
+ int spacesToGive
+ )
+ {
+ var positions = new int [sizes.Length]; // positions of the items. the return value.
+
+ if (sizes.Length > 1)
+ {
+ var currentPosition = 0;
+ if (totalItemsSize > containerSize)
+ {
+ currentPosition = containerSize - totalItemsSize - spacesToGive;
+ }
+
+ for (var i = 0; i < sizes.Length; i++)
+ {
+ CheckSizeCannotBeNegative (i, in sizes);
+
+ if (i < sizes.Length - 1)
+ {
+ int spaceBefore = spacesToGive-- > 0 ? maxSpaceBetweenItems : 0;
+
+ positions [i] = currentPosition;
+ currentPosition += sizes [i] + spaceBefore;
+ }
+ }
+
+ positions [sizes.Length - 1] = containerSize - sizes [^1];
+ }
+ else if (sizes.Length == 1)
+ {
+ CheckSizeCannotBeNegative (0, in sizes);
+
+ positions [0] = containerSize - sizes [0]; // single item is flush right
+ }
+
+ return positions;
+ }
+
+ internal static int [] Fill (ref readonly int [] sizes, int containerSize, int totalItemsSize)
+ {
+ var positions = new int [sizes.Length]; // positions of the items. the return value.
+
+ int spaceBetween = sizes.Length > 1 ? (containerSize - totalItemsSize) / (sizes.Length - 1) : 0;
+ int remainder = sizes.Length > 1 ? (containerSize - totalItemsSize) % (sizes.Length - 1) : 0;
+ var currentPosition = 0;
+
+ for (var i = 0; i < sizes.Length; i++)
+ {
+ CheckSizeCannotBeNegative (i, in sizes);
+ positions [i] = currentPosition;
+ int extraSpace = i < remainder ? 1 : 0;
+ currentPosition += sizes [i] + spaceBetween + extraSpace;
+ }
+
+ return positions;
+ }
+
+ internal static int [] Center (ref readonly int [] sizes, int containerSize, int totalItemsSize, int maxSpaceBetweenItems, int spacesToGive)
+ {
+ var positions = new int [sizes.Length]; // positions of the items. the return value.
+
+ if (sizes.Length > 1)
+ {
+ // remaining space to be distributed before first and after the items
+ int remainingSpace = containerSize - totalItemsSize - spacesToGive;
+
+ for (var i = 0; i < sizes.Length; i++)
+ {
+ CheckSizeCannotBeNegative (i, in sizes);
+
+ if (i == 0)
+ {
+ positions [i] = remainingSpace / 2; // first item position
+
+ continue;
+ }
+
+ int spaceBefore = spacesToGive-- > 0 ? maxSpaceBetweenItems : 0;
+
+ // subsequent items are placed one space after the previous item
+ positions [i] = positions [i - 1] + sizes [i - 1] + spaceBefore;
+ }
+ }
+ else if (sizes.Length == 1)
+ {
+ CheckSizeCannotBeNegative (0, in sizes);
+ positions [0] = (containerSize - sizes [0]) / 2; // single item is centered
+ }
+
+ return positions;
+ }
+
+ internal static int [] End (ref readonly int [] sizes, int containerSize, int totalItemsSize, int maxSpaceBetweenItems, int spacesToGive)
+ {
+ var positions = new int [sizes.Length]; // positions of the items. the return value.
+ int currentPosition = containerSize - totalItemsSize - spacesToGive;
+
+ for (var i = 0; i < sizes.Length; i++)
+ {
+ CheckSizeCannotBeNegative (i, in sizes);
+ int spaceBefore = spacesToGive-- > 0 ? maxSpaceBetweenItems : 0;
+
+ positions [i] = currentPosition;
+ currentPosition += sizes [i] + spaceBefore;
+ }
+
+ return positions;
+ }
+
+ private static void CheckSizeCannotBeNegative (int i, ref readonly int [] sizes)
+ {
+ if (sizes [i] < 0)
+ {
+ throw new ArgumentException ("The size of an item cannot be negative.");
+ }
+ }
+}
diff --git a/Terminal.Gui/Drawing/Alignment.cs b/Terminal.Gui/Drawing/Alignment.cs
new file mode 100644
index 000000000..5a32cb491
--- /dev/null
+++ b/Terminal.Gui/Drawing/Alignment.cs
@@ -0,0 +1,78 @@
+namespace Terminal.Gui;
+
+///
+/// Determines the position of items when arranged in a container.
+///
+public enum Alignment
+{
+ ///
+ /// The items will be aligned to the start (left or top) of the container.
+ ///
+ ///
+ ///
+ /// If the container is smaller than the total size of the items, the end items will be clipped (their locations
+ /// will be greater than the container size).
+ ///
+ ///
+ /// The enumeration provides additional options for aligning items in a container.
+ ///
+ ///
+ ///
+ ///
+ /// |111 2222 33333 |
+ ///
+ ///
+ Start = 0,
+
+ ///
+ /// The items will be aligned to the end (right or bottom) of the container.
+ ///
+ ///
+ ///
+ /// If the container is smaller than the total size of the items, the start items will be clipped (their locations
+ /// will be negative).
+ ///
+ ///
+ /// The enumeration provides additional options for aligning items in a container.
+ ///
+ ///
+ ///
+ ///
+ /// | 111 2222 33333|
+ ///
+ ///
+ End,
+
+ ///
+ /// Center in the available space.
+ ///
+ ///
+ ///
+ /// If centering is not possible, the group will be left-aligned.
+ ///
+ ///
+ /// Extra space will be distributed between the items, biased towards the left.
+ ///
+ ///
+ ///
+ ///
+ /// | 111 2222 33333 |
+ ///
+ ///
+ Center,
+
+ ///
+ /// The items will fill the available space.
+ ///
+ ///
+ ///
+ /// Extra space will be distributed between the items, biased towards the end.
+ ///
+ ///
+ ///
+ ///
+ /// |111 2222 33333|
+ ///
+ ///
+ Fill,
+}
\ No newline at end of file
diff --git a/Terminal.Gui/Drawing/AlignmentModes.cs b/Terminal.Gui/Drawing/AlignmentModes.cs
new file mode 100644
index 000000000..abd88a397
--- /dev/null
+++ b/Terminal.Gui/Drawing/AlignmentModes.cs
@@ -0,0 +1,49 @@
+namespace Terminal.Gui;
+
+///
+/// Determines alignment modes for .
+///
+[Flags]
+public enum AlignmentModes
+{
+ ///
+ /// The items will be arranged from start (left/top) to end (right/bottom).
+ ///
+ StartToEnd = 0,
+
+ ///
+ /// The items will be arranged from end (right/bottom) to start (left/top).
+ ///
+ ///
+ /// Not implemented.
+ ///
+ EndToStart = 1,
+
+ ///
+ /// At least one space will be added between items. Useful for justifying text where at least one space is needed.
+ ///
+ ///
+ ///
+ /// If the total size of the items is greater than the container size, the space between items will be ignored
+ /// starting from the end.
+ ///
+ ///
+ AddSpaceBetweenItems = 2,
+
+ ///
+ /// When aligning via or , the item opposite to the alignment (the first or last item) will be ignored.
+ ///
+ ///
+ ///
+ /// If the container is smaller than the total size of the items, the end items will be clipped (their locations
+ /// will be greater than the container size).
+ ///
+ ///
+ ///
+ ///
+ /// Start: |111 2222 33333|
+ /// End: |111 2222 33333|
+ ///
+ ///
+ IgnoreFirstOrLast = 4,
+}
\ No newline at end of file
diff --git a/Terminal.Gui/Drawing/Justification.cs b/Terminal.Gui/Drawing/Justification.cs
deleted file mode 100644
index f1fba56a8..000000000
--- a/Terminal.Gui/Drawing/Justification.cs
+++ /dev/null
@@ -1,333 +0,0 @@
-namespace Terminal.Gui;
-
-///
-/// Controls how the justifies items within a container.
-///
-public enum Justification
-{
- ///
- /// The items will be aligned to the left.
- /// Set to to ensure at least one space between
- /// each item.
- ///
- ///
- ///
- /// 111 2222 33333
- ///
- ///
- Left,
-
- ///
- /// The items will be aligned to the right.
- /// Set to to ensure at least one space between
- /// each item.
- ///
- ///
- ///
- /// 111 2222 33333
- ///
- ///
- Right,
-
- ///
- /// The group will be centered in the container.
- /// If centering is not possible, the group will be left-justified.
- /// Set to to ensure at least one space between
- /// each item.
- ///
- ///
- ///
- /// 111 2222 33333
- ///
- ///
- Centered,
-
- ///
- /// The items will be justified. Space will be added between the items such that the first item
- /// is at the start and the right side of the last item against the end.
- /// Set to to ensure at least one space between
- /// each item.
- ///
- ///
- ///
- /// 111 2222 33333
- ///
- ///
- Justified,
-
- ///
- /// The first item will be aligned to the left and the remaining will aligned to the right.
- /// Set to to ensure at least one space between
- /// each item.
- ///
- ///
- ///
- /// 111 2222 33333
- ///
- ///
- FirstLeftRestRight,
-
- ///
- /// The last item will be aligned to the right and the remaining will aligned to the left.
- /// Set to to ensure at least one space between
- /// each item.
- ///
- ///
- ///
- /// 111 2222 33333
- ///
- ///
- LastRightRestLeft
-}
-
-///
-/// Justifies items within a container based on the specified .
-///
-public class Justifier
-{
- ///
- /// Gets or sets how the justifies items within a container.
- ///
- public Justification Justification { get; set; }
-
- ///
- /// The size of the container.
- ///
- public int ContainerSize { get; set; }
-
- ///
- /// Gets or sets whether puts a space is placed between items. Default is . If , a space will be
- /// placed between each item, which is useful for justifying text.
- ///
- public bool PutSpaceBetweenItems { get; set; }
-
- ///
- /// Takes a list of items and returns their positions when justified within a container wide based on the specified
- /// .
- ///
- /// The sizes of the items to justify.
- /// The locations of the items, from left to right.
- public int [] Justify (int [] sizes)
- {
- return Justify (Justification, PutSpaceBetweenItems, ContainerSize, sizes);
- }
-
- ///
- /// Takes a list of items and returns their positions when justified within a container wide based on the specified
- /// .
- ///
- /// The sizes of the items to justify.
- /// The justification style.
- ///
- /// The size of the container.
- /// The locations of the items, from left to right.
- public static int [] Justify (Justification justification, bool putSpaceBetweenItems, int containerSize, int [] sizes)
- {
- if (sizes.Length == 0)
- {
- return new int [] { };
- }
-
- int maxSpaceBetweenItems = putSpaceBetweenItems ? 1 : 0;
-
- var positions = new int [sizes.Length]; // positions of the items. the return value.
- int totalItemsSize = sizes.Sum ();
- int totalGaps = sizes.Length - 1; // total gaps between items
- int totalItemsAndSpaces = totalItemsSize + totalGaps * maxSpaceBetweenItems; // total size of items and spaces if we had enough room
-
- int spaces = totalGaps * maxSpaceBetweenItems; // We'll decrement this below to place one space between each item until we run out
- if (totalItemsSize >= containerSize)
- {
- spaces = 0;
- }
- else if (totalItemsAndSpaces > containerSize)
- {
- spaces = containerSize - totalItemsSize;
- }
-
- switch (justification)
- {
- case Justification.Left:
- var currentPosition = 0;
-
- for (var i = 0; i < sizes.Length; i++)
- {
- if (sizes [i] < 0)
- {
- throw new ArgumentException ("The size of an item cannot be negative.");
- }
-
- if (i == 0)
- {
- positions [0] = 0; // first item position
-
- continue;
- }
-
- int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
-
- // subsequent items are placed one space after the previous item
- positions [i] = positions [i - 1] + sizes [i - 1] + spaceBefore;
- }
-
- break;
- case Justification.Right:
- currentPosition = Math.Max (0, containerSize - totalItemsSize - spaces);
-
- for (var i = 0; i < sizes.Length; i++)
- {
- if (sizes [i] < 0)
- {
- throw new ArgumentException ("The size of an item cannot be negative.");
- }
-
- int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
-
- positions [i] = currentPosition;
- currentPosition += sizes [i] + spaceBefore;
- }
-
- break;
-
- case Justification.Centered:
- if (sizes.Length > 1)
- {
- // remaining space to be distributed before first and after the items
- int remainingSpace = Math.Max (0, containerSize - totalItemsSize - spaces);
-
- for (var i = 0; i < sizes.Length; i++)
- {
- if (sizes [i] < 0)
- {
- throw new ArgumentException ("The size of an item cannot be negative.");
- }
-
- if (i == 0)
- {
- positions [i] = remainingSpace / 2; // first item position
-
- continue;
- }
-
- int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
-
- // subsequent items are placed one space after the previous item
- positions [i] = positions [i - 1] + sizes [i - 1] + spaceBefore;
- }
- }
- else if (sizes.Length == 1)
- {
- if (sizes [0] < 0)
- {
- throw new ArgumentException ("The size of an item cannot be negative.");
- }
-
- positions [0] = (containerSize - sizes [0]) / 2; // single item is centered
- }
-
- break;
-
- case Justification.Justified:
- int spaceBetween = sizes.Length > 1 ? (containerSize - totalItemsSize) / (sizes.Length - 1) : 0;
- int remainder = sizes.Length > 1 ? (containerSize - totalItemsSize) % (sizes.Length - 1) : 0;
- currentPosition = 0;
-
- for (var i = 0; i < sizes.Length; i++)
- {
- if (sizes [i] < 0)
- {
- throw new ArgumentException ("The size of an item cannot be negative.");
- }
-
- positions [i] = currentPosition;
- int extraSpace = i < remainder ? 1 : 0;
- currentPosition += sizes [i] + spaceBetween + extraSpace;
- }
-
- break;
-
- // 111 2222 33333
- case Justification.LastRightRestLeft:
- if (sizes.Length > 1)
- {
- currentPosition = 0;
-
- for (var i = 0; i < sizes.Length; i++)
- {
- if (sizes [i] < 0)
- {
- throw new ArgumentException ("The size of an item cannot be negative.");
- }
-
- if (i < sizes.Length - 1)
- {
- int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
-
- positions [i] = currentPosition;
- currentPosition += sizes [i] + spaceBefore;
- }
- }
-
- positions [sizes.Length - 1] = containerSize - sizes [sizes.Length - 1];
- }
- else if (sizes.Length == 1)
- {
- if (sizes [0] < 0)
- {
- throw new ArgumentException ("The size of an item cannot be negative.");
- }
-
- positions [0] = containerSize - sizes [0]; // single item is flush right
- }
-
- break;
-
- // 111 2222 33333
- case Justification.FirstLeftRestRight:
- if (sizes.Length > 1)
- {
- currentPosition = 0;
- positions [0] = currentPosition; // first item is flush left
-
- for (int i = sizes.Length - 1; i >= 0; i--)
- {
- if (sizes [i] < 0)
- {
- throw new ArgumentException ("The size of an item cannot be negative.");
- }
-
- if (i == sizes.Length - 1)
- {
- // start at right
- currentPosition = containerSize - sizes [i];
- positions [i] = currentPosition;
- }
-
- if (i < sizes.Length - 1 && i > 0)
- {
- int spaceBefore = spaces-- > 0 ? maxSpaceBetweenItems : 0;
-
- positions [i] = currentPosition - sizes [i] - spaceBefore;
- currentPosition = positions [i];
- }
- }
- }
- else if (sizes.Length == 1)
- {
- if (sizes [0] < 0)
- {
- throw new ArgumentException ("The size of an item cannot be negative.");
- }
-
- positions [0] = 0; // single item is flush left
- }
-
- break;
-
- default:
- throw new ArgumentOutOfRangeException (nameof (justification), justification, null);
- }
-
- return positions;
- }
-}
diff --git a/Terminal.Gui/Drawing/Thickness.cs b/Terminal.Gui/Drawing/Thickness.cs
index 6070e6cbe..ad684470b 100644
--- a/Terminal.Gui/Drawing/Thickness.cs
+++ b/Terminal.Gui/Drawing/Thickness.cs
@@ -230,8 +230,8 @@ public class Thickness : IEquatable
var tf = new TextFormatter
{
Text = label is null ? string.Empty : $"{label} {this}",
- Alignment = TextAlignment.Centered,
- VerticalAlignment = VerticalTextAlignment.Bottom,
+ Alignment = Alignment.Center,
+ VerticalAlignment = Alignment.End,
AutoSize = true
};
tf.Draw (rect, Application.Driver.CurrentAttribute, Application.Driver.CurrentAttribute, rect);
diff --git a/Terminal.Gui/Resources/config.json b/Terminal.Gui/Resources/config.json
index 368ccd8bf..8380a14f5 100644
--- a/Terminal.Gui/Resources/config.json
+++ b/Terminal.Gui/Resources/config.json
@@ -24,7 +24,8 @@
"Themes": [
{
"Default": {
- "Dialog.DefaultButtonAlignment": "Center",
+ "Dialog.DefaultButtonAlignment": "End",
+ "Dialog.DefaultButtonAlignmentModes": "AddSpaceBetweenItems",
"FrameView.DefaultBorderStyle": "Single",
"Window.DefaultBorderStyle": "Single",
"ColorSchemes": [
diff --git a/Terminal.Gui/Text/TextAlignment.cs b/Terminal.Gui/Text/TextAlignment.cs
deleted file mode 100644
index 44950cfd5..000000000
--- a/Terminal.Gui/Text/TextAlignment.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace Terminal.Gui;
-
-/// Text alignment enumeration, controls how text is displayed.
-public enum TextAlignment
-{
- /// The text will be left-aligned.
- Left,
-
- /// The text will be right-aligned.
- Right,
-
- /// The text will be centered horizontally.
- Centered,
-
- ///
- /// The text will be justified (spaces will be added to existing spaces such that the text fills the container
- /// horizontally).
- ///
- Justified
-}
\ No newline at end of file
diff --git a/Terminal.Gui/Text/TextFormatter.cs b/Terminal.Gui/Text/TextFormatter.cs
index af4a7b97b..bee37de67 100644
--- a/Terminal.Gui/Text/TextFormatter.cs
+++ b/Terminal.Gui/Text/TextFormatter.cs
@@ -1,3 +1,5 @@
+using System.Diagnostics;
+
namespace Terminal.Gui;
///
@@ -15,14 +17,14 @@ public class TextFormatter
private Size _size;
private int _tabWidth = 4;
private string _text;
- private TextAlignment _textAlignment;
+ private Alignment _textAlignment = Alignment.Start;
private TextDirection _textDirection;
- private VerticalTextAlignment _textVerticalAlignment;
+ private Alignment _textVerticalAlignment = Alignment.Start;
private bool _wordWrap = true;
- /// Controls the horizontal text-alignment property.
+ /// Get or sets the horizontal text alignment.
/// The text alignment.
- public TextAlignment Alignment
+ public Alignment Alignment
{
get => _textAlignment;
set => _textAlignment = EnableNeedsFormat (value);
@@ -32,8 +34,7 @@ public class TextFormatter
///
/// Used when is using to resize the view's to fit .
///
- /// AutoSize is ignored if and
- /// are used.
+ /// AutoSize is ignored if is used.
///
///
public bool AutoSize
@@ -68,9 +69,8 @@ public class TextFormatter
/// Only the first HotKey specifier found in is supported.
///
///
- /// If (the default) the width required for the HotKey specifier is returned. Otherwise the
- /// height
- /// is returned.
+ /// If (the default) the width required for the HotKey specifier is returned. Otherwise, the
+ /// height is returned.
///
///
/// The number of characters required for the . If the text
@@ -97,8 +97,8 @@ public class TextFormatter
///
public int CursorPosition { get; internal set; }
- /// Controls the text-direction property.
- /// The text vertical alignment.
+ /// Gets or sets the text-direction.
+ /// The text direction.
public TextDirection Direction
{
get => _textDirection;
@@ -112,8 +112,7 @@ public class TextFormatter
}
}
}
-
-
+
///
/// Determines if the viewport width will be used or only the text width will be used,
/// If all the viewport area will be filled with whitespaces and the same background color
@@ -223,9 +222,9 @@ public class TextFormatter
}
}
- /// Controls the vertical text-alignment property.
+ /// Gets or sets the vertical text-alignment.
/// The text vertical alignment.
- public VerticalTextAlignment VerticalAlignment
+ public Alignment VerticalAlignment
{
get => _textVerticalAlignment;
set => _textVerticalAlignment = EnableNeedsFormat (value);
@@ -318,10 +317,10 @@ public class TextFormatter
// When text is justified, we lost left or right, so we use the direction to align.
- int x, y;
+ int x = 0, y = 0;
// Horizontal Alignment
- if (Alignment is TextAlignment.Right)
+ if (Alignment is Alignment.End)
{
if (isVertical)
{
@@ -336,7 +335,7 @@ public class TextFormatter
CursorPosition = screen.Width - runesWidth + (_hotKeyPos > -1 ? _hotKeyPos : 0);
}
}
- else if (Alignment is TextAlignment.Left)
+ else if (Alignment is Alignment.Start)
{
if (isVertical)
{
@@ -352,7 +351,7 @@ public class TextFormatter
CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0;
}
- else if (Alignment is TextAlignment.Justified)
+ else if (Alignment is Alignment.Fill)
{
if (isVertical)
{
@@ -375,7 +374,7 @@ public class TextFormatter
CursorPosition = _hotKeyPos > -1 ? _hotKeyPos : 0;
}
- else if (Alignment is TextAlignment.Centered)
+ else if (Alignment is Alignment.Center)
{
if (isVertical)
{
@@ -395,11 +394,13 @@ public class TextFormatter
}
else
{
- throw new ArgumentOutOfRangeException ($"{nameof (Alignment)}");
+ Debug.WriteLine ($"Unsupported Alignment: {nameof (VerticalAlignment)}");
+
+ return;
}
// Vertical Alignment
- if (VerticalAlignment is VerticalTextAlignment.Bottom)
+ if (VerticalAlignment is Alignment.End)
{
if (isVertical)
{
@@ -410,7 +411,7 @@ public class TextFormatter
y = screen.Bottom - linesFormatted.Count + line;
}
}
- else if (VerticalAlignment is VerticalTextAlignment.Top)
+ else if (VerticalAlignment is Alignment.Start)
{
if (isVertical)
{
@@ -421,7 +422,7 @@ public class TextFormatter
y = screen.Top + line;
}
}
- else if (VerticalAlignment is VerticalTextAlignment.Justified)
+ else if (VerticalAlignment is Alignment.Fill)
{
if (isVertical)
{
@@ -435,7 +436,7 @@ public class TextFormatter
line < linesFormatted.Count - 1 ? screen.Height - interval <= 1 ? screen.Top + 1 : screen.Top + line * interval : screen.Bottom - 1;
}
}
- else if (VerticalAlignment is VerticalTextAlignment.Middle)
+ else if (VerticalAlignment is Alignment.Center)
{
if (isVertical)
{
@@ -450,7 +451,9 @@ public class TextFormatter
}
else
{
- throw new ArgumentOutOfRangeException ($"{nameof (VerticalAlignment)}");
+ Debug.WriteLine ($"Unsupported Alignment: {nameof (VerticalAlignment)}");
+
+ return;
}
int colOffset = screen.X < 0 ? Math.Abs (screen.X) : 0;
@@ -471,8 +474,8 @@ public class TextFormatter
{
if (idx < 0
|| (isVertical
- ? VerticalAlignment != VerticalTextAlignment.Bottom && current < 0
- : Alignment != TextAlignment.Right && x + current + colOffset < 0))
+ ? VerticalAlignment != Alignment.End && current < 0
+ : Alignment != Alignment.End && x + current + colOffset < 0))
{
current++;
@@ -561,7 +564,7 @@ public class TextFormatter
if (HotKeyPos > -1 && idx == HotKeyPos)
{
- if ((isVertical && VerticalAlignment == VerticalTextAlignment.Justified) || (!isVertical && Alignment == TextAlignment.Justified))
+ if ((isVertical && VerticalAlignment == Alignment.Fill) || (!isVertical && Alignment == Alignment.Fill))
{
CursorPosition = idx - start;
}
@@ -699,7 +702,7 @@ public class TextFormatter
_lines = Format (
text,
Size.Height,
- VerticalAlignment == VerticalTextAlignment.Justified,
+ VerticalAlignment == Alignment.Fill,
Size.Width > colsWidth && WordWrap,
PreserveTrailingSpaces,
TabWidth,
@@ -723,7 +726,7 @@ public class TextFormatter
_lines = Format (
text,
Size.Width,
- Alignment == TextAlignment.Justified,
+ Alignment == Alignment.Fill,
Size.Height > 1 && WordWrap,
PreserveTrailingSpaces,
TabWidth,
@@ -977,7 +980,7 @@ public class TextFormatter
// if value is not wide enough
if (text.EnumerateRunes ().Sum (c => c.GetColumns ()) < width)
{
- // pad it out with spaces to the given alignment
+ // pad it out with spaces to the given Alignment
int toPad = width - text.EnumerateRunes ().Sum (c => c.GetColumns ());
return text + new string (' ', toPad);
@@ -999,7 +1002,7 @@ public class TextFormatter
/// instance to access any of his objects.
/// A list of word wrapped lines.
///
- /// This method does not do any justification.
+ /// This method does not do any alignment.
/// This method strips Newline ('\n' and '\r\n') sequences before processing.
///
/// If is at most one space will be preserved
@@ -1031,7 +1034,7 @@ public class TextFormatter
List runes = StripCRLF (text).ToRuneList ();
int start = Math.Max (
- !runes.Contains ((Rune)' ') && textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom } && IsVerticalDirection (textDirection)
+ !runes.Contains ((Rune)' ') && textFormatter is { VerticalAlignment: Alignment.End } && IsVerticalDirection (textDirection)
? runes.Count - width
: 0,
0);
@@ -1249,7 +1252,7 @@ public class TextFormatter
/// The number of columns to clip the text to. Text longer than will be
/// clipped.
///
- /// Alignment.
+ /// Alignment.
/// The text direction.
/// The number of columns used for a tab.
/// instance to access any of his objects.
@@ -1257,13 +1260,13 @@ public class TextFormatter
public static string ClipAndJustify (
string text,
int width,
- TextAlignment talign,
+ Alignment textAlignment,
TextDirection textDirection = TextDirection.LeftRight_TopBottom,
int tabWidth = 0,
TextFormatter textFormatter = null
)
{
- return ClipAndJustify (text, width, talign == TextAlignment.Justified, textDirection, tabWidth, textFormatter);
+ return ClipAndJustify (text, width, textAlignment == Alignment.Fill, textDirection, tabWidth, textFormatter);
}
/// Justifies text within a specified width.
@@ -1304,12 +1307,12 @@ public class TextFormatter
{
if (IsHorizontalDirection (textDirection))
{
- if (textFormatter is { Alignment: TextAlignment.Right })
+ if (textFormatter is { Alignment: Alignment.End })
{
return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
}
- if (textFormatter is { Alignment: TextAlignment.Centered })
+ if (textFormatter is { Alignment: Alignment.Center })
{
return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
}
@@ -1319,12 +1322,12 @@ public class TextFormatter
if (IsVerticalDirection (textDirection))
{
- if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom })
+ if (textFormatter is { VerticalAlignment: Alignment.End })
{
return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
}
- if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Middle })
+ if (textFormatter is { VerticalAlignment: Alignment.Center })
{
return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
}
@@ -1342,14 +1345,14 @@ public class TextFormatter
if (IsHorizontalDirection (textDirection))
{
- if (textFormatter is { Alignment: TextAlignment.Right })
+ if (textFormatter is { Alignment: Alignment.End })
{
if (GetRuneWidth (text, tabWidth, textDirection) > width)
{
return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
}
}
- else if (textFormatter is { Alignment: TextAlignment.Centered })
+ else if (textFormatter is { Alignment: Alignment.Center })
{
return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
}
@@ -1361,14 +1364,14 @@ public class TextFormatter
if (IsVerticalDirection (textDirection))
{
- if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Bottom })
+ if (textFormatter is { VerticalAlignment: Alignment.End })
{
if (runes.Count - zeroLength > width)
{
return GetRangeThatFits (runes, runes.Count - width, text, width, tabWidth, textDirection);
}
}
- else if (textFormatter is { VerticalAlignment: VerticalTextAlignment.Middle })
+ else if (textFormatter is { VerticalAlignment: Alignment.Center })
{
return GetRangeThatFits (runes, Math.Max ((runes.Count - width) / 2, 0), text, width, tabWidth, textDirection);
}
@@ -1475,7 +1478,7 @@ public class TextFormatter
/// Formats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries.
///
/// The number of columns to constrain the text to for word wrapping and clipping.
- /// Specifies how the text will be aligned horizontally.
+ /// Specifies how the text will be aligned horizontally.
///
/// If , the text will be wrapped to new lines no longer than
/// . If , forces text to fit a single line. Line breaks are converted
@@ -1498,7 +1501,7 @@ public class TextFormatter
public static List Format (
string text,
int width,
- TextAlignment talign,
+ Alignment textAlignment,
bool wordWrap,
bool preserveTrailingSpaces = false,
int tabWidth = 0,
@@ -1510,7 +1513,7 @@ public class TextFormatter
return Format (
text,
width,
- talign == TextAlignment.Justified,
+ textAlignment == Alignment.Fill,
wordWrap,
preserveTrailingSpaces,
tabWidth,
@@ -1884,7 +1887,7 @@ public class TextFormatter
return lineIdx;
}
- /// Calculates the rectangle required to hold text, assuming no word wrapping or justification.
+ /// Calculates the rectangle required to hold text, assuming no word wrapping or alignment.
///
/// This API will return incorrect results if the text includes glyphs who's width is dependent on surrounding
/// glyphs (e.g. Arabic).
diff --git a/Terminal.Gui/Text/VerticalTextAlignment.cs b/Terminal.Gui/Text/VerticalTextAlignment.cs
deleted file mode 100644
index ef7788577..000000000
--- a/Terminal.Gui/Text/VerticalTextAlignment.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace Terminal.Gui;
-
-/// Vertical text alignment enumeration, controls how text is displayed.
-public enum VerticalTextAlignment
-{
- /// The text will be top-aligned.
- Top,
-
- /// The text will be bottom-aligned.
- Bottom,
-
- /// The text will centered vertically.
- Middle,
-
- ///
- /// The text will be justified (spaces will be added to existing spaces such that the text fills the container
- /// vertically).
- ///
- Justified
-}
\ No newline at end of file
diff --git a/Terminal.Gui/View/Layout/Dim.cs b/Terminal.Gui/View/Layout/Dim.cs
index 1fc16c9c2..79c2e6db0 100644
--- a/Terminal.Gui/View/Layout/Dim.cs
+++ b/Terminal.Gui/View/Layout/Dim.cs
@@ -150,7 +150,11 @@ public abstract class Dim
/// Creates a percentage object that is a percentage of the width or height of the SuperView.
/// The percent object.
/// A value between 0 and 100 representing the percentage.
- ///
+ ///
+ /// If the dimension is computed using the View's position ( or
+ /// ).
+ /// If the dimension is computed using the View's .
+ ///
///
/// This initializes a that will be centered horizontally, is 50% of the way down, is 30% the
/// height,
diff --git a/Terminal.Gui/View/Layout/Pos.cs b/Terminal.Gui/View/Layout/Pos.cs
index e27fabb3c..3a4e27340 100644
--- a/Terminal.Gui/View/Layout/Pos.cs
+++ b/Terminal.Gui/View/Layout/Pos.cs
@@ -26,6 +26,14 @@ namespace Terminal.Gui;
///
/// -
///
+///
+///
+///
+/// Creates a object that aligns a set of views.
+///
+///
+/// -
+///
///
///
///
@@ -132,6 +140,30 @@ public abstract class Pos
/// The value to convert to the .
public static Pos Absolute (int position) { return new PosAbsolute (position); }
+ ///
+ /// Creates a object that aligns a set of views according to the specified
+ /// and .
+ ///
+ /// The alignment.
+ /// The optional alignment modes.
+ ///
+ /// The optional identifier of a set of views that should be aligned together. When only a single
+ /// set of views in a SuperView is aligned, this parameter is optional.
+ ///
+ ///
+ public static Pos Align (Alignment alignment, AlignmentModes modes = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, int groupId = 0)
+ {
+ return new PosAlign
+ {
+ Aligner = new ()
+ {
+ Alignment = alignment,
+ AlignmentModes = modes
+ },
+ GroupId = groupId
+ };
+ }
+
///
/// Creates a object that is anchored to the end (right side or
/// bottom) of the SuperView's Content Area, minus the respective size of the View. This is equivalent to using
@@ -359,5 +391,4 @@ public abstract class Pos
}
#endregion operators
-
-}
\ No newline at end of file
+}
diff --git a/Terminal.Gui/View/Layout/PosAlign.cs b/Terminal.Gui/View/Layout/PosAlign.cs
new file mode 100644
index 000000000..83ba4a1c8
--- /dev/null
+++ b/Terminal.Gui/View/Layout/PosAlign.cs
@@ -0,0 +1,169 @@
+#nullable enable
+
+using System.ComponentModel;
+
+namespace Terminal.Gui;
+
+///
+/// Enables alignment of a set of views.
+///
+///
+///
+/// Updating the properties of is supported, but will not automatically cause re-layout to
+/// happen.
+/// must be called on the SuperView.
+///
+///
+/// Views that should be aligned together must have a distinct . When only a single
+/// set of views is aligned within a SuperView, setting is optional because it defaults to 0.
+///
+///
+/// The first view added to the Superview with a given is used to determine the alignment of
+/// the group.
+/// The alignment is applied to all views with the same .
+///
+///
+public class PosAlign : Pos
+{
+ ///
+ /// The cached location. Used to store the calculated location to minimize recalculating it.
+ ///
+ private int? _cachedLocation;
+
+ ///
+ /// Gets the identifier of a set of views that should be aligned together. When only a single
+ /// set of views in a SuperView is aligned, setting is not needed because it defaults to 0.
+ ///
+ public int GroupId { get; init; }
+
+ private readonly Aligner? _aligner;
+
+ ///
+ /// Gets the alignment settings.
+ ///
+ public required Aligner Aligner
+ {
+ get => _aligner!;
+ init
+ {
+ if (_aligner is { })
+ {
+ _aligner.PropertyChanged -= Aligner_PropertyChanged;
+ }
+
+ _aligner = value;
+ _aligner.PropertyChanged += Aligner_PropertyChanged;
+ }
+ }
+
+ ///
+ /// Aligns the views in that have the same group ID as .
+ /// Updates each view's cached _location.
+ ///
+ ///
+ ///
+ ///
+ ///
+ private static void AlignAndUpdateGroup (int groupId, IList views, Dimension dimension, int size)
+ {
+ List dimensionsList = new ();
+
+ // PERF: If this proves a perf issue, consider caching a ref to this list in each item
+ List viewsInGroup = views.Where (
+ v =>
+ {
+ return dimension switch
+ {
+ Dimension.Width when v.X is PosAlign alignX => alignX.GroupId == groupId,
+ Dimension.Height when v.Y is PosAlign alignY => alignY.GroupId == groupId,
+ _ => false
+ };
+ })
+ .ToList ();
+
+ if (viewsInGroup.Count == 0)
+ {
+ return;
+ }
+
+ // PERF: We iterate over viewsInGroup multiple times here.
+
+ Aligner? firstInGroup = null;
+
+ // Update the dimensionList with the sizes of the views
+ for (var index = 0; index < viewsInGroup.Count; index++)
+ {
+ View view = viewsInGroup [index];
+ PosAlign? posAlign = dimension == Dimension.Width ? view.X as PosAlign : view.Y as PosAlign;
+
+ if (posAlign is { })
+ {
+ if (index == 0)
+ {
+ firstInGroup = posAlign.Aligner;
+ }
+
+ dimensionsList.Add (dimension == Dimension.Width ? view.Frame.Width : view.Frame.Height);
+ }
+ }
+
+ // Update the first item in the group with the new container size.
+ firstInGroup!.ContainerSize = size;
+
+ // Align
+ int [] locations = firstInGroup.Align (dimensionsList.ToArray ());
+
+ // Update the cached location for each item
+ for (var index = 0; index < viewsInGroup.Count; index++)
+ {
+ View view = viewsInGroup [index];
+ PosAlign? align = dimension == Dimension.Width ? view.X as PosAlign : view.Y as PosAlign;
+
+ if (align is { })
+ {
+ align._cachedLocation = locations [index];
+ }
+ }
+ }
+
+ private void Aligner_PropertyChanged (object? sender, PropertyChangedEventArgs e) { _cachedLocation = null; }
+
+ ///
+ public override bool Equals (object? other)
+ {
+ return other is PosAlign align
+ && GroupId == align.GroupId
+ && align.Aligner.Alignment == Aligner.Alignment
+ && align.Aligner.AlignmentModes == Aligner.AlignmentModes;
+ }
+
+ ///
+ public override int GetHashCode () { return HashCode.Combine (Aligner, GroupId); }
+
+ ///
+ public override string ToString () { return $"Align(alignment={Aligner.Alignment},modes={Aligner.AlignmentModes},groupId={GroupId})"; }
+
+ internal override int GetAnchor (int width) { return _cachedLocation ?? 0 - width; }
+
+ internal override int Calculate (int superviewDimension, Dim dim, View us, Dimension dimension)
+ {
+ if (_cachedLocation.HasValue && Aligner.ContainerSize == superviewDimension)
+ {
+ return _cachedLocation.Value;
+ }
+
+ if (us?.SuperView is null)
+ {
+ return 0;
+ }
+
+ AlignAndUpdateGroup (GroupId, us.SuperView.Subviews, dimension, superviewDimension);
+
+ if (_cachedLocation.HasValue)
+ {
+ return _cachedLocation.Value;
+ }
+
+ return 0;
+ }
+}
diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs
index 2ee3a51a0..4b203091b 100644
--- a/Terminal.Gui/View/ViewText.cs
+++ b/Terminal.Gui/View/ViewText.cs
@@ -87,7 +87,7 @@ public partial class View
/// or are using , the will be adjusted to fit the text.
///
/// The text alignment.
- public virtual TextAlignment TextAlignment
+ public virtual Alignment TextAlignment
{
get => TextFormatter.Alignment;
set
@@ -105,7 +105,7 @@ public partial class View
///
/// or are using , the will be adjusted to fit the text.
///
- /// The text alignment.
+ /// The text direction.
public virtual TextDirection TextDirection
{
get => TextFormatter.Direction;
@@ -129,8 +129,8 @@ public partial class View
///
/// or are using , the will be adjusted to fit the text.
///
- /// The text alignment.
- public virtual VerticalTextAlignment VerticalTextAlignment
+ /// The vertical text alignment.
+ public virtual Alignment VerticalTextAlignment
{
get => TextFormatter.VerticalAlignment;
set
diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs
index 52c72ab5f..5b1cfcf3d 100644
--- a/Terminal.Gui/Views/Button.cs
+++ b/Terminal.Gui/Views/Button.cs
@@ -37,8 +37,8 @@ public class Button : View
/// The width of the is computed based on the text length. The height will always be 1.
public Button ()
{
- TextAlignment = TextAlignment.Centered;
- VerticalTextAlignment = VerticalTextAlignment.Middle;
+ TextAlignment = Alignment.Center;
+ VerticalTextAlignment = Alignment.Center;
_leftBracket = Glyphs.LeftBracket;
_rightBracket = Glyphs.RightBracket;
diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs
index 5971c02ed..cf0adeefc 100644
--- a/Terminal.Gui/Views/CheckBox.cs
+++ b/Terminal.Gui/Views/CheckBox.cs
@@ -155,13 +155,13 @@ public class CheckBox : View
{
switch (TextAlignment)
{
- case TextAlignment.Left:
- case TextAlignment.Centered:
- case TextAlignment.Justified:
+ case Alignment.Start:
+ case Alignment.Center:
+ case Alignment.Fill:
TextFormatter.Text = $"{GetCheckedState ()} {Text}";
break;
- case TextAlignment.Right:
+ case Alignment.End:
TextFormatter.Text = $"{Text} {GetCheckedState ()}";
break;
diff --git a/Terminal.Gui/Views/DatePicker.cs b/Terminal.Gui/Views/DatePicker.cs
index 613051fbe..d0cb41330 100644
--- a/Terminal.Gui/Views/DatePicker.cs
+++ b/Terminal.Gui/Views/DatePicker.cs
@@ -215,7 +215,6 @@ public class DatePicker : View
{
X = Pos.Center () - 2,
Y = Pos.Bottom (_calendar) - 1,
- Height = 1,
Width = 2,
Text = GetBackButtonText (),
WantContinuousButtonPressed = true,
@@ -234,7 +233,6 @@ public class DatePicker : View
{
X = Pos.Right (_previousMonthButton) + 2,
Y = Pos.Bottom (_calendar) - 1,
- Height = 1,
Width = 2,
Text = GetForwardButtonText (),
WantContinuousButtonPressed = true,
@@ -273,8 +271,8 @@ public class DatePicker : View
Text = _date.ToString (Format);
};
- Height = Dim.Auto ();
- Width = Dim.Auto ();
+ Width = Dim.Auto (DimAutoStyle.Content);
+ Height = Dim.Auto (DimAutoStyle.Content);
// BUGBUG: Remove when Dim.Auto(subviews) fully works
SetContentSize (new (_calendar.Style.ColumnStyles.Sum (c => c.Value.MinWidth) + 7, _calendar.Frame.Height + 1));
diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs
index 9a964d86c..8d31511b1 100644
--- a/Terminal.Gui/Views/Dialog.cs
+++ b/Terminal.Gui/Views/Dialog.cs
@@ -15,21 +15,6 @@ namespace Terminal.Gui;
///
public class Dialog : Window
{
- /// Determines the horizontal alignment of the Dialog buttons.
- public enum ButtonAlignments
- {
- /// Center-aligns the buttons (the default).
- Center = 0,
-
- /// Justifies the buttons
- Justify,
-
- /// Left-aligns the buttons
- Left,
-
- /// Right-aligns the buttons
- Right
- }
// TODO: Reenable once border/borderframe design is settled
///
@@ -59,27 +44,25 @@ public class Dialog : Window
Y = Pos.Center ();
//ValidatePosDim = true;
- Width = Dim.Percent (85);
+ Width = Dim.Percent (85);
Height = Dim.Percent (85);
ColorScheme = Colors.ColorSchemes ["Dialog"];
Modal = true;
ButtonAlignment = DefaultButtonAlignment;
+ ButtonAlignmentModes = DefaultButtonAlignmentModes;
- AddCommand (Command.QuitToplevel, () =>
- {
- Canceled = true;
- RequestStop ();
- return true;
- });
+ AddCommand (
+ Command.QuitToplevel,
+ () =>
+ {
+ Canceled = true;
+ RequestStop ();
+
+ return true;
+ });
KeyBindings.Add (Key.Esc, Command.QuitToplevel);
- Initialized += Dialog_Initialized; ;
- }
-
- private void Dialog_Initialized (object sender, EventArgs e)
- {
- LayoutButtons ();
}
private bool _canceled;
@@ -107,12 +90,19 @@ public class Dialog : Window
}
#endif
_canceled = value;
+
return;
}
}
+ // TODO: Update button.X = Pos.Justify when alignment changes
/// Determines how the s are aligned along the bottom of the dialog.
- public ButtonAlignments ButtonAlignment { get; set; }
+ public Alignment ButtonAlignment { get; set; }
+
+ ///
+ /// Gets or sets the alignment modes for the dialog's buttons.
+ ///
+ public AlignmentModes ButtonAlignmentModes { get; set; }
/// Optional buttons to lay out at the bottom of the dialog.
public Button [] Buttons
@@ -132,11 +122,17 @@ public class Dialog : Window
}
}
- /// The default for .
+ /// The default for .
/// This property can be set in a Theme.
[SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
[JsonConverter (typeof (JsonStringEnumConverter))]
- public static ButtonAlignments DefaultButtonAlignment { get; set; } = ButtonAlignments.Center;
+ public static Alignment DefaultButtonAlignment { get; set; } = Alignment.End;
+
+ /// The default for .
+ /// This property can be set in a Theme.
+ [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
+ [JsonConverter (typeof (JsonStringEnumConverter))]
+ public static AlignmentModes DefaultButtonAlignmentModes { get; set; } = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems;
///
/// Adds a to the , its layout will be controlled by the
@@ -150,6 +146,10 @@ public class Dialog : Window
return;
}
+ // Use a distinct GroupId so users can use Pos.Align for other views in the Dialog
+ button.X = Pos.Align (ButtonAlignment, ButtonAlignmentModes, groupId: GetHashCode ());
+ button.Y = Pos.AnchorEnd ();
+
_buttons.Add (button);
Add (button);
@@ -189,109 +189,4 @@ public class Dialog : Window
return widths.Sum ();
}
-
- private void LayoutButtons ()
- {
- if (_buttons.Count == 0 || !IsInitialized)
- {
- return;
- }
-
- var shiftLeft = 0;
-
- int buttonsWidth = GetButtonsWidth ();
-
- switch (ButtonAlignment)
- {
- case ButtonAlignments.Center:
- // Center Buttons
- shiftLeft = (Viewport.Width - buttonsWidth - _buttons.Count - 1) / 2 + 1;
-
- for (int i = _buttons.Count - 1; i >= 0; i--)
- {
- Button button = _buttons [i];
- shiftLeft += button.Frame.Width + (i == _buttons.Count - 1 ? 0 : 1);
-
- if (shiftLeft > -1)
- {
- button.X = Pos.AnchorEnd (shiftLeft);
- }
- else
- {
- button.X = Viewport.Width - shiftLeft;
- }
-
- button.Y = Pos.AnchorEnd ();
- }
-
- break;
-
- case ButtonAlignments.Justify:
- // Justify Buttons
- // leftmost and rightmost buttons are hard against edges. The rest are evenly spaced.
-
- var spacing = (int)Math.Ceiling ((double)(Viewport.Width - buttonsWidth) / (_buttons.Count - 1));
-
- for (int i = _buttons.Count - 1; i >= 0; i--)
- {
- Button button = _buttons [i];
-
- if (i == _buttons.Count - 1)
- {
- shiftLeft += button.Frame.Width;
- button.X = Pos.AnchorEnd (shiftLeft);
- }
- else
- {
- if (i == 0)
- {
- // first (leftmost) button
- int left = Viewport.Width;
- button.X = Pos.AnchorEnd (left);
- }
- else
- {
- shiftLeft += button.Frame.Width + spacing;
- button.X = Pos.AnchorEnd (shiftLeft);
- }
- }
-
- button.Y = Pos.AnchorEnd ();
- }
-
- break;
-
- case ButtonAlignments.Left:
- // Left Align Buttons
- Button prevButton = _buttons [0];
- prevButton.X = 0;
- prevButton.Y = Pos.AnchorEnd (1);
-
- for (var i = 1; i < _buttons.Count; i++)
- {
- Button button = _buttons [i];
- button.X = Pos.Right (prevButton) + 1;
- button.Y = Pos.AnchorEnd (1);
- prevButton = button;
- }
-
- break;
-
- case ButtonAlignments.Right:
- // Right align buttons
- shiftLeft = _buttons [_buttons.Count - 1].Frame.Width;
- _buttons [_buttons.Count - 1].X = Pos.AnchorEnd (shiftLeft);
- _buttons [_buttons.Count - 1].Y = Pos.AnchorEnd (1);
-
- for (int i = _buttons.Count - 2; i >= 0; i--)
- {
- Button button = _buttons [i];
- shiftLeft += button.Frame.Width + 1;
- button.X = Pos.AnchorEnd (shiftLeft);
- button.Y = Pos.AnchorEnd ();
- }
-
- break;
- }
- }
}
diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs
index 725fe6bd8..bf2586185 100644
--- a/Terminal.Gui/Views/ListView.cs
+++ b/Terminal.Gui/Views/ListView.cs
@@ -1002,7 +1002,7 @@ public class ListWrapper : IListDataSource
private void RenderUstr (ConsoleDriver driver, string ustr, int col, int line, int width, int start = 0)
{
string str = start > ustr.GetColumns () ? string.Empty : ustr.Substring (Math.Min (start, ustr.ToRunes ().Length - 1));
- string u = TextFormatter.ClipAndJustify (str, width, TextAlignment.Left);
+ string u = TextFormatter.ClipAndJustify (str, width, Alignment.Start);
driver.AddStr (u);
width -= u.GetColumns ();
diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs
index 11bc71c7e..17e92cd1d 100644
--- a/Terminal.Gui/Views/Menu/Menu.cs
+++ b/Terminal.Gui/Views/Menu/Menu.cs
@@ -890,7 +890,7 @@ internal sealed class Menu : View
var tf = new TextFormatter
{
AutoSize = true,
- Alignment = TextAlignment.Centered, HotKeySpecifier = MenuBar.HotKeySpecifier, Text = textToDraw
+ Alignment = Alignment.Center, HotKeySpecifier = MenuBar.HotKeySpecifier, Text = textToDraw
};
// The -3 is left/right border + one space (not sure what for)
diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs
index 74826cc41..10a40ec39 100644
--- a/Terminal.Gui/Views/MessageBox.cs
+++ b/Terminal.Gui/Views/MessageBox.cs
@@ -325,7 +325,10 @@ public static class MessageBox
foreach (string s in buttons)
{
- var b = new Button { Text = s };
+ var b = new Button
+ {
+ Text = s,
+ };
if (count == defaultButton)
{
@@ -337,10 +340,10 @@ public static class MessageBox
}
}
- Dialog d;
-
- d = new Dialog
+ var d = new Dialog
{
+ ButtonAlignment = Alignment.Center,
+ ButtonAlignmentModes = AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems,
Buttons = buttonList.ToArray (),
Title = title,
BorderStyle = DefaultBorderStyle,
@@ -370,7 +373,7 @@ public static class MessageBox
var messageLabel = new Label
{
Text = message,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
X = Pos.Center (),
Y = 0,
// ColorScheme = Colors.ColorSchemes ["Error"]
diff --git a/Terminal.Gui/Views/OrientationEventArgs.cs b/Terminal.Gui/Views/OrientationEventArgs.cs
new file mode 100644
index 000000000..8a633ca83
--- /dev/null
+++ b/Terminal.Gui/Views/OrientationEventArgs.cs
@@ -0,0 +1,19 @@
+namespace Terminal.Gui;
+
+/// for events.
+public class OrientationEventArgs : EventArgs
+{
+ /// Constructs a new instance.
+ /// the new orientation
+ public OrientationEventArgs (Orientation orientation)
+ {
+ Orientation = orientation;
+ Cancel = false;
+ }
+
+ /// If set to true, the orientation change operation will be canceled, if applicable.
+ public bool Cancel { get; set; }
+
+ /// The new orientation.
+ public Orientation Orientation { get; set; }
+}
\ No newline at end of file
diff --git a/Terminal.Gui/Views/ProgressBar.cs b/Terminal.Gui/Views/ProgressBar.cs
index f599b299f..80b7545b7 100644
--- a/Terminal.Gui/Views/ProgressBar.cs
+++ b/Terminal.Gui/Views/ProgressBar.cs
@@ -175,7 +175,7 @@ public class ProgressBar : View
if (ProgressBarFormat != ProgressBarFormat.Simple && !_isActivity)
{
- var tf = new TextFormatter { Alignment = TextAlignment.Centered, Text = Text, AutoSize = true };
+ var tf = new TextFormatter { Alignment = Alignment.Center, Text = Text, AutoSize = true };
var attr = new Attribute (ColorScheme.HotNormal.Foreground, ColorScheme.HotNormal.Background);
if (_fraction > .5)
diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs
index 992bc72fa..c42247299 100644
--- a/Terminal.Gui/Views/Slider.cs
+++ b/Terminal.Gui/Views/Slider.cs
@@ -1,210 +1,5 @@
namespace Terminal.Gui;
-/// for events.
-public class SliderOptionEventArgs : EventArgs
-{
- /// Initializes a new instance of
- /// indicates whether the option is set
- public SliderOptionEventArgs (bool isSet) { IsSet = isSet; }
-
- /// Gets whether the option is set or not.
- public bool IsSet { get; }
-}
-
-/// Represents an option in a .
-/// Data type of the option.
-public class SliderOption
-{
- /// Creates a new empty instance of the class.
- public SliderOption () { }
-
- /// Creates a new instance of the class with values for each property.
- public SliderOption (string legend, Rune legendAbbr, T data)
- {
- Legend = legend;
- LegendAbbr = legendAbbr;
- Data = data;
- }
-
- /// Event fired when the an option has changed.
- public event EventHandler Changed;
-
- /// Custom data of the option.
- public T Data { get; set; }
-
- /// Legend of the option.
- public string Legend { get; set; }
-
- ///
- /// Abbreviation of the Legend. When the too small to fit
- /// .
- ///
- public Rune LegendAbbr { get; set; }
-
- /// Event Raised when this option is set.
- public event EventHandler Set;
-
- /// Creates a human-readable string that represents this .
- public override string ToString () { return "{Legend=" + Legend + ", LegendAbbr=" + LegendAbbr + ", Data=" + Data + "}"; }
-
- /// Event Raised when this option is unset.
- public event EventHandler UnSet;
-
- /// To Raise the event from the Slider.
- internal void OnChanged (bool isSet) { Changed?.Invoke (this, new (isSet)); }
-
- /// To Raise the event from the Slider.
- internal void OnSet () { Set?.Invoke (this, new (true)); }
-
- /// To Raise the event from the Slider.
- internal void OnUnSet () { UnSet?.Invoke (this, new (false)); }
-}
-
-/// Types
-public enum SliderType
-{
- ///
- ///
- /// ├─┼─┼─┼─┼─█─┼─┼─┼─┼─┼─┼─┤
- ///
- ///
- Single,
-
- ///
- ///
- /// ├─┼─█─┼─┼─█─┼─┼─┼─┼─█─┼─┤
- ///
- ///
- Multiple,
-
- ///
- ///
- /// ├▒▒▒▒▒▒▒▒▒█─┼─┼─┼─┼─┼─┼─┤
- ///
- ///
- LeftRange,
-
- ///
- ///
- /// ├─┼─┼─┼─┼─█▒▒▒▒▒▒▒▒▒▒▒▒▒┤
- ///
- ///
- RightRange,
-
- ///
- ///
- /// ├─┼─┼─┼─┼─█▒▒▒▒▒▒▒█─┼─┼─┤
- ///
- ///
- Range
-}
-
-/// Legend Style
-public class SliderAttributes
-{
- /// Attribute for the Legends Container.
- public Attribute? EmptyAttribute { get; set; }
-
- /// Attribute for when the respective Option is NOT Set.
- public Attribute? NormalAttribute { get; set; }
-
- /// Attribute for when the respective Option is Set.
- public Attribute? SetAttribute { get; set; }
-}
-
-/// Style
-public class SliderStyle
-{
- /// Constructs a new instance.
- public SliderStyle () { LegendAttributes = new (); }
-
- /// The glyph and the attribute to indicate mouse dragging.
- public Cell DragChar { get; set; }
-
- /// The glyph and the attribute used for empty spaces on the slider.
- public Cell EmptyChar { get; set; }
-
- /// The glyph and the attribute used for the end of ranges on the slider.
- public Cell EndRangeChar { get; set; }
-
- /// Legend attributes
- public SliderAttributes LegendAttributes { get; set; }
-
- /// The glyph and the attribute used for each option (tick) on the slider.
- public Cell OptionChar { get; set; }
-
- /// The glyph and the attribute used for filling in ranges on the slider.
- public Cell RangeChar { get; set; }
-
- /// The glyph and the attribute used for options (ticks) that are set on the slider.
- public Cell SetChar { get; set; }
-
- /// The glyph and the attribute used for spaces between options (ticks) on the slider.
- public Cell SpaceChar { get; set; }
-
- /// The glyph and the attribute used for the start of ranges on the slider.
- public Cell StartRangeChar { get; set; }
-}
-
-/// All configuration are grouped in this class.
-internal class SliderConfiguration
-{
- internal bool _allowEmpty;
- internal int _endSpacing;
- internal int _minInnerSpacing = 1;
- internal int _cachedInnerSpacing; // Currently calculated
- internal Orientation _legendsOrientation = Orientation.Horizontal;
- internal bool _rangeAllowSingle;
- internal bool _showEndSpacing;
- internal bool _showLegends;
- internal bool _showLegendsAbbr;
- internal Orientation _sliderOrientation = Orientation.Horizontal;
- internal int _startSpacing;
- internal SliderType _type = SliderType.Single;
- internal bool _useMinimumSize;
-}
-
-/// for events.
-public class SliderEventArgs : EventArgs
-{
- /// Initializes a new instance of
- /// The current options.
- /// Index of the option that is focused. -1 if no option has the focus.
- public SliderEventArgs (Dictionary> options, int focused = -1)
- {
- Options = options;
- Focused = focused;
- Cancel = false;
- }
-
- /// If set to true, the focus operation will be canceled, if applicable.
- public bool Cancel { get; set; }
-
- /// Gets or sets the index of the option that is focused.
- public int Focused { get; set; }
-
- /// Gets/sets whether the option is set or not.
- public Dictionary> Options { get; set; }
-}
-
-/// for events.
-public class OrientationEventArgs : EventArgs
-{
- /// Constructs a new instance.
- /// the new orientation
- public OrientationEventArgs (Orientation orientation)
- {
- Orientation = orientation;
- Cancel = false;
- }
-
- /// If set to true, the orientation change operation will be canceled, if applicable.
- public bool Cancel { get; set; }
-
- /// The new orientation.
- public Orientation Orientation { get; set; }
-}
-
/// Slider control.
public class Slider : Slider
{
@@ -1002,7 +797,7 @@ public class Slider : View
}
}
- private string AlignText (string text, int width, TextAlignment textAlignment)
+ private string AlignText (string text, int width, Alignment alignment)
{
if (text is null)
{
@@ -1019,20 +814,20 @@ public class Slider : View
string s2 = new (' ', w % 2);
// Note: The formatter doesn't handle all of this ???
- switch (textAlignment)
+ switch (alignment)
{
- case TextAlignment.Justified:
+ case Alignment.Fill:
return TextFormatter.Justify (text, width);
- case TextAlignment.Left:
+ case Alignment.Start:
return text + s1 + s1 + s2;
- case TextAlignment.Centered:
+ case Alignment.Center:
if (text.Length % 2 != 0)
{
return s1 + text + s1 + s2;
}
return s1 + s2 + text + s1;
- case TextAlignment.Right:
+ case Alignment.End:
return s1 + s1 + s2 + text;
default:
return text;
@@ -1139,12 +934,6 @@ public class Slider : View
}
break;
- case SliderType.Single:
- break;
- case SliderType.Multiple:
- break;
- default:
- throw new ArgumentOutOfRangeException ();
}
}
@@ -1365,7 +1154,7 @@ public class Slider : View
switch (_config._legendsOrientation)
{
case Orientation.Horizontal:
- text = AlignText (text, _config._cachedInnerSpacing + 1, TextAlignment.Centered);
+ text = AlignText (text, _config._cachedInnerSpacing + 1, Alignment.Center);
break;
case Orientation.Vertical:
@@ -1383,7 +1172,7 @@ public class Slider : View
break;
case Orientation.Vertical:
- text = AlignText (text, _config._cachedInnerSpacing + 1, TextAlignment.Centered);
+ text = AlignText (text, _config._cachedInnerSpacing + 1, Alignment.Center);
break;
}
diff --git a/Terminal.Gui/Views/SliderAttributes.cs b/Terminal.Gui/Views/SliderAttributes.cs
new file mode 100644
index 000000000..6f75546dd
--- /dev/null
+++ b/Terminal.Gui/Views/SliderAttributes.cs
@@ -0,0 +1,14 @@
+namespace Terminal.Gui;
+
+/// Legend Style
+public class SliderAttributes
+{
+ /// Attribute for the Legends Container.
+ public Attribute? EmptyAttribute { get; set; }
+
+ /// Attribute for when the respective Option is NOT Set.
+ public Attribute? NormalAttribute { get; set; }
+
+ /// Attribute for when the respective Option is Set.
+ public Attribute? SetAttribute { get; set; }
+}
\ No newline at end of file
diff --git a/Terminal.Gui/Views/SliderConfiguration.cs b/Terminal.Gui/Views/SliderConfiguration.cs
new file mode 100644
index 000000000..3cadafd86
--- /dev/null
+++ b/Terminal.Gui/Views/SliderConfiguration.cs
@@ -0,0 +1,19 @@
+namespace Terminal.Gui;
+
+/// All configuration are grouped in this class.
+internal class SliderConfiguration
+{
+ internal bool _allowEmpty;
+ internal int _endSpacing;
+ internal int _minInnerSpacing = 1;
+ internal int _cachedInnerSpacing; // Currently calculated
+ internal Orientation _legendsOrientation = Orientation.Horizontal;
+ internal bool _rangeAllowSingle;
+ internal bool _showEndSpacing;
+ internal bool _showLegends;
+ internal bool _showLegendsAbbr;
+ internal Orientation _sliderOrientation = Orientation.Horizontal;
+ internal int _startSpacing;
+ internal SliderType _type = SliderType.Single;
+ internal bool _useMinimumSize;
+}
\ No newline at end of file
diff --git a/Terminal.Gui/Views/SliderEventArgs.cs b/Terminal.Gui/Views/SliderEventArgs.cs
new file mode 100644
index 000000000..76c4eed90
--- /dev/null
+++ b/Terminal.Gui/Views/SliderEventArgs.cs
@@ -0,0 +1,24 @@
+namespace Terminal.Gui;
+
+/// for events.
+public class SliderEventArgs : EventArgs
+{
+ /// Initializes a new instance of
+ /// The current options.
+ /// Index of the option that is focused. -1 if no option has the focus.
+ public SliderEventArgs (Dictionary> options, int focused = -1)
+ {
+ Options = options;
+ Focused = focused;
+ Cancel = false;
+ }
+
+ /// If set to true, the focus operation will be canceled, if applicable.
+ public bool Cancel { get; set; }
+
+ /// Gets or sets the index of the option that is focused.
+ public int Focused { get; set; }
+
+ /// Gets/sets whether the option is set or not.
+ public Dictionary> Options { get; set; }
+}
\ No newline at end of file
diff --git a/Terminal.Gui/Views/SliderOption.cs b/Terminal.Gui/Views/SliderOption.cs
new file mode 100644
index 000000000..1cfcc1f07
--- /dev/null
+++ b/Terminal.Gui/Views/SliderOption.cs
@@ -0,0 +1,50 @@
+namespace Terminal.Gui;
+
+/// Represents an option in a .
+/// Data type of the option.
+public class SliderOption
+{
+ /// Creates a new empty instance of the class.
+ public SliderOption () { }
+
+ /// Creates a new instance of the class with values for each property.
+ public SliderOption (string legend, Rune legendAbbr, T data)
+ {
+ Legend = legend;
+ LegendAbbr = legendAbbr;
+ Data = data;
+ }
+
+ /// Event fired when the an option has changed.
+ public event EventHandler Changed;
+
+ /// Custom data of the option.
+ public T Data { get; set; }
+
+ /// Legend of the option.
+ public string Legend { get; set; }
+
+ ///
+ /// Abbreviation of the Legend. When the too small to fit
+ /// .
+ ///
+ public Rune LegendAbbr { get; set; }
+
+ /// Event Raised when this option is set.
+ public event EventHandler Set;
+
+ /// Creates a human-readable string that represents this .
+ public override string ToString () { return "{Legend=" + Legend + ", LegendAbbr=" + LegendAbbr + ", Data=" + Data + "}"; }
+
+ /// Event Raised when this option is unset.
+ public event EventHandler UnSet;
+
+ /// To Raise the event from the Slider.
+ internal void OnChanged (bool isSet) { Changed?.Invoke (this, new (isSet)); }
+
+ /// To Raise the event from the Slider.
+ internal void OnSet () { Set?.Invoke (this, new (true)); }
+
+ /// To Raise the event from the Slider.
+ internal void OnUnSet () { UnSet?.Invoke (this, new (false)); }
+}
\ No newline at end of file
diff --git a/Terminal.Gui/Views/SliderOptionEventArgs.cs b/Terminal.Gui/Views/SliderOptionEventArgs.cs
new file mode 100644
index 000000000..b4b5e6936
--- /dev/null
+++ b/Terminal.Gui/Views/SliderOptionEventArgs.cs
@@ -0,0 +1,12 @@
+namespace Terminal.Gui;
+
+/// for events.
+public class SliderOptionEventArgs : EventArgs
+{
+ /// Initializes a new instance of
+ /// indicates whether the option is set
+ public SliderOptionEventArgs (bool isSet) { IsSet = isSet; }
+
+ /// Gets whether the option is set or not.
+ public bool IsSet { get; }
+}
\ No newline at end of file
diff --git a/Terminal.Gui/Views/SliderStyle.cs b/Terminal.Gui/Views/SliderStyle.cs
new file mode 100644
index 000000000..e6429d6cb
--- /dev/null
+++ b/Terminal.Gui/Views/SliderStyle.cs
@@ -0,0 +1,35 @@
+namespace Terminal.Gui;
+
+/// Style
+public class SliderStyle
+{
+ /// Constructs a new instance.
+ public SliderStyle () { LegendAttributes = new (); }
+
+ /// The glyph and the attribute to indicate mouse dragging.
+ public Cell DragChar { get; set; }
+
+ /// The glyph and the attribute used for empty spaces on the slider.
+ public Cell EmptyChar { get; set; }
+
+ /// The glyph and the attribute used for the end of ranges on the slider.
+ public Cell EndRangeChar { get; set; }
+
+ /// Legend attributes
+ public SliderAttributes LegendAttributes { get; set; }
+
+ /// The glyph and the attribute used for each option (tick) on the slider.
+ public Cell OptionChar { get; set; }
+
+ /// The glyph and the attribute used for filling in ranges on the slider.
+ public Cell RangeChar { get; set; }
+
+ /// The glyph and the attribute used for options (ticks) that are set on the slider.
+ public Cell SetChar { get; set; }
+
+ /// The glyph and the attribute used for spaces between options (ticks) on the slider.
+ public Cell SpaceChar { get; set; }
+
+ /// The glyph and the attribute used for the start of ranges on the slider.
+ public Cell StartRangeChar { get; set; }
+}
\ No newline at end of file
diff --git a/Terminal.Gui/Views/SliderType.cs b/Terminal.Gui/Views/SliderType.cs
new file mode 100644
index 000000000..7cbde908a
--- /dev/null
+++ b/Terminal.Gui/Views/SliderType.cs
@@ -0,0 +1,40 @@
+namespace Terminal.Gui;
+
+/// Types
+public enum SliderType
+{
+ ///
+ ///
+ /// ├─┼─┼─┼─┼─█─┼─┼─┼─┼─┼─┼─┤
+ ///
+ ///
+ Single,
+
+ ///
+ ///
+ /// ├─┼─█─┼─┼─█─┼─┼─┼─┼─█─┼─┤
+ ///
+ ///
+ Multiple,
+
+ ///
+ ///
+ /// ├▒▒▒▒▒▒▒▒▒█─┼─┼─┼─┼─┼─┼─┤
+ ///
+ ///
+ LeftRange,
+
+ ///
+ ///
+ /// ├─┼─┼─┼─┼─█▒▒▒▒▒▒▒▒▒▒▒▒▒┤
+ ///
+ ///
+ RightRange,
+
+ ///
+ ///
+ /// ├─┼─┼─┼─┼─█▒▒▒▒▒▒▒█─┼─┼─┤
+ ///
+ ///
+ Range
+}
\ No newline at end of file
diff --git a/Terminal.Gui/Views/TableView/ColumnStyle.cs b/Terminal.Gui/Views/TableView/ColumnStyle.cs
index cbbc2a3ac..2d277abd9 100644
--- a/Terminal.Gui/Views/TableView/ColumnStyle.cs
+++ b/Terminal.Gui/Views/TableView/ColumnStyle.cs
@@ -8,10 +8,10 @@
public class ColumnStyle
{
///
- /// Defines a delegate for returning custom alignment per cell based on cell values. When specified this will
+ /// Defines a delegate for returning custom alignment per cell based on cell values. When specified this will
/// override
///
- public Func AlignmentGetter;
+ public Func AlignmentGetter;
///
/// Defines a delegate for returning a custom color scheme per cell based on cell values. Return null for the
@@ -20,26 +20,26 @@ public class ColumnStyle
public CellColorGetterDelegate ColorGetter;
///
- /// Defines a delegate for returning custom representations of cell values. If not set then
- /// is used. Return values from your delegate may be truncated e.g. based on
+ /// Defines a delegate for returning custom representations of cell values. If not set then
+ /// is used. Return values from your delegate may be truncated e.g. based on
///
///
public Func RepresentationGetter;
- private bool visible = true;
+ private bool _visible = true;
///
- /// Defines the default alignment for all values rendered in this column. For custom alignment based on cell
+ /// Defines the default alignment for all values rendered in this column. For custom alignment based on cell
/// contents use .
///
- public TextAlignment Alignment { get; set; }
+ public Alignment Alignment { get; set; }
/// Defines the format for values e.g. "yyyy-MM-dd" for dates
public string Format { get; set; }
///
- /// Set the maximum width of the column in characters. This value will be ignored if more than the tables
- /// . Defaults to
+ /// Set the maximum width of the column in characters. This value will be ignored if more than the tables
+ /// . Defaults to
///
public int MaxWidth { get; set; } = TableView.DefaultMaxCellWidth;
@@ -47,7 +47,7 @@ public class ColumnStyle
public int MinAcceptableWidth { get; set; } = TableView.DefaultMinAcceptableWidth;
///
- /// Set the minimum width of the column in characters. Setting this will ensure that even when a column has short
+ /// Set the minimum width of the column in characters. Setting this will ensure that even when a column has short
/// content/header it still fills a given width of the control.
///
/// This value will be ignored if more than the tables or the
@@ -64,8 +64,8 @@ public class ColumnStyle
/// If is 0 then will always return false.
public bool Visible
{
- get => MaxWidth >= 0 && visible;
- set => visible = value;
+ get => MaxWidth >= 0 && _visible;
+ set => _visible = value;
}
///
@@ -74,7 +74,7 @@ public class ColumnStyle
///
///
///
- public TextAlignment GetAlignment (object cellValue)
+ public Alignment GetAlignment (object cellValue)
{
if (AlignmentGetter is { })
{
diff --git a/Terminal.Gui/Views/TableView/TableStyle.cs b/Terminal.Gui/Views/TableView/TableStyle.cs
index 2cf258bee..4dd947734 100644
--- a/Terminal.Gui/Views/TableView/TableStyle.cs
+++ b/Terminal.Gui/Views/TableView/TableStyle.cs
@@ -15,11 +15,11 @@ public class TableStyle
///
public bool AlwaysUseNormalColorForVerticalCellLines { get; set; } = false;
- /// Collection of columns for which you want special rendering (e.g. custom column lengths, text alignment etc)
+ /// Collection of columns for which you want special rendering (e.g. custom column lengths, text justification, etc.)
public Dictionary ColumnStyles { get; set; } = new ();
///
- /// Determines rendering when the last column in the table is visible but it's content or
+ /// Determines rendering when the last column in the table is visible, but it's content or
/// is less than the remaining space in the control. True (the default) will expand
/// the column to fill the remaining bounds of the control. False will draw a column ending line and leave a blank
/// column that cannot be selected in the remaining space.
diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs
index 0c39895e3..5e8ed2d74 100644
--- a/Terminal.Gui/Views/TableView/TableView.cs
+++ b/Terminal.Gui/Views/TableView/TableView.cs
@@ -2116,16 +2116,16 @@ public class TableView : View
- (representation.EnumerateRunes ().Sum (c => c.GetColumns ())
+ 1 /*leave 1 space for cell boundary*/);
- switch (colStyle?.GetAlignment (originalCellValue) ?? TextAlignment.Left)
+ switch (colStyle?.GetAlignment (originalCellValue) ?? Alignment.Start)
{
- case TextAlignment.Left:
+ case Alignment.Start:
return representation + new string (' ', toPad);
- case TextAlignment.Right:
+ case Alignment.End:
return new string (' ', toPad) + representation;
// TODO: With single line cells, centered and justified are the same right?
- case TextAlignment.Centered:
- case TextAlignment.Justified:
+ case Alignment.Center:
+ case Alignment.Fill:
return
new string (' ', (int)Math.Floor (toPad / 2.0))
+ // round down
diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs
index 268bf0c73..3aac68f09 100644
--- a/Terminal.Gui/Views/TextValidateField.cs
+++ b/Terminal.Gui/Views/TextValidateField.cs
@@ -539,7 +539,7 @@ namespace Terminal.Gui
{
int c = _provider.Cursor (mouseEvent.Position.X - GetMargins (Viewport.Width).left);
- if (_provider.Fixed == false && TextAlignment == TextAlignment.Right && Text.Length > 0)
+ if (_provider.Fixed == false && TextAlignment == Alignment.End && Text.Length > 0)
{
c++;
}
@@ -633,7 +633,7 @@ namespace Terminal.Gui
// When it's right-aligned and it's a normal input, the cursor behaves differently.
int curPos;
- if (_provider?.Fixed == false && TextAlignment == TextAlignment.Right)
+ if (_provider?.Fixed == false && TextAlignment == Alignment.End)
{
curPos = _cursorPosition + left - 1;
}
@@ -650,7 +650,7 @@ namespace Terminal.Gui
///
private bool BackspaceKeyHandler ()
{
- if (_provider.Fixed == false && TextAlignment == TextAlignment.Right && _cursorPosition <= 1)
+ if (_provider.Fixed == false && TextAlignment == Alignment.End && _cursorPosition <= 1)
{
return false;
}
@@ -688,7 +688,7 @@ namespace Terminal.Gui
///
private bool DeleteKeyHandler ()
{
- if (_provider.Fixed == false && TextAlignment == TextAlignment.Right)
+ if (_provider.Fixed == false && TextAlignment == Alignment.End)
{
_cursorPosition = _provider.CursorLeft (_cursorPosition);
}
@@ -719,11 +719,11 @@ namespace Terminal.Gui
switch (TextAlignment)
{
- case TextAlignment.Left:
+ case Alignment.Start:
return (0, total);
- case TextAlignment.Centered:
+ case Alignment.Center:
return (total / 2, total / 2 + total % 2);
- case TextAlignment.Right:
+ case Alignment.End:
return (total, 0);
default:
return (0, total);
diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs
index 7a70a94d0..d36fcda57 100644
--- a/Terminal.Gui/Views/TextView.cs
+++ b/Terminal.Gui/Views/TextView.cs
@@ -1784,7 +1784,7 @@ internal class WordWrapManager
TextFormatter.Format (
TextModel.ToString (line),
width,
- TextAlignment.Left,
+ Alignment.Start,
true,
preserveTrailingSpaces,
tabWidth
@@ -4161,7 +4161,10 @@ public class TextView : View
}
else
{
- PositionCursor ();
+ if (IsInitialized)
+ {
+ PositionCursor ();
+ }
}
OnUnwrappedCursorPosition ();
diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs
index 205739d44..deeda162d 100644
--- a/Terminal.Gui/Views/Wizard/Wizard.cs
+++ b/Terminal.Gui/Views/Wizard/Wizard.cs
@@ -54,23 +54,6 @@ public class Wizard : Dialog
private readonly LinkedList _steps = new ();
private WizardStep _currentStep;
private bool _finishedPressed;
-
- /////
- ///// The title of the Wizard, shown at the top of the Wizard with " - currentStep.Title" appended.
- /////
- /////
- ///// The Title is only displayed when the is set to false .
- /////
- //public new string Title {
- // get {
- // // The base (Dialog) Title holds the full title ("Wizard Title - Step Title")
- // return base.Title;
- // }
- // set {
- // wizardTitle = value;
- // base.Title = $"{wizardTitle}{(steps.Count > 0 && currentStep is { } ? " - " + currentStep.Title : string.Empty)}";
- // }
- //}
private string _wizardTitle = string.Empty;
///
@@ -83,9 +66,9 @@ public class Wizard : Dialog
///
public Wizard ()
{
- // Using Justify causes the Back and Next buttons to be hard justified against
- // the left and right edge
- ButtonAlignment = ButtonAlignments.Justify;
+ // TODO: LastEndRestStart will enable a "Quit" button to always appear at the far left
+ ButtonAlignment = Alignment.Start;
+ ButtonAlignmentModes |= AlignmentModes.IgnoreFirstOrLast;
BorderStyle = LineStyle.Double;
//// Add a horiz separator
diff --git a/Terminal.sln.DotSettings b/Terminal.sln.DotSettings
index ca15b5583..8ca3af1c0 100644
--- a/Terminal.sln.DotSettings
+++ b/Terminal.sln.DotSettings
@@ -391,6 +391,7 @@
<Policy><Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy>
<Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy>
<Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy>
+ PushToShowHints
True
True
True
@@ -439,5 +440,6 @@
Concurrency Issue
(?<=\W|^)(?<TAG>CONCURRENCY:)(\W|$)(.*)
Warning
+ True
True
diff --git a/UICatalog/Scenarios/AllViewsTester.cs b/UICatalog/Scenarios/AllViewsTester.cs
index faea44377..fd76ed158 100644
--- a/UICatalog/Scenarios/AllViewsTester.cs
+++ b/UICatalog/Scenarios/AllViewsTester.cs
@@ -42,14 +42,14 @@ public class AllViewsTester : Scenario
private string _demoText = "This, that, and the other thing.";
private TextView _demoTextView;
- public override void Init ()
+ public override void Main ()
{
// Don't create a sub-win (Scenario.Win); just use Application.Top
Application.Init ();
- ConfigurationManager.Themes.Theme = Theme;
ConfigurationManager.Apply ();
- Top = new ();
- Top.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
+
+ var app = new Window ();
+ app.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
var statusBar = new StatusBar (
new StatusItem []
@@ -66,7 +66,7 @@ public class AllViewsTester : Scenario
{
View.Diagnostics ^=
ViewDiagnosticFlags.Ruler;
- Top.SetNeedsDisplay ();
+ app.SetNeedsDisplay ();
}
),
new (
@@ -76,12 +76,12 @@ public class AllViewsTester : Scenario
{
View.Diagnostics ^=
ViewDiagnosticFlags.Padding;
- Top.SetNeedsDisplay ();
+ app.SetNeedsDisplay ();
}
)
}
);
- Top.Add (statusBar);
+ app.Add (statusBar);
_viewClasses = GetAllViewClassesCollection ()
.OrderBy (t => t.Name)
@@ -145,7 +145,7 @@ public class AllViewsTester : Scenario
{
X = 0,
Y = 0,
- Height = Dim.Auto (),
+ Height = Dim.Auto (),
Width = Dim.Auto (),
Title = "Location (Pos)"
};
@@ -279,7 +279,7 @@ public class AllViewsTester : Scenario
};
_orientation.SelectedItemChanged += (s, selected) =>
{
- if (_curView?.GetType ().GetProperty ("Orientation") is {} prop)
+ if (_curView?.GetType ().GetProperty ("Orientation") is { } prop)
{
prop.GetSetMethod ()?.Invoke (_curView, new object [] { _orientation.SelectedItem });
}
@@ -312,9 +312,13 @@ public class AllViewsTester : Scenario
ColorScheme = Colors.ColorSchemes ["Dialog"]
};
- Top.Add (_leftPane, _settingsPane, _hostPane);
+ app.Add (_leftPane, _settingsPane, _hostPane);
_curView = CreateClass (_viewClasses.First ().Value);
+
+ Application.Run (app);
+ app.Dispose ();
+ Application.Shutdown ();
}
// TODO: Add Command.HotKey handler (pop a message box?)
@@ -389,9 +393,9 @@ public class AllViewsTester : Scenario
}
// If the view supports a Title property, set it so we have something to look at
- if (view?.GetType ().GetProperty ("Orientation") is {} prop)
+ if (view?.GetType ().GetProperty ("Orientation") is { } prop)
{
- _orientation.SelectedItem = (int)prop.GetGetMethod()!.Invoke (view, null)!;
+ _orientation.SelectedItem = (int)prop.GetGetMethod ()!.Invoke (view, null)!;
_orientation.Enabled = true;
}
else
diff --git a/UICatalog/Scenarios/BasicColors.cs b/UICatalog/Scenarios/BasicColors.cs
index 1780d7cbb..b1b75c54f 100644
--- a/UICatalog/Scenarios/BasicColors.cs
+++ b/UICatalog/Scenarios/BasicColors.cs
@@ -32,7 +32,7 @@ public class BasicColors : Scenario
Y = 0,
Width = 1,
Height = 13,
- VerticalTextAlignment = VerticalTextAlignment.Bottom,
+ VerticalTextAlignment = Alignment.End,
ColorScheme = new ColorScheme { Normal = attr },
Text = bg.ToString (),
TextDirection = TextDirection.TopBottom_LeftRight
@@ -45,7 +45,7 @@ public class BasicColors : Scenario
Y = y,
Width = 13,
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
ColorScheme = new ColorScheme { Normal = attr },
Text = bg.ToString ()
};
diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs
index 6ba57e02f..d8e612ae5 100644
--- a/UICatalog/Scenarios/Buttons.cs
+++ b/UICatalog/Scenarios/Buttons.cs
@@ -218,7 +218,7 @@ public class Buttons : Scenario
X = 4,
Y = Pos.Bottom (label) + 1,
SelectedItem = 2,
- RadioLabels = new [] { "Left", "Right", "Centered", "Justified" }
+ RadioLabels = new [] { "Start", "End", "Center", "Fill" }
};
main.Add (radioGroup);
@@ -287,39 +287,39 @@ public class Buttons : Scenario
switch (args.SelectedItem)
{
case 0:
- moveBtn.TextAlignment = TextAlignment.Left;
- sizeBtn.TextAlignment = TextAlignment.Left;
- moveBtnA.TextAlignment = TextAlignment.Left;
- sizeBtnA.TextAlignment = TextAlignment.Left;
- moveHotKeyBtn.TextAlignment = TextAlignment.Left;
- moveUnicodeHotKeyBtn.TextAlignment = TextAlignment.Left;
+ moveBtn.TextAlignment = Alignment.Start;
+ sizeBtn.TextAlignment = Alignment.Start;
+ moveBtnA.TextAlignment = Alignment.Start;
+ sizeBtnA.TextAlignment = Alignment.Start;
+ moveHotKeyBtn.TextAlignment = Alignment.Start;
+ moveUnicodeHotKeyBtn.TextAlignment = Alignment.Start;
break;
case 1:
- moveBtn.TextAlignment = TextAlignment.Right;
- sizeBtn.TextAlignment = TextAlignment.Right;
- moveBtnA.TextAlignment = TextAlignment.Right;
- sizeBtnA.TextAlignment = TextAlignment.Right;
- moveHotKeyBtn.TextAlignment = TextAlignment.Right;
- moveUnicodeHotKeyBtn.TextAlignment = TextAlignment.Right;
+ moveBtn.TextAlignment = Alignment.End;
+ sizeBtn.TextAlignment = Alignment.End;
+ moveBtnA.TextAlignment = Alignment.End;
+ sizeBtnA.TextAlignment = Alignment.End;
+ moveHotKeyBtn.TextAlignment = Alignment.End;
+ moveUnicodeHotKeyBtn.TextAlignment = Alignment.End;
break;
case 2:
- moveBtn.TextAlignment = TextAlignment.Centered;
- sizeBtn.TextAlignment = TextAlignment.Centered;
- moveBtnA.TextAlignment = TextAlignment.Centered;
- sizeBtnA.TextAlignment = TextAlignment.Centered;
- moveHotKeyBtn.TextAlignment = TextAlignment.Centered;
- moveUnicodeHotKeyBtn.TextAlignment = TextAlignment.Centered;
+ moveBtn.TextAlignment = Alignment.Center;
+ sizeBtn.TextAlignment = Alignment.Center;
+ moveBtnA.TextAlignment = Alignment.Center;
+ sizeBtnA.TextAlignment = Alignment.Center;
+ moveHotKeyBtn.TextAlignment = Alignment.Center;
+ moveUnicodeHotKeyBtn.TextAlignment = Alignment.Center;
break;
case 3:
- moveBtn.TextAlignment = TextAlignment.Justified;
- sizeBtn.TextAlignment = TextAlignment.Justified;
- moveBtnA.TextAlignment = TextAlignment.Justified;
- sizeBtnA.TextAlignment = TextAlignment.Justified;
- moveHotKeyBtn.TextAlignment = TextAlignment.Justified;
- moveUnicodeHotKeyBtn.TextAlignment = TextAlignment.Justified;
+ moveBtn.TextAlignment = Alignment.Fill;
+ sizeBtn.TextAlignment = Alignment.Fill;
+ moveBtnA.TextAlignment = Alignment.Fill;
+ sizeBtnA.TextAlignment = Alignment.Fill;
+ moveHotKeyBtn.TextAlignment = Alignment.Fill;
+ moveUnicodeHotKeyBtn.TextAlignment = Alignment.Fill;
break;
}
@@ -418,9 +418,8 @@ public class Buttons : Scenario
throw new InvalidOperationException ("T must be a numeric type that supports addition and subtraction.");
}
- // TODO: Use Dim.Auto for the Width and Height
- Height = 1;
- Width = Dim.Func (() => Digits + 2); // button + 3 for number + button
+ Width = Dim.Auto (DimAutoStyle.Content); //Dim.Function (() => Digits + 2); // button + 3 for number + button
+ Height = Dim.Auto (DimAutoStyle.Content);
_down = new ()
{
@@ -440,7 +439,7 @@ public class Buttons : Scenario
Y = Pos.Top (_down),
Width = Dim.Func (() => Digits),
Height = 1,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
CanFocus = true
};
diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs
index 0a32490de..9616c30d5 100644
--- a/UICatalog/Scenarios/CharacterMap.cs
+++ b/UICatalog/Scenarios/CharacterMap.cs
@@ -958,7 +958,7 @@ internal class CharMap : View
Y = 1,
Width = Dim.Fill (),
Height = Dim.Fill (1),
- TextAlignment = TextAlignment.Centered
+ TextAlignment = Alignment.Center
};
var spinner = new SpinnerView { X = Pos.Center (), Y = Pos.Center (), Style = new Aesthetic () };
spinner.AutoSpin = true;
diff --git a/UICatalog/Scenarios/CollectionNavigatorTester.cs b/UICatalog/Scenarios/CollectionNavigatorTester.cs
index ef31ac6a7..4797e4c22 100644
--- a/UICatalog/Scenarios/CollectionNavigatorTester.cs
+++ b/UICatalog/Scenarios/CollectionNavigatorTester.cs
@@ -142,7 +142,7 @@ public class CollectionNavigatorTester : Scenario
var label = new Label
{
Text = "ListView",
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
X = 0,
Y = 1, // for menu
Width = Dim.Percent (50),
@@ -171,7 +171,7 @@ public class CollectionNavigatorTester : Scenario
var label = new Label
{
Text = "TreeView",
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
X = Pos.Right (_listView) + 2,
Y = 1, // for menu
Width = Dim.Percent (50),
diff --git a/UICatalog/Scenarios/ColorPicker.cs b/UICatalog/Scenarios/ColorPicker.cs
index fe2b08fad..5bc84b70d 100644
--- a/UICatalog/Scenarios/ColorPicker.cs
+++ b/UICatalog/Scenarios/ColorPicker.cs
@@ -69,8 +69,8 @@ public class ColorPickers : Scenario
{
Title = "Color Sample",
Text = "Lorem Ipsum",
- TextAlignment = TextAlignment.Centered,
- VerticalTextAlignment = VerticalTextAlignment.Middle,
+ TextAlignment = Alignment.Center,
+ VerticalTextAlignment = Alignment.Center,
BorderStyle = LineStyle.Heavy,
X = Pos.Center (),
Y = Pos.Center (),
diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs
index 5e6eb5cd2..a28e866f8 100644
--- a/UICatalog/Scenarios/ComputedLayout.cs
+++ b/UICatalog/Scenarios/ComputedLayout.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Terminal.Gui;
+using static Terminal.Gui.Dialog;
namespace UICatalog.Scenarios;
@@ -85,12 +86,12 @@ public class ComputedLayout : Scenario
var i = 1;
var txt = "Resize the terminal to see computed layout in action.";
List labelList = new ();
- labelList.Add (new Label { Text = "The lines below show different TextAlignments" });
+ labelList.Add (new Label { Text = "The lines below show different alignment" });
labelList.Add (
new Label
{
- TextAlignment = TextAlignment.Left,
+ TextAlignment = Alignment.Start,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -102,7 +103,7 @@ public class ComputedLayout : Scenario
labelList.Add (
new Label
{
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -114,7 +115,7 @@ public class ComputedLayout : Scenario
labelList.Add (
new Label
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -126,7 +127,7 @@ public class ComputedLayout : Scenario
labelList.Add (
new Label
{
- TextAlignment = TextAlignment.Justified,
+ TextAlignment = Alignment.Fill,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -147,12 +148,12 @@ public class ComputedLayout : Scenario
};
i = 1;
labelList = new List ();
- labelList.Add (new Label { Text = "The lines below show different TextAlignments" });
+ labelList.Add (new Label { Text = "The lines below show different alignment" });
labelList.Add (
new Label
{
- TextAlignment = TextAlignment.Left,
+ TextAlignment = Alignment.Start,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -164,7 +165,7 @@ public class ComputedLayout : Scenario
labelList.Add (
new Label
{
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -176,7 +177,7 @@ public class ComputedLayout : Scenario
labelList.Add (
new Label
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -188,7 +189,7 @@ public class ComputedLayout : Scenario
labelList.Add (
new Label
{
- TextAlignment = TextAlignment.Justified,
+ TextAlignment = Alignment.Fill,
Width = Dim.Fill (),
X = 0,
Y = Pos.Bottom (labelList.LastOrDefault ()),
@@ -304,7 +305,7 @@ public class ComputedLayout : Scenario
app.Add (oddballButton);
// Demonstrate AnchorEnd - Button is anchored to bottom/right
- var anchorButton = new Button { Text = "Button using AnchorEnd", Y = Pos.AnchorEnd ()};
+ var anchorButton = new Button { Text = "Button using AnchorEnd", Y = Pos.AnchorEnd () };
anchorButton.X = Pos.AnchorEnd ();
anchorButton.Accept += (s, e) =>
@@ -322,12 +323,12 @@ public class ComputedLayout : Scenario
// This is intentionally convoluted to illustrate potential bugs.
var anchorEndLabel1 = new Label
{
- Text = "This Label should be the 2nd to last line (AnchorEnd (2)).",
- TextAlignment = TextAlignment.Centered,
+ Text = "This Label should be the 3rd to last line (AnchorEnd (3)).",
+ TextAlignment = Alignment.Center,
ColorScheme = Colors.ColorSchemes ["Menu"],
Width = Dim.Fill (5),
X = 5,
- Y = Pos.AnchorEnd (2)
+ Y = Pos.AnchorEnd (3)
};
app.Add (anchorEndLabel1);
@@ -336,19 +337,23 @@ public class ComputedLayout : Scenario
var anchorEndLabel2 = new TextField
{
Text =
- "This TextField should be the 3rd to last line (AnchorEnd (2) - 1).",
- TextAlignment = TextAlignment.Left,
+ "This TextField should be the 4th to last line (AnchorEnd (3) - 1).",
+ TextAlignment = Alignment.Start,
ColorScheme = Colors.ColorSchemes ["Menu"],
Width = Dim.Fill (5),
X = 5,
- Y = Pos.AnchorEnd (2) - 1 // Pos.Combine
+ Y = Pos.AnchorEnd (3) - 1 // Pos.Combine
};
app.Add (anchorEndLabel2);
- // Show positioning vertically using Pos.AnchorEnd via Pos.Combine
+ // Demonstrate AnchorEnd() in combination with Pos.Align to align a set of buttons centered across the
+ // bottom - 1
+ // This is intentionally convoluted to illustrate potential bugs.
var leftButton = new Button
{
- Text = "Left", Y = Pos.AnchorEnd (0) - 1 // Pos.Combine
+ Text = "Left",
+ X = Pos.Align (Alignment.Center),
+ Y = Pos.AnchorEnd () - 1
};
leftButton.Accept += (s, e) =>
@@ -364,7 +369,9 @@ public class ComputedLayout : Scenario
// show positioning vertically using Pos.AnchorEnd
var centerButton = new Button
{
- Text = "Center", X = Pos.Center (), Y = Pos.AnchorEnd (1) // Pos.AnchorEnd(1)
+ Text = "Center",
+ X = Pos.Align (Alignment.Center),
+ Y = Pos.AnchorEnd (2),
};
centerButton.Accept += (s, e) =>
@@ -378,7 +385,12 @@ public class ComputedLayout : Scenario
};
// show positioning vertically using another window and Pos.Bottom
- var rightButton = new Button { Text = "Right", Y = Pos.Y (centerButton) };
+ var rightButton = new Button
+ {
+ Text = "Right",
+ X = Pos.Align (Alignment.Center),
+ Y = Pos.Y (centerButton)
+ };
rightButton.Accept += (s, e) =>
{
@@ -390,10 +402,7 @@ public class ComputedLayout : Scenario
app.LayoutSubviews ();
};
- // Center three buttons with 5 spaces between them
- leftButton.X = Pos.Left (centerButton) - (Pos.Right (leftButton) - Pos.Left (leftButton)) - 5;
- rightButton.X = Pos.Right (centerButton) + 5;
-
+ View [] buttons = { leftButton, centerButton, rightButton };
app.Add (leftButton);
app.Add (centerButton);
app.Add (rightButton);
diff --git a/UICatalog/Scenarios/CsvEditor.cs b/UICatalog/Scenarios/CsvEditor.cs
index 4279594ab..2584462bc 100644
--- a/UICatalog/Scenarios/CsvEditor.cs
+++ b/UICatalog/Scenarios/CsvEditor.cs
@@ -78,17 +78,17 @@ public class CsvEditor : Scenario
_miLeft = new MenuItem (
"_Align Left",
"",
- () => Align (TextAlignment.Left)
+ () => Align (Alignment.Start)
),
_miRight = new MenuItem (
"_Align Right",
"",
- () => Align (TextAlignment.Right)
+ () => Align (Alignment.End)
),
_miCentered = new MenuItem (
"_Align Centered",
"",
- () => Align (TextAlignment.Centered)
+ () => Align (Alignment.Center)
),
// Format requires hard typed data table, when we read a CSV everything is untyped (string) so this only works for new columns in this demo
@@ -133,7 +133,7 @@ public class CsvEditor : Scenario
Y = Pos.Bottom (_tableView),
Text = "0,0",
Width = Dim.Fill (),
- TextAlignment = TextAlignment.Right
+ TextAlignment = Alignment.End
};
_selectedCellLabel.TextChanged += SelectedCellLabel_TextChanged;
@@ -218,7 +218,7 @@ public class CsvEditor : Scenario
_tableView.Update ();
}
- private void Align (TextAlignment newAlignment)
+ private void Align (Alignment newAlignment)
{
if (NoTableLoaded ())
{
@@ -228,9 +228,9 @@ public class CsvEditor : Scenario
ColumnStyle style = _tableView.Style.GetOrCreateColumnStyle (_tableView.SelectedColumn);
style.Alignment = newAlignment;
- _miLeft.Checked = style.Alignment == TextAlignment.Left;
- _miRight.Checked = style.Alignment == TextAlignment.Right;
- _miCentered.Checked = style.Alignment == TextAlignment.Centered;
+ _miLeft.Checked = style.Alignment == Alignment.Start;
+ _miRight.Checked = style.Alignment == Alignment.End;
+ _miCentered.Checked = style.Alignment == Alignment.Center;
_tableView.Update ();
}
@@ -437,9 +437,9 @@ public class CsvEditor : Scenario
ColumnStyle style = _tableView.Style.GetColumnStyleIfAny (_tableView.SelectedColumn);
- _miLeft.Checked = style?.Alignment == TextAlignment.Left;
- _miRight.Checked = style?.Alignment == TextAlignment.Right;
- _miCentered.Checked = style?.Alignment == TextAlignment.Centered;
+ _miLeft.Checked = style?.Alignment == Alignment.Start;
+ _miRight.Checked = style?.Alignment == Alignment.End;
+ _miCentered.Checked = style?.Alignment == Alignment.Center;
}
private void Open ()
diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs
index bcfbf5a18..dfaf86744 100644
--- a/UICatalog/Scenarios/Dialogs.cs
+++ b/UICatalog/Scenarios/Dialogs.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using Terminal.Gui;
namespace UICatalog.Scenarios;
@@ -31,7 +32,7 @@ public class Dialogs : Scenario
var numButtonsLabel = new Label
{
X = 0,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "_Number of Buttons:"
};
@@ -41,7 +42,7 @@ public class Dialogs : Scenario
Y = 0,
Width = Dim.Width (numButtonsLabel),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "_Width:"
};
frame.Add (label);
@@ -62,7 +63,7 @@ public class Dialogs : Scenario
Y = Pos.Bottom (label),
Width = Dim.Width (numButtonsLabel),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "_Height:"
};
frame.Add (label);
@@ -96,7 +97,7 @@ public class Dialogs : Scenario
Y = Pos.Bottom (label),
Width = Dim.Width (numButtonsLabel),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "_Title:"
};
frame.Add (label);
@@ -128,7 +129,7 @@ public class Dialogs : Scenario
{
X = Pos.Right (numButtonsLabel) + 1,
Y = Pos.Bottom (numButtonsLabel),
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = $"_Add {char.ConvertFromUtf32 (CODE_POINT)} to button text to stress wide char support",
Checked = false
};
@@ -140,18 +141,20 @@ public class Dialogs : Scenario
Y = Pos.Bottom (glyphsNotWords),
Width = Dim.Width (numButtonsLabel),
Height = 1,
- TextAlignment = TextAlignment.Right,
- Text = "Button St_yle:"
+ TextAlignment = Alignment.End,
+ Text = "Button A_lignment:"
};
frame.Add (label);
- var styleRadioGroup = new RadioGroup
+ var labels = Enum.GetNames ();
+ var alignmentGroup = new RadioGroup
{
X = Pos.Right (label) + 1,
Y = Pos.Top (label),
- RadioLabels = new [] { "_Center", "_Justify", "_Left", "_Right" }
+ RadioLabels = labels.ToArray (),
};
- frame.Add (styleRadioGroup);
+ frame.Add (alignmentGroup);
+ alignmentGroup.SelectedItem = labels.ToList ().IndexOf (Dialog.DefaultButtonAlignment.ToString ());
frame.ValidatePosDim = true;
@@ -159,7 +162,7 @@ public class Dialogs : Scenario
label = new ()
{
- X = Pos.Center (), Y = Pos.Bottom (frame) + 4, TextAlignment = TextAlignment.Right, Text = "Button Pressed:"
+ X = Pos.Center (), Y = Pos.Bottom (frame) + 4, TextAlignment = Alignment.End, Text = "Button Pressed:"
};
app.Add (label);
@@ -186,7 +189,7 @@ public class Dialogs : Scenario
titleEdit,
numButtonsEdit,
glyphsNotWords,
- styleRadioGroup,
+ alignmentGroup,
buttonPressedLabel
);
Application.Run (dlg);
@@ -209,7 +212,7 @@ public class Dialogs : Scenario
TextField titleEdit,
TextField numButtonsEdit,
CheckBox glyphsNotWords,
- RadioGroup styleRadioGroup,
+ RadioGroup alignmentRadioGroup,
Label buttonPressedLabel
)
{
@@ -268,7 +271,8 @@ public class Dialogs : Scenario
dialog = new ()
{
Title = titleEdit.Text,
- ButtonAlignment = (Dialog.ButtonAlignments)styleRadioGroup.SelectedItem,
+ ButtonAlignment = (Alignment)Enum.Parse (typeof (Alignment), alignmentRadioGroup.RadioLabels [alignmentRadioGroup.SelectedItem]),
+
Buttons = buttons.ToArray ()
};
diff --git a/UICatalog/Scenarios/DynamicMenuBar.cs b/UICatalog/Scenarios/DynamicMenuBar.cs
index d76c0e1b2..3bfed35af 100644
--- a/UICatalog/Scenarios/DynamicMenuBar.cs
+++ b/UICatalog/Scenarios/DynamicMenuBar.cs
@@ -623,7 +623,7 @@ public class DynamicMenuBar : Scenario
var _lblMenuBar = new Label
{
ColorScheme = Colors.ColorSchemes ["Dialog"],
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
X = Pos.Right (_btnPrevious) + 1,
Y = Pos.Top (_btnPrevious),
@@ -636,7 +636,7 @@ public class DynamicMenuBar : Scenario
var _lblParent = new Label
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
X = Pos.Right (_btnPrevious) + 1,
Y = Pos.Top (_btnPrevious) + 1,
diff --git a/UICatalog/Scenarios/Editor.cs b/UICatalog/Scenarios/Editor.cs
index 301b1b168..f475f45f8 100644
--- a/UICatalog/Scenarios/Editor.cs
+++ b/UICatalog/Scenarios/Editor.cs
@@ -882,7 +882,7 @@ public class Editor : Scenario
{
Y = 1,
Width = lblWidth,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "Find:"
};
@@ -903,7 +903,7 @@ public class Editor : Scenario
Y = Pos.Top (label),
Width = 20,
Enabled = !string.IsNullOrEmpty (txtToFind.Text),
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
IsDefault = true,
Text = "Find _Next"
@@ -917,7 +917,7 @@ public class Editor : Scenario
Y = Pos.Top (btnFindNext) + 1,
Width = 20,
Enabled = !string.IsNullOrEmpty (txtToFind.Text),
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Text = "Find _Previous"
};
@@ -937,7 +937,7 @@ public class Editor : Scenario
X = Pos.Right (txtToFind) + 1,
Y = Pos.Top (btnFindPrevious) + 2,
Width = 20,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Text = "Cancel"
};
@@ -1134,7 +1134,7 @@ public class Editor : Scenario
{
Y = 1,
Width = lblWidth,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "Find:"
};
@@ -1155,7 +1155,7 @@ public class Editor : Scenario
Y = Pos.Top (label),
Width = 20,
Enabled = !string.IsNullOrEmpty (txtToFind.Text),
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
IsDefault = true,
Text = "Replace _Next"
@@ -1181,7 +1181,7 @@ public class Editor : Scenario
Y = Pos.Top (btnFindNext) + 1,
Width = 20,
Enabled = !string.IsNullOrEmpty (txtToFind.Text),
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Text = "Replace _Previous"
};
@@ -1194,7 +1194,7 @@ public class Editor : Scenario
Y = Pos.Top (btnFindPrevious) + 1,
Width = 20,
Enabled = !string.IsNullOrEmpty (txtToFind.Text),
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Text = "Replace _All"
};
@@ -1215,7 +1215,7 @@ public class Editor : Scenario
X = Pos.Right (txtToFind) + 1,
Y = Pos.Top (btnReplaceAll) + 1,
Width = 20,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Text = "Cancel"
};
diff --git a/UICatalog/Scenarios/ListColumns.cs b/UICatalog/Scenarios/ListColumns.cs
index e4b3b5d19..09aad302e 100644
--- a/UICatalog/Scenarios/ListColumns.cs
+++ b/UICatalog/Scenarios/ListColumns.cs
@@ -247,7 +247,7 @@ public class ListColumns : Scenario
Text = "0,0",
Width = Dim.Fill (),
- TextAlignment = TextAlignment.Right
+ TextAlignment = Alignment.End
};
Win.Add (selectedCellLabel);
diff --git a/UICatalog/Scenarios/MessageBoxes.cs b/UICatalog/Scenarios/MessageBoxes.cs
index 1e90c4a0f..79bc622f0 100644
--- a/UICatalog/Scenarios/MessageBoxes.cs
+++ b/UICatalog/Scenarios/MessageBoxes.cs
@@ -30,7 +30,7 @@ public class MessageBoxes : Scenario
app.Add (frame);
// TODO: Use Pos.Align her to demo aligning labels and fields
- var label = new Label { X = 0, Y = 0, Width = 15, TextAlignment = TextAlignment.Right, Text = "Width:" };
+ var label = new Label { X = 0, Y = 0, Width = 15, TextAlignment = Alignment.End, Text = "Width:" };
frame.Add (label);
var widthEdit = new TextField
@@ -50,7 +50,7 @@ public class MessageBoxes : Scenario
Width = Dim.Width (label),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "Height:"
};
frame.Add (label);
@@ -85,7 +85,7 @@ public class MessageBoxes : Scenario
Width = Dim.Width (label),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "Title:"
};
frame.Add (label);
@@ -107,7 +107,7 @@ public class MessageBoxes : Scenario
Width = Dim.Width (label),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "Message:"
};
frame.Add (label);
@@ -129,7 +129,7 @@ public class MessageBoxes : Scenario
Width = Dim.Width (label),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "Num Buttons:"
};
frame.Add (label);
@@ -151,7 +151,7 @@ public class MessageBoxes : Scenario
Width = Dim.Width (label),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "Default Button:"
};
frame.Add (label);
@@ -173,7 +173,7 @@ public class MessageBoxes : Scenario
Width = Dim.Width (label),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "Style:"
};
frame.Add (label);
@@ -194,7 +194,7 @@ public class MessageBoxes : Scenario
label = new ()
{
- X = Pos.Center (), Y = Pos.Bottom (frame) + 2, TextAlignment = TextAlignment.Right, Text = "Button Pressed:"
+ X = Pos.Center (), Y = Pos.Bottom (frame) + 2, TextAlignment = Alignment.End, Text = "Button Pressed:"
};
app.Add (label);
@@ -203,7 +203,7 @@ public class MessageBoxes : Scenario
X = Pos.Center (),
Y = Pos.Bottom (label) + 1,
ColorScheme = Colors.ColorSchemes ["Error"],
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Text = " "
};
diff --git a/UICatalog/Scenarios/Mouse.cs b/UICatalog/Scenarios/Mouse.cs
index d32c7b371..20a5e6118 100644
--- a/UICatalog/Scenarios/Mouse.cs
+++ b/UICatalog/Scenarios/Mouse.cs
@@ -100,8 +100,8 @@ public class Mouse : Scenario
Width = 20,
Height = 3,
Text = "Enter/Leave Demo",
- TextAlignment = TextAlignment.Centered,
- VerticalTextAlignment = VerticalTextAlignment.Middle,
+ TextAlignment = Alignment.Center,
+ VerticalTextAlignment = Alignment.Center,
ColorScheme = Colors.ColorSchemes ["Dialog"]
};
win.Add (demo);
diff --git a/UICatalog/Scenarios/PosAlignDemo.cs b/UICatalog/Scenarios/PosAlignDemo.cs
new file mode 100644
index 000000000..086563a1a
--- /dev/null
+++ b/UICatalog/Scenarios/PosAlignDemo.cs
@@ -0,0 +1,383 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Terminal.Gui;
+
+namespace UICatalog.Scenarios;
+
+[ScenarioMetadata ("Pos.Align", "Demonstrates Pos.Align")]
+[ScenarioCategory ("Layout")]
+public sealed class PosAlignDemo : Scenario
+{
+ private readonly Aligner _horizAligner = new ();
+ private int _leftMargin;
+ private readonly Aligner _vertAligner = new ();
+ private int _topMargin;
+
+ public override void Main ()
+ {
+ // Init
+ Application.Init ();
+
+ // Setup - Create a top-level application window and configure it.
+ Window appWindow = new ()
+ {
+ Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()} - {GetDescription ()}"
+ };
+
+ SetupControls (appWindow, Dimension.Width, Colors.ColorSchemes ["TopLevel"]);
+
+ SetupControls (appWindow, Dimension.Height, Colors.ColorSchemes ["Error"]);
+
+ Setup3By3Grid (appWindow);
+
+ // Run - Start the application.
+ Application.Run (appWindow);
+ appWindow.Dispose ();
+
+ // Shutdown - Calling Application.Shutdown is required.
+ Application.Shutdown ();
+ }
+
+ private void SetupControls (Window appWindow, Dimension dimension, ColorScheme colorScheme)
+ {
+ RadioGroup alignRadioGroup = new ()
+ {
+ RadioLabels = Enum.GetNames (),
+ ColorScheme = colorScheme
+ };
+
+ if (dimension == Dimension.Width)
+ {
+ alignRadioGroup.X = Pos.Align (_horizAligner.Alignment);
+ alignRadioGroup.Y = Pos.Center ();
+ }
+ else
+ {
+ alignRadioGroup.X = Pos.Center ();
+ alignRadioGroup.Y = Pos.Align (_vertAligner.Alignment);
+ }
+
+ alignRadioGroup.SelectedItemChanged += (s, e) =>
+ {
+ if (dimension == Dimension.Width)
+ {
+ _horizAligner.Alignment =
+ (Alignment)Enum.Parse (
+ typeof (Alignment),
+ alignRadioGroup.RadioLabels [alignRadioGroup.SelectedItem]);
+ UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
+ }
+ else
+ {
+ _vertAligner.Alignment =
+ (Alignment)Enum.Parse (
+ typeof (Alignment),
+ alignRadioGroup.RadioLabels [alignRadioGroup.SelectedItem]);
+ UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
+ }
+ };
+ appWindow.Add (alignRadioGroup);
+
+ CheckBox ignoreFirstOrLast = new ()
+ {
+ ColorScheme = colorScheme,
+ Text = "IgnoreFirstOrLast"
+ };
+
+ if (dimension == Dimension.Width)
+ {
+ ignoreFirstOrLast.Checked = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.IgnoreFirstOrLast);
+ ignoreFirstOrLast.X = Pos.Align (_horizAligner.Alignment);
+ ignoreFirstOrLast.Y = Pos.Top (alignRadioGroup);
+ }
+ else
+ {
+ ignoreFirstOrLast.Checked = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.IgnoreFirstOrLast);
+ ignoreFirstOrLast.X = Pos.Left (alignRadioGroup);
+ ignoreFirstOrLast.Y = Pos.Align (_vertAligner.Alignment);
+ }
+
+ ignoreFirstOrLast.Toggled += (s, e) =>
+ {
+ if (dimension == Dimension.Width)
+ {
+ _horizAligner.AlignmentModes =
+ e.NewValue is { } && e.NewValue.Value
+ ? _horizAligner.AlignmentModes | AlignmentModes.IgnoreFirstOrLast
+ : _horizAligner.AlignmentModes & ~AlignmentModes.IgnoreFirstOrLast;
+ UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
+ }
+ else
+ {
+ _vertAligner.AlignmentModes =
+ e.NewValue is { } && e.NewValue.Value
+ ? _vertAligner.AlignmentModes | AlignmentModes.IgnoreFirstOrLast
+ : _vertAligner.AlignmentModes & ~AlignmentModes.IgnoreFirstOrLast;
+ UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
+ }
+ };
+ appWindow.Add (ignoreFirstOrLast);
+
+ CheckBox addSpacesBetweenItems = new ()
+ {
+ ColorScheme = colorScheme,
+ Text = "AddSpaceBetweenItems"
+ };
+
+ if (dimension == Dimension.Width)
+ {
+ addSpacesBetweenItems.Checked = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.AddSpaceBetweenItems);
+ addSpacesBetweenItems.X = Pos.Align (_horizAligner.Alignment);
+ addSpacesBetweenItems.Y = Pos.Top (alignRadioGroup);
+ }
+ else
+ {
+ addSpacesBetweenItems.Checked = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.AddSpaceBetweenItems);
+ addSpacesBetweenItems.X = Pos.Left (alignRadioGroup);
+ addSpacesBetweenItems.Y = Pos.Align (_vertAligner.Alignment);
+ }
+
+ addSpacesBetweenItems.Toggled += (s, e) =>
+ {
+ if (dimension == Dimension.Width)
+ {
+ _horizAligner.AlignmentModes =
+ e.NewValue is { } && e.NewValue.Value
+ ? _horizAligner.AlignmentModes | AlignmentModes.AddSpaceBetweenItems
+ : _horizAligner.AlignmentModes & ~AlignmentModes.AddSpaceBetweenItems;
+ UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
+ }
+ else
+ {
+ _vertAligner.AlignmentModes =
+ e.NewValue is { } && e.NewValue.Value
+ ? _vertAligner.AlignmentModes | AlignmentModes.AddSpaceBetweenItems
+ : _vertAligner.AlignmentModes & ~AlignmentModes.AddSpaceBetweenItems;
+ UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
+ }
+ };
+
+ appWindow.Add (addSpacesBetweenItems);
+
+ CheckBox margin = new ()
+ {
+ ColorScheme = colorScheme,
+ Text = "Margin"
+ };
+
+ if (dimension == Dimension.Width)
+ {
+ margin.X = Pos.Align (_horizAligner.Alignment);
+ margin.Y = Pos.Top (alignRadioGroup);
+ }
+ else
+ {
+ margin.X = Pos.Left (addSpacesBetweenItems);
+ margin.Y = Pos.Align (_vertAligner.Alignment);
+ }
+
+ margin.Toggled += (s, e) =>
+ {
+ if (dimension == Dimension.Width)
+ {
+ _leftMargin = e.NewValue is { } && e.NewValue.Value ? 1 : 0;
+ UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
+ }
+ else
+ {
+ _topMargin = e.NewValue is { } && e.NewValue.Value ? 1 : 0;
+ UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
+ }
+ };
+ appWindow.Add (margin);
+
+ List addedViews =
+ [
+ new ()
+ {
+ X = dimension == Dimension.Width ? Pos.Align (_horizAligner.Alignment) : Pos.Left (alignRadioGroup),
+ Y = dimension == Dimension.Width ? Pos.Top (alignRadioGroup) : Pos.Align (_vertAligner.Alignment),
+ Text = NumberToWords.Convert (0)
+ }
+ ];
+
+ Buttons.NumericUpDown addedViewsUpDown = new()
+ {
+ Width = 9,
+ Title = "Added",
+ ColorScheme = colorScheme,
+ BorderStyle = LineStyle.None,
+ Value = addedViews.Count
+ };
+
+ if (dimension == Dimension.Width)
+ {
+ addedViewsUpDown.X = Pos.Align (_horizAligner.Alignment);
+ addedViewsUpDown.Y = Pos.Top (alignRadioGroup);
+ addedViewsUpDown.Border.Thickness = new (0, 1, 0, 0);
+ }
+ else
+ {
+ addedViewsUpDown.X = Pos.Left (alignRadioGroup);
+ addedViewsUpDown.Y = Pos.Align (_vertAligner.Alignment);
+ addedViewsUpDown.Border.Thickness = new (1, 0, 0, 0);
+ }
+
+ addedViewsUpDown.ValueChanging += (s, e) =>
+ {
+ if (e.NewValue < 0)
+ {
+ e.Cancel = true;
+
+ return;
+ }
+
+ // Add or remove buttons
+ if (e.NewValue < e.OldValue)
+ {
+ // Remove buttons
+ for (int i = e.OldValue - 1; i >= e.NewValue; i--)
+ {
+ Button button = addedViews [i];
+ appWindow.Remove (button);
+ addedViews.RemoveAt (i);
+ button.Dispose ();
+ }
+ }
+
+ if (e.NewValue > e.OldValue)
+ {
+ // Add buttons
+ for (int i = e.OldValue; i < e.NewValue; i++)
+ {
+ var button = new Button
+ {
+ X = dimension == Dimension.Width ? Pos.Align (_horizAligner.Alignment) : Pos.Left (alignRadioGroup),
+ Y = dimension == Dimension.Width ? Pos.Top (alignRadioGroup) : Pos.Align (_vertAligner.Alignment),
+ Text = NumberToWords.Convert (i + 1)
+ };
+ appWindow.Add (button);
+ addedViews.Add (button);
+ }
+ }
+ };
+ appWindow.Add (addedViewsUpDown);
+
+ appWindow.Add (addedViews [0]);
+ }
+
+ private void UpdatePosAlignObjects (View superView, Dimension dimension, Aligner aligner)
+ {
+ foreach (View view in superView.Subviews.Where (v => dimension == Dimension.Width ? v.X is PosAlign : v.Y is PosAlign))
+ {
+ if (dimension == Dimension.Width ? view.X is PosAlign : view.Y is PosAlign)
+ {
+ //posAlign.Aligner.Alignment = _horizAligner.Alignment;
+ //posAlign.Aligner.AlignmentMode = _horizAligner.AlignmentMode;
+
+ // BUGBUG: Create and assign a new Pos object because we currently have no way for X to be notified
+ // BUGBUG: of changes in the Pos object. See https://github.com/gui-cs/Terminal.Gui/issues/3485
+ if (dimension == Dimension.Width)
+ {
+ var posAlign = view.X as PosAlign;
+
+ view.X = Pos.Align (
+ aligner.Alignment,
+ aligner.AlignmentModes,
+ posAlign!.GroupId);
+ view.Margin.Thickness = new (_leftMargin, 0, 0, 0);
+ }
+ else
+ {
+ var posAlign = view.Y as PosAlign;
+
+ view.Y = Pos.Align (
+ aligner.Alignment,
+ aligner.AlignmentModes,
+ posAlign!.GroupId);
+
+ view.Margin.Thickness = new (0, _topMargin, 0, 0);
+ }
+ }
+ }
+
+ superView.LayoutSubviews ();
+ }
+
+ ///
+ /// Creates a 3x3 grid of views with two GroupIds: One for aligning X and one for aligning Y.
+ /// Demonstrates using PosAlign to create a grid of views that flow.
+ ///
+ ///
+ private void Setup3By3Grid (View appWindow)
+ {
+ var container = new FrameView
+ {
+ Title = "3 by 3",
+ X = Pos.AnchorEnd (),
+ Y = Pos.AnchorEnd (),
+ Width = Dim.Percent (40),
+ Height = Dim.Percent (40)
+ };
+ container.Padding.Thickness = new (8, 1, 0, 0);
+ container.Padding.ColorScheme = Colors.ColorSchemes ["error"];
+
+ Aligner widthAligner = new () { AlignmentModes = AlignmentModes.StartToEnd };
+
+ RadioGroup widthAlignRadioGroup = new ()
+ {
+ RadioLabels = Enum.GetNames (),
+ Orientation = Orientation.Horizontal,
+ X = Pos.Center ()
+ };
+ container.Padding.Add (widthAlignRadioGroup);
+
+ widthAlignRadioGroup.SelectedItemChanged += (sender, e) =>
+ {
+ widthAligner.Alignment =
+ (Alignment)Enum.Parse (
+ typeof (Alignment),
+ widthAlignRadioGroup.RadioLabels [widthAlignRadioGroup.SelectedItem]);
+ UpdatePosAlignObjects (container, Dimension.Width, widthAligner);
+ };
+
+ Aligner heightAligner = new () { AlignmentModes = AlignmentModes.StartToEnd };
+
+ RadioGroup heightAlignRadioGroup = new ()
+ {
+ RadioLabels = Enum.GetNames (),
+ Orientation = Orientation.Vertical,
+ Y = Pos.Center ()
+ };
+ container.Padding.Add (heightAlignRadioGroup);
+
+ heightAlignRadioGroup.SelectedItemChanged += (sender, e) =>
+ {
+ heightAligner.Alignment =
+ (Alignment)Enum.Parse (
+ typeof (Alignment),
+ heightAlignRadioGroup.RadioLabels [heightAlignRadioGroup.SelectedItem]);
+ UpdatePosAlignObjects (container, Dimension.Height, heightAligner);
+ };
+
+ for (var i = 0; i < 9; i++)
+
+ {
+ var v = new View
+ {
+ Title = $"{i}",
+ BorderStyle = LineStyle.Dashed,
+ Height = 3,
+ Width = 5
+ };
+
+ v.X = Pos.Align (widthAligner.Alignment, widthAligner.AlignmentModes, i / 3);
+ v.Y = Pos.Align (heightAligner.Alignment, heightAligner.AlignmentModes, i % 3 + 10);
+
+ container.Add (v);
+ }
+
+ appWindow.Add (container);
+ }
+}
diff --git a/UICatalog/Scenarios/ProgressBarStyles.cs b/UICatalog/Scenarios/ProgressBarStyles.cs
index f450ad73d..e13942358 100644
--- a/UICatalog/Scenarios/ProgressBarStyles.cs
+++ b/UICatalog/Scenarios/ProgressBarStyles.cs
@@ -50,13 +50,12 @@ public class ProgressBarStyles : Scenario
var pbList = new ListView
{
Title = "Focused ProgressBar",
- Y = 0,
+ Y = Pos.Align (Alignment.Start),
X = Pos.Center (),
Width = Dim.Auto (),
Height = Dim.Auto (),
BorderStyle = LineStyle.Single
};
-
container.Add (pbList);
#region ColorPicker
@@ -97,7 +96,9 @@ public class ProgressBarStyles : Scenario
var fgColorPickerBtn = new Button
{
- Text = "Foreground HotNormal Color", X = Pos.Center (), Y = Pos.Bottom (pbList)
+ Text = "Foreground HotNormal Color",
+ X = Pos.Center (),
+ Y = Pos.Align (Alignment.Start),
};
container.Add (fgColorPickerBtn);
@@ -122,7 +123,9 @@ public class ProgressBarStyles : Scenario
var bgColorPickerBtn = new Button
{
- X = Pos.Center (), Y = Pos.Bottom (fgColorPickerBtn), Text = "Background HotNormal Color"
+ X = Pos.Center (),
+ Y = Pos.Align (Alignment.Start),
+ Text = "Background HotNormal Color"
};
container.Add (bgColorPickerBtn);
@@ -154,20 +157,25 @@ public class ProgressBarStyles : Scenario
{
BorderStyle = LineStyle.Single,
Title = "ProgressBarFormat",
- X = Pos.Left (pbList),
- Y = Pos.Bottom (bgColorPickerBtn) + 1,
+ X = Pos.Center (),
+ Y = Pos.Align (Alignment.Start),
RadioLabels = pbFormatEnum.Select (e => e.ToString ()).ToArray ()
};
container.Add (rbPBFormat);
- var button = new Button { X = Pos.Center (), Y = Pos.Bottom (rbPBFormat) + 1, Text = "Start timer" };
+ var button = new Button
+ {
+ X = Pos.Center (),
+ Y = Pos.Align (Alignment.Start),
+ Text = "Start timer"
+ };
container.Add (button);
var blocksPB = new ProgressBar
{
Title = "Blocks",
X = Pos.Center (),
- Y = Pos.Bottom (button) + 1,
+ Y = Pos.Align (Alignment.Start),
Width = Dim.Percent (50),
BorderStyle = LineStyle.Single,
CanFocus = true
@@ -180,7 +188,7 @@ public class ProgressBarStyles : Scenario
{
Title = "Continuous",
X = Pos.Center (),
- Y = Pos.Bottom (blocksPB) + 1,
+ Y = Pos.Align (Alignment.Start),
Width = Dim.Percent (50),
ProgressBarStyle = ProgressBarStyle.Continuous,
BorderStyle = LineStyle.Single,
@@ -230,7 +238,7 @@ public class ProgressBarStyles : Scenario
{
Title = "Marquee Blocks",
X = Pos.Center (),
- Y = Pos.Bottom (ckbBidirectional) + 1,
+ Y = Pos.Align (Alignment.Start),
Width = Dim.Percent (50),
ProgressBarStyle = ProgressBarStyle.MarqueeBlocks,
BorderStyle = LineStyle.Single,
@@ -242,7 +250,7 @@ public class ProgressBarStyles : Scenario
{
Title = "Marquee Continuous",
X = Pos.Center (),
- Y = Pos.Bottom (marqueesBlocksPB) + 1,
+ Y = Pos.Align (Alignment.Start),
Width = Dim.Percent (50),
ProgressBarStyle = ProgressBarStyle.MarqueeContinuous,
BorderStyle = LineStyle.Single,
diff --git a/UICatalog/Scenarios/TableEditor.cs b/UICatalog/Scenarios/TableEditor.cs
index 468c66418..70c3151b8 100644
--- a/UICatalog/Scenarios/TableEditor.cs
+++ b/UICatalog/Scenarios/TableEditor.cs
@@ -707,7 +707,7 @@ public class TableEditor : Scenario
Text = "0,0",
Width = Dim.Fill (),
- TextAlignment = TextAlignment.Right
+ TextAlignment = Alignment.End
};
Win.Add (selectedCellLabel);
@@ -1107,12 +1107,12 @@ public class TableEditor : Scenario
{
_tableView.Style.ColumnStyles.Clear ();
- var alignMid = new ColumnStyle { Alignment = TextAlignment.Centered };
- var alignRight = new ColumnStyle { Alignment = TextAlignment.Right };
+ var alignMid = new ColumnStyle { Alignment = Alignment.Center };
+ var alignRight = new ColumnStyle { Alignment = Alignment.End };
var dateFormatStyle = new ColumnStyle
{
- Alignment = TextAlignment.Right,
+ Alignment = Alignment.End,
RepresentationGetter = v =>
v is DateTime d ? d.ToString ("yyyy-MM-dd") : v.ToString ()
};
@@ -1126,15 +1126,15 @@ public class TableEditor : Scenario
// align negative values right
d < 0
- ? TextAlignment.Right
+ ? Alignment.End
:
// align positive values left
- TextAlignment.Left
+ Alignment.Start
:
// not a double
- TextAlignment.Left,
+ Alignment.Start,
ColorGetter = a => a.CellValue is double d
?
diff --git a/UICatalog/Scenarios/Text.cs b/UICatalog/Scenarios/Text.cs
index 929da3c3e..13e61c168 100644
--- a/UICatalog/Scenarios/Text.cs
+++ b/UICatalog/Scenarios/Text.cs
@@ -290,7 +290,7 @@ public class Text : Scenario
X = Pos.Right (regexProvider) + 1,
Y = Pos.Y (regexProvider),
Width = 30,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Provider = provider2
};
Win.Add (regexProviderField);
diff --git a/UICatalog/Scenarios/TextAlignmentsAndDirection.cs b/UICatalog/Scenarios/TextAlignmentAndDirection.cs
similarity index 71%
rename from UICatalog/Scenarios/TextAlignmentsAndDirection.cs
rename to UICatalog/Scenarios/TextAlignmentAndDirection.cs
index bdc11c14f..eb4f08bf1 100644
--- a/UICatalog/Scenarios/TextAlignmentsAndDirection.cs
+++ b/UICatalog/Scenarios/TextAlignmentAndDirection.cs
@@ -6,9 +6,9 @@ using Terminal.Gui;
namespace UICatalog.Scenarios;
-[ScenarioMetadata ("Text Alignment and Direction", "Demos horizontal and vertical text alignment and text direction.")]
+[ScenarioMetadata ("Text Alignment and Direction", "Demos horizontal and vertical text alignment and direction.")]
[ScenarioCategory ("Text and Formatting")]
-public class TextAlignmentsAndDirections : Scenario
+public class TextAlignmentAndDirection : Scenario
{
public override void Main ()
{
@@ -24,63 +24,63 @@ public class TextAlignmentsAndDirections : Scenario
var color1 = new ColorScheme { Normal = new (Color.Black, Color.Gray) };
var color2 = new ColorScheme { Normal = new (Color.Black, Color.DarkGray) };
- List txts = new (); // single line
- List mtxts = new (); // multi line
+ List singleLineLabels = new (); // single line
+ List multiLineLabels = new (); // multi line
// Horizontal Single-Line
var labelHL = new Label
{
- X = 1,
- Y = 1,
- Width = 9,
+ X = 0,
+ Y = 0,
+ Width = 6,
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
ColorScheme = Colors.ColorSchemes ["Dialog"],
- Text = "Left"
+ Text = "Start"
};
var labelHC = new Label
{
- X = 1,
- Y = 2,
- Width = 9,
+ X = 0,
+ Y = 1,
+ Width = 6,
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
ColorScheme = Colors.ColorSchemes ["Dialog"],
- Text = "Centered"
+ Text = "Center"
};
var labelHR = new Label
{
- X = 1,
- Y = 3,
- Width = 9,
+ X = 0,
+ Y = 2,
+ Width = 6,
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
ColorScheme = Colors.ColorSchemes ["Dialog"],
- Text = "Right"
+ Text = "End"
};
var labelHJ = new Label
{
- X = 1,
- Y = 4,
- Width = 9,
+ X = 0,
+ Y = 3,
+ Width = 6,
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
ColorScheme = Colors.ColorSchemes ["Dialog"],
- Text = "Justified"
+ Text = "Fill"
};
var txtLabelHL = new Label
{
X = Pos.Right (labelHL) + 1,
Y = Pos.Y (labelHL),
- Width = Dim.Fill (1) - 9,
+ Width = Dim.Fill (9),
Height = 1,
ColorScheme = color1,
- TextAlignment = TextAlignment.Left,
+ TextAlignment = Alignment.Start,
Text = txt
};
@@ -88,10 +88,10 @@ public class TextAlignmentsAndDirections : Scenario
{
X = Pos.Right (labelHC) + 1,
Y = Pos.Y (labelHC),
- Width = Dim.Fill (1) - 9,
+ Width = Dim.Fill (9),
Height = 1,
ColorScheme = color2,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Text = txt
};
@@ -99,10 +99,10 @@ public class TextAlignmentsAndDirections : Scenario
{
X = Pos.Right (labelHR) + 1,
Y = Pos.Y (labelHR),
- Width = Dim.Fill (1) - 9,
+ Width = Dim.Fill (9),
Height = 1,
ColorScheme = color1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = txt
};
@@ -110,17 +110,17 @@ public class TextAlignmentsAndDirections : Scenario
{
X = Pos.Right (labelHJ) + 1,
Y = Pos.Y (labelHJ),
- Width = Dim.Fill (1) - 9,
+ Width = Dim.Fill (9),
Height = 1,
ColorScheme = color2,
- TextAlignment = TextAlignment.Justified,
+ TextAlignment = Alignment.Fill,
Text = txt
};
- txts.Add (txtLabelHL);
- txts.Add (txtLabelHC);
- txts.Add (txtLabelHR);
- txts.Add (txtLabelHJ);
+ singleLineLabels.Add (txtLabelHL);
+ singleLineLabels.Add (txtLabelHC);
+ singleLineLabels.Add (txtLabelHR);
+ singleLineLabels.Add (txtLabelHJ);
app.Add (labelHL);
app.Add (txtLabelHL);
@@ -135,53 +135,53 @@ public class TextAlignmentsAndDirections : Scenario
var labelVT = new Label
{
- X = Pos.AnchorEnd (8),
- Y = 1,
+ X = Pos.AnchorEnd () - 6,
+ Y = 0,
Width = 2,
- Height = 9,
+ Height = 6,
ColorScheme = color1,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Bottom,
- Text = "Top"
+ VerticalTextAlignment = Alignment.End,
+ Text = "Start"
};
labelVT.TextFormatter.WordWrap = false;
var labelVM = new Label
{
- X = Pos.AnchorEnd (6),
- Y = 1,
+ X = Pos.AnchorEnd () - 4,
+ Y = 0,
Width = 2,
- Height = 9,
+ Height = 6,
ColorScheme = color1,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Bottom,
- Text = "Middle"
+ VerticalTextAlignment = Alignment.End,
+ Text = "Center"
};
labelVM.TextFormatter.WordWrap = false;
var labelVB = new Label
{
- X = Pos.AnchorEnd (4),
- Y = 1,
+ X = Pos.AnchorEnd () - 2,
+ Y = 0,
Width = 2,
- Height = 9,
+ Height = 6,
ColorScheme = color1,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Bottom,
- Text = "Bottom"
+ VerticalTextAlignment = Alignment.End,
+ Text = "End"
};
labelVB.TextFormatter.WordWrap = false;
var labelVJ = new Label
{
- X = Pos.AnchorEnd (2),
- Y = 1,
+ X = Pos.AnchorEnd (),
+ Y = 0,
Width = 2,
- Height = 9,
+ Height = 6,
ColorScheme = color1,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Bottom,
- Text = "Justified"
+ VerticalTextAlignment = Alignment.End,
+ Text = "Fill"
};
labelVJ.TextFormatter.WordWrap = false;
@@ -190,10 +190,10 @@ public class TextAlignmentsAndDirections : Scenario
X = Pos.X (labelVT),
Y = Pos.Bottom (labelVT) + 1,
Width = 2,
- Height = Dim.Fill (1),
+ Height = Dim.Fill (),
ColorScheme = color1,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Top,
+ VerticalTextAlignment = Alignment.Start,
Text = txt
};
txtLabelVT.TextFormatter.WordWrap = false;
@@ -203,10 +203,10 @@ public class TextAlignmentsAndDirections : Scenario
X = Pos.X (labelVM),
Y = Pos.Bottom (labelVM) + 1,
Width = 2,
- Height = Dim.Fill (1),
+ Height = Dim.Fill (),
ColorScheme = color2,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Middle,
+ VerticalTextAlignment = Alignment.Center,
Text = txt
};
txtLabelVM.TextFormatter.WordWrap = false;
@@ -216,10 +216,10 @@ public class TextAlignmentsAndDirections : Scenario
X = Pos.X (labelVB),
Y = Pos.Bottom (labelVB) + 1,
Width = 2,
- Height = Dim.Fill (1),
+ Height = Dim.Fill (),
ColorScheme = color1,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Bottom,
+ VerticalTextAlignment = Alignment.End,
Text = txt
};
txtLabelVB.TextFormatter.WordWrap = false;
@@ -229,18 +229,18 @@ public class TextAlignmentsAndDirections : Scenario
X = Pos.X (labelVJ),
Y = Pos.Bottom (labelVJ) + 1,
Width = 2,
- Height = Dim.Fill (1),
+ Height = Dim.Fill (),
ColorScheme = color2,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Justified,
+ VerticalTextAlignment = Alignment.Fill,
Text = txt
};
txtLabelVJ.TextFormatter.WordWrap = false;
- txts.Add (txtLabelVT);
- txts.Add (txtLabelVM);
- txts.Add (txtLabelVB);
- txts.Add (txtLabelVJ);
+ singleLineLabels.Add (txtLabelVT);
+ singleLineLabels.Add (txtLabelVM);
+ singleLineLabels.Add (txtLabelVB);
+ singleLineLabels.Add (txtLabelVJ);
app.Add (labelVT);
app.Add (txtLabelVT);
@@ -258,18 +258,19 @@ public class TextAlignmentsAndDirections : Scenario
X = 0,
Y = Pos.Bottom (txtLabelHJ),
Width = Dim.Fill (31),
- Height = Dim.Fill (4),
- ColorScheme = color2
+ Height = Dim.Fill (4)
+
+ //ColorScheme = color2
};
var txtLabelTL = new Label
{
- X = 1 /* */,
+ X = 0 /* */,
Y = 1,
Width = Dim.Percent (100 / 3),
Height = Dim.Percent (100 / 3),
- TextAlignment = TextAlignment.Left,
- VerticalTextAlignment = VerticalTextAlignment.Top,
+ TextAlignment = Alignment.Start,
+ VerticalTextAlignment = Alignment.Start,
ColorScheme = color1,
Text = txt
};
@@ -281,8 +282,8 @@ public class TextAlignmentsAndDirections : Scenario
Y = 1,
Width = Dim.Percent (33),
Height = Dim.Percent (33),
- TextAlignment = TextAlignment.Centered,
- VerticalTextAlignment = VerticalTextAlignment.Top,
+ TextAlignment = Alignment.Center,
+ VerticalTextAlignment = Alignment.Start,
ColorScheme = color1,
Text = txt
};
@@ -294,8 +295,8 @@ public class TextAlignmentsAndDirections : Scenario
Y = 1,
Width = Dim.Percent (100, DimPercentMode.Position),
Height = Dim.Percent (33),
- TextAlignment = TextAlignment.Right,
- VerticalTextAlignment = VerticalTextAlignment.Top,
+ TextAlignment = Alignment.End,
+ VerticalTextAlignment = Alignment.Start,
ColorScheme = color1,
Text = txt
};
@@ -307,8 +308,8 @@ public class TextAlignmentsAndDirections : Scenario
Y = Pos.Bottom (txtLabelTL) + 1,
Width = Dim.Width (txtLabelTL),
Height = Dim.Percent (33),
- TextAlignment = TextAlignment.Left,
- VerticalTextAlignment = VerticalTextAlignment.Middle,
+ TextAlignment = Alignment.Start,
+ VerticalTextAlignment = Alignment.Center,
ColorScheme = color1,
Text = txt
};
@@ -320,8 +321,8 @@ public class TextAlignmentsAndDirections : Scenario
Y = Pos.Bottom (txtLabelTC) + 1,
Width = Dim.Width (txtLabelTC),
Height = Dim.Percent (33),
- TextAlignment = TextAlignment.Centered,
- VerticalTextAlignment = VerticalTextAlignment.Middle,
+ TextAlignment = Alignment.Center,
+ VerticalTextAlignment = Alignment.Center,
ColorScheme = color1,
Text = txt
};
@@ -333,8 +334,8 @@ public class TextAlignmentsAndDirections : Scenario
Y = Pos.Bottom (txtLabelTR) + 1,
Width = Dim.Percent (100, DimPercentMode.Position),
Height = Dim.Percent (33),
- TextAlignment = TextAlignment.Right,
- VerticalTextAlignment = VerticalTextAlignment.Middle,
+ TextAlignment = Alignment.End,
+ VerticalTextAlignment = Alignment.Center,
ColorScheme = color1,
Text = txt
};
@@ -346,8 +347,8 @@ public class TextAlignmentsAndDirections : Scenario
Y = Pos.Bottom (txtLabelML) + 1,
Width = Dim.Width (txtLabelML),
Height = Dim.Percent (100, DimPercentMode.Position),
- TextAlignment = TextAlignment.Left,
- VerticalTextAlignment = VerticalTextAlignment.Bottom,
+ TextAlignment = Alignment.Start,
+ VerticalTextAlignment = Alignment.End,
ColorScheme = color1,
Text = txt
};
@@ -359,8 +360,8 @@ public class TextAlignmentsAndDirections : Scenario
Y = Pos.Bottom (txtLabelMC) + 1,
Width = Dim.Width (txtLabelMC),
Height = Dim.Percent (100, DimPercentMode.Position),
- TextAlignment = TextAlignment.Centered,
- VerticalTextAlignment = VerticalTextAlignment.Bottom,
+ TextAlignment = Alignment.Center,
+ VerticalTextAlignment = Alignment.End,
ColorScheme = color1,
Text = txt
};
@@ -372,25 +373,25 @@ public class TextAlignmentsAndDirections : Scenario
Y = Pos.Bottom (txtLabelMR) + 1,
Width = Dim.Percent (100, DimPercentMode.Position),
Height = Dim.Percent (100, DimPercentMode.Position),
- TextAlignment = TextAlignment.Right,
- VerticalTextAlignment = VerticalTextAlignment.Bottom,
+ TextAlignment = Alignment.End,
+ VerticalTextAlignment = Alignment.End,
ColorScheme = color1,
Text = txt
};
txtLabelBR.TextFormatter.MultiLine = true;
- mtxts.Add (txtLabelTL);
- mtxts.Add (txtLabelTC);
- mtxts.Add (txtLabelTR);
- mtxts.Add (txtLabelML);
- mtxts.Add (txtLabelMC);
- mtxts.Add (txtLabelMR);
- mtxts.Add (txtLabelBL);
- mtxts.Add (txtLabelBC);
- mtxts.Add (txtLabelBR);
+ multiLineLabels.Add (txtLabelTL);
+ multiLineLabels.Add (txtLabelTC);
+ multiLineLabels.Add (txtLabelTR);
+ multiLineLabels.Add (txtLabelML);
+ multiLineLabels.Add (txtLabelMC);
+ multiLineLabels.Add (txtLabelMR);
+ multiLineLabels.Add (txtLabelBL);
+ multiLineLabels.Add (txtLabelBC);
+ multiLineLabels.Add (txtLabelBR);
- // Save Alignments in Data
- foreach (Label t in mtxts)
+ // Save Alignment in Data
+ foreach (Label t in multiLineLabels)
{
t.Data = new { h = t.TextAlignment, v = t.VerticalTextAlignment };
}
@@ -411,24 +412,32 @@ public class TextAlignmentsAndDirections : Scenario
// Edit Text
- var editText = new TextView
+ var label = new Label
{
X = 1,
Y = Pos.Bottom (container) + 1,
- Width = Dim.Fill (10),
- Height = Dim.Fill (1),
- ColorScheme = Colors.ColorSchemes ["TopLevel"],
+ Width = 10,
+ Height = 1,
+ Text = "Edit Text:"
+ };
+
+ var editText = new TextView
+ {
+ X = Pos.Right (label) + 1,
+ Y = Pos.Top (label),
+ Width = Dim.Fill (31),
+ Height = 3,
Text = txt
};
editText.MouseClick += (s, m) =>
{
- foreach (Label v in txts)
+ foreach (Label v in singleLineLabels)
{
v.Text = editText.Text;
}
- foreach (Label v in mtxts)
+ foreach (Label v in multiLineLabels)
{
v.Text = editText.Text;
}
@@ -436,12 +445,12 @@ public class TextAlignmentsAndDirections : Scenario
app.KeyUp += (s, m) =>
{
- foreach (Label v in txts)
+ foreach (Label v in singleLineLabels)
{
v.Text = editText.Text;
}
- foreach (Label v in mtxts)
+ foreach (Label v in multiLineLabels)
{
v.Text = editText.Text;
}
@@ -449,7 +458,7 @@ public class TextAlignmentsAndDirections : Scenario
editText.SetFocus ();
- app.Add (editText);
+ app.Add (label, editText);
// JUSTIFY CHECKBOX
@@ -459,7 +468,7 @@ public class TextAlignmentsAndDirections : Scenario
Y = Pos.Y (container) + 1,
Width = Dim.Fill (10),
Height = 1,
- Text = "Justify"
+ Text = "Fill"
};
app.Add (justifyCheckbox);
@@ -470,17 +479,14 @@ public class TextAlignmentsAndDirections : Scenario
{
X = Pos.Left (justifyCheckbox) + 1,
Y = Pos.Y (justifyCheckbox) + 1,
- Width = Dim.Fill (11),
- RadioLabels = ["Current direction", "Opposite direction", "Justify Both"],
+ Width = Dim.Fill (9),
+ RadioLabels = ["Current direction", "Opposite direction", "FIll Both"],
Enabled = false
};
justifyCheckbox.Toggled += (s, e) => ToggleJustify (e.OldValue is { } && (bool)e.OldValue);
- justifyOptions.SelectedItemChanged += (s, e) =>
- {
- ToggleJustify (false, true);
- };
+ justifyOptions.SelectedItemChanged += (s, e) => { ToggleJustify (false, true); };
app.Add (justifyOptions);
@@ -492,21 +498,22 @@ public class TextAlignmentsAndDirections : Scenario
Y = Pos.Bottom (justifyOptions),
Width = Dim.Fill (10),
Height = 1,
- Text = "Word Wrap",
+ Text = "Word Wrap"
};
wrapCheckbox.Checked = wrapCheckbox.TextFormatter.WordWrap;
+
wrapCheckbox.Toggled += (s, e) =>
{
if (e.OldValue == true)
{
- foreach (Label t in mtxts)
+ foreach (Label t in multiLineLabels)
{
t.TextFormatter.WordWrap = false;
}
}
else
{
- foreach (Label t in mtxts)
+ foreach (Label t in multiLineLabels)
{
t.TextFormatter.WordWrap = true;
}
@@ -523,21 +530,22 @@ public class TextAlignmentsAndDirections : Scenario
Y = Pos.Y (wrapCheckbox) + 1,
Width = Dim.Fill (10),
Height = 1,
- Text = "AutoSize",
+ Text = "AutoSize"
};
autoSizeCheckbox.Checked = autoSizeCheckbox.TextFormatter.AutoSize;
+
autoSizeCheckbox.Toggled += (s, e) =>
{
if (e.OldValue == true)
{
- foreach (Label t in mtxts)
+ foreach (Label t in multiLineLabels)
{
t.TextFormatter.AutoSize = false;
}
}
else
{
- foreach (Label t in mtxts)
+ foreach (Label t in multiLineLabels)
{
t.TextFormatter.AutoSize = true;
}
@@ -562,15 +570,18 @@ public class TextAlignmentsAndDirections : Scenario
directionOptions.SelectedItemChanged += (s, ev) =>
{
- var justChecked = justifyCheckbox.Checked is { } && (bool)justifyCheckbox.Checked;
+ bool justChecked = justifyCheckbox.Checked is { } && (bool)justifyCheckbox.Checked;
+
if (justChecked)
{
ToggleJustify (true);
}
- foreach (Label v in mtxts)
+
+ foreach (Label v in multiLineLabels)
{
v.TextDirection = (TextDirection)ev.SelectedItem;
}
+
if (justChecked)
{
ToggleJustify (false);
@@ -584,22 +595,22 @@ public class TextAlignmentsAndDirections : Scenario
void ToggleJustify (bool oldValue, bool wasJustOptions = false)
{
- if (oldValue == true)
+ if (oldValue)
{
if (!wasJustOptions)
{
justifyOptions.Enabled = false;
}
- foreach (Label t in mtxts)
+ foreach (Label t in multiLineLabels)
{
- t.TextAlignment = (TextAlignment)((dynamic)t.Data).h;
- t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v;
+ t.TextAlignment = (Alignment)((dynamic)t.Data).h;
+ t.VerticalTextAlignment = (Alignment)((dynamic)t.Data).v;
}
}
else
{
- foreach (Label t in mtxts)
+ foreach (Label t in multiLineLabels)
{
if (!wasJustOptions)
{
@@ -611,16 +622,19 @@ public class TextAlignmentsAndDirections : Scenario
switch (justifyOptions.SelectedItem)
{
case 0:
- t.VerticalTextAlignment = VerticalTextAlignment.Justified;
+ t.VerticalTextAlignment = Alignment.Fill;
t.TextAlignment = ((dynamic)t.Data).h;
+
break;
case 1:
- t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v;
- t.TextAlignment = TextAlignment.Justified;
+ t.VerticalTextAlignment = (Alignment)((dynamic)t.Data).v;
+ t.TextAlignment = Alignment.Fill;
+
break;
case 2:
- t.VerticalTextAlignment = VerticalTextAlignment.Justified;
- t.TextAlignment = TextAlignment.Justified;
+ t.VerticalTextAlignment = Alignment.Fill;
+ t.TextAlignment = Alignment.Fill;
+
break;
}
}
@@ -629,16 +643,19 @@ public class TextAlignmentsAndDirections : Scenario
switch (justifyOptions.SelectedItem)
{
case 0:
- t.TextAlignment = TextAlignment.Justified;
+ t.TextAlignment = Alignment.Fill;
t.VerticalTextAlignment = ((dynamic)t.Data).v;
+
break;
case 1:
- t.TextAlignment = (TextAlignment)((dynamic)t.Data).h;
- t.VerticalTextAlignment = VerticalTextAlignment.Justified;
+ t.TextAlignment = (Alignment)((dynamic)t.Data).h;
+ t.VerticalTextAlignment = Alignment.Fill;
+
break;
case 2:
- t.TextAlignment = TextAlignment.Justified;
- t.VerticalTextAlignment = VerticalTextAlignment.Justified;
+ t.TextAlignment = Alignment.Fill;
+ t.VerticalTextAlignment = Alignment.Fill;
+
break;
}
}
diff --git a/UICatalog/Scenarios/TextAlignments.cs b/UICatalog/Scenarios/TextAlignments.cs
deleted file mode 100644
index 92ee344e1..000000000
--- a/UICatalog/Scenarios/TextAlignments.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Terminal.Gui;
-
-namespace UICatalog.Scenarios;
-
-[ScenarioMetadata ("Simple Text Alignment", "Demonstrates horizontal text alignment")]
-[ScenarioCategory ("Text and Formatting")]
-public class TextAlignments : Scenario
-{
- public override void Setup ()
- {
- Win.X = 10;
- Win.Width = Dim.Fill (10);
-
- var txt = "Hello world, how are you today? Pretty neat!";
- var unicodeSampleText = "A Unicode sentence (пÑРвеÑ) has words.";
-
- List alignments = Enum.GetValues (typeof (TextAlignment)).Cast ().ToList ();
- Label [] singleLines = new Label [alignments.Count];
- Label [] multipleLines = new Label [alignments.Count];
-
- var multiLineHeight = 5;
-
- foreach (TextAlignment alignment in alignments)
- {
- singleLines [(int)alignment] = new()
- {
- TextAlignment = alignment,
- X = 1,
-
- Width = Dim.Fill (1),
- Height = 1,
- ColorScheme = Colors.ColorSchemes ["Dialog"],
- Text = txt
- };
-
- multipleLines [(int)alignment] = new()
- {
- TextAlignment = alignment,
- X = 1,
-
- Width = Dim.Fill (1),
- Height = multiLineHeight,
- ColorScheme = Colors.ColorSchemes ["Dialog"],
- Text = txt
- };
- }
-
- // Add a label & text field so we can demo IsDefault
- var editLabel = new Label { X = 0, Y = 0, Text = "Text:" };
- Win.Add (editLabel);
-
- var edit = new TextView
- {
- X = Pos.Right (editLabel) + 1,
- Y = Pos.Y (editLabel),
- Width = Dim.Fill ("Text:".Length + " Unicode Sample".Length + 2),
- Height = 4,
- ColorScheme = Colors.ColorSchemes ["TopLevel"],
- Text = txt
- };
-
- edit.TextChanged += (s, e) =>
- {
- foreach (TextAlignment alignment in alignments)
- {
- singleLines [(int)alignment].Text = edit.Text;
- multipleLines [(int)alignment].Text = edit.Text;
- }
- };
- Win.Add (edit);
-
- var unicodeSample = new Button { X = Pos.Right (edit) + 1, Y = 0, Text = "Unicode Sample" };
- unicodeSample.Accept += (s, e) => { edit.Text = unicodeSampleText; };
- Win.Add (unicodeSample);
-
- var update = new Button { X = Pos.Right (edit) + 1, Y = Pos.Bottom (edit) - 1, Text = "_Update" };
-
- update.Accept += (s, e) =>
- {
- foreach (TextAlignment alignment in alignments)
- {
- singleLines [(int)alignment].Text = edit.Text;
- multipleLines [(int)alignment].Text = edit.Text;
- }
- };
- Win.Add (update);
-
- var enableHotKeyCheckBox = new CheckBox
- {
- X = 0, Y = Pos.Bottom (edit), Text = "Enable Hotkey (_)", Checked = false
- };
-
- Win.Add (enableHotKeyCheckBox);
-
- var label = new Label
- {
- Y = Pos.Bottom (enableHotKeyCheckBox) + 1, Text = "Demonstrating single-line (should clip):"
- };
- Win.Add (label);
-
- foreach (TextAlignment alignment in alignments)
- {
- label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" };
- Win.Add (label);
- singleLines [(int)alignment].Y = Pos.Bottom (label);
- Win.Add (singleLines [(int)alignment]);
- label = singleLines [(int)alignment];
- }
-
- txt += "\nSecond line\n\nFourth Line.";
- label = new() { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" };
- Win.Add (label);
-
- foreach (TextAlignment alignment in alignments)
- {
- label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" };
- Win.Add (label);
- multipleLines [(int)alignment].Y = Pos.Bottom (label);
- Win.Add (multipleLines [(int)alignment]);
- label = multipleLines [(int)alignment];
- }
-
- enableHotKeyCheckBox.Toggled += (s, e) =>
- {
- foreach (TextAlignment alignment in alignments)
- {
- singleLines [(int)alignment].HotKeySpecifier =
- e.OldValue == true ? (Rune)0xffff : (Rune)'_';
-
- multipleLines [(int)alignment].HotKeySpecifier =
- e.OldValue == true ? (Rune)0xffff : (Rune)'_';
- }
-
- Win.SetNeedsDisplay ();
- Win.LayoutSubviews ();
- };
- }
-}
diff --git a/UICatalog/Scenarios/TextFormatterDemo.cs b/UICatalog/Scenarios/TextFormatterDemo.cs
index 00029c033..81bf6a839 100644
--- a/UICatalog/Scenarios/TextFormatterDemo.cs
+++ b/UICatalog/Scenarios/TextFormatterDemo.cs
@@ -63,17 +63,29 @@ public class TextFormatterDemo : Scenario
app.Add (unicodeCheckBox);
- List alignments = Enum.GetValues (typeof (TextAlignment)).Cast ().ToList ();
+ static IEnumerable GetUniqueEnumValues () where T : Enum
+ {
+ var values = new HashSet ();
+ foreach (T v in Enum.GetValues (typeof (T)))
+ {
+ if (values.Add (v))
+ {
+ yield return v;
+ }
+ }
+ }
+
+ List alignments = new () { Alignment.Start, Alignment.End, Alignment.Center, Alignment.Fill };
Label [] singleLines = new Label [alignments.Count];
Label [] multipleLines = new Label [alignments.Count];
var multiLineHeight = 5;
- foreach (TextAlignment alignment in alignments)
+ for (int i = 0; i < alignments.Count; i++)
{
- singleLines [(int)alignment] = new()
+ singleLines [i] = new ()
{
- TextAlignment = alignment,
+ TextAlignment = alignments [i],
X = 0,
Width = Dim.Fill (),
@@ -82,9 +94,9 @@ public class TextFormatterDemo : Scenario
Text = text
};
- multipleLines [(int)alignment] = new()
+ multipleLines [i] = new ()
{
- TextAlignment = alignment,
+ TextAlignment = alignments [i],
X = 0,
Width = Dim.Fill (),
@@ -100,33 +112,33 @@ public class TextFormatterDemo : Scenario
};
app.Add (label);
- foreach (TextAlignment alignment in alignments)
+ for (int i = 0; i < alignments.Count; i++)
{
- label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" };
+ label = new () { Y = Pos.Bottom (label), Text = $"{alignments [i]}:" };
app.Add (label);
- singleLines [(int)alignment].Y = Pos.Bottom (label);
- app.Add (singleLines [(int)alignment]);
- label = singleLines [(int)alignment];
+ singleLines [i].Y = Pos.Bottom (label);
+ app.Add (singleLines [i]);
+ label = singleLines [i];
}
- label = new() { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" };
+ label = new () { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" };
app.Add (label);
- foreach (TextAlignment alignment in alignments)
+ for (int i = 0; i < alignments.Count; i++)
{
- label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" };
+ label = new () { Y = Pos.Bottom (label), Text = $"{alignments [i]}:" };
app.Add (label);
- multipleLines [(int)alignment].Y = Pos.Bottom (label);
- app.Add (multipleLines [(int)alignment]);
- label = multipleLines [(int)alignment];
+ multipleLines [i].Y = Pos.Bottom (label);
+ app.Add (multipleLines [i]);
+ label = multipleLines [i];
}
unicodeCheckBox.Toggled += (s, e) =>
{
- foreach (TextAlignment alignment in alignments)
+ for (int i = 0; i < alignments.Count; i++)
{
- singleLines [(int)alignment].Text = e.OldValue == true ? text : unicode;
- multipleLines [(int)alignment].Text = e.OldValue == true ? text : unicode;
+ singleLines [i].Text = e.OldValue == true ? text : unicode;
+ multipleLines [i].Text = e.OldValue == true ? text : unicode;
}
};
diff --git a/UICatalog/Scenarios/TimeAndDate.cs b/UICatalog/Scenarios/TimeAndDate.cs
index ddfc8fc7d..4db2ace96 100644
--- a/UICatalog/Scenarios/TimeAndDate.cs
+++ b/UICatalog/Scenarios/TimeAndDate.cs
@@ -57,7 +57,7 @@ public class TimeAndDate : Scenario
{
X = Pos.Center (),
Y = Pos.Bottom (longDate) + 1,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = Dim.Fill (),
Text = "Old Time: "
@@ -68,7 +68,7 @@ public class TimeAndDate : Scenario
{
X = Pos.Center (),
Y = Pos.Bottom (_lblOldTime) + 1,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = Dim.Fill (),
Text = "New Time: "
@@ -79,7 +79,7 @@ public class TimeAndDate : Scenario
{
X = Pos.Center (),
Y = Pos.Bottom (_lblNewTime) + 1,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = Dim.Fill (),
Text = "Time Format: "
@@ -90,7 +90,7 @@ public class TimeAndDate : Scenario
{
X = Pos.Center (),
Y = Pos.Bottom (_lblTimeFmt) + 2,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = Dim.Fill (),
Text = "Old Date: "
@@ -101,7 +101,7 @@ public class TimeAndDate : Scenario
{
X = Pos.Center (),
Y = Pos.Bottom (_lblOldDate) + 1,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = Dim.Fill (),
Text = "New Date: "
@@ -112,7 +112,7 @@ public class TimeAndDate : Scenario
{
X = Pos.Center (),
Y = Pos.Bottom (_lblNewDate) + 1,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = Dim.Fill (),
Text = "Date Format: "
diff --git a/UICatalog/Scenarios/Unicode.cs b/UICatalog/Scenarios/Unicode.cs
index 987c50934..c9654e59d 100644
--- a/UICatalog/Scenarios/Unicode.cs
+++ b/UICatalog/Scenarios/Unicode.cs
@@ -132,8 +132,8 @@ public class UnicodeInMenu : Scenario
Width = Dim.Percent (50),
Height = 1,
- TextAlignment = TextAlignment.Right,
- Text = $"Align Right - {gitString}"
+ TextAlignment = Alignment.End,
+ Text = $"End - {gitString}"
};
Win.Add (checkBox, checkBoxRight);
diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs
index be9bbdf5c..915a2b96a 100644
--- a/UICatalog/Scenarios/ViewExperiments.cs
+++ b/UICatalog/Scenarios/ViewExperiments.cs
@@ -60,7 +60,7 @@ public class ViewExperiments : Scenario
Width = 17,
Title = "Window 1",
Text = "Window #2",
- TextAlignment = TextAlignment.Centered
+ TextAlignment = Alignment.Center
};
window1.Margin.Thickness = new (0);
@@ -84,7 +84,7 @@ public class ViewExperiments : Scenario
Width = 37,
Title = "Window2",
Text = "Window #2 (Right(window1)+1",
- TextAlignment = TextAlignment.Centered
+ TextAlignment = Alignment.Center
};
//view3.InitializeFrames ();
@@ -109,7 +109,7 @@ public class ViewExperiments : Scenario
Width = 37,
Title = "View4",
Text = "View #4 (Right(window2)+1",
- TextAlignment = TextAlignment.Centered
+ TextAlignment = Alignment.Center
};
//view4.InitializeFrames ();
@@ -134,7 +134,7 @@ public class ViewExperiments : Scenario
Width = Dim.Fill (),
Title = "View5",
Text = "View #5 (Right(view4)+1 Fill",
- TextAlignment = TextAlignment.Centered
+ TextAlignment = Alignment.Center
};
//view5.InitializeFrames ();
@@ -181,7 +181,7 @@ public class ViewExperiments : Scenario
X = Pos.Center (),
Y = Pos.Percent (50),
Width = 30,
- TextAlignment = TextAlignment.Centered
+ TextAlignment = Alignment.Center
};
label50.Border.Thickness = new (1, 3, 1, 1);
label50.Height = 5;
diff --git a/UICatalog/Scenarios/Wizards.cs b/UICatalog/Scenarios/Wizards.cs
index 22f7e042e..5fd52f4e8 100644
--- a/UICatalog/Scenarios/Wizards.cs
+++ b/UICatalog/Scenarios/Wizards.cs
@@ -21,7 +21,7 @@ public class Wizards : Scenario
};
Win.Add (frame);
- var label = new Label { X = 0, Y = 0, TextAlignment = TextAlignment.Right, Text = "Width:" };
+ var label = new Label { X = 0, Y = 0, TextAlignment = Alignment.End, Text = "Width:" };
frame.Add (label);
var widthEdit = new TextField
@@ -41,7 +41,7 @@ public class Wizards : Scenario
Width = Dim.Width (label),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "Height:"
};
frame.Add (label);
@@ -63,7 +63,7 @@ public class Wizards : Scenario
Width = Dim.Width (label),
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Text = "Title:"
};
frame.Add (label);
@@ -88,7 +88,7 @@ public class Wizards : Scenario
label = new()
{
- X = Pos.Center (), Y = Pos.AnchorEnd (1), TextAlignment = TextAlignment.Right, Text = "Action:"
+ X = Pos.Center (), Y = Pos.AnchorEnd (1), TextAlignment = Alignment.End, Text = "Action:"
};
Win.Add (label);
diff --git a/UnitTests/Configuration/ConfigurationMangerTests.cs b/UnitTests/Configuration/ConfigurationMangerTests.cs
index 6d3273847..553df407d 100644
--- a/UnitTests/Configuration/ConfigurationMangerTests.cs
+++ b/UnitTests/Configuration/ConfigurationMangerTests.cs
@@ -783,8 +783,7 @@ public class ConfigurationManagerTests
}
}
}
- ],
- ""Dialog.DefaultButtonAlignment"": ""Center""
+ ]
}
}
]
diff --git a/UnitTests/Configuration/ThemeScopeTests.cs b/UnitTests/Configuration/ThemeScopeTests.cs
index 3da7f881a..7991da5e7 100644
--- a/UnitTests/Configuration/ThemeScopeTests.cs
+++ b/UnitTests/Configuration/ThemeScopeTests.cs
@@ -29,12 +29,12 @@ public class ThemeScopeTests
{
Reset ();
Assert.NotEmpty (Themes);
- Assert.Equal (Dialog.ButtonAlignments.Center, Dialog.DefaultButtonAlignment);
+ Assert.Equal (Alignment.End, Dialog.DefaultButtonAlignment);
- Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = Dialog.ButtonAlignments.Right;
+ Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = Alignment.Center;
ThemeManager.Themes! [ThemeManager.SelectedTheme]!.Apply ();
- Assert.Equal (Dialog.ButtonAlignments.Right, Dialog.DefaultButtonAlignment);
+ Assert.Equal (Alignment.Center, Dialog.DefaultButtonAlignment);
Reset ();
}
diff --git a/UnitTests/Configuration/ThemeTests.cs b/UnitTests/Configuration/ThemeTests.cs
index f7d8c732f..99038bd86 100644
--- a/UnitTests/Configuration/ThemeTests.cs
+++ b/UnitTests/Configuration/ThemeTests.cs
@@ -77,15 +77,15 @@ public class ThemeTests
public void TestSerialize_RoundTrip ()
{
var theme = new ThemeScope ();
- theme ["Dialog.DefaultButtonAlignment"].PropertyValue = Dialog.ButtonAlignments.Right;
+ theme ["Dialog.DefaultButtonAlignment"].PropertyValue = Alignment.End;
string json = JsonSerializer.Serialize (theme, _jsonOptions);
var deserialized = JsonSerializer.Deserialize (json, _jsonOptions);
Assert.Equal (
- Dialog.ButtonAlignments.Right,
- (Dialog.ButtonAlignments)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue
+ Alignment.End,
+ (Alignment)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue
);
Reset ();
}
diff --git a/UnitTests/Dialogs/DialogTests.cs b/UnitTests/Dialogs/DialogTests.cs
index 2bd03de1a..4152440bf 100644
--- a/UnitTests/Dialogs/DialogTests.cs
+++ b/UnitTests/Dialogs/DialogTests.cs
@@ -32,14 +32,14 @@ public class DialogTests
Title = title,
Width = width,
Height = 1,
- ButtonAlignment = Dialog.ButtonAlignments.Center,
- Buttons = [new () { Text = btn1Text }]
+ ButtonAlignment = Alignment.Center,
+ Buttons = [new Button { Text = btn1Text }]
};
// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
dlg.Border.Thickness = new (1, 0, 1, 0);
runstate = Begin (dlg);
- var buttonRow = $"{CM.Glyphs.VLine} {btn1} {CM.Glyphs.VLine}";
+ var buttonRow = $"{CM.Glyphs.VLine} {btn1} {CM.Glyphs.VLine}";
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
// Now add a second button
@@ -57,14 +57,14 @@ public class DialogTests
Title = title,
Width = width,
Height = 1,
- ButtonAlignment = Dialog.ButtonAlignments.Justify,
- Buttons = [new () { Text = btn1Text }]
+ ButtonAlignment = Alignment.Fill,
+ Buttons = [new Button { Text = btn1Text }]
};
// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
dlg.Border.Thickness = new (1, 0, 1, 0);
runstate = Begin (dlg);
- buttonRow = $"{CM.Glyphs.VLine} {btn1}{CM.Glyphs.VLine}";
+ buttonRow = $"{CM.Glyphs.VLine}{btn1} {CM.Glyphs.VLine}";
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
// Now add a second button
@@ -82,8 +82,8 @@ public class DialogTests
Title = title,
Width = width,
Height = 1,
- ButtonAlignment = Dialog.ButtonAlignments.Right,
- Buttons = [new () { Text = btn1Text }]
+ ButtonAlignment = Alignment.End,
+ Buttons = [new Button { Text = btn1Text }]
};
// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -107,8 +107,8 @@ public class DialogTests
Title = title,
Width = width,
Height = 1,
- ButtonAlignment = Dialog.ButtonAlignments.Left,
- Buttons = [new () { Text = btn1Text }]
+ ButtonAlignment = Alignment.Start,
+ Buttons = [new Button { Text = btn1Text }]
};
// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -153,9 +153,26 @@ public class DialogTests
// Default - Center
(runstate, Dialog dlg) = RunButtonTestDialog (
+ title,
+ width,
+ Alignment.Center,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
+ TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
+ End (runstate);
+ dlg.Dispose ();
+
+ // Justify
+ buttonRow = $"{CM.Glyphs.VLine}{btn1} {btn2} {btn3} {btn4}{CM.Glyphs.VLine}";
+ Assert.Equal (width, buttonRow.Length);
+
+ (runstate, dlg) = RunButtonTestDialog (
title,
width,
- Dialog.ButtonAlignments.Center,
+ Alignment.Fill,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
@@ -165,36 +182,19 @@ public class DialogTests
End (runstate);
dlg.Dispose ();
- // Justify
- buttonRow = $"{CM.Glyphs.VLine}{btn1} {btn2} {btn3} {btn4}{CM.Glyphs.VLine}";
- Assert.Equal (width, buttonRow.Length);
-
- (runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Justify,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
- TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
- End (runstate);
- dlg.Dispose ();
-
// Right
buttonRow = $"{CM.Glyphs.VLine} {btn1} {btn2} {btn3} {btn4}{CM.Glyphs.VLine}";
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Right,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.End,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -204,14 +204,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Left,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.Start,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -243,12 +243,12 @@ public class DialogTests
// Default - Center
buttonRow =
- $"{CM.Glyphs.VLine}es {CM.Glyphs.RightBracket} {btn2} {btn3} {CM.Glyphs.LeftBracket} neve{CM.Glyphs.VLine}";
+ $"{CM.Glyphs.VLine}{CM.Glyphs.LeftBracket} yes {CM.Glyphs.RightBracket}{btn2}{btn3}{CM.Glyphs.LeftBracket} neve{CM.Glyphs.VLine}";
(runstate, Dialog dlg) = RunButtonTestDialog (
title,
width,
- Dialog.ButtonAlignments.Center,
+ Alignment.Center,
new Button { Text = btn1Text },
new Button { Text = btn2Text },
new Button { Text = btn3Text },
@@ -264,46 +264,47 @@ public class DialogTests
$"{CM.Glyphs.VLine}{CM.Glyphs.LeftBracket} yes {CM.Glyphs.LeftBracket} no {CM.Glyphs.LeftBracket} maybe {CM.Glyphs.LeftBracket} never {CM.Glyphs.RightBracket}{CM.Glyphs.VLine}";
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Justify,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.Fill,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
// Right
- buttonRow = $"{CM.Glyphs.VLine}{CM.Glyphs.RightBracket} {btn2} {btn3} {btn4}{CM.Glyphs.VLine}";
+ buttonRow = $"{CM.Glyphs.VLine}es {CM.Glyphs.RightBracket}{btn2}{btn3}{btn4}{CM.Glyphs.VLine}";
+ Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Right,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.End,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
// Left
- buttonRow = $"{CM.Glyphs.VLine}{btn1} {btn2} {btn3} {CM.Glyphs.LeftBracket} n{CM.Glyphs.VLine}";
+ buttonRow = $"{CM.Glyphs.VLine}{btn1}{btn2}{btn3}{CM.Glyphs.LeftBracket} neve{CM.Glyphs.VLine}";
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Left,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.Start,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -337,14 +338,14 @@ public class DialogTests
// Default - Center
(runstate, Dialog dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Center,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.Center,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -354,14 +355,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Justify,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.Fill,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -371,14 +372,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Right,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.End,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -388,14 +389,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Left,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.Start,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -431,14 +432,14 @@ public class DialogTests
// Default - Center
(runstate, Dialog dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Center,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.Center,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -448,14 +449,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.GetColumns ());
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Justify,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.Fill,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -465,14 +466,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.GetColumns ());
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Right,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.End,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -482,14 +483,14 @@ public class DialogTests
Assert.Equal (width, buttonRow.GetColumns ());
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Left,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text },
- new Button { Text = btn4Text }
- );
+ title,
+ width,
+ Alignment.Start,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text },
+ new Button { Text = btn4Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -514,11 +515,11 @@ public class DialogTests
d.SetBufferSize (width, 1);
(runstate, Dialog dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Center,
- new Button { Text = btnText }
- );
+ title,
+ width,
+ Alignment.Center,
+ new Button { Text = btnText }
+ );
// Center
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -527,15 +528,15 @@ public class DialogTests
// Justify
buttonRow =
- $"{CM.Glyphs.VLine} {CM.Glyphs.LeftBracket} {btnText} {CM.Glyphs.RightBracket}{CM.Glyphs.VLine}";
+ $"{CM.Glyphs.VLine}{CM.Glyphs.LeftBracket} {btnText} {CM.Glyphs.RightBracket} {CM.Glyphs.VLine}";
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Justify,
- new Button { Text = btnText }
- );
+ title,
+ width,
+ Alignment.Fill,
+ new Button { Text = btnText }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -546,11 +547,11 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Right,
- new Button { Text = btnText }
- );
+ title,
+ width,
+ Alignment.End,
+ new Button { Text = btnText }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -561,11 +562,11 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Left,
- new Button { Text = btnText }
- );
+ title,
+ width,
+ Alignment.Start,
+ new Button { Text = btnText }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -578,26 +579,26 @@ public class DialogTests
d.SetBufferSize (width, 1);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Center,
- new Button { Text = btnText }
- );
+ title,
+ width,
+ Alignment.Center,
+ new Button { Text = btnText }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
// Justify
buttonRow =
- $"{CM.Glyphs.VLine} {CM.Glyphs.LeftBracket} {btnText} {CM.Glyphs.RightBracket}{CM.Glyphs.VLine}";
+ $"{CM.Glyphs.VLine}{CM.Glyphs.LeftBracket} {btnText} {CM.Glyphs.RightBracket} {CM.Glyphs.VLine}";
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Justify,
- new Button { Text = btnText }
- );
+ title,
+ width,
+ Alignment.Fill,
+ new Button { Text = btnText }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -608,11 +609,11 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Right,
- new Button { Text = btnText }
- );
+ title,
+ width,
+ Alignment.End,
+ new Button { Text = btnText }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -623,11 +624,11 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Left,
- new Button { Text = btnText }
- );
+ title,
+ width,
+ Alignment.Start,
+ new Button { Text = btnText }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -657,13 +658,13 @@ public class DialogTests
d.SetBufferSize (buttonRow.Length, 3);
(runstate, Dialog dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Center,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text }
- );
+ title,
+ width,
+ Alignment.Center,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -673,13 +674,13 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Justify,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text }
- );
+ title,
+ width,
+ Alignment.Fill,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -689,13 +690,13 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Right,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text }
- );
+ title,
+ width,
+ Alignment.End,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -705,13 +706,13 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Left,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text },
- new Button { Text = btn3Text }
- );
+ title,
+ width,
+ Alignment.Start,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text },
+ new Button { Text = btn3Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -739,12 +740,12 @@ public class DialogTests
d.SetBufferSize (buttonRow.Length, 3);
(runstate, Dialog dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Center,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text }
- );
+ title,
+ width,
+ Alignment.Center,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -754,12 +755,12 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Justify,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text }
- );
+ title,
+ width,
+ Alignment.Fill,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -769,12 +770,12 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Right,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text }
- );
+ title,
+ width,
+ Alignment.End,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -784,12 +785,12 @@ public class DialogTests
Assert.Equal (width, buttonRow.Length);
(runstate, dlg) = RunButtonTestDialog (
- title,
- width,
- Dialog.ButtonAlignments.Left,
- new Button { Text = btn1Text },
- new Button { Text = btn2Text }
- );
+ title,
+ width,
+ Alignment.Start,
+ new Button { Text = btn1Text },
+ new Button { Text = btn2Text }
+ );
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
dlg.Dispose ();
@@ -821,9 +822,9 @@ public class DialogTests
Button button1, button2;
// Default (Center)
- button1 = new () { Text = btn1Text };
- button2 = new () { Text = btn2Text };
- (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, button1, button2);
+ button1 = new Button { Text = btn1Text };
+ button2 = new Button { Text = btn2Text };
+ (runstate, dlg) = RunButtonTestDialog (title, width, Alignment.Center, button1, button2);
button1.Visible = false;
RunIteration (ref runstate, ref firstIteration);
buttonRow = $@"{CM.Glyphs.VLine} {btn2} {CM.Glyphs.VLine}";
@@ -833,9 +834,9 @@ public class DialogTests
// Justify
Assert.Equal (width, buttonRow.Length);
- button1 = new () { Text = btn1Text };
- button2 = new () { Text = btn2Text };
- (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, button1, button2);
+ button1 = new Button { Text = btn1Text };
+ button2 = new Button { Text = btn2Text };
+ (runstate, dlg) = RunButtonTestDialog (title, width, Alignment.Fill, button1, button2);
button1.Visible = false;
RunIteration (ref runstate, ref firstIteration);
buttonRow = $@"{CM.Glyphs.VLine} {btn2}{CM.Glyphs.VLine}";
@@ -845,9 +846,9 @@ public class DialogTests
// Right
Assert.Equal (width, buttonRow.Length);
- button1 = new () { Text = btn1Text };
- button2 = new () { Text = btn2Text };
- (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, button1, button2);
+ button1 = new Button { Text = btn1Text };
+ button2 = new Button { Text = btn2Text };
+ (runstate, dlg) = RunButtonTestDialog (title, width, Alignment.End, button1, button2);
button1.Visible = false;
RunIteration (ref runstate, ref firstIteration);
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -856,9 +857,9 @@ public class DialogTests
// Left
Assert.Equal (width, buttonRow.Length);
- button1 = new () { Text = btn1Text };
- button2 = new () { Text = btn2Text };
- (runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, button1, button2);
+ button1 = new Button { Text = btn1Text };
+ button2 = new Button { Text = btn2Text };
+ (runstate, dlg) = RunButtonTestDialog (title, width, Alignment.Start, button1, button2);
button1.Visible = false;
RunIteration (ref runstate, ref firstIteration);
buttonRow = $@"{CM.Glyphs.VLine} {btn2} {CM.Glyphs.VLine}";
@@ -888,6 +889,7 @@ public class DialogTests
win.Loaded += (s, a) =>
{
+ Dialog.DefaultButtonAlignment = Alignment.Center;
var dlg = new Dialog { Width = 18, Height = 3, Buttons = [new () { Text = "Ok" }] };
dlg.Loaded += (s, a) =>
@@ -915,7 +917,7 @@ public class DialogTests
@"
┌┌───────────────┐─┐
││ │ │
-││ ⟦ Ok ⟧ │ │
+││ ⟦ Ok ⟧ │ │
│└───────────────┘ │
└──────────────────┘"
)]
@@ -925,7 +927,7 @@ public class DialogTests
┌┌───────────────┐─┐
││ │ │
││ │ │
-││ ⟦ Ok ⟧ │ │
+││ ⟦ Ok ⟧ │ │
│└───────────────┘ │
└──────────────────┘"
)]
@@ -936,7 +938,7 @@ public class DialogTests
│┌───────────────┐ │
││ │ │
││ │ │
-││ ⟦ Ok ⟧ │ │
+││ ⟦ Ok ⟧ │ │
│└───────────────┘ │
└──────────────────┘"
)]
@@ -948,7 +950,7 @@ public class DialogTests
││ │ │
││ │ │
││ │ │
-││ ⟦ Ok ⟧ │ │
+││ ⟦ Ok ⟧ │ │
│└───────────────┘ │
└──────────────────┘"
)]
@@ -961,7 +963,7 @@ public class DialogTests
││ │ │
││ │ │
││ │ │
-││ ⟦ Ok ⟧ │ │
+││ ⟦ Ok ⟧ │ │
│└───────────────┘ │
└──────────────────┘"
)]
@@ -971,6 +973,7 @@ public class DialogTests
var win = new Window ();
int iterations = -1;
+ Dialog.DefaultButtonAlignment = Alignment.Center;
Iteration += (s, a) =>
{
@@ -1005,6 +1008,7 @@ public class DialogTests
public void Dialog_Opened_From_Another_Dialog ()
{
((FakeDriver)Driver).SetBufferSize (30, 10);
+ Dialog.DefaultButtonAlignment = Alignment.Center;
var btn1 = new Button { Text = "press me 1" };
Button btn2 = null;
@@ -1281,7 +1285,7 @@ public class DialogTests
(runstate, Dialog _) = RunButtonTestDialog (
title,
width,
- Dialog.ButtonAlignments.Center,
+ Alignment.Center,
new Button { Text = btnText }
);
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -1334,7 +1338,7 @@ public class DialogTests
int width = buttonRow.Length;
d.SetBufferSize (buttonRow.Length, 3);
- (runstate, Dialog dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, null);
+ (runstate, Dialog dlg) = RunButtonTestDialog (title, width, Alignment.Center, null);
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
End (runstate);
@@ -1344,7 +1348,7 @@ public class DialogTests
private (RunState, Dialog) RunButtonTestDialog (
string title,
int width,
- Dialog.ButtonAlignments align,
+ Alignment align,
params Button [] btns
)
{
diff --git a/UnitTests/Dialogs/MessageBoxTests.cs b/UnitTests/Dialogs/MessageBoxTests.cs
index 1101a2737..21768924f 100644
--- a/UnitTests/Dialogs/MessageBoxTests.cs
+++ b/UnitTests/Dialogs/MessageBoxTests.cs
@@ -278,7 +278,7 @@ public class MessageBoxTests
│ffffffffffffffffff│
│ ffffffffffffff │
│ │
-│ {btn} │
+│ {btn} │
└──────────────────┘",
_output
);
@@ -302,7 +302,7 @@ public class MessageBoxTests
│ffffffffffffffffff│
│ffffffffffffffffff│
│ffffffffffffffffff│
-│ {btn} │",
+│ {btn} │",
_output
);
Application.RequestStop ();
@@ -377,7 +377,7 @@ ff ff ff ff ff ff ff
────────────────────
ffffffffffffffffffff
- ⟦► btn ◄⟧
+ ⟦► btn ◄⟧
────────────────────
",
_output
@@ -459,7 +459,7 @@ ffffffffffffffffffff
│ffffffffffffffffff│
│ffffffffffffffffff│
│ffffffffffffffffff│
-│ {btn} │",
+│ {btn} │",
_output
);
Application.RequestStop ();
@@ -509,7 +509,7 @@ ffffffffffffffffffff
────────────────────
ffffffffffffffffffff
- ⟦► btn ◄⟧
+ ⟦► btn ◄⟧
────────────────────
",
_output
@@ -529,7 +529,7 @@ ffffffffffffffffffff
────────────────────
ffffffffffffffffffff
- ⟦► btn ◄⟧
+ ⟦► btn ◄⟧
────────────────────
",
_output
diff --git a/UnitTests/Drawing/AlignerTests.cs b/UnitTests/Drawing/AlignerTests.cs
new file mode 100644
index 000000000..a168fd1a1
--- /dev/null
+++ b/UnitTests/Drawing/AlignerTests.cs
@@ -0,0 +1,454 @@
+using System.Text;
+using System.Text.Json;
+using Xunit.Abstractions;
+
+namespace Terminal.Gui.DrawingTests;
+
+public class AlignerTests (ITestOutputHelper output)
+{
+ private readonly ITestOutputHelper _output = output;
+
+ public static IEnumerable AlignmentEnumValues ()
+ {
+ foreach (object number in Enum.GetValues (typeof (Alignment)))
+ {
+ yield return new [] { number };
+ }
+ }
+
+ [Theory]
+ [MemberData (nameof (AlignmentEnumValues))]
+ public void Alignment_Round_Trips (Alignment alignment)
+ {
+ string serialized = JsonSerializer.Serialize (alignment);
+ var deserialized = JsonSerializer.Deserialize (serialized);
+
+ Assert.Equal (alignment, deserialized);
+ }
+
+ [Theory]
+ [MemberData (nameof (AlignmentEnumValues))]
+ public void NoItems_Works (Alignment alignment)
+ {
+ int [] sizes = [];
+ int [] positions = Aligner.Align (alignment, AlignmentModes.StartToEnd, 100, sizes);
+ Assert.Equal (new int [] { }, positions);
+ }
+
+ [Theory]
+ [MemberData (nameof (AlignmentEnumValues))]
+ public void Negative_Widths_Not_Allowed (Alignment alignment)
+ {
+ Assert.Throws (
+ () => new Aligner
+ {
+ Alignment = alignment,
+ ContainerSize = 100
+ }.Align (new [] { -10, 20, 30 }));
+
+ Assert.Throws (
+ () => new Aligner
+ {
+ Alignment = alignment,
+ ContainerSize = 100
+ }.Align (new [] { 10, -20, 30 }));
+
+ Assert.Throws (
+ () => new Aligner
+ {
+ Alignment = alignment,
+ ContainerSize = 100
+ }.Align (new [] { 10, 20, -30 }));
+ }
+
+ [Theory]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0 }, 1, new [] { 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 1, new [] { 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 2, new [] { 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 3, new [] { 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 4, new [] { 0, 2 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 10, new [] { 0, 2, 5 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 11, new [] { 0, 2, 5 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 12, new [] { 0, 2, 5 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 13, new [] { 0, 2, 5 })]
+ [InlineData (
+ Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems,
+ new [] { 1, 2, 3 },
+ 5,
+ new [] { 0, 1, 3 })] // 5 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10 }, 101, new [] { 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20 }, 101, new [] { 0, 11 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 100, new [] { 0, 11, 32 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 101, new [] { 0, 11, 32 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0 }, 1, new [] { 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 10, new [] { 2, 4, 7 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 11, new [] { 3, 5, 8 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 12, new [] { 4, 6, 9 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 13, new [] { 5, 7, 10 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1.
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 100, new [] { 38, 49, 70 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10 }, 101, new [] { 91 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20 }, 101, new [] { 70, 81 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 101, new [] { 39, 50, 71 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0 }, 1, new [] { 0 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 1, new [] { 0 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 2, new [] { 0 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1 }, 3, new [] { 1 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1 }, 4, new [] { 0, 2 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 10, new [] { 1, 3, 6 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 11, new [] { 1, 3, 6 })]
+ [InlineData (
+ Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems,
+ new [] { 1, 2, 3 },
+ 5,
+ new [] { 0, 1, 3 })] // 5 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+ [InlineData (
+ Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems,
+ new [] { 1, 2, 3 },
+ 4,
+ new [] { -1, 0, 2 })] // 4 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 9, new [] { 0, 3, 6 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 10, new [] { 0, 4, 7 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 11, new [] { 0, 4, 8 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 12, new [] { 0, 4, 8 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 13, new [] { 1, 5, 9 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 101, new [] { 0, 34, 68 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 102, new [] { 0, 34, 68 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 103, new [] { 1, 35, 69 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 104, new [] { 1, 35, 69 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10 }, 101, new [] { 45 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20 }, 101, new [] { 35, 46 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 100, new [] { 19, 30, 51 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 101, new [] { 19, 30, 51 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40 }, 100, new [] { 0, 10, 30, 60 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5, 6 }, 25, new [] { 2, 6, 11, 17 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 100, new [] { 0, 30, 70 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20, 30 }, 101, new [] { 0, 31, 71 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 11, 17, 23 }, 100, new [] { 0, 36, 77 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 1, 2, 3 }, 11, new [] { 0, 4, 8 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 10 }, 101, new [] { 0 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 3, 3 }, 21, new [] { 0, 9, 18 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5 }, 21, new [] { 0, 8, 16 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5, 6 }, 18, new [] { 0, 3, 7, 12 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5, 6 }, 19, new [] { 0, 4, 8, 13 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5, 6 }, 20, new [] { 0, 4, 9, 14 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 3, 4, 5, 6 }, 21, new [] { 0, 4, 9, 15 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 22, new [] { 0, 8, 14, 19 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 23, new [] { 0, 8, 15, 20 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 24, new [] { 0, 8, 15, 21 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 25, new [] { 0, 9, 16, 22 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 26, new [] { 0, 9, 17, 23 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems, new [] { 6, 5, 4, 3 }, 31, new [] { 0, 11, 20, 28 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0 }, 1, new [] { 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 1, new [] { 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 2, new [] { 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 3, new [] { 2 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 8, new [] { 0, 2, 5 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 9, new [] { 0, 2, 6 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 10, new [] { 0, 2, 7 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 11, new [] { 0, 2, 8 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1.})]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 3, 3 }, 21, new [] { 0, 4, 18 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 4, 5 }, 21, new [] { 0, 4, 16 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10 }, 101, new [] { 91 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 100, new [] { 0, 11, 70 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 101, new [] { 0, 11, 71 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0 }, 1, new [] { 0 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 1, new [] { 0 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 2, new [] { 0 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 3, new [] { 0 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 4 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 8, new [] { 0, 2, 5 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 9, new [] { 0, 3, 6 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 10, new [] { 0, 4, 7 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 11, new [] { 0, 5, 8 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 5, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 7 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 1, 4, 8 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 3, 3 }, 21, new [] { 0, 14, 18 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 67 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10 }, 101, new [] { 0 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 100, new [] { 0, 49, 70 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 101, new [] { 0, 50, 71 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.AddSpaceBetweenItems | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
+
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 0 }, 1, new [] { 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 0, 0 }, 1, new [] { 0, 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 10, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 11, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 12, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 13, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 6 })]
+ [InlineData (
+ Alignment.Start, AlignmentModes.StartToEnd,
+ new [] { 1, 2, 3 },
+ 5,
+ new [] { 0, 1, 3 })] // 5 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 100, new [] { 0, 10, 30 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 66 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10 }, 101, new [] { 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10, 20 }, 101, new [] { 0, 10 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 101, new [] { 0, 10, 30 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 60 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 100 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 0 }, 1, new [] { 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 0, 0 }, 1, new [] { 1, 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 0, 0, 0 }, 1, new [] { 1, 1, 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 7, new [] { 1, 2, 4 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 10, new [] { 4, 5, 7 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 11, new [] { 5, 6, 8 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 12, new [] { 6, 7, 9 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 13, new [] { 7, 8, 10 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 5, new [] { -1, 0, 2 })] // 5 is too small to fit the items. The first item is at -1.
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 11, new [] { 1, 2, 4, 7 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 100, new [] { 40, 50, 70 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 100, new [] { 1, 34, 67 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10 }, 101, new [] { 91 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10, 20 }, 101, new [] { 71, 81 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 101, new [] { 41, 51, 71 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40 }, 101, new [] { 1, 11, 31, 61 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 1, 11, 31, 61, 101 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1 }, 1, new [] { 0 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1 }, 2, new [] { 0 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1 }, 3, new [] { 1 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 1 }, 3, new [] { 0, 1 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 1 }, 4, new [] { 1, 2 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 10, new [] { 2, 3, 5 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 11, new [] { 2, 3, 5 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 9, new [] { 0, 3, 6 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 10, new [] { 0, 3, 6 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 11, new [] { 1, 4, 7 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 12, new [] { 1, 4, 7 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 13, new [] { 2, 5, 8 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 5, new [] { 0, 1, 3 })] // 5 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 4, new [] { -1, 0, 2 })] // 4 is too small to fit the items. The first item is at 0, the items to the right are clipped.
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 66 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 101, new [] { 1, 34, 67 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 102, new [] { 1, 34, 67 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 103, new [] { 2, 35, 68 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 104, new [] { 2, 35, 68 })]
+ [InlineData (Alignment.Center, AlignmentModes.StartToEnd, new [] { 3, 4, 5, 6 }, 25, new [] { 3, 6, 10, 15 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 100, new [] { 0, 30, 70 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10, 20, 30 }, 101, new [] { 0, 31, 71 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 11, 17, 23 }, 100, new [] { 0, 36, 77 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 1, 2, 3 }, 11, new [] { 0, 4, 8 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 10 }, 101, new [] { 0 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 3, 3 }, 21, new [] { 0, 9, 18 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 4, 5 }, 21, new [] { 0, 8, 16 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 4, 5, 6 }, 18, new [] { 0, 3, 7, 12 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 4, 5, 6 }, 19, new [] { 0, 4, 8, 13 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 4, 5, 6 }, 20, new [] { 0, 4, 9, 14 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 3, 4, 5, 6 }, 21, new [] { 0, 4, 9, 15 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 22, new [] { 0, 8, 14, 19 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 23, new [] { 0, 8, 15, 20 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 24, new [] { 0, 8, 15, 21 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 25, new [] { 0, 9, 16, 22 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 26, new [] { 0, 9, 17, 23 })]
+ [InlineData (Alignment.Fill, AlignmentModes.StartToEnd, new [] { 6, 5, 4, 3 }, 31, new [] { 0, 11, 20, 28 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0 }, 1, new [] { 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 1, new [] { 0 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 2, new [] { 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 3, new [] { 2 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 4 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 8, new [] { 0, 1, 5 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 9, new [] { 0, 1, 6 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 10, new [] { 0, 1, 7 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 11, new [] { 0, 1, 8 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 7 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 1, 3, 8 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 3, 3 }, 21, new [] { 0, 3, 18 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 4, 5 }, 21, new [] { 0, 3, 16 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 67 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10 }, 101, new [] { 91 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 100, new [] { 0, 10, 70 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 101, new [] { 0, 10, 71 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
+ [InlineData (Alignment.Start, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0 }, 1, new [] { 0 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0 }, 1, new [] { 0, 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 1, new [] { 0 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 2, new [] { 0 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1 }, 3, new [] { 0 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 2, new [] { 0, 1 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 3, new [] { 0, 2 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1 }, 4, new [] { 0, 3 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 8, new [] { 0, 3, 5 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 9, new [] { 0, 4, 6 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 10, new [] { 0, 5, 7 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3 }, 11, new [] { 0, 6, 8 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 3, 5, 8 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 3, 3 }, 21, new [] { 0, 15, 18 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 3, 4, 5 }, 21, new [] { 0, 12, 16 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10 }, 101, new [] { 0 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20 }, 101, new [] { 0, 81 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 100, new [] { 0, 50, 70 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30 }, 101, new [] { 0, 51, 71 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
+ [InlineData (Alignment.End, AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
+
+ public void Alignment_Aligns (Alignment alignment, AlignmentModes modes, int [] sizes, int containerSize, int [] expected)
+ {
+ int [] positions = new Aligner
+ {
+ Alignment = alignment,
+ AlignmentModes = AlignmentModes.StartToEnd | modes,
+ ContainerSize = containerSize
+ }.Align (sizes);
+ AssertAlignment (alignment, sizes, containerSize, positions, expected);
+ }
+
+
+ private void AssertAlignment (Alignment alignment, int [] sizes, int totalSize, int [] positions, int [] expected)
+ {
+ try
+ {
+ _output.WriteLine ($"Testing: {RenderAlignment (alignment, sizes, totalSize, expected)}");
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine ($"Exception rendering expected: {e.Message}");
+ _output.WriteLine ($"Actual: {RenderAlignment (alignment, sizes, totalSize, positions)}");
+ }
+
+ if (!expected.SequenceEqual (positions))
+ {
+ _output.WriteLine ($"Expected: {RenderAlignment (alignment, sizes, totalSize, expected)}");
+ _output.WriteLine ($"Actual: {RenderAlignment (alignment, sizes, totalSize, positions)}");
+ Assert.Fail (" Expected and actual do not match");
+ }
+ }
+
+ private string RenderAlignment (Alignment alignment, int [] sizes, int totalSize, int [] positions)
+ {
+ var output = new StringBuilder ();
+ output.AppendLine ($"Alignment: {alignment}, Positions: {string.Join (", ", positions)}, TotalSize: {totalSize}");
+
+ for (var i = 0; i <= totalSize / 10; i++)
+ {
+ output.Append (i.ToString ().PadRight (9) + " ");
+ }
+
+ output.AppendLine ();
+
+ for (var i = 0; i < totalSize; i++)
+ {
+ output.Append (i % 10);
+ }
+
+ output.AppendLine ();
+
+ var items = new char [totalSize];
+
+ for (var position = 0; position < positions.Length; position++)
+ {
+ // try
+ {
+ for (var j = 0; j < sizes [position] && positions [position] + j < totalSize; j++)
+ {
+ if (positions [position] + j >= 0)
+ {
+ items [positions [position] + j] = (position + 1).ToString () [0];
+ }
+ }
+ }
+ }
+
+ output.Append (new string (items).Replace ('\0', ' '));
+
+ return output.ToString ();
+ }
+}
diff --git a/UnitTests/Drawing/JustifierTests.cs b/UnitTests/Drawing/JustifierTests.cs
deleted file mode 100644
index 481848640..000000000
--- a/UnitTests/Drawing/JustifierTests.cs
+++ /dev/null
@@ -1,426 +0,0 @@
-using System.Text;
-using Xunit.Abstractions;
-
-namespace Terminal.Gui.DrawingTests;
-
-public class JustifierTests (ITestOutputHelper output)
-{
- private readonly ITestOutputHelper _output = output;
-
- public static IEnumerable JustificationEnumValues ()
- {
- foreach (object number in Enum.GetValues (typeof (Justification)))
- {
- yield return new [] { number };
- }
- }
-
- [Theory]
- [MemberData (nameof (JustificationEnumValues))]
- public void NoItems_Works (Justification justification)
- {
- int [] sizes = [];
- int [] positions = Justifier.Justify (justification, false, 100, sizes);
- Assert.Equal (new int [] { }, positions);
- }
-
- [Theory]
- [MemberData (nameof (JustificationEnumValues))]
- public void Negative_Widths_Not_Allowed (Justification justification)
- {
- Assert.Throws (() => new Justifier ()
- {
- Justification = justification,
- ContainerSize = 100
- }.Justify (new [] { -10, 20, 30 }));
- Assert.Throws (() => new Justifier ()
- {
- Justification = justification,
- ContainerSize = 100
- }.Justify (new [] { 10, -20, 30 }));
- Assert.Throws (() => new Justifier ()
- {
- Justification = justification,
- ContainerSize = 100
- }.Justify (new [] { 10, 20, -30 }));
- }
-
- [Theory]
- [InlineData (Justification.Left, new [] { 0 }, 1, new [] { 0 })]
- [InlineData (Justification.Left, new [] { 0, 0 }, 1, new [] { 0, 1 })]
- [InlineData (Justification.Left, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
- [InlineData (Justification.Left, new [] { 1 }, 1, new [] { 0 })]
- [InlineData (Justification.Left, new [] { 1 }, 2, new [] { 0 })]
- [InlineData (Justification.Left, new [] { 1 }, 3, new [] { 0 })]
- [InlineData (Justification.Left, new [] { 1, 1 }, 2, new [] { 0, 1 })]
- [InlineData (Justification.Left, new [] { 1, 1 }, 3, new [] { 0, 2 })]
- [InlineData (Justification.Left, new [] { 1, 1 }, 4, new [] { 0, 2 })]
- [InlineData (Justification.Left, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 10, new [] { 0, 2, 5 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 11, new [] { 0, 2, 5 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 12, new [] { 0, 2, 5 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 13, new [] { 0, 2, 5 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
- [InlineData (Justification.Left, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
- [InlineData (Justification.Left, new [] { 10 }, 101, new [] { 0 })]
- [InlineData (Justification.Left, new [] { 10, 20 }, 101, new [] { 0, 11 })]
- [InlineData (Justification.Left, new [] { 10, 20, 30 }, 100, new [] { 0, 11, 32 })]
- [InlineData (Justification.Left, new [] { 10, 20, 30 }, 101, new [] { 0, 11, 32 })]
- [InlineData (Justification.Left, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
- [InlineData (Justification.Left, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
- [InlineData (Justification.Right, new [] { 0 }, 1, new [] { 1 })]
- [InlineData (Justification.Right, new [] { 0, 0 }, 1, new [] { 0, 1 })]
- [InlineData (Justification.Right, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 10, new [] { 2, 4, 7 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 11, new [] { 3, 5, 8 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 12, new [] { 4, 6, 9 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 13, new [] { 5, 7, 10 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
- [InlineData (Justification.Right, new [] { 10, 20, 30 }, 100, new [] { 38, 49, 70 })]
- [InlineData (Justification.Right, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
- [InlineData (Justification.Right, new [] { 10 }, 101, new [] { 91 })]
- [InlineData (Justification.Right, new [] { 10, 20 }, 101, new [] { 70, 81 })]
- [InlineData (Justification.Right, new [] { 10, 20, 30 }, 101, new [] { 39, 50, 71 })]
- [InlineData (Justification.Right, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
- [InlineData (Justification.Right, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
- [InlineData (Justification.Centered, new [] { 0 }, 1, new [] { 0 })]
- [InlineData (Justification.Centered, new [] { 0, 0 }, 1, new [] { 0, 1 })]
- [InlineData (Justification.Centered, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
- [InlineData (Justification.Centered, new [] { 1 }, 1, new [] { 0 })]
- [InlineData (Justification.Centered, new [] { 1 }, 2, new [] { 0 })]
- [InlineData (Justification.Centered, new [] { 1 }, 3, new [] { 1 })]
- [InlineData (Justification.Centered, new [] { 1, 1 }, 2, new [] { 0, 1 })]
- [InlineData (Justification.Centered, new [] { 1, 1 }, 3, new [] { 0, 2 })]
- [InlineData (Justification.Centered, new [] { 1, 1 }, 4, new [] { 0, 2 })]
- [InlineData (Justification.Centered, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 10, new [] { 1, 3, 6 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 11, new [] { 1, 3, 6 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
- [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 9, new [] { 0, 3, 6 })]
- [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 10, new [] { 0, 4, 7 })]
- [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 11, new [] { 0, 4, 8 })]
- [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 12, new [] { 0, 4, 8 })]
- [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 13, new [] { 1, 5, 9 })]
- [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
- [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 101, new [] { 0, 34, 68 })]
- [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 102, new [] { 0, 34, 68 })]
- [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 103, new [] { 1, 35, 69 })]
- [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 104, new [] { 1, 35, 69 })]
- [InlineData (Justification.Centered, new [] { 10 }, 101, new [] { 45 })]
- [InlineData (Justification.Centered, new [] { 10, 20 }, 101, new [] { 35, 46 })]
- [InlineData (Justification.Centered, new [] { 10, 20, 30 }, 100, new [] { 19, 30, 51 })]
- [InlineData (Justification.Centered, new [] { 10, 20, 30 }, 101, new [] { 19, 30, 51 })]
- [InlineData (Justification.Centered, new [] { 10, 20, 30, 40 }, 100, new [] { 0, 10, 30, 60 })]
- [InlineData (Justification.Centered, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
- [InlineData (Justification.Centered, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
- [InlineData (Justification.Centered, new [] { 3, 4, 5, 6 }, 25, new [] { 2, 6, 11, 17 })]
- [InlineData (Justification.Justified, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
- [InlineData (Justification.Justified, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
- [InlineData (Justification.Justified, new [] { 10, 20, 30 }, 100, new [] { 0, 30, 70 })]
- [InlineData (Justification.Justified, new [] { 10, 20, 30 }, 101, new [] { 0, 31, 71 })]
- [InlineData (Justification.Justified, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
- [InlineData (Justification.Justified, new [] { 11, 17, 23 }, 100, new [] { 0, 36, 77 })]
- [InlineData (Justification.Justified, new [] { 1, 2, 3 }, 11, new [] { 0, 4, 8 })]
- [InlineData (Justification.Justified, new [] { 10, 20 }, 101, new [] { 0, 81 })]
- [InlineData (Justification.Justified, new [] { 10 }, 101, new [] { 0 })]
- [InlineData (Justification.Justified, new [] { 3, 3, 3 }, 21, new [] { 0, 9, 18 })]
- [InlineData (Justification.Justified, new [] { 3, 4, 5 }, 21, new [] { 0, 8, 16 })]
- [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 18, new [] { 0, 3, 7, 12 })]
- [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 19, new [] { 0, 4, 8, 13 })]
- [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 20, new [] { 0, 4, 9, 14 })]
- [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 21, new [] { 0, 4, 9, 15 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 22, new [] { 0, 8, 14, 19 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 23, new [] { 0, 8, 15, 20 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 24, new [] { 0, 8, 15, 21 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 25, new [] { 0, 9, 16, 22 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 26, new [] { 0, 9, 17, 23 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 31, new [] { 0, 11, 20, 28 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 0 }, 1, new [] { 1 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 0, 0 }, 1, new [] { 0, 1 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 1, new [] { 0 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 2, new [] { 1 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 3, new [] { 2 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 2, new [] { 0, 1 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 3, new [] { 0, 2 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 4, new [] { 0, 3 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 8, new [] { 0, 2, 5 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 9, new [] { 0, 2, 6 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 10, new [] { 0, 2, 7 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 11, new [] { 0, 2, 8 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 3, 3, 3 }, 21, new [] { 0, 4, 18 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 3, 4, 5 }, 21, new [] { 0, 4, 16 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10 }, 101, new [] { 91 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10, 20 }, 101, new [] { 0, 81 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30 }, 100, new [] { 0, 11, 70 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30 }, 101, new [] { 0, 11, 71 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 0 }, 1, new [] { 0 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 0, 0 }, 1, new [] { 0, 1 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 1 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 1, new [] { 0 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 2, new [] { 0 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 3, new [] { 0 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 2, new [] { 0, 1 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 3, new [] { 0, 2 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 4, new [] { 0, 3 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 4 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 8, new [] { 0, 2, 5 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 9, new [] { 0, 3, 6 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 10, new [] { 0, 4, 7 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 11, new [] { 0, 5, 8 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 7 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 1, 4, 8 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 3, 3, 3 }, 21, new [] { 0, 14, 18 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 11, 16 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 67 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10 }, 101, new [] { 0 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20 }, 101, new [] { 0, 81 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30 }, 100, new [] { 0, 49, 70 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30 }, 101, new [] { 0, 50, 71 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
- public void TestJustifications_PutSpaceBetweenItems (Justification justification, int [] sizes, int containerSize, int [] expected)
- {
- int [] positions = new Justifier
- {
- PutSpaceBetweenItems = true,
- Justification = justification,
- ContainerSize = containerSize
- }.Justify (sizes);
- AssertJustification (justification, sizes, containerSize, positions, expected);
- }
-
- [Theory]
- [InlineData (Justification.Left, new [] { 0 }, 1, new [] { 0 })]
- [InlineData (Justification.Left, new [] { 0, 0 }, 1, new [] { 0, 0 })]
- [InlineData (Justification.Left, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 0 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 3 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 10, new [] { 0, 1, 3 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 11, new [] { 0, 1, 3 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 12, new [] { 0, 1, 3 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3 }, 13, new [] { 0, 1, 3 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.Left, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.Left, new [] { 10, 20, 30 }, 100, new [] { 0, 10, 30 })]
- [InlineData (Justification.Left, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 66 })]
- [InlineData (Justification.Left, new [] { 10 }, 101, new [] { 0 })]
- [InlineData (Justification.Left, new [] { 10, 20 }, 101, new [] { 0, 10 })]
- [InlineData (Justification.Left, new [] { 10, 20, 30 }, 101, new [] { 0, 10, 30 })]
- [InlineData (Justification.Left, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 60 })]
- [InlineData (Justification.Left, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 100 })]
- [InlineData (Justification.Right, new [] { 0 }, 1, new [] { 1 })]
- [InlineData (Justification.Right, new [] { 0, 0 }, 1, new [] { 1, 1 })]
- [InlineData (Justification.Right, new [] { 0, 0, 0 }, 1, new [] { 1, 1, 1 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 7, new [] { 1, 2, 4 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 10, new [] { 4, 5, 7 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 11, new [] { 5, 6, 8 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 12, new [] { 6, 7, 9 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3 }, 13, new [] { 7, 8, 10 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.Right, new [] { 1, 2, 3, 4 }, 11, new [] { 1, 2, 4, 7 })]
- [InlineData (Justification.Right, new [] { 10, 20, 30 }, 100, new [] { 40, 50, 70 })]
- [InlineData (Justification.Right, new [] { 33, 33, 33 }, 100, new [] { 1, 34, 67 })]
- [InlineData (Justification.Right, new [] { 10 }, 101, new [] { 91 })]
- [InlineData (Justification.Right, new [] { 10, 20 }, 101, new [] { 71, 81 })]
- [InlineData (Justification.Right, new [] { 10, 20, 30 }, 101, new [] { 41, 51, 71 })]
- [InlineData (Justification.Right, new [] { 10, 20, 30, 40 }, 101, new [] { 1, 11, 31, 61 })]
- [InlineData (Justification.Right, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 1, 11, 31, 61, 101 })]
- [InlineData (Justification.Centered, new [] { 1 }, 1, new [] { 0 })]
- [InlineData (Justification.Centered, new [] { 1 }, 2, new [] { 0 })]
- [InlineData (Justification.Centered, new [] { 1 }, 3, new [] { 1 })]
- [InlineData (Justification.Centered, new [] { 1, 1 }, 2, new [] { 0, 1 })]
- [InlineData (Justification.Centered, new [] { 1, 1 }, 3, new [] { 0, 1 })]
- [InlineData (Justification.Centered, new [] { 1, 1 }, 4, new [] { 1, 2 })]
- [InlineData (Justification.Centered, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 3 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 10, new [] { 2, 3, 5 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3 }, 11, new [] { 2, 3, 5 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.Centered, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 9, new [] { 0, 3, 6 })]
- [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 10, new [] { 0, 3, 6 })]
- [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 11, new [] { 1, 4, 7 })]
- [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 12, new [] { 1, 4, 7 })]
- [InlineData (Justification.Centered, new [] { 3, 3, 3 }, 13, new [] { 2, 5, 8 })]
- [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 66 })]
- [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 101, new [] { 1, 34, 67 })]
- [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 102, new [] { 1, 34, 67 })]
- [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 103, new [] { 2, 35, 68 })]
- [InlineData (Justification.Centered, new [] { 33, 33, 33 }, 104, new [] { 2, 35, 68 })]
- [InlineData (Justification.Centered, new [] { 3, 4, 5, 6 }, 25, new [] { 3, 6, 10, 15 })]
- [InlineData (Justification.Justified, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
- [InlineData (Justification.Justified, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
- [InlineData (Justification.Justified, new [] { 10, 20, 30 }, 100, new [] { 0, 30, 70 })]
- [InlineData (Justification.Justified, new [] { 10, 20, 30 }, 101, new [] { 0, 31, 71 })]
- [InlineData (Justification.Justified, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
- [InlineData (Justification.Justified, new [] { 11, 17, 23 }, 100, new [] { 0, 36, 77 })]
- [InlineData (Justification.Justified, new [] { 1, 2, 3 }, 11, new [] { 0, 4, 8 })]
- [InlineData (Justification.Justified, new [] { 10, 20 }, 101, new [] { 0, 81 })]
- [InlineData (Justification.Justified, new [] { 10 }, 101, new [] { 0 })]
- [InlineData (Justification.Justified, new [] { 3, 3, 3 }, 21, new [] { 0, 9, 18 })]
- [InlineData (Justification.Justified, new [] { 3, 4, 5 }, 21, new [] { 0, 8, 16 })]
- [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 18, new [] { 0, 3, 7, 12 })]
- [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 19, new [] { 0, 4, 8, 13 })]
- [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 20, new [] { 0, 4, 9, 14 })]
- [InlineData (Justification.Justified, new [] { 3, 4, 5, 6 }, 21, new [] { 0, 4, 9, 15 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 22, new [] { 0, 8, 14, 19 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 23, new [] { 0, 8, 15, 20 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 24, new [] { 0, 8, 15, 21 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 25, new [] { 0, 9, 16, 22 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 26, new [] { 0, 9, 17, 23 })]
- [InlineData (Justification.Justified, new [] { 6, 5, 4, 3 }, 31, new [] { 0, 11, 20, 28 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 0 }, 1, new [] { 1 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 0, 0 }, 1, new [] { 0, 1 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 0, 0, 0 }, 1, new [] { 0, 0, 1 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 1, new [] { 0 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 2, new [] { 1 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1 }, 3, new [] { 2 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 2, new [] { 0, 1 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 3, new [] { 0, 2 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 1 }, 4, new [] { 0, 3 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 7, new [] { 0, 1, 4 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 8, new [] { 0, 1, 5 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 9, new [] { 0, 1, 6 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 10, new [] { 0, 1, 7 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3 }, 11, new [] { 0, 1, 8 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 1, 3, 7 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 1, 3, 8 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 3, 3, 3 }, 21, new [] { 0, 3, 18 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 3, 4, 5 }, 21, new [] { 0, 3, 16 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 33, 33, 33 }, 100, new [] { 0, 33, 67 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10 }, 101, new [] { 91 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10, 20 }, 101, new [] { 0, 81 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30 }, 100, new [] { 0, 10, 70 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30 }, 101, new [] { 0, 10, 71 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 10, 30, 61 })]
- [InlineData (Justification.LastRightRestLeft, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 10, 30, 60, 101 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 0 }, 1, new [] { 0 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 0, 0 }, 1, new [] { 0, 1 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 0, 0, 0 }, 1, new [] { 0, 1, 1 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 1, new [] { 0 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 2, new [] { 0 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1 }, 3, new [] { 0 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 2, new [] { 0, 1 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 3, new [] { 0, 2 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1 }, 4, new [] { 0, 3 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 1, 1 }, 3, new [] { 0, 1, 2 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 6, new [] { 0, 1, 3 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 7, new [] { 0, 2, 4 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 8, new [] { 0, 3, 5 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 9, new [] { 0, 4, 6 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 10, new [] { 0, 5, 7 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3 }, 11, new [] { 0, 6, 8 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 10, new [] { 0, 1, 3, 6 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 11, new [] { 0, 2, 4, 7 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 1, 2, 3, 4 }, 12, new [] { 0, 3, 5, 8 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 3, 3, 3 }, 21, new [] { 0, 15, 18 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 3, 4, 5 }, 21, new [] { 0, 12, 16 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 33, 33, 33 }, 100, new [] { 0, 34, 67 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10 }, 101, new [] { 0 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20 }, 101, new [] { 0, 81 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30 }, 100, new [] { 0, 50, 70 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30 }, 101, new [] { 0, 51, 71 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30, 40 }, 101, new [] { 0, 11, 31, 61 })]
- [InlineData (Justification.FirstLeftRestRight, new [] { 10, 20, 30, 40, 50 }, 151, new [] { 0, 11, 31, 61, 101 })]
- public void TestJustifications_NoSpaceBetweenItems (Justification justification, int [] sizes, int containerSize, int [] expected)
- {
- int [] positions = new Justifier
- {
- PutSpaceBetweenItems = false,
- Justification = justification,
- ContainerSize = containerSize
- }.Justify (sizes);
- AssertJustification (justification, sizes, containerSize, positions, expected);
- }
-
- public void AssertJustification (Justification justification, int [] sizes, int totalSize, int [] positions, int [] expected)
- {
- try
- {
- _output.WriteLine ($"Testing: {RenderJustification (justification, sizes, totalSize, expected)}");
- }
- catch (Exception e)
- {
- _output.WriteLine ($"Exception rendering expected: {e.Message}");
- _output.WriteLine ($"Actual: {RenderJustification (justification, sizes, totalSize, positions)}");
- }
-
- if (!expected.SequenceEqual (positions))
- {
- _output.WriteLine ($"Expected: {RenderJustification (justification, sizes, totalSize, expected)}");
- _output.WriteLine ($"Actual: {RenderJustification (justification, sizes, totalSize, positions)}");
- Assert.Fail (" Expected and actual do not match");
- }
- }
-
- public string RenderJustification (Justification justification, int [] sizes, int totalSize, int [] positions)
- {
- var output = new StringBuilder ();
- output.AppendLine ($"Justification: {justification}, Positions: {string.Join (", ", positions)}, TotalSize: {totalSize}");
-
- for (var i = 0; i <= totalSize / 10; i++)
- {
- output.Append (i.ToString ().PadRight (9) + " ");
- }
-
- output.AppendLine ();
-
- for (var i = 0; i < totalSize; i++)
- {
- output.Append (i % 10);
- }
-
- output.AppendLine ();
-
- var items = new char [totalSize];
-
- for (var position = 0; position < positions.Length; position++)
- {
- // try
- {
- for (var j = 0; j < sizes [position] && positions [position] + j < totalSize; j++)
- {
- items [positions [position] + j] = (position + 1).ToString () [0];
- }
- }
-
- //catch (Exception e)
- //{
- // output.AppendLine ($"{e.Message} - position = {position}, positions[{position}]: {positions [position]}, sizes[{position}]: {sizes [position]}, totalSize: {totalSize}");
- // output.Append (new string (items).Replace ('\0', ' '));
-
- // Assert.Fail (e.Message + output.ToString ());
- //}
- }
-
- output.Append (new string (items).Replace ('\0', ' '));
-
- return output.ToString ();
- }
-}
diff --git a/UnitTests/Drawing/ThicknessTests.cs b/UnitTests/Drawing/ThicknessTests.cs
index 76a1ab205..437a88469 100644
--- a/UnitTests/Drawing/ThicknessTests.cs
+++ b/UnitTests/Drawing/ThicknessTests.cs
@@ -841,19 +841,7 @@ public class ThicknessTests
3,
4,
5)]
- [InlineData (
- 1,
- 2,
- 3,
- 4,
- 1,
- 1,
- 1,
- 1,
- 2,
- 3,
- 4,
- 5)]
+
public void AddTest (
int left,
int top,
diff --git a/UnitTests/Text/TextFormatterTests.cs b/UnitTests/Text/TextFormatterTests.cs
index fda92ad8e..6746f8ad7 100644
--- a/UnitTests/Text/TextFormatterTests.cs
+++ b/UnitTests/Text/TextFormatterTests.cs
@@ -53,36 +53,36 @@ public class TextFormatterTests
tf.Text = testText;
Size expectedSize = new (testText.Length, 1);
Assert.Equal (testText, tf.Text);
- Assert.Equal (TextAlignment.Left, tf.Alignment);
+ Assert.Equal (Alignment.Start, tf.Alignment);
Assert.Equal (expectedSize, tf.Size);
tf.Draw (testBounds, new Attribute (), new Attribute ());
Assert.Equal (expectedSize, tf.Size);
Assert.NotEmpty (tf.GetLines ());
- tf.Alignment = TextAlignment.Right;
+ tf.Alignment = Alignment.End;
expectedSize = new (testText.Length, 1);
Assert.Equal (testText, tf.Text);
- Assert.Equal (TextAlignment.Right, tf.Alignment);
+ Assert.Equal (Alignment.End, tf.Alignment);
Assert.Equal (expectedSize, tf.Size);
tf.Draw (testBounds, new Attribute (), new Attribute ());
Assert.Equal (expectedSize, tf.Size);
Assert.NotEmpty (tf.GetLines ());
- tf.Alignment = TextAlignment.Right;
+ tf.Alignment = Alignment.End;
expectedSize = new (testText.Length, 1);
tf.Size = expectedSize;
Assert.Equal (testText, tf.Text);
- Assert.Equal (TextAlignment.Right, tf.Alignment);
+ Assert.Equal (Alignment.End, tf.Alignment);
Assert.Equal (expectedSize, tf.Size);
tf.Draw (testBounds, new Attribute (), new Attribute ());
Assert.Equal (expectedSize, tf.Size);
Assert.NotEmpty (tf.GetLines ());
- tf.Alignment = TextAlignment.Centered;
+ tf.Alignment = Alignment.Center;
expectedSize = new (testText.Length, 1);
tf.Size = expectedSize;
Assert.Equal (testText, tf.Text);
- Assert.Equal (TextAlignment.Centered, tf.Alignment);
+ Assert.Equal (Alignment.Center, tf.Alignment);
Assert.Equal (expectedSize, tf.Size);
tf.Draw (testBounds, new Attribute (), new Attribute ());
Assert.Equal (expectedSize, tf.Size);
@@ -191,12 +191,12 @@ public class TextFormatterTests
public void ClipAndJustify_Invalid_Returns_Original (string text)
{
string expected = string.IsNullOrEmpty (text) ? text : "";
- Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, TextAlignment.Left));
- Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, TextAlignment.Left));
+ Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, Alignment.Start));
+ Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, Alignment.Start));
Assert.Throws (
() =>
- TextFormatter.ClipAndJustify (text, -1, TextAlignment.Left)
+ TextFormatter.ClipAndJustify (text, -1, Alignment.Start)
);
}
@@ -219,19 +219,19 @@ public class TextFormatterTests
[InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit
public void ClipAndJustify_Valid_Centered (string text, string justifiedText, int maxWidth)
{
- var align = TextAlignment.Centered;
+ var alignment = Alignment.Center;
var textDirection = TextDirection.LeftRight_TopBottom;
var tabWidth = 1;
Assert.Equal (
justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, align, textDirection, tabWidth)
+ TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
);
int expectedClippedWidth = Math.Min (justifiedText.GetRuneCount (), maxWidth);
Assert.Equal (
justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, align, textDirection, tabWidth)
+ TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
);
Assert.True (justifiedText.GetRuneCount () <= maxWidth);
Assert.True (justifiedText.GetColumns () <= maxWidth);
@@ -277,19 +277,19 @@ public class TextFormatterTests
[InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit
public void ClipAndJustify_Valid_Justified (string text, string justifiedText, int maxWidth)
{
- var align = TextAlignment.Justified;
+ var alignment = Alignment.Fill;
var textDirection = TextDirection.LeftRight_TopBottom;
var tabWidth = 1;
Assert.Equal (
justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, align, textDirection, tabWidth)
+ TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
);
int expectedClippedWidth = Math.Min (justifiedText.GetRuneCount (), maxWidth);
Assert.Equal (
justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, align, textDirection, tabWidth)
+ TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
);
Assert.True (justifiedText.GetRuneCount () <= maxWidth);
Assert.True (justifiedText.GetColumns () <= maxWidth);
@@ -328,19 +328,19 @@ public class TextFormatterTests
[InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit
public void ClipAndJustify_Valid_Left (string text, string justifiedText, int maxWidth)
{
- var align = TextAlignment.Left;
+ var alignment = Alignment.Start;
var textDirection = TextDirection.LeftRight_BottomTop;
var tabWidth = 1;
Assert.Equal (
justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, align, textDirection, tabWidth)
+ TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
);
int expectedClippedWidth = Math.Min (justifiedText.GetRuneCount (), maxWidth);
Assert.Equal (
justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, align, textDirection, tabWidth)
+ TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
);
Assert.True (justifiedText.GetRuneCount () <= maxWidth);
Assert.True (justifiedText.GetColumns () <= maxWidth);
@@ -377,19 +377,19 @@ public class TextFormatterTests
[InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit
public void ClipAndJustify_Valid_Right (string text, string justifiedText, int maxWidth)
{
- var align = TextAlignment.Right;
+ var alignment = Alignment.End;
var textDirection = TextDirection.LeftRight_BottomTop;
var tabWidth = 1;
Assert.Equal (
justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, align, textDirection, tabWidth)
+ TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
);
int expectedClippedWidth = Math.Min (justifiedText.GetRuneCount (), maxWidth);
Assert.Equal (
justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, align, textDirection, tabWidth)
+ TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
);
Assert.True (justifiedText.GetRuneCount () <= maxWidth);
Assert.True (justifiedText.GetColumns () <= maxWidth);
@@ -757,7 +757,7 @@ ssb
TextFormatter.Format (
"Some text",
4,
- TextAlignment.Left,
+ Alignment.Start,
false,
true
)
@@ -785,7 +785,7 @@ ssb
for (int i = text.GetRuneCount (); i < maxWidth; i++)
{
- fmtText = TextFormatter.Format (text, i, TextAlignment.Justified, false, true) [0];
+ fmtText = TextFormatter.Format (text, i, Alignment.Fill, false, true) [0];
Assert.Equal (i, fmtText.GetRuneCount ());
char c = fmtText [^1];
Assert.True (text.EndsWith (c));
@@ -817,7 +817,7 @@ ssb
fmtText = TextFormatter.Format (
text,
i,
- TextAlignment.Justified,
+ Alignment.Fill,
false,
true,
0,
@@ -862,7 +862,7 @@ ssb
" A sentence has words. \n This is the second Line - 2. ",
4,
-50,
- TextAlignment.Left,
+ Alignment.Start,
true,
false,
new [] { " A", "sent", "ence", "has", "word", "s. ", " Thi", "s is", "the", "seco", "nd", "Line", "- 2." },
@@ -872,7 +872,7 @@ ssb
" A sentence has words. \n This is the second Line - 2. ",
4,
-50,
- TextAlignment.Left,
+ Alignment.Start,
true,
true,
new []
@@ -900,7 +900,7 @@ ssb
string text,
int maxWidth,
int widthOffset,
- TextAlignment textAlignment,
+ Alignment alignment,
bool wrap,
bool preserveTrailingSpaces,
IEnumerable resultLines,
@@ -908,7 +908,7 @@ ssb
)
{
Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap, preserveTrailingSpaces);
+ List list = TextFormatter.Format (text, maxWidth, alignment, wrap, preserveTrailingSpaces);
Assert.Equal (list.Count, resultLines.Count ());
Assert.Equal (resultLines, list);
var wrappedText = string.Empty;
@@ -1336,30 +1336,30 @@ ssb
Assert.NotEmpty (tf.GetLines ());
Assert.False (tf.NeedsFormat); // get_Lines causes a Format
- tf.Alignment = TextAlignment.Centered;
+ tf.Alignment = Alignment.Center;
Assert.True (tf.NeedsFormat);
Assert.NotEmpty (tf.GetLines ());
Assert.False (tf.NeedsFormat); // get_Lines causes a Format
}
[Theory]
- [InlineData ("", -1, TextAlignment.Left, false, 0)]
- [InlineData (null, 0, TextAlignment.Left, false, 1)]
- [InlineData (null, 0, TextAlignment.Left, true, 1)]
- [InlineData ("", 0, TextAlignment.Left, false, 1)]
- [InlineData ("", 0, TextAlignment.Left, true, 1)]
- public void Reformat_Invalid (string text, int maxWidth, TextAlignment textAlignment, bool wrap, int linesCount)
+ [InlineData ("", -1, Alignment.Start, false, 0)]
+ [InlineData (null, 0, Alignment.Start, false, 1)]
+ [InlineData (null, 0, Alignment.Start, true, 1)]
+ [InlineData ("", 0, Alignment.Start, false, 1)]
+ [InlineData ("", 0, Alignment.Start, true, 1)]
+ public void Reformat_Invalid (string text, int maxWidth, Alignment alignment, bool wrap, int linesCount)
{
if (maxWidth < 0)
{
Assert.Throws (
() =>
- TextFormatter.Format (text, maxWidth, textAlignment, wrap)
+ TextFormatter.Format (text, maxWidth, alignment, wrap)
);
}
else
{
- List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap);
+ List list = TextFormatter.Format (text, maxWidth, alignment, wrap);
Assert.NotEmpty (list);
Assert.True (list.Count == linesCount);
Assert.Equal (string.Empty, list [0]);
@@ -1367,25 +1367,25 @@ ssb
}
[Theory]
- [InlineData ("A sentence has words.\nLine 2.", 0, -29, TextAlignment.Left, false, 1, true)]
- [InlineData ("A sentence has words.\nLine 2.", 1, -28, TextAlignment.Left, false, 1, false)]
- [InlineData ("A sentence has words.\nLine 2.", 5, -24, TextAlignment.Left, false, 1, false)]
- [InlineData ("A sentence has words.\nLine 2.", 28, -1, TextAlignment.Left, false, 1, false)]
+ [InlineData ("A sentence has words.\nLine 2.", 0, -29, Alignment.Start, false, 1, true)]
+ [InlineData ("A sentence has words.\nLine 2.", 1, -28, Alignment.Start, false, 1, false)]
+ [InlineData ("A sentence has words.\nLine 2.", 5, -24, Alignment.Start, false, 1, false)]
+ [InlineData ("A sentence has words.\nLine 2.", 28, -1, Alignment.Start, false, 1, false)]
// no clip
- [InlineData ("A sentence has words.\nLine 2.", 29, 0, TextAlignment.Left, false, 1, false)]
- [InlineData ("A sentence has words.\nLine 2.", 30, 1, TextAlignment.Left, false, 1, false)]
- [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, TextAlignment.Left, false, 1, true)]
- [InlineData ("A sentence has words.\r\nLine 2.", 1, -29, TextAlignment.Left, false, 1, false)]
- [InlineData ("A sentence has words.\r\nLine 2.", 5, -25, TextAlignment.Left, false, 1, false)]
- [InlineData ("A sentence has words.\r\nLine 2.", 29, -1, TextAlignment.Left, false, 1, false, 1)]
- [InlineData ("A sentence has words.\r\nLine 2.", 30, 0, TextAlignment.Left, false, 1, false)]
- [InlineData ("A sentence has words.\r\nLine 2.", 31, 1, TextAlignment.Left, false, 1, false)]
+ [InlineData ("A sentence has words.\nLine 2.", 29, 0, Alignment.Start, false, 1, false)]
+ [InlineData ("A sentence has words.\nLine 2.", 30, 1, Alignment.Start, false, 1, false)]
+ [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Alignment.Start, false, 1, true)]
+ [InlineData ("A sentence has words.\r\nLine 2.", 1, -29, Alignment.Start, false, 1, false)]
+ [InlineData ("A sentence has words.\r\nLine 2.", 5, -25, Alignment.Start, false, 1, false)]
+ [InlineData ("A sentence has words.\r\nLine 2.", 29, -1, Alignment.Start, false, 1, false, 1)]
+ [InlineData ("A sentence has words.\r\nLine 2.", 30, 0, Alignment.Start, false, 1, false)]
+ [InlineData ("A sentence has words.\r\nLine 2.", 31, 1, Alignment.Start, false, 1, false)]
public void Reformat_NoWordrap_NewLines_MultiLine_False (
string text,
int maxWidth,
int widthOffset,
- TextAlignment textAlignment,
+ Alignment alignment,
bool wrap,
int linesCount,
bool stringEmpty,
@@ -1394,7 +1394,7 @@ ssb
{
Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth) + clipWidthOffset;
- List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap);
+ List list = TextFormatter.Format (text, maxWidth, alignment, wrap);
Assert.NotEmpty (list);
Assert.True (list.Count == linesCount);
@@ -1430,12 +1430,12 @@ ssb
}
[Theory]
- [InlineData ("A sentence has words.\nLine 2.", 0, -29, TextAlignment.Left, false, 1, true, new [] { "" })]
+ [InlineData ("A sentence has words.\nLine 2.", 0, -29, Alignment.Start, false, 1, true, new [] { "" })]
[InlineData (
"A sentence has words.\nLine 2.",
1,
-28,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1445,7 +1445,7 @@ ssb
"A sentence has words.\nLine 2.",
5,
-24,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1455,7 +1455,7 @@ ssb
"A sentence has words.\nLine 2.",
28,
-1,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1466,7 +1466,7 @@ ssb
"A sentence has words.\nLine 2.",
29,
0,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1476,18 +1476,18 @@ ssb
"A sentence has words.\nLine 2.",
30,
1,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
new [] { "A sentence has words.", "Line 2." }
)]
- [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, TextAlignment.Left, false, 1, true, new [] { "" })]
+ [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Alignment.Start, false, 1, true, new [] { "" })]
[InlineData (
"A sentence has words.\r\nLine 2.",
1,
-29,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1497,7 +1497,7 @@ ssb
"A sentence has words.\r\nLine 2.",
5,
-25,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1507,7 +1507,7 @@ ssb
"A sentence has words.\r\nLine 2.",
29,
-1,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1517,7 +1517,7 @@ ssb
"A sentence has words.\r\nLine 2.",
30,
0,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1527,7 +1527,7 @@ ssb
"A sentence has words.\r\nLine 2.",
31,
1,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1537,7 +1537,7 @@ ssb
string text,
int maxWidth,
int widthOffset,
- TextAlignment textAlignment,
+ Alignment alignment,
bool wrap,
int linesCount,
bool stringEmpty,
@@ -1549,7 +1549,7 @@ ssb
List list = TextFormatter.Format (
text,
maxWidth,
- textAlignment,
+ alignment,
wrap,
false,
0,
@@ -1572,12 +1572,12 @@ ssb
}
[Theory]
- [InlineData ("A sentence has words.\nLine 2.", 0, -29, TextAlignment.Left, false, 1, true, new [] { "" })]
+ [InlineData ("A sentence has words.\nLine 2.", 0, -29, Alignment.Start, false, 1, true, new [] { "" })]
[InlineData (
"A sentence has words.\nLine 2.",
1,
-28,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1587,7 +1587,7 @@ ssb
"A sentence has words.\nLine 2.",
5,
-24,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1597,7 +1597,7 @@ ssb
"A sentence has words.\nLine 2.",
28,
-1,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1608,7 +1608,7 @@ ssb
"A sentence has words.\nLine 2.",
29,
0,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1618,18 +1618,18 @@ ssb
"A sentence has words.\nLine 2.",
30,
1,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
new [] { "A sentence has words.", "Line 2." }
)]
- [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, TextAlignment.Left, false, 1, true, new [] { "" })]
+ [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Alignment.Start, false, 1, true, new [] { "" })]
[InlineData (
"A sentence has words.\r\nLine 2.",
1,
-29,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1639,7 +1639,7 @@ ssb
"A sentence has words.\r\nLine 2.",
5,
-25,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1649,7 +1649,7 @@ ssb
"A sentence has words.\r\nLine 2.",
29,
-1,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1659,7 +1659,7 @@ ssb
"A sentence has words.\r\nLine 2.",
30,
0,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1669,7 +1669,7 @@ ssb
"A sentence has words.\r\nLine 2.",
31,
1,
- TextAlignment.Left,
+ Alignment.Start,
false,
2,
false,
@@ -1679,7 +1679,7 @@ ssb
string text,
int maxWidth,
int widthOffset,
- TextAlignment textAlignment,
+ Alignment alignment,
bool wrap,
int linesCount,
bool stringEmpty,
@@ -1691,7 +1691,7 @@ ssb
List list = TextFormatter.Format (
text,
maxWidth,
- textAlignment,
+ alignment,
wrap,
false,
0,
@@ -1714,21 +1714,21 @@ ssb
}
[Theory]
- [InlineData ("", 0, 0, TextAlignment.Left, false, 1, true)]
- [InlineData ("", 1, 1, TextAlignment.Left, false, 1, true)]
- [InlineData ("A sentence has words.", 0, -21, TextAlignment.Left, false, 1, true)]
- [InlineData ("A sentence has words.", 1, -20, TextAlignment.Left, false, 1, false)]
- [InlineData ("A sentence has words.", 5, -16, TextAlignment.Left, false, 1, false)]
- [InlineData ("A sentence has words.", 20, -1, TextAlignment.Left, false, 1, false)]
+ [InlineData ("", 0, 0, Alignment.Start, false, 1, true)]
+ [InlineData ("", 1, 1, Alignment.Start, false, 1, true)]
+ [InlineData ("A sentence has words.", 0, -21, Alignment.Start, false, 1, true)]
+ [InlineData ("A sentence has words.", 1, -20, Alignment.Start, false, 1, false)]
+ [InlineData ("A sentence has words.", 5, -16, Alignment.Start, false, 1, false)]
+ [InlineData ("A sentence has words.", 20, -1, Alignment.Start, false, 1, false)]
// no clip
- [InlineData ("A sentence has words.", 21, 0, TextAlignment.Left, false, 1, false)]
- [InlineData ("A sentence has words.", 22, 1, TextAlignment.Left, false, 1, false)]
+ [InlineData ("A sentence has words.", 21, 0, Alignment.Start, false, 1, false)]
+ [InlineData ("A sentence has words.", 22, 1, Alignment.Start, false, 1, false)]
public void Reformat_NoWordrap_SingleLine (
string text,
int maxWidth,
int widthOffset,
- TextAlignment textAlignment,
+ Alignment alignment,
bool wrap,
int linesCount,
bool stringEmpty
@@ -1736,7 +1736,7 @@ ssb
{
Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap);
+ List list = TextFormatter.Format (text, maxWidth, alignment, wrap);
Assert.NotEmpty (list);
Assert.True (list.Count == linesCount);
@@ -1759,7 +1759,7 @@ ssb
"\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464",
8,
-1,
- TextAlignment.Left,
+ Alignment.Start,
true,
false,
new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" }
@@ -1770,7 +1770,7 @@ ssb
"\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464",
9,
0,
- TextAlignment.Left,
+ Alignment.Start,
true,
false,
new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" }
@@ -1779,7 +1779,7 @@ ssb
"\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464",
10,
1,
- TextAlignment.Left,
+ Alignment.Start,
true,
false,
new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" }
@@ -1788,14 +1788,14 @@ ssb
string text,
int maxWidth,
int widthOffset,
- TextAlignment textAlignment,
+ Alignment alignment,
bool wrap,
bool preserveTrailingSpaces,
IEnumerable resultLines
)
{
Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap, preserveTrailingSpaces);
+ List list = TextFormatter.Format (text, maxWidth, alignment, wrap, preserveTrailingSpaces);
Assert.Equal (list.Count, resultLines.Count ());
Assert.Equal (resultLines, list);
}
@@ -1805,32 +1805,32 @@ ssb
// Unicode
// Even # of chars
// 0123456789
- [InlineData ("\u2660пÑРвРÑ", 10, -1, TextAlignment.Left, true, false, new [] { "\u2660пÑРвÐ", "Ñ" })]
+ [InlineData ("\u2660пÑРвРÑ", 10, -1, Alignment.Start, true, false, new [] { "\u2660пÑРвÐ", "Ñ" })]
// no clip
- [InlineData ("\u2660пÑРвРÑ", 11, 0, TextAlignment.Left, true, false, new [] { "\u2660пÑРвРÑ" })]
- [InlineData ("\u2660пÑРвРÑ", 12, 1, TextAlignment.Left, true, false, new [] { "\u2660пÑРвРÑ" })]
+ [InlineData ("\u2660пÑРвРÑ", 11, 0, Alignment.Start, true, false, new [] { "\u2660пÑРвРÑ" })]
+ [InlineData ("\u2660пÑРвРÑ", 12, 1, Alignment.Start, true, false, new [] { "\u2660пÑРвРÑ" })]
// Unicode
// Odd # of chars
// 0123456789
- [InlineData ("\u2660 ÑРвРÑ", 9, -1, TextAlignment.Left, true, false, new [] { "\u2660 ÑРвÐ", "Ñ" })]
+ [InlineData ("\u2660 ÑРвРÑ", 9, -1, Alignment.Start, true, false, new [] { "\u2660 ÑРвÐ", "Ñ" })]
// no clip
- [InlineData ("\u2660 ÑРвРÑ", 10, 0, TextAlignment.Left, true, false, new [] { "\u2660 ÑРвРÑ" })]
- [InlineData ("\u2660 ÑРвРÑ", 11, 1, TextAlignment.Left, true, false, new [] { "\u2660 ÑРвРÑ" })]
+ [InlineData ("\u2660 ÑРвРÑ", 10, 0, Alignment.Start, true, false, new [] { "\u2660 ÑРвРÑ" })]
+ [InlineData ("\u2660 ÑРвРÑ", 11, 1, Alignment.Start, true, false, new [] { "\u2660 ÑРвРÑ" })]
public void Reformat_Unicode_Wrap_Spaces_No_NewLines (
string text,
int maxWidth,
int widthOffset,
- TextAlignment textAlignment,
+ Alignment alignment,
bool wrap,
bool preserveTrailingSpaces,
IEnumerable resultLines
)
{
Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap, preserveTrailingSpaces);
+ List list = TextFormatter.Format (text, maxWidth, alignment, wrap, preserveTrailingSpaces);
Assert.Equal (list.Count, resultLines.Count ());
Assert.Equal (resultLines, list);
}
@@ -1839,37 +1839,37 @@ ssb
// Even # of spaces
// 0123456789
- [InlineData ("012 456 89", 0, -10, TextAlignment.Left, true, true, true, new [] { "" })]
+ [InlineData ("012 456 89", 0, -10, Alignment.Start, true, true, true, new [] { "" })]
[InlineData (
"012 456 89",
1,
-9,
- TextAlignment.Left,
+ Alignment.Start,
true,
true,
false,
new [] { "0", "1", "2", " ", "4", "5", "6", " ", "8", "9" },
"01245689"
)]
- [InlineData ("012 456 89", 5, -5, TextAlignment.Left, true, true, false, new [] { "012 ", "456 ", "89" })]
- [InlineData ("012 456 89", 9, -1, TextAlignment.Left, true, true, false, new [] { "012 456 ", "89" })]
+ [InlineData ("012 456 89", 5, -5, Alignment.Start, true, true, false, new [] { "012 ", "456 ", "89" })]
+ [InlineData ("012 456 89", 9, -1, Alignment.Start, true, true, false, new [] { "012 456 ", "89" })]
// no clip
- [InlineData ("012 456 89", 10, 0, TextAlignment.Left, true, true, false, new [] { "012 456 89" })]
- [InlineData ("012 456 89", 11, 1, TextAlignment.Left, true, true, false, new [] { "012 456 89" })]
+ [InlineData ("012 456 89", 10, 0, Alignment.Start, true, true, false, new [] { "012 456 89" })]
+ [InlineData ("012 456 89", 11, 1, Alignment.Start, true, true, false, new [] { "012 456 89" })]
// Odd # of spaces
// 01234567890123
- [InlineData ("012 456 89 end", 13, -1, TextAlignment.Left, true, true, false, new [] { "012 456 89 ", "end" })]
+ [InlineData ("012 456 89 end", 13, -1, Alignment.Start, true, true, false, new [] { "012 456 89 ", "end" })]
// no clip
- [InlineData ("012 456 89 end", 14, 0, TextAlignment.Left, true, true, false, new [] { "012 456 89 end" })]
- [InlineData ("012 456 89 end", 15, 1, TextAlignment.Left, true, true, false, new [] { "012 456 89 end" })]
+ [InlineData ("012 456 89 end", 14, 0, Alignment.Start, true, true, false, new [] { "012 456 89 end" })]
+ [InlineData ("012 456 89 end", 15, 1, Alignment.Start, true, true, false, new [] { "012 456 89 end" })]
public void Reformat_Wrap_Spaces_No_NewLines (
string text,
int maxWidth,
int widthOffset,
- TextAlignment textAlignment,
+ Alignment alignment,
bool wrap,
bool preserveTrailingSpaces,
bool stringEmpty,
@@ -1879,7 +1879,7 @@ ssb
{
Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- List list = TextFormatter.Format (text, maxWidth, textAlignment, wrap, preserveTrailingSpaces);
+ List list = TextFormatter.Format (text, maxWidth, alignment, wrap, preserveTrailingSpaces);
Assert.NotEmpty (list);
Assert.True (list.Count == resultLines.Count ());
@@ -1909,7 +1909,7 @@ ssb
);
}
- list = TextFormatter.Format (text, maxWidth, TextAlignment.Left, wrap);
+ list = TextFormatter.Format (text, maxWidth, Alignment.Start, wrap);
if (maxWidth == 1)
{
@@ -2222,176 +2222,6 @@ ssb
Assert.Equal (new Size (expectedWidth, expectedHeight), tf.Size);
}
-
- //[Theory]
- //[InlineData (TextAlignment.Left, false)]
- //[InlineData (TextAlignment.Centered, true)]
- //[InlineData (TextAlignment.Right, false)]
- //[InlineData (TextAlignment.Justified, true)]
- //public void TestSize_DirectionChange_AutoSize_True_Or_False_Horizontal (
- // TextAlignment textAlignment,
- // bool autoSize
- //)
- //{
- // var tf = new TextFormatter
- // {
- // Direction = TextDirection.LeftRight_TopBottom, Text = "你你", Alignment = textAlignment, AutoSize = autoSize
- // };
- // Assert.Equal (4, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
-
- // tf.Direction = TextDirection.TopBottom_LeftRight;
-
- // if (autoSize/* && textAlignment != TextAlignment.Justified*/)
- // {
- // Assert.Equal (2, tf.Size.Width);
- // Assert.Equal (2, tf.Size.Height);
- // }
- // else
- // {
- // Assert.Equal (4, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
- // }
- //}
-
- //[Theory]
- //[InlineData (VerticalTextAlignment.Top, false)]
- //[InlineData (VerticalTextAlignment.Middle, true)]
- //[InlineData (VerticalTextAlignment.Bottom, false)]
- //[InlineData (VerticalTextAlignment.Justified, true)]
- //public void TestSize_DirectionChange_AutoSize_True_Or_False_Vertical (
- // VerticalTextAlignment textAlignment,
- // bool autoSize
- //)
- //{
- // var tf = new TextFormatter
- // {
- // Direction = TextDirection.TopBottom_LeftRight,
- // Text = "你你",
- // VerticalAlignment = textAlignment,
- // AutoSize = autoSize
- // };
- // Assert.Equal (2, tf.Size.Width);
- // Assert.Equal (2, tf.Size.Height);
-
- // tf.Direction = TextDirection.LeftRight_TopBottom;
-
- // if (autoSize/* && textAlignment != VerticalTextAlignment.Justified*/)
- // {
- // Assert.Equal (4, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
- // }
- // else
- // {
- // Assert.Equal (2, tf.Size.Width);
- // Assert.Equal (2, tf.Size.Height);
- // }
- //}
-
- //[Theory]
- //[InlineData (TextDirection.LeftRight_TopBottom, false)]
- //[InlineData (TextDirection.LeftRight_TopBottom, true)]
- //[InlineData (TextDirection.TopBottom_LeftRight, false)]
- //[InlineData (TextDirection.TopBottom_LeftRight, true)]
- //public void TestSize_SizeChange_AutoSize_True_Or_False (TextDirection textDirection, bool autoSize)
- //{
- // var tf = new TextFormatter { Direction = textDirection, Text = "你你", AutoSize = autoSize };
-
- // if (textDirection == TextDirection.LeftRight_TopBottom)
- // {
- // Assert.Equal (4, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
- // }
- // else
- // {
- // Assert.Equal (2, tf.Size.Width);
- // Assert.Equal (2, tf.Size.Height);
- // }
-
- // tf.Size = new (1, 1);
-
- // if (autoSize)
- // {
- // if (textDirection == TextDirection.LeftRight_TopBottom)
- // {
- // Assert.Equal (4, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
- // }
- // else
- // {
- // Assert.Equal (2, tf.Size.Width);
- // Assert.Equal (2, tf.Size.Height);
- // }
- // }
- // else
- // {
- // Assert.Equal (1, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
- // }
- //}
-
- //[Theory]
- //[InlineData (TextAlignment.Left, false)]
- //[InlineData (TextAlignment.Centered, true)]
- //[InlineData (TextAlignment.Right, false)]
- //[InlineData (TextAlignment.Justified, true)]
- //public void TestSize_SizeChange_AutoSize_True_Or_False_Horizontal (TextAlignment textAlignment, bool autoSize)
- //{
- // var tf = new TextFormatter
- // {
- // Direction = TextDirection.LeftRight_TopBottom, Text = "你你", Alignment = textAlignment, AutoSize = autoSize
- // };
- // Assert.Equal (4, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
-
- // tf.Size = new (1, 1);
-
- // if (autoSize)
- // {
- // Assert.Equal (4, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
- // }
- // else
- // {
- // Assert.Equal (1, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
- // }
- //}
-
- //[Theory]
- //[InlineData (VerticalTextAlignment.Top, false)]
- //[InlineData (VerticalTextAlignment.Middle, true)]
- //[InlineData (VerticalTextAlignment.Bottom, false)]
- //[InlineData (VerticalTextAlignment.Justified, true)]
- //public void TestSize_SizeChange_AutoSize_True_Or_False_Vertical (
- // VerticalTextAlignment textAlignment,
- // bool autoSize
- //)
- //{
- // var tf = new TextFormatter
- // {
- // Direction = TextDirection.TopBottom_LeftRight,
- // Text = "你你",
- // VerticalAlignment = textAlignment,
- // AutoSize = autoSize
- // };
- // Assert.Equal (2, tf.Size.Width);
- // Assert.Equal (2, tf.Size.Height);
-
- // tf.Size = new (1, 1);
-
- // if (autoSize)
- // {
- // Assert.Equal (2, tf.Size.Width);
- // Assert.Equal (2, tf.Size.Height);
- // }
- // else
- // {
- // Assert.Equal (1, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
- // }
- //}
-
[Theory]
[InlineData ("你", TextDirection.LeftRight_TopBottom, false, 0, 0)]
[InlineData ("你", TextDirection.LeftRight_TopBottom, true, 2, 1)]
@@ -2408,39 +2238,6 @@ ssb
Assert.Equal (new Size (expectedWidth, expectedHeight), tf.Size);
}
- //[Theory]
- //[InlineData (TextDirection.LeftRight_TopBottom, false)]
- //[InlineData (TextDirection.LeftRight_TopBottom, true)]
- //[InlineData (TextDirection.TopBottom_LeftRight, false)]
- //[InlineData (TextDirection.TopBottom_LeftRight, true)]
- //public void TestSize_TextChange (TextDirection textDirection, bool autoSize)
- //{
- // var tf = new TextFormatter { Direction = textDirection, Text = "你", AutoSize = autoSize };
- // Assert.Equal (new Size (2, 1), tf.Size);
- // tf.Text = "你你";
-
- // Assert.Equal (autoSize, tf.AutoSize);
-
- // if (autoSize)
- // {
- // if (textDirection == TextDirection.LeftRight_TopBottom)
- // {
- // Assert.Equal (4, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
- // }
- // else
- // {
- // Assert.Equal (2, tf.Size.Width);
- // Assert.Equal (2, tf.Size.Height);
- // }
- // }
- // else
- // {
- // Assert.Equal (2, tf.Size.Width);
- // Assert.Equal (1, tf.Size.Height);
- // }
- //}
-
[Fact]
public void WordWrap_BigWidth ()
{
@@ -3362,7 +3159,7 @@ ssb
TextFormatter tf = new ()
{
Text = text,
- Alignment = TextAlignment.Left,
+ Alignment = Alignment.Start,
AutoSize = autoSize,
};
@@ -3399,7 +3196,7 @@ ssb
TextFormatter tf = new ()
{
Text = text,
- Alignment = TextAlignment.Right,
+ Alignment = Alignment.End,
AutoSize = autoSize,
};
@@ -3442,7 +3239,7 @@ ssb
TextFormatter tf = new ()
{
Text = text,
- Alignment = TextAlignment.Centered,
+ Alignment = Alignment.Center,
AutoSize = autoSize,
};
@@ -3463,7 +3260,6 @@ ssb
[InlineData ("A B", 3, false, "A B")]
[InlineData ("A B", 1, false, "A")]
[InlineData ("A B", 2, false, "A")]
- [InlineData ("A B", 3, false, "A B")]
[InlineData ("A B", 4, false, "A B")]
[InlineData ("A B", 5, false, "A B")]
[InlineData ("A B", 6, false, "A B")]
@@ -3473,7 +3269,6 @@ ssb
[InlineData ("A", 0, true, "")]
[InlineData ("A", 1, true, "A")]
[InlineData ("A", 2, true, "A")]
- [InlineData ("A B", 3, true, "A B")]
[InlineData ("A B", 1, true, "A")]
[InlineData ("A B", 2, true, "A")]
[InlineData ("A B", 3, true, "A B")]
@@ -3487,7 +3282,7 @@ ssb
TextFormatter tf = new ()
{
Text = text,
- Alignment = TextAlignment.Justified,
+ Alignment = Alignment.Fill,
AutoSize = autoSize,
};
@@ -3577,7 +3372,7 @@ Nice Work")]
TextFormatter tf = new ()
{
Text = text,
- Alignment = TextAlignment.Justified,
+ Alignment = Alignment.Fill,
Size = new Size (width, height),
MultiLine = true
};
@@ -3629,7 +3424,7 @@ ek")]
{
Text = text,
Direction = TextDirection.TopBottom_LeftRight,
- VerticalAlignment = VerticalTextAlignment.Justified,
+ VerticalAlignment = Alignment.Fill,
Size = new Size (width, height),
MultiLine = true
};
@@ -3685,9 +3480,9 @@ ek")]
TextFormatter tf = new ()
{
Text = text,
- Alignment = TextAlignment.Right,
+ Alignment = Alignment.End,
Direction = TextDirection.TopBottom_LeftRight,
- VerticalAlignment = VerticalTextAlignment.Bottom,
+ VerticalAlignment = Alignment.End,
AutoSize = autoSize,
};
@@ -3827,7 +3622,7 @@ B")]
{
Text = text,
Direction = TextDirection.TopBottom_LeftRight,
- VerticalAlignment = VerticalTextAlignment.Middle,
+ VerticalAlignment = Alignment.Center,
AutoSize = autoSize,
};
@@ -4083,9 +3878,9 @@ B")]
[SetupFakeDriver]
[Theory]
- // Horizontal with VerticalTextAlignment.Top
+ // Horizontal with Alignment.Start
// LeftRight_TopBottom
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Start, TextDirection.LeftRight_TopBottom, @"
0 2 4**
*******
*******
@@ -4093,7 +3888,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Start, TextDirection.LeftRight_TopBottom, @"
**0 2 4
*******
*******
@@ -4101,7 +3896,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Start, TextDirection.LeftRight_TopBottom, @"
*0 2 4*
*******
*******
@@ -4109,7 +3904,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Start, TextDirection.LeftRight_TopBottom, @"
0 2 4
*******
*******
@@ -4118,7 +3913,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Start, TextDirection.LeftRight_TopBottom, @"
0 你 4*
*******
*******
@@ -4126,7 +3921,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Start, TextDirection.LeftRight_TopBottom, @"
*0 你 4
*******
*******
@@ -4134,7 +3929,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Start, TextDirection.LeftRight_TopBottom, @"
0 你 4*
*******
*******
@@ -4142,7 +3937,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Start, TextDirection.LeftRight_TopBottom, @"
0 你 4
*******
*******
@@ -4152,7 +3947,7 @@ B")]
*******")]
// LeftRight_BottomTop
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Start, TextDirection.LeftRight_BottomTop, @"
0 2 4**
*******
*******
@@ -4160,7 +3955,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Start, TextDirection.LeftRight_BottomTop, @"
**0 2 4
*******
*******
@@ -4168,7 +3963,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Start, TextDirection.LeftRight_BottomTop, @"
*0 2 4*
*******
*******
@@ -4176,7 +3971,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Start, TextDirection.LeftRight_BottomTop, @"
0 2 4
*******
*******
@@ -4185,7 +3980,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Start, TextDirection.LeftRight_BottomTop, @"
0 你 4*
*******
*******
@@ -4193,7 +3988,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Start, TextDirection.LeftRight_BottomTop, @"
*0 你 4
*******
*******
@@ -4201,7 +3996,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Start, TextDirection.LeftRight_BottomTop, @"
0 你 4*
*******
*******
@@ -4209,7 +4004,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Start, TextDirection.LeftRight_BottomTop, @"
0 你 4
*******
*******
@@ -4219,7 +4014,7 @@ B")]
*******")]
// RightLeft_TopBottom
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Start, TextDirection.RightLeft_TopBottom, @"
4 2 0**
*******
*******
@@ -4227,7 +4022,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Start, TextDirection.RightLeft_TopBottom, @"
**4 2 0
*******
*******
@@ -4235,7 +4030,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Start, TextDirection.RightLeft_TopBottom, @"
*4 2 0*
*******
*******
@@ -4243,7 +4038,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Start, TextDirection.RightLeft_TopBottom, @"
4 2 0
*******
*******
@@ -4252,7 +4047,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Start, TextDirection.RightLeft_TopBottom, @"
4 你 0*
*******
*******
@@ -4260,7 +4055,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Start, TextDirection.RightLeft_TopBottom, @"
*4 你 0
*******
*******
@@ -4268,7 +4063,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Start, TextDirection.RightLeft_TopBottom, @"
4 你 0*
*******
*******
@@ -4276,7 +4071,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Start, TextDirection.RightLeft_TopBottom, @"
4 你 0
*******
*******
@@ -4286,7 +4081,7 @@ B")]
*******")]
// RightLeft_BottomTop
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Start, TextDirection.RightLeft_BottomTop, @"
4 2 0**
*******
*******
@@ -4294,7 +4089,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Start, TextDirection.RightLeft_BottomTop, @"
**4 2 0
*******
*******
@@ -4302,7 +4097,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Start, TextDirection.RightLeft_BottomTop, @"
*4 2 0*
*******
*******
@@ -4310,7 +4105,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Start, TextDirection.RightLeft_BottomTop, @"
4 2 0
*******
*******
@@ -4319,7 +4114,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Start, TextDirection.RightLeft_BottomTop, @"
4 你 0*
*******
*******
@@ -4327,7 +4122,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Start, TextDirection.RightLeft_BottomTop, @"
*4 你 0
*******
*******
@@ -4335,7 +4130,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Start, TextDirection.RightLeft_BottomTop, @"
4 你 0*
*******
*******
@@ -4343,7 +4138,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Start, TextDirection.RightLeft_BottomTop, @"
4 你 0
*******
*******
@@ -4352,9 +4147,9 @@ B")]
*******
*******")]
- // Horizontal with VerticalTextAlignment.Bottom
+ // Horizontal with Alignment.End
// LeftRight_TopBottom
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.End, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4362,7 +4157,7 @@ B")]
*******
*******
0 2 4**")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.End, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4370,7 +4165,7 @@ B")]
*******
*******
**0 2 4")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.End, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4378,7 +4173,7 @@ B")]
*******
*******
*0 2 4*")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.End, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4387,7 +4182,7 @@ B")]
*******
0 2 4")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.End, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4395,7 +4190,7 @@ B")]
*******
*******
0 你 4*")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.End, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4403,7 +4198,7 @@ B")]
*******
*******
*0 你 4")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.End, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4411,7 +4206,7 @@ B")]
*******
*******
0 你 4*")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.End, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4421,7 +4216,7 @@ B")]
0 你 4")]
// LeftRight_BottomTop
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.End, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4429,7 +4224,7 @@ B")]
*******
*******
0 2 4**")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.End, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4437,7 +4232,7 @@ B")]
*******
*******
**0 2 4")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.End, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4445,7 +4240,7 @@ B")]
*******
*******
*0 2 4*")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.End, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4454,7 +4249,7 @@ B")]
*******
0 2 4")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.End, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4462,7 +4257,7 @@ B")]
*******
*******
0 你 4*")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.End, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4470,7 +4265,7 @@ B")]
*******
*******
*0 你 4")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.End, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4478,7 +4273,7 @@ B")]
*******
*******
0 你 4*")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.End, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4488,7 +4283,7 @@ B")]
0 你 4")]
// RightLeft_TopBottom
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.End, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4496,7 +4291,7 @@ B")]
*******
*******
4 2 0**")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.End, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4504,7 +4299,7 @@ B")]
*******
*******
**4 2 0")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.End, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4512,7 +4307,7 @@ B")]
*******
*******
*4 2 0*")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.End, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4521,7 +4316,7 @@ B")]
*******
4 2 0")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.End, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4529,7 +4324,7 @@ B")]
*******
*******
4 你 0*")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.End, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4537,7 +4332,7 @@ B")]
*******
*******
*4 你 0")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.End, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4545,7 +4340,7 @@ B")]
*******
*******
4 你 0*")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.End, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4555,7 +4350,7 @@ B")]
4 你 0")]
// RightLeft_BottomTop
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.End, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4563,7 +4358,7 @@ B")]
*******
*******
4 2 0**")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.End, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4571,7 +4366,7 @@ B")]
*******
*******
**4 2 0")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.End, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4579,7 +4374,7 @@ B")]
*******
*******
*4 2 0*")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.End, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4588,7 +4383,7 @@ B")]
*******
4 2 0")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.End, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4596,7 +4391,7 @@ B")]
*******
*******
4 你 0*")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.End, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4604,7 +4399,7 @@ B")]
*******
*******
*4 你 0")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.End, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4612,7 +4407,7 @@ B")]
*******
*******
4 你 0*")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.End, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4621,9 +4416,9 @@ B")]
*******
4 你 0")]
- // Horizontal with VerticalTextAlignment.Middle
+ // Horizontal with alignment.Centered
// LeftRight_TopBottom
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Center, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4631,7 +4426,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Center, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4639,7 +4434,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Center, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4647,7 +4442,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Center, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4656,7 +4451,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Center, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4664,7 +4459,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Center, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4672,7 +4467,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Center, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4680,7 +4475,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Center, TextDirection.LeftRight_TopBottom, @"
*******
*******
*******
@@ -4690,7 +4485,7 @@ B")]
*******")]
// LeftRight_BottomTop
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Center, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4698,7 +4493,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Center, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4706,7 +4501,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Center, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4714,7 +4509,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Center, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4723,7 +4518,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Center, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4731,7 +4526,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Center, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4739,7 +4534,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Center, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4747,7 +4542,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Center, TextDirection.LeftRight_BottomTop, @"
*******
*******
*******
@@ -4757,7 +4552,7 @@ B")]
*******")]
// RightLeft_TopBottom
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Center, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4765,7 +4560,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Center, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4773,7 +4568,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Center, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4781,7 +4576,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Center, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4790,7 +4585,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Center, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4798,7 +4593,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Center, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4806,7 +4601,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Center, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4814,7 +4609,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Center, TextDirection.RightLeft_TopBottom, @"
*******
*******
*******
@@ -4824,7 +4619,7 @@ B")]
*******")]
// RightLeft_BottomTop
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Center, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4832,7 +4627,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Center, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4840,7 +4635,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Center, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4848,7 +4643,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Center, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4857,7 +4652,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Center, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4865,7 +4660,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Center, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4873,7 +4668,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Center, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4881,7 +4676,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Center, TextDirection.RightLeft_BottomTop, @"
*******
*******
*******
@@ -4890,9 +4685,9 @@ B")]
*******
*******")]
- // Horizontal with VerticalTextAlignment.Justified
+ // Horizontal with alignment.Justified
// LeftRight_TopBottom
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Fill, TextDirection.LeftRight_TopBottom, @"
0 2 4**
*******
*******
@@ -4900,7 +4695,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Fill, TextDirection.LeftRight_TopBottom, @"
**0 2 4
*******
*******
@@ -4908,7 +4703,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Fill, TextDirection.LeftRight_TopBottom, @"
*0 2 4*
*******
*******
@@ -4916,7 +4711,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Fill, TextDirection.LeftRight_TopBottom, @"
0 2 4
*******
*******
@@ -4925,7 +4720,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Fill, TextDirection.LeftRight_TopBottom, @"
0 你 4*
*******
*******
@@ -4933,7 +4728,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Fill, TextDirection.LeftRight_TopBottom, @"
*0 你 4
*******
*******
@@ -4941,7 +4736,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Fill, TextDirection.LeftRight_TopBottom, @"
0 你 4*
*******
*******
@@ -4949,7 +4744,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.LeftRight_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Fill, TextDirection.LeftRight_TopBottom, @"
0 你 4
*******
*******
@@ -4959,7 +4754,7 @@ B")]
*******")]
// LeftRight_BottomTop
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Fill, TextDirection.LeftRight_BottomTop, @"
0 2 4**
*******
*******
@@ -4967,7 +4762,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Fill, TextDirection.LeftRight_BottomTop, @"
**0 2 4
*******
*******
@@ -4975,7 +4770,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Fill, TextDirection.LeftRight_BottomTop, @"
*0 2 4*
*******
*******
@@ -4983,7 +4778,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Fill, TextDirection.LeftRight_BottomTop, @"
0 2 4
*******
*******
@@ -4992,7 +4787,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Fill, TextDirection.LeftRight_BottomTop, @"
0 你 4*
*******
*******
@@ -5000,7 +4795,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Fill, TextDirection.LeftRight_BottomTop, @"
*0 你 4
*******
*******
@@ -5008,7 +4803,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Fill, TextDirection.LeftRight_BottomTop, @"
0 你 4*
*******
*******
@@ -5016,7 +4811,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.LeftRight_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Fill, TextDirection.LeftRight_BottomTop, @"
0 你 4
*******
*******
@@ -5026,7 +4821,7 @@ B")]
*******")]
// RightLeft_TopBottom
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Fill, TextDirection.RightLeft_TopBottom, @"
4 2 0**
*******
*******
@@ -5034,7 +4829,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Fill, TextDirection.RightLeft_TopBottom, @"
**4 2 0
*******
*******
@@ -5042,7 +4837,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Fill, TextDirection.RightLeft_TopBottom, @"
*4 2 0*
*******
*******
@@ -5050,7 +4845,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Fill, TextDirection.RightLeft_TopBottom, @"
4 2 0
*******
*******
@@ -5059,7 +4854,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Fill, TextDirection.RightLeft_TopBottom, @"
4 你 0*
*******
*******
@@ -5067,7 +4862,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Fill, TextDirection.RightLeft_TopBottom, @"
*4 你 0
*******
*******
@@ -5075,7 +4870,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Fill, TextDirection.RightLeft_TopBottom, @"
4 你 0*
*******
*******
@@ -5083,7 +4878,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.RightLeft_TopBottom, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Fill, TextDirection.RightLeft_TopBottom, @"
4 你 0
*******
*******
@@ -5093,7 +4888,7 @@ B")]
*******")]
// RightLeft_BottomTop
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Fill, TextDirection.RightLeft_BottomTop, @"
4 2 0**
*******
*******
@@ -5101,7 +4896,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Fill, TextDirection.RightLeft_BottomTop, @"
**4 2 0
*******
*******
@@ -5109,7 +4904,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Fill, TextDirection.RightLeft_BottomTop, @"
*4 2 0*
*******
*******
@@ -5117,7 +4912,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Fill, TextDirection.RightLeft_BottomTop, @"
4 2 0
*******
*******
@@ -5126,7 +4921,7 @@ B")]
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Fill, TextDirection.RightLeft_BottomTop, @"
4 你 0*
*******
*******
@@ -5134,7 +4929,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Fill, TextDirection.RightLeft_BottomTop, @"
*4 你 0
*******
*******
@@ -5142,7 +4937,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Fill, TextDirection.RightLeft_BottomTop, @"
4 你 0*
*******
*******
@@ -5150,7 +4945,7 @@ B")]
*******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.RightLeft_BottomTop, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Fill, TextDirection.RightLeft_BottomTop, @"
4 你 0
*******
*******
@@ -5159,9 +4954,9 @@ B")]
*******
*******")]
- // Vertical with TextAlignment.Left
+ // Vertical with alignment.Left
// TopBottom_LeftRight
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Start, TextDirection.TopBottom_LeftRight, @"
0******
******
2******
@@ -5169,7 +4964,7 @@ B")]
4******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.End, TextDirection.TopBottom_LeftRight, @"
*******
*******
0******
@@ -5177,7 +4972,7 @@ B")]
2******
******
4******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Center, TextDirection.TopBottom_LeftRight, @"
*******
0******
******
@@ -5185,7 +4980,7 @@ B")]
******
4******
*******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Fill, TextDirection.TopBottom_LeftRight, @"
0******
******
******
@@ -5194,7 +4989,7 @@ B")]
******
4******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Start, TextDirection.TopBottom_LeftRight, @"
0******
******
你*****
@@ -5202,7 +4997,7 @@ B")]
4******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.End, TextDirection.TopBottom_LeftRight, @"
*******
*******
0******
@@ -5210,7 +5005,7 @@ B")]
你*****
******
4******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Center, TextDirection.TopBottom_LeftRight, @"
*******
0******
******
@@ -5218,7 +5013,7 @@ B")]
******
4******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Fill, TextDirection.TopBottom_LeftRight, @"
0******
******
******
@@ -5228,7 +5023,7 @@ B")]
4******")]
// TopBottom_RightLeft
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Start, TextDirection.TopBottom_RightLeft, @"
0******
******
2******
@@ -5236,7 +5031,7 @@ B")]
4******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.End, TextDirection.TopBottom_RightLeft, @"
*******
*******
0******
@@ -5244,7 +5039,7 @@ B")]
2******
******
4******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Center, TextDirection.TopBottom_RightLeft, @"
*******
0******
******
@@ -5252,7 +5047,7 @@ B")]
******
4******
*******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Fill, TextDirection.TopBottom_RightLeft, @"
0******
******
******
@@ -5261,7 +5056,7 @@ B")]
******
4******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Start, TextDirection.TopBottom_RightLeft, @"
0******
******
你*****
@@ -5269,7 +5064,7 @@ B")]
4******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.End, TextDirection.TopBottom_RightLeft, @"
*******
*******
0******
@@ -5277,7 +5072,7 @@ B")]
你*****
******
4******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Center, TextDirection.TopBottom_RightLeft, @"
*******
0******
******
@@ -5285,7 +5080,7 @@ B")]
******
4******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Fill, TextDirection.TopBottom_RightLeft, @"
0******
******
******
@@ -5295,7 +5090,7 @@ B")]
4******")]
// BottomTop_LeftRight
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Start, TextDirection.BottomTop_LeftRight, @"
4******
******
2******
@@ -5303,7 +5098,7 @@ B")]
0******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.End, TextDirection.BottomTop_LeftRight, @"
*******
*******
4******
@@ -5311,7 +5106,7 @@ B")]
2******
******
0******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Center, TextDirection.BottomTop_LeftRight, @"
*******
4******
******
@@ -5319,7 +5114,7 @@ B")]
******
0******
*******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Fill, TextDirection.BottomTop_LeftRight, @"
4******
******
******
@@ -5328,7 +5123,7 @@ B")]
******
0******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Start, TextDirection.BottomTop_LeftRight, @"
4******
******
你*****
@@ -5336,7 +5131,7 @@ B")]
0******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.End, TextDirection.BottomTop_LeftRight, @"
*******
*******
4******
@@ -5344,7 +5139,7 @@ B")]
你*****
******
0******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Center, TextDirection.BottomTop_LeftRight, @"
*******
4******
******
@@ -5352,7 +5147,7 @@ B")]
******
0******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Fill, TextDirection.BottomTop_LeftRight, @"
4******
******
******
@@ -5362,7 +5157,7 @@ B")]
0******")]
// BottomTop_RightLeft
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Start, TextDirection.BottomTop_RightLeft, @"
4******
******
2******
@@ -5370,7 +5165,7 @@ B")]
0******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.End, TextDirection.BottomTop_RightLeft, @"
*******
*******
4******
@@ -5378,7 +5173,7 @@ B")]
2******
******
0******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Center, TextDirection.BottomTop_RightLeft, @"
*******
4******
******
@@ -5386,7 +5181,7 @@ B")]
******
0******
*******")]
- [InlineData ("0 2 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Start, Alignment.Fill, TextDirection.BottomTop_RightLeft, @"
4******
******
******
@@ -5395,7 +5190,7 @@ B")]
******
0******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Start, TextDirection.BottomTop_RightLeft, @"
4******
******
你*****
@@ -5403,7 +5198,7 @@ B")]
0******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.End, TextDirection.BottomTop_RightLeft, @"
*******
*******
4******
@@ -5411,7 +5206,7 @@ B")]
你*****
******
0******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Center, TextDirection.BottomTop_RightLeft, @"
*******
4******
******
@@ -5419,7 +5214,7 @@ B")]
******
0******
*******")]
- [InlineData ("0 你 4", TextAlignment.Left, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Start, Alignment.Fill, TextDirection.BottomTop_RightLeft, @"
4******
******
******
@@ -5428,9 +5223,9 @@ B")]
******
0******")]
- // Vertical with TextAlignment.Right
+ // Vertical with alignment.Right
// TopBottom_LeftRight
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Start, TextDirection.TopBottom_LeftRight, @"
******0
******
******2
@@ -5438,7 +5233,7 @@ B")]
******4
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.End, TextDirection.TopBottom_LeftRight, @"
*******
*******
******0
@@ -5446,7 +5241,7 @@ B")]
******2
******
******4")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Center, TextDirection.TopBottom_LeftRight, @"
*******
******0
******
@@ -5454,7 +5249,7 @@ B")]
******
******4
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Fill, TextDirection.TopBottom_LeftRight, @"
******0
******
******
@@ -5463,7 +5258,7 @@ B")]
******
******4")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Start, TextDirection.TopBottom_LeftRight, @"
*****0*
***** *
*****你
@@ -5471,7 +5266,7 @@ B")]
*****4*
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.End, TextDirection.TopBottom_LeftRight, @"
*******
*******
*****0*
@@ -5479,7 +5274,7 @@ B")]
*****你
***** *
*****4*")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Center, TextDirection.TopBottom_LeftRight, @"
*******
*****0*
***** *
@@ -5487,7 +5282,7 @@ B")]
***** *
*****4*
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Fill, TextDirection.TopBottom_LeftRight, @"
*****0*
***** *
***** *
@@ -5497,7 +5292,7 @@ B")]
*****4*")]
// TopBottom_RightLeft
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Start, TextDirection.TopBottom_RightLeft, @"
******0
******
******2
@@ -5505,7 +5300,7 @@ B")]
******4
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.End, TextDirection.TopBottom_RightLeft, @"
*******
*******
******0
@@ -5513,7 +5308,7 @@ B")]
******2
******
******4")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Center, TextDirection.TopBottom_RightLeft, @"
*******
******0
******
@@ -5521,7 +5316,7 @@ B")]
******
******4
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Fill, TextDirection.TopBottom_RightLeft, @"
******0
******
******
@@ -5530,7 +5325,7 @@ B")]
******
******4")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Start, TextDirection.TopBottom_RightLeft, @"
*****0*
***** *
*****你
@@ -5538,7 +5333,7 @@ B")]
*****4*
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.End, TextDirection.TopBottom_RightLeft, @"
*******
*******
*****0*
@@ -5546,7 +5341,7 @@ B")]
*****你
***** *
*****4*")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Center, TextDirection.TopBottom_RightLeft, @"
*******
*****0*
***** *
@@ -5554,7 +5349,7 @@ B")]
***** *
*****4*
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Fill, TextDirection.TopBottom_RightLeft, @"
*****0*
***** *
***** *
@@ -5564,7 +5359,7 @@ B")]
*****4*")]
// BottomTop_LeftRight
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Start, TextDirection.BottomTop_LeftRight, @"
******4
******
******2
@@ -5572,7 +5367,7 @@ B")]
******0
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.End, TextDirection.BottomTop_LeftRight, @"
*******
*******
******4
@@ -5580,7 +5375,7 @@ B")]
******2
******
******0")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Center, TextDirection.BottomTop_LeftRight, @"
*******
******4
******
@@ -5588,7 +5383,7 @@ B")]
******
******0
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Fill, TextDirection.BottomTop_LeftRight, @"
******4
******
******
@@ -5597,7 +5392,7 @@ B")]
******
******0")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Start, TextDirection.BottomTop_LeftRight, @"
*****4*
***** *
*****你
@@ -5605,7 +5400,7 @@ B")]
*****0*
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.End, TextDirection.BottomTop_LeftRight, @"
*******
*******
*****4*
@@ -5613,7 +5408,7 @@ B")]
*****你
***** *
*****0*")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Center, TextDirection.BottomTop_LeftRight, @"
*******
*****4*
***** *
@@ -5621,7 +5416,7 @@ B")]
***** *
*****0*
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Fill, TextDirection.BottomTop_LeftRight, @"
*****4*
***** *
***** *
@@ -5631,7 +5426,7 @@ B")]
*****0*")]
// BottomTop_RightLeft
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Start, TextDirection.BottomTop_RightLeft, @"
******4
******
******2
@@ -5639,7 +5434,7 @@ B")]
******0
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.End, TextDirection.BottomTop_RightLeft, @"
*******
*******
******4
@@ -5647,7 +5442,7 @@ B")]
******2
******
******0")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Center, TextDirection.BottomTop_RightLeft, @"
*******
******4
******
@@ -5655,7 +5450,7 @@ B")]
******
******0
*******")]
- [InlineData ("0 2 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.End, Alignment.Fill, TextDirection.BottomTop_RightLeft, @"
******4
******
******
@@ -5664,7 +5459,7 @@ B")]
******
******0")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Start, TextDirection.BottomTop_RightLeft, @"
*****4*
***** *
*****你
@@ -5672,7 +5467,7 @@ B")]
*****0*
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.End, TextDirection.BottomTop_RightLeft, @"
*******
*******
*****4*
@@ -5680,7 +5475,7 @@ B")]
*****你
***** *
*****0*")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Center, TextDirection.BottomTop_RightLeft, @"
*******
*****4*
***** *
@@ -5688,7 +5483,7 @@ B")]
***** *
*****0*
*******")]
- [InlineData ("0 你 4", TextAlignment.Right, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.End, Alignment.Fill, TextDirection.BottomTop_RightLeft, @"
*****4*
***** *
***** *
@@ -5697,9 +5492,9 @@ B")]
***** *
*****0*")]
- // Vertical with TextAlignment.Centered
+ // Vertical with alignment.Centered
// TopBottom_LeftRight
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Start, TextDirection.TopBottom_LeftRight, @"
***0***
*** ***
***2***
@@ -5707,7 +5502,7 @@ B")]
***4***
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.End, TextDirection.TopBottom_LeftRight, @"
*******
*******
***0***
@@ -5715,7 +5510,7 @@ B")]
***2***
*** ***
***4***")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Center, TextDirection.TopBottom_LeftRight, @"
*******
***0***
*** ***
@@ -5723,7 +5518,7 @@ B")]
*** ***
***4***
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Fill, TextDirection.TopBottom_LeftRight, @"
***0***
*** ***
*** ***
@@ -5732,7 +5527,7 @@ B")]
*** ***
***4***")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Start, TextDirection.TopBottom_LeftRight, @"
**0****
** ****
**你***
@@ -5740,7 +5535,7 @@ B")]
**4****
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.End, TextDirection.TopBottom_LeftRight, @"
*******
*******
**0****
@@ -5748,7 +5543,7 @@ B")]
**你***
** ****
**4****")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Center, TextDirection.TopBottom_LeftRight, @"
*******
**0****
** ****
@@ -5756,7 +5551,7 @@ B")]
** ****
**4****
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Fill, TextDirection.TopBottom_LeftRight, @"
**0****
** ****
** ****
@@ -5766,7 +5561,7 @@ B")]
**4****")]
// TopBottom_RightLeft
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Start, TextDirection.TopBottom_RightLeft, @"
***0***
*** ***
***2***
@@ -5774,7 +5569,7 @@ B")]
***4***
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.End, TextDirection.TopBottom_RightLeft, @"
*******
*******
***0***
@@ -5782,7 +5577,7 @@ B")]
***2***
*** ***
***4***")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Center, TextDirection.TopBottom_RightLeft, @"
*******
***0***
*** ***
@@ -5790,7 +5585,7 @@ B")]
*** ***
***4***
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Fill, TextDirection.TopBottom_RightLeft, @"
***0***
*** ***
*** ***
@@ -5799,7 +5594,7 @@ B")]
*** ***
***4***")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Start, TextDirection.TopBottom_RightLeft, @"
**0****
** ****
**你***
@@ -5807,7 +5602,7 @@ B")]
**4****
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.End, TextDirection.TopBottom_RightLeft, @"
*******
*******
**0****
@@ -5815,7 +5610,7 @@ B")]
**你***
** ****
**4****")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Center, TextDirection.TopBottom_RightLeft, @"
*******
**0****
** ****
@@ -5823,7 +5618,7 @@ B")]
** ****
**4****
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Fill, TextDirection.TopBottom_RightLeft, @"
**0****
** ****
** ****
@@ -5833,7 +5628,7 @@ B")]
**4****")]
// BottomTop_LeftRight
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Start, TextDirection.BottomTop_LeftRight, @"
***4***
*** ***
***2***
@@ -5841,7 +5636,7 @@ B")]
***0***
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.End, TextDirection.BottomTop_LeftRight, @"
*******
*******
***4***
@@ -5849,7 +5644,7 @@ B")]
***2***
*** ***
***0***")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Center, TextDirection.BottomTop_LeftRight, @"
*******
***4***
*** ***
@@ -5857,7 +5652,7 @@ B")]
*** ***
***0***
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Fill, TextDirection.BottomTop_LeftRight, @"
***4***
*** ***
*** ***
@@ -5866,7 +5661,7 @@ B")]
*** ***
***0***")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Start, TextDirection.BottomTop_LeftRight, @"
**4****
** ****
**你***
@@ -5874,7 +5669,7 @@ B")]
**0****
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.End, TextDirection.BottomTop_LeftRight, @"
*******
*******
**4****
@@ -5882,7 +5677,7 @@ B")]
**你***
** ****
**0****")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Center, TextDirection.BottomTop_LeftRight, @"
*******
**4****
** ****
@@ -5890,7 +5685,7 @@ B")]
** ****
**0****
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Fill, TextDirection.BottomTop_LeftRight, @"
**4****
** ****
** ****
@@ -5900,7 +5695,7 @@ B")]
**0****")]
// BottomTop_RightLeft
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Start, TextDirection.BottomTop_RightLeft, @"
***4***
*** ***
***2***
@@ -5908,7 +5703,7 @@ B")]
***0***
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.End, TextDirection.BottomTop_RightLeft, @"
*******
*******
***4***
@@ -5916,7 +5711,7 @@ B")]
***2***
*** ***
***0***")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Center, TextDirection.BottomTop_RightLeft, @"
*******
***4***
*** ***
@@ -5924,7 +5719,7 @@ B")]
*** ***
***0***
*******")]
- [InlineData ("0 2 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Center, Alignment.Fill, TextDirection.BottomTop_RightLeft, @"
***4***
*** ***
*** ***
@@ -5933,7 +5728,7 @@ B")]
*** ***
***0***")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Start, TextDirection.BottomTop_RightLeft, @"
**4****
** ****
**你***
@@ -5941,7 +5736,7 @@ B")]
**0****
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.End, TextDirection.BottomTop_RightLeft, @"
*******
*******
**4****
@@ -5949,7 +5744,7 @@ B")]
**你***
** ****
**0****")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Center, TextDirection.BottomTop_RightLeft, @"
*******
**4****
** ****
@@ -5957,7 +5752,7 @@ B")]
** ****
**0****
*******")]
- [InlineData ("0 你 4", TextAlignment.Centered, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Center, Alignment.Fill, TextDirection.BottomTop_RightLeft, @"
**4****
** ****
** ****
@@ -5966,9 +5761,9 @@ B")]
** ****
**0****")]
- // Vertical with TextAlignment.Justified
+ // Vertical with alignment.Justified
// TopBottom_LeftRight
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Start, TextDirection.TopBottom_LeftRight, @"
0******
******
2******
@@ -5976,7 +5771,7 @@ B")]
4******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.End, TextDirection.TopBottom_LeftRight, @"
*******
*******
0******
@@ -5984,7 +5779,7 @@ B")]
2******
******
4******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Center, TextDirection.TopBottom_LeftRight, @"
*******
0******
******
@@ -5992,7 +5787,7 @@ B")]
******
4******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Fill, TextDirection.TopBottom_LeftRight, @"
0******
******
******
@@ -6001,7 +5796,7 @@ B")]
******
4******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Start, TextDirection.TopBottom_LeftRight, @"
0******
******
你*****
@@ -6009,7 +5804,7 @@ B")]
4******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.End, TextDirection.TopBottom_LeftRight, @"
*******
*******
0******
@@ -6017,7 +5812,7 @@ B")]
你*****
******
4******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Center, TextDirection.TopBottom_LeftRight, @"
*******
0******
******
@@ -6025,7 +5820,7 @@ B")]
******
4******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.TopBottom_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Fill, TextDirection.TopBottom_LeftRight, @"
0******
******
******
@@ -6035,7 +5830,7 @@ B")]
4******")]
// TopBottom_RightLeft
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Start, TextDirection.TopBottom_RightLeft, @"
0******
******
2******
@@ -6043,7 +5838,7 @@ B")]
4******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.End, TextDirection.TopBottom_RightLeft, @"
*******
*******
0******
@@ -6051,7 +5846,7 @@ B")]
2******
******
4******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Center, TextDirection.TopBottom_RightLeft, @"
*******
0******
******
@@ -6059,7 +5854,7 @@ B")]
******
4******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Fill, TextDirection.TopBottom_RightLeft, @"
0******
******
******
@@ -6068,7 +5863,7 @@ B")]
******
4******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Start, TextDirection.TopBottom_RightLeft, @"
0******
******
你*****
@@ -6076,7 +5871,7 @@ B")]
4******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.End, TextDirection.TopBottom_RightLeft, @"
*******
*******
0******
@@ -6084,7 +5879,7 @@ B")]
你*****
******
4******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Center, TextDirection.TopBottom_RightLeft, @"
*******
0******
******
@@ -6092,7 +5887,7 @@ B")]
******
4******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.TopBottom_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Fill, TextDirection.TopBottom_RightLeft, @"
0******
******
******
@@ -6102,7 +5897,7 @@ B")]
4******")]
// BottomTop_LeftRight
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Start, TextDirection.BottomTop_LeftRight, @"
4******
******
2******
@@ -6110,7 +5905,7 @@ B")]
0******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.End, TextDirection.BottomTop_LeftRight, @"
*******
*******
4******
@@ -6118,7 +5913,7 @@ B")]
2******
******
0******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Center, TextDirection.BottomTop_LeftRight, @"
*******
4******
******
@@ -6126,7 +5921,7 @@ B")]
******
0******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Fill, TextDirection.BottomTop_LeftRight, @"
4******
******
******
@@ -6135,7 +5930,7 @@ B")]
******
0******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Start, TextDirection.BottomTop_LeftRight, @"
4******
******
你*****
@@ -6143,7 +5938,7 @@ B")]
0******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.End, TextDirection.BottomTop_LeftRight, @"
*******
*******
4******
@@ -6151,7 +5946,7 @@ B")]
你*****
******
0******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Center, TextDirection.BottomTop_LeftRight, @"
*******
4******
******
@@ -6159,7 +5954,7 @@ B")]
******
0******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.BottomTop_LeftRight, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Fill, TextDirection.BottomTop_LeftRight, @"
4******
******
******
@@ -6169,7 +5964,7 @@ B")]
0******")]
// BottomTop_RightLeft
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Start, TextDirection.BottomTop_RightLeft, @"
4******
******
2******
@@ -6177,7 +5972,7 @@ B")]
0******
*******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.End, TextDirection.BottomTop_RightLeft, @"
*******
*******
4******
@@ -6185,7 +5980,7 @@ B")]
2******
******
0******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Center, TextDirection.BottomTop_RightLeft, @"
*******
4******
******
@@ -6193,7 +5988,7 @@ B")]
******
0******
*******")]
- [InlineData ("0 2 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 2 4", Alignment.Fill, Alignment.Fill, TextDirection.BottomTop_RightLeft, @"
4******
******
******
@@ -6202,7 +5997,7 @@ B")]
******
0******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Top, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Start, TextDirection.BottomTop_RightLeft, @"
4******
******
你*****
@@ -6210,7 +6005,7 @@ B")]
0******
*******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Bottom, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.End, TextDirection.BottomTop_RightLeft, @"
*******
*******
4******
@@ -6218,7 +6013,7 @@ B")]
你*****
******
0******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Middle, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Center, TextDirection.BottomTop_RightLeft, @"
*******
4******
******
@@ -6226,7 +6021,7 @@ B")]
******
0******
*******")]
- [InlineData ("0 你 4", TextAlignment.Justified, VerticalTextAlignment.Justified, TextDirection.BottomTop_RightLeft, @"
+ [InlineData ("0 你 4", Alignment.Fill, Alignment.Fill, TextDirection.BottomTop_RightLeft, @"
4******
******
******
@@ -6235,12 +6030,12 @@ B")]
******
0******")]
- public void Draw_Text_Alignment (string text, TextAlignment horizontalTextAlignment, VerticalTextAlignment verticalTextAlignment, TextDirection textDirection, string expectedText)
+ public void Draw_Text_Justification (string text, Alignment horizontalTextAlignment, Alignment alignment, TextDirection textDirection, string expectedText)
{
TextFormatter tf = new ()
{
Alignment = horizontalTextAlignment,
- VerticalAlignment = verticalTextAlignment,
+ VerticalAlignment = alignment,
Direction = textDirection,
Size = new (7, 7),
Text = text
diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs
index 48208bb8e..378fd8016 100644
--- a/UnitTests/View/DrawTests.cs
+++ b/UnitTests/View/DrawTests.cs
@@ -339,7 +339,7 @@ public class DrawTests (ITestOutputHelper _output)
Text = "Test",
Width = 6,
Height = 1,
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
ColorScheme = Colors.ColorSchemes ["Base"]
};
@@ -350,7 +350,7 @@ public class DrawTests (ITestOutputHelper _output)
Y = 1,
Width = 1,
Height = 6,
- VerticalTextAlignment = VerticalTextAlignment.Bottom,
+ VerticalTextAlignment = Alignment.End,
ColorScheme = Colors.ColorSchemes ["Base"]
};
Toplevel top = new ();
diff --git a/UnitTests/View/Layout/Dim.AutoTests.cs b/UnitTests/View/Layout/Dim.AutoTests.cs
index 8bd0054bd..e77d3ce48 100644
--- a/UnitTests/View/Layout/Dim.AutoTests.cs
+++ b/UnitTests/View/Layout/Dim.AutoTests.cs
@@ -787,11 +787,11 @@ public class DimAutoTests (ITestOutputHelper output)
Assert.False (view.TextFormatter.AutoSize);
Assert.Equal (Size.Empty, view.Frame.Size);
- view.TextFormatter.Alignment = TextAlignment.Justified;
+ view.TextFormatter.Alignment = Alignment.Fill;
Assert.False (view.TextFormatter.AutoSize);
Assert.Equal (Size.Empty, view.Frame.Size);
- view.TextFormatter.VerticalAlignment = VerticalTextAlignment.Middle;
+ view.TextFormatter.VerticalAlignment = Alignment.Center;
Assert.False (view.TextFormatter.AutoSize);
Assert.Equal (Size.Empty, view.Frame.Size);
@@ -815,11 +815,11 @@ public class DimAutoTests (ITestOutputHelper output)
Assert.False (view.TextFormatter.AutoSize);
Assert.Equal (Size.Empty, view.Frame.Size);
- view.TextAlignment = TextAlignment.Justified;
+ view.TextAlignment = Alignment.Fill;
Assert.False (view.TextFormatter.AutoSize);
Assert.Equal (Size.Empty, view.Frame.Size);
- view.VerticalTextAlignment = VerticalTextAlignment.Middle;
+ view.VerticalTextAlignment = Alignment.Center;
Assert.False (view.TextFormatter.AutoSize);
Assert.Equal (Size.Empty, view.Frame.Size);
@@ -844,7 +844,7 @@ public class DimAutoTests (ITestOutputHelper output)
Assert.False (view.TextFormatter.AutoSize);
Assert.NotEqual (Size.Empty, view.Frame.Size);
- view.TextAlignment = TextAlignment.Justified;
+ view.TextAlignment = Alignment.Fill;
Assert.False (view.TextFormatter.AutoSize);
Assert.NotEqual (Size.Empty, view.Frame.Size);
@@ -853,7 +853,7 @@ public class DimAutoTests (ITestOutputHelper output)
Text = "_1234",
Width = Dim.Auto ()
};
- view.VerticalTextAlignment = VerticalTextAlignment.Middle;
+ view.VerticalTextAlignment = Alignment.Center;
Assert.False (view.TextFormatter.AutoSize);
Assert.NotEqual (Size.Empty, view.Frame.Size);
diff --git a/UnitTests/View/Layout/Dim.PercentTests.cs b/UnitTests/View/Layout/Dim.PercentTests.cs
index d9fa64f8d..c5bcb25d3 100644
--- a/UnitTests/View/Layout/Dim.PercentTests.cs
+++ b/UnitTests/View/Layout/Dim.PercentTests.cs
@@ -7,8 +7,6 @@ namespace Terminal.Gui.LayoutTests;
public class DimPercentTests
{
- //private readonly ITestOutputHelper _output;
-
[Fact]
public void DimFactor_Calculate_ReturnsCorrectValue ()
{
diff --git a/UnitTests/View/Layout/Pos.AlignTests.cs b/UnitTests/View/Layout/Pos.AlignTests.cs
new file mode 100644
index 000000000..57afc4943
--- /dev/null
+++ b/UnitTests/View/Layout/Pos.AlignTests.cs
@@ -0,0 +1,99 @@
+
+using static Unix.Terminal.Delegates;
+
+namespace Terminal.Gui.PosDimTests;
+
+public class PosAlignTests ()
+{
+ [Fact]
+ public void PosAlign_Constructor ()
+ {
+ var posAlign = new PosAlign ()
+ {
+ Aligner = new Aligner(),
+ };
+ Assert.NotNull (posAlign);
+ }
+
+ [Theory]
+ [InlineData (Alignment.Start, Alignment.Start, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, true)]
+ [InlineData (Alignment.Center, Alignment.Center, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, true)]
+ [InlineData (Alignment.Start, Alignment.Center, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, false)]
+ [InlineData (Alignment.Center, Alignment.Start, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, false)]
+ [InlineData (Alignment.Start, Alignment.Start, AlignmentModes.StartToEnd, AlignmentModes.AddSpaceBetweenItems, false)]
+ public void PosAlign_Equals (Alignment align1, Alignment align2, AlignmentModes mode1, AlignmentModes mode2, bool expectedEquals)
+ {
+ var posAlign1 = new PosAlign ()
+ {
+ Aligner = new Aligner ()
+ {
+ Alignment = align1,
+ AlignmentModes = mode1
+ }
+ };
+ var posAlign2 = new PosAlign ()
+ {
+ Aligner = new Aligner ()
+ {
+ Alignment = align2,
+ AlignmentModes = mode2
+ }
+ };
+
+ Assert.Equal (expectedEquals, posAlign1.Equals (posAlign2));
+ Assert.Equal (expectedEquals, posAlign2.Equals (posAlign1));
+ }
+
+ [Fact]
+ public void PosAlign_Equals_CachedLocation_Not_Used ()
+ {
+ View superView = new ()
+ {
+ Width = 10,
+ Height = 25
+ };
+ View view = new ();
+ superView.Add (view);
+
+ var posAlign1 = Pos.Align (Alignment.Center, AlignmentModes.AddSpaceBetweenItems);
+ view.X = posAlign1;
+ var pos1 = posAlign1.Calculate (10, Dim.Absolute(0)!, view, Dimension.Width);
+
+ var posAlign2 = Pos.Align (Alignment.Center, AlignmentModes.AddSpaceBetweenItems);
+ view.Y = posAlign2;
+ var pos2 = posAlign2.Calculate (25, Dim.Absolute (0)!, view, Dimension.Height);
+
+ Assert.NotEqual(pos1, pos2);
+ Assert.Equal (posAlign1, posAlign2);
+ }
+
+ [Fact]
+ public void PosAlign_ToString ()
+ {
+ var posAlign = Pos.Align (Alignment.Fill);
+ var expectedString = "Align(alignment=Fill,modes=AddSpaceBetweenItems,groupId=0)";
+
+ Assert.Equal (expectedString, posAlign.ToString ());
+ }
+
+ [Fact]
+ public void PosAlign_Anchor ()
+ {
+ var posAlign = Pos.Align (Alignment.Start);
+ var width = 50;
+ var expectedAnchor = -width;
+
+ Assert.Equal (expectedAnchor, posAlign.GetAnchor (width));
+ }
+
+ [Fact]
+ public void PosAlign_CreatesCorrectInstance ()
+ {
+ var pos = Pos.Align (Alignment.Start);
+ Assert.IsType (pos);
+ }
+
+ // TODO: Test scenarios where views with matching GroupId's are added/removed from a Superview
+
+ // TODO: Make AlignAndUpdateGroup internal and write low-level unit tests for it
+}
diff --git a/UnitTests/View/Layout/Pos.Tests.cs b/UnitTests/View/Layout/Pos.Tests.cs
index 4f51e7874..9a98cf8ff 100644
--- a/UnitTests/View/Layout/Pos.Tests.cs
+++ b/UnitTests/View/Layout/Pos.Tests.cs
@@ -78,7 +78,7 @@ public class PosTests ()
{
Application.Init (new FakeDriver ());
- Toplevel t = new Toplevel();
+ Toplevel t = new Toplevel ();
var w = new Window { X = Pos.Left (t) + 2, Y = Pos.Top (t) + 2 };
var f = new FrameView ();
diff --git a/UnitTests/View/NeedsDisplayTests.cs b/UnitTests/View/NeedsDisplayTests.cs
index f5bba1b2b..c3f971250 100644
--- a/UnitTests/View/NeedsDisplayTests.cs
+++ b/UnitTests/View/NeedsDisplayTests.cs
@@ -5,7 +5,7 @@ using Xunit.Abstractions;
namespace Terminal.Gui.ViewTests;
[Trait("Category","Output")]
-public class NeedsDisplayTests (ITestOutputHelper output)
+public class NeedsDisplayTests ()
{
[Fact]
public void NeedsDisplay_False_If_Width_Height_Zero ()
diff --git a/UnitTests/View/TextTests.cs b/UnitTests/View/TextTests.cs
index 09f151e6e..66b639adc 100644
--- a/UnitTests/View/TextTests.cs
+++ b/UnitTests/View/TextTests.cs
@@ -850,7 +850,7 @@ Y
Y = 1,
Width = width,
Height = 1,
- TextAlignment = TextAlignment.Centered
+ TextAlignment = Alignment.Center
};
if (autoSize)
@@ -865,7 +865,7 @@ Y
Y = 2,
Width = width,
Height = 1,
- TextAlignment = TextAlignment.Right
+ TextAlignment = Alignment.End
};
if (autoSize)
@@ -880,7 +880,7 @@ Y
Y = 3,
Width = width,
Height = 1,
- TextAlignment = TextAlignment.Justified
+ TextAlignment = Alignment.Fill
};
if (autoSize)
@@ -974,7 +974,7 @@ Y
Width = 1,
Height = height,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Middle
+ VerticalTextAlignment = Alignment.Center
};
if (autoSize)
@@ -990,7 +990,7 @@ Y
Width = 1,
Height = height,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Bottom
+ VerticalTextAlignment = Alignment.End
};
if (autoSize)
@@ -1006,7 +1006,7 @@ Y
Width = 1,
Height = height,
TextDirection = TextDirection.TopBottom_LeftRight,
- VerticalTextAlignment = VerticalTextAlignment.Justified
+ VerticalTextAlignment = Alignment.Fill
};
if (autoSize)
@@ -1227,7 +1227,7 @@ Y
{
Text = "01234",
TextDirection = TextDirection.LeftRight_TopBottom,
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 10,
Height = Dim.Auto (DimAutoStyle.Text)
};
diff --git a/UnitTests/Views/ButtonTests.cs b/UnitTests/Views/ButtonTests.cs
index 0d91bc151..51e1faaea 100644
--- a/UnitTests/Views/ButtonTests.cs
+++ b/UnitTests/Views/ButtonTests.cs
@@ -155,14 +155,14 @@ public class ButtonTests (ITestOutputHelper output)
Assert.Equal ($"{CM.Glyphs.LeftBracket} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text);
Assert.False (btn.IsDefault);
- Assert.Equal (TextAlignment.Centered, btn.TextAlignment);
+ Assert.Equal (Alignment.Center, btn.TextAlignment);
Assert.Equal ('_', btn.HotKeySpecifier.Value);
Assert.True (btn.CanFocus);
Assert.Equal (new (0, 0, 4, 1), btn.Viewport);
Assert.Equal (new (0, 0, 4, 1), btn.Frame);
Assert.Equal ($"{CM.Glyphs.LeftBracket} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text);
Assert.False (btn.IsDefault);
- Assert.Equal (TextAlignment.Centered, btn.TextAlignment);
+ Assert.Equal (Alignment.Center, btn.TextAlignment);
Assert.Equal ('_', btn.HotKeySpecifier.Value);
Assert.True (btn.CanFocus);
Assert.Equal (new (0, 0, 4, 1), btn.Viewport);
@@ -195,7 +195,7 @@ public class ButtonTests (ITestOutputHelper output)
btn.TextFormatter.Format ()
);
Assert.True (btn.IsDefault);
- Assert.Equal (TextAlignment.Centered, btn.TextAlignment);
+ Assert.Equal (Alignment.Center, btn.TextAlignment);
Assert.True (btn.CanFocus);
btn.SetRelativeLayout (new (100, 100));
@@ -222,7 +222,7 @@ public class ButtonTests (ITestOutputHelper output)
btn.TextFormatter.Format ()
);
Assert.True (btn.IsDefault);
- Assert.Equal (TextAlignment.Centered, btn.TextAlignment);
+ Assert.Equal (Alignment.Center, btn.TextAlignment);
Assert.Equal ('_', btn.HotKeySpecifier.Value);
Assert.True (btn.CanFocus);
diff --git a/UnitTests/Views/CheckBoxTests.cs b/UnitTests/Views/CheckBoxTests.cs
index c7b5e73a5..3cd134268 100644
--- a/UnitTests/Views/CheckBoxTests.cs
+++ b/UnitTests/Views/CheckBoxTests.cs
@@ -28,7 +28,6 @@ public class CheckBoxTests
[InlineData ("0_12你", 0, 1, 0, 1)]
[InlineData ("0_12你", 1, 1, 1, 1)]
[InlineData ("0_12你", 10, 1, 10, 1)]
- [InlineData ("0_12你", 10, 3, 10, 3)]
public void CheckBox_AbsoluteSize_Text (string text, int width, int height, int expectedWidth, int expectedHeight)
{
var checkBox = new CheckBox
@@ -251,7 +250,7 @@ public class CheckBoxTests
X = 1,
Y = Pos.Center (),
Text = "Check this out 你",
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 25
};
var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
@@ -262,7 +261,7 @@ public class CheckBoxTests
Application.Begin (top);
((FakeDriver)Application.Driver).SetBufferSize (30, 5);
- Assert.Equal (TextAlignment.Centered, checkBox.TextAlignment);
+ Assert.Equal (Alignment.Center, checkBox.TextAlignment);
Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
@@ -301,7 +300,7 @@ public class CheckBoxTests
X = 1,
Y = Pos.Center (),
Text = "Check first out 你",
- TextAlignment = TextAlignment.Justified,
+ TextAlignment = Alignment.Fill,
Width = 25
};
@@ -310,7 +309,7 @@ public class CheckBoxTests
X = 1,
Y = Pos.Bottom (checkBox1),
Text = "Check second out 你",
- TextAlignment = TextAlignment.Justified,
+ TextAlignment = Alignment.Fill,
Width = 25
};
var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
@@ -321,9 +320,9 @@ public class CheckBoxTests
Application.Begin (top);
((FakeDriver)Application.Driver).SetBufferSize (30, 6);
- Assert.Equal (TextAlignment.Justified, checkBox1.TextAlignment);
+ Assert.Equal (Alignment.Fill, checkBox1.TextAlignment);
Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
- Assert.Equal (TextAlignment.Justified, checkBox2.TextAlignment);
+ Assert.Equal (Alignment.Fill, checkBox2.TextAlignment);
Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
var expected = @$"
@@ -378,7 +377,7 @@ public class CheckBoxTests
Application.Begin (top);
((FakeDriver)Application.Driver).SetBufferSize (30, 5);
- Assert.Equal (TextAlignment.Left, checkBox.TextAlignment);
+ Assert.Equal (Alignment.Start, checkBox.TextAlignment);
Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
@@ -417,7 +416,7 @@ public class CheckBoxTests
X = 1,
Y = Pos.Center (),
Text = "Check this out 你",
- TextAlignment = TextAlignment.Right,
+ TextAlignment = Alignment.End,
Width = 25
};
var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
@@ -428,7 +427,7 @@ public class CheckBoxTests
Application.Begin (top);
((FakeDriver)Application.Driver).SetBufferSize (30, 5);
- Assert.Equal (TextAlignment.Right, checkBox.TextAlignment);
+ Assert.Equal (Alignment.End, checkBox.TextAlignment);
Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
diff --git a/UnitTests/Views/LabelTests.cs b/UnitTests/Views/LabelTests.cs
index 938b3a788..d8f734889 100644
--- a/UnitTests/Views/LabelTests.cs
+++ b/UnitTests/Views/LabelTests.cs
@@ -207,7 +207,7 @@ public class LabelTests
{
var label = new Label ();
Assert.Equal (string.Empty, label.Text);
- Assert.Equal (TextAlignment.Left, label.TextAlignment);
+ Assert.Equal (Alignment.Start, label.TextAlignment);
Assert.False (label.CanFocus);
Assert.Equal (new Rectangle (0, 0, 0, 0), label.Frame);
Assert.Equal (KeyCode.Null, label.HotKey);
diff --git a/UnitTests/Views/TextValidateFieldTests.cs b/UnitTests/Views/TextValidateFieldTests.cs
index ad149a705..96a0d6d17 100644
--- a/UnitTests/Views/TextValidateFieldTests.cs
+++ b/UnitTests/Views/TextValidateFieldTests.cs
@@ -10,7 +10,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// ****
@@ -44,7 +44,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Left,
+ TextAlignment = Alignment.Start,
Width = 30,
// ****
@@ -81,7 +81,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// ****
@@ -115,7 +115,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// *
@@ -137,7 +137,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// *
@@ -161,7 +161,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// ****
@@ -179,7 +179,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// ****
@@ -196,7 +196,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// ****
@@ -214,7 +214,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// *
@@ -233,7 +233,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// *
@@ -253,7 +253,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// ** **
@@ -283,7 +283,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// *
@@ -308,7 +308,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Left,
+ TextAlignment = Alignment.Start,
Width = 30,
// ****
@@ -338,7 +338,7 @@ public class TextValidateField_NET_Provider_Tests
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Left, Width = 30, Provider = new NetMaskedTextProvider ("--(0000)--")
+ TextAlignment = Alignment.Start, Width = 30, Provider = new NetMaskedTextProvider ("--(0000)--")
};
field.Provider.TextChanged += (sender, e) => wasTextChanged = true;
@@ -356,7 +356,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// *
@@ -381,7 +381,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Left,
+ TextAlignment = Alignment.Start,
Width = 30,
// ****
@@ -400,7 +400,7 @@ public class TextValidateField_NET_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
// ****
@@ -540,7 +540,7 @@ public class TextValidateField_Regex_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false }
};
@@ -596,7 +596,7 @@ public class TextValidateField_Regex_Provider_Tests
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false }
};
@@ -616,7 +616,7 @@ public class TextValidateField_Regex_Provider_Tests
{
var field = new TextValidateField
{
- TextAlignment = TextAlignment.Centered,
+ TextAlignment = Alignment.Center,
Width = 20,
Provider = new TextRegexProvider ("^[0-9][0-9][0-9]$") { ValidateOnInput = false }
};
diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs
index b17c3cbf0..62f4580fc 100644
--- a/UnitTests/Views/ToplevelTests.cs
+++ b/UnitTests/Views/ToplevelTests.cs
@@ -1453,8 +1453,8 @@ public class ToplevelTests
Y = Pos.Center (),
Width = Dim.Fill (),
Height = Dim.Fill (),
- TextAlignment = TextAlignment.Centered,
- VerticalTextAlignment = VerticalTextAlignment.Middle,
+ TextAlignment = Alignment.Center,
+ VerticalTextAlignment = Alignment.Center,
Text = "Test"
}
);
diff --git a/docfx/docs/layout.md b/docfx/docs/layout.md
index 4cb797918..56c94b5d9 100644
--- a/docfx/docs/layout.md
+++ b/docfx/docs/layout.md
@@ -65,6 +65,7 @@ The [Pos](~/api/Terminal.Gui.Pos.yml) is the type of `View.X` and `View.Y` and s
* Anchored from the end of the dimension - `Pos.AnchorEnd()`.
* Centered, using `Pos.Center()`.
* The `Pos.Left(otherView)`, `Pos.Top(otherView)`, `Pos.Bottom(otherView)`, `Pos.Right(otherView)` positions of another view.
+* Aligned (left, right, center, etc...) with other views - `Pos.Justify(Justification)`.
All `Pos` coordinates are relative to the Superview's content area.
diff --git a/docfx/docs/migratingfromv1.md b/docfx/docs/migratingfromv1.md
index a58f5449e..f8749071c 100644
--- a/docfx/docs/migratingfromv1.md
+++ b/docfx/docs/migratingfromv1.md
@@ -247,4 +247,14 @@ Replace references to to nested types with the new standalone version
```diff
- var myTab = new TabView.Tab();
+ var myTab = new Tab();
-```
\ No newline at end of file
+```
+
+## View and Text Alignment is now Justification
+
+In v1, both `TextAlignment` and `VerticalTextAlignment` enums were used to align text in views. In v2, these enums have been replaced with the `Alignment` enum. The `View.TextAlignment` property controls horizontal text alignment, and the `View.VerticalTextAlignment` property controls vertical text alignment.
+
+v2 now supports `Pos.Align` which enables views to be justified within their superview.
+
+### How to Fix
+
+* Replace `VerticalAlignment.Middle` is now `Alignment.Center`.
diff --git a/docfx/docs/newinv2.md b/docfx/docs/newinv2.md
index 08d9fe882..66fbfcd37 100644
--- a/docfx/docs/newinv2.md
+++ b/docfx/docs/newinv2.md
@@ -11,23 +11,23 @@ Apps built with Terminal.Gui now feel modern thanks to these improvements:
* *TrueColor support* - 24-bit color support for Windows, Mac, and Linux. Legacy 16-color systems are still supported, automatically. See [TrueColor](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#truecolor) for details.
* *Enhanced Borders and Padding* - Terminal.Gui now supports a `Border`, `Margin`, and `Padding` property on all views. This simplifies View development and enables a sophisticated look and feel. See [Adornments](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#adornments) for details.
* *User Configurable Color Themes* - See [Color Themes](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#color-themes) for details.
-* *Enhanced Unicode/Wide Character support *- Terminal.Gui now supports the full range of Unicode/wide characters. See [Unicode](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#unicode) for details.
+* *Enhanced Unicode/Wide Character support* - Terminal.Gui now supports the full range of Unicode/wide characters. See [Unicode](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#unicode) for details.
* *Line Canvas* - Terminal.Gui now supports a line canvas enabling high-performance drawing of lines and shapes using box-drawing glyphs. `LineCanvas` provides *auto join*, a smart TUI drawing system that automatically selects the correct line/box drawing glyphs for intersections making drawing complex shapes easy. See [Line Canvas](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#line-canvas) for details.
## Simplified API
The entire library has been reviewed and simplified. As a result, the API is more consistent and uses modern .NET API standards (e.g. for events). This refactoring resulted in the removal of thousands of lines of code, better unit tests, and higher performance than v1. See [Simplified API](overview.md#simplified-api) for details.
-## View Improvements
+## `View` Improvements
* *Life Cycle Management* -
-* In v1, `View` was derived from `Responder` which supported `IDisposable`. In v2, `Responder` has been removed and `View` is the base-class supporting `IDisposable`.
-* `Application.Init` no longer automatically creates a toplevel or sets `Applicaton.Top`; app developers must explicitly create the toplevel view and pass it to `Appliation.Run` (or use `Application.Run`). Developers are responsible for calling `Dispose` on any toplevel they create before exiting.
-* *Adornments* -
-* *Built-in Scrolling/Virtual Content Area* - In v1, to have a view a user could scroll required either a bespoke scrolling implementation, inheriting from `ScrollView`, or managing the complexity of `ScrollBarView` directly. In v2, the base-View class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by `View.ContentSize`. See [Layout](layout.md) for details.
-* *Computed Layout Improvements* -
-* *`Pos.AnchorEnd ()`* - New to v2 is `Pos.AnchorEnd ()` (with no parameters) which allows a view to be anchored to the right or bottom of the Superview.
-* *`Dim.Auto`* - Automatic size based on the View's content (either Subviews or Text) - `Dim.Auto()` - See the [DimAuto Deep Dive](dimauto.md) for more information.
+ * In v1, `View` was derived from `Responder` which supported `IDisposable`. In v2, `Responder` has been removed and `View` is the base-class supporting `IDisposable`.
+ * `Application.Init` no longer automatically creates a toplevel or sets `Applicaton.Top`; app developers must explicitly create the toplevel view and pass it to `Appliation.Run` (or use `Application.Run`). Developers are responsible for calling `Dispose` on any toplevel they create before exiting.
+* New! *Adornments* - Adornments are a special form of View that appear outside the `Viewport`: `Margin`, `Border`, and `Padding`.
+* New! *Built-in Scrolling/Virtual Content Area* - In v1, to have a view a user could scroll required either a bespoke scrolling implementation, inheriting from `ScrollView`, or managing the complexity of `ScrollBarView` directly. In v2, the base-View class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called `Bounds`. `Bounds.Location` was always `Point.Empty`. In v2 the visible area is a rectangle called `Viewport` which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing `View.Viewport.Location`. The View's content described by `View.ContentSize`. See [Layout](layout.md) for details.
+* New! *`Dim.Auto`* - Automatically sizes the view to fitthe view's Text, SubViews, or ContentArea.
+* Improved! *`Pos.AnchorEnd ()`* - New to v2 is `Pos.AnchorEnd ()` (with no parameters) which allows a view to be anchored to the right or bottom of the Superview.
+* New! *`Pos.Align ()`* - Aligns a set of views horizontally or vertically (left, rigth, center, etc...).
* ...
## New and Improved Built-in Views