mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Initial commit. Just a prototype
This commit is contained in:
@@ -1,4 +1,22 @@
|
||||
namespace Terminal.Gui;
|
||||
using static Terminal.Gui.Dialog;
|
||||
|
||||
namespace Terminal.Gui;
|
||||
|
||||
/// <summary>Determines the horizontal alignment of Views.</summary>
|
||||
public enum ViewAlignments
|
||||
{
|
||||
/// <summary>Center-aligns the buttons (the default).</summary>
|
||||
Center = 0,
|
||||
|
||||
/// <summary>Justifies the buttons</summary>
|
||||
Justify,
|
||||
|
||||
/// <summary>Left-aligns the buttons</summary>
|
||||
Left,
|
||||
|
||||
/// <summary>Right-aligns the buttons</summary>
|
||||
Right
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes the position of a <see cref="View"/> which can be an absolute value, a percentage, centered, or
|
||||
@@ -169,14 +187,6 @@ public class Pos
|
||||
/// <param name="n">The value to convert to the <see cref="Pos"/>.</param>
|
||||
public static Pos At (int n) { return new PosAbsolute (n); }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Pos"/> object that tracks the Bottom (Y+Height) coordinate of the specified
|
||||
/// <see cref="View"/>
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Pos"/> that depends on the other view.</returns>
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos Bottom (View view) { return new PosView (view, Side.Bottom); }
|
||||
|
||||
/// <summary>Creates a <see cref="Pos"/> object that can be used to center the <see cref="View"/>.</summary>
|
||||
/// <returns>The center Pos.</returns>
|
||||
/// <example>
|
||||
@@ -193,6 +203,12 @@ public class Pos
|
||||
/// </example>
|
||||
public static Pos Center () { return new PosCenter (); }
|
||||
|
||||
public static Pos Justify (View[] views, ViewAlignments alignment)
|
||||
{
|
||||
return new PosJustify (views, alignment);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Determines whether the specified object is equal to the current object.</summary>
|
||||
/// <param name="other">The object to compare with the current object. </param>
|
||||
/// <returns>
|
||||
@@ -213,11 +229,6 @@ public class Pos
|
||||
/// <returns>A hash code for the current object.</returns>
|
||||
public override int GetHashCode () { return Anchor (0).GetHashCode (); }
|
||||
|
||||
/// <summary>Creates a <see cref="Pos"/> object that tracks the Left (X) position of the specified <see cref="View"/>.</summary>
|
||||
/// <returns>The <see cref="Pos"/> that depends on the other view.</returns>
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos Left (View view) { return new PosView (view, Side.X); }
|
||||
|
||||
/// <summary>Adds a <see cref="Terminal.Gui.Pos"/> to a <see cref="Terminal.Gui.Pos"/>, yielding a new <see cref="Pos"/>.</summary>
|
||||
/// <param name="left">The first <see cref="Terminal.Gui.Pos"/> to add.</param>
|
||||
/// <param name="right">The second <see cref="Terminal.Gui.Pos"/> to add.</param>
|
||||
@@ -293,6 +304,34 @@ public class Pos
|
||||
return new PosFactor (percent / 100);
|
||||
}
|
||||
|
||||
/// <summary>Creates a <see cref="Pos"/> object that tracks the Top (Y) position of the specified <see cref="View"/>.</summary>
|
||||
/// <returns>The <see cref="Pos"/> that depends on the other view.</returns>
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos Top (View view) { return new PosView (view, Side.Y); }
|
||||
|
||||
/// <summary>Creates a <see cref="Pos"/> object that tracks the Top (Y) position of the specified <see cref="View"/>.</summary>
|
||||
/// <returns>The <see cref="Pos"/> that depends on the other view.</returns>
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos Y (View view) { return new PosView (view, Side.Y); }
|
||||
|
||||
/// <summary>Creates a <see cref="Pos"/> object that tracks the Left (X) position of the specified <see cref="View"/>.</summary>
|
||||
/// <returns>The <see cref="Pos"/> that depends on the other view.</returns>
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos Left (View view) { return new PosView (view, Side.X); }
|
||||
|
||||
/// <summary>Creates a <see cref="Pos"/> object that tracks the Left (X) position of the specified <see cref="View"/>.</summary>
|
||||
/// <returns>The <see cref="Pos"/> that depends on the other view.</returns>
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos X (View view) { return new PosView (view, Side.X); }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Pos"/> object that tracks the Bottom (Y+Height) coordinate of the specified
|
||||
/// <see cref="View"/>
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Pos"/> that depends on the other view.</returns>
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos Bottom (View view) { return new PosView (view, Side.Bottom); }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Pos"/> object that tracks the Right (X+Width) coordinate of the specified
|
||||
/// <see cref="View"/>.
|
||||
@@ -301,21 +340,6 @@ public class Pos
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos Right (View view) { return new PosView (view, Side.Right); }
|
||||
|
||||
/// <summary>Creates a <see cref="Pos"/> object that tracks the Top (Y) position of the specified <see cref="View"/>.</summary>
|
||||
/// <returns>The <see cref="Pos"/> that depends on the other view.</returns>
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos Top (View view) { return new PosView (view, Side.Y); }
|
||||
|
||||
/// <summary>Creates a <see cref="Pos"/> object that tracks the Left (X) position of the specified <see cref="View"/>.</summary>
|
||||
/// <returns>The <see cref="Pos"/> that depends on the other view.</returns>
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos X (View view) { return new PosView (view, Side.X); }
|
||||
|
||||
/// <summary>Creates a <see cref="Pos"/> object that tracks the Top (Y) position of the specified <see cref="View"/>.</summary>
|
||||
/// <returns>The <see cref="Pos"/> that depends on the other view.</returns>
|
||||
/// <param name="view">The <see cref="View"/> that will be tracked.</param>
|
||||
public static Pos Y (View view) { return new PosView (view, Side.Y); }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a position that is anchored to a certain point in the layout. This method is typically used
|
||||
/// internally by the layout system to determine where a View should be positioned.
|
||||
@@ -460,7 +484,7 @@ public class Pos
|
||||
internal override int Anchor (int width) { return _function (); }
|
||||
}
|
||||
|
||||
internal enum Side
|
||||
public enum Side
|
||||
{
|
||||
X = 0,
|
||||
Y = 1,
|
||||
@@ -478,13 +502,13 @@ public class Pos
|
||||
public override string ToString ()
|
||||
{
|
||||
string sideString = side switch
|
||||
{
|
||||
Side.X => "x",
|
||||
Side.Y => "y",
|
||||
Side.Right => "right",
|
||||
Side.Bottom => "bottom",
|
||||
_ => "unknown"
|
||||
};
|
||||
{
|
||||
Side.X => "x",
|
||||
Side.Y => "y",
|
||||
Side.Right => "right",
|
||||
Side.Bottom => "bottom",
|
||||
_ => "unknown"
|
||||
};
|
||||
|
||||
if (Target == null)
|
||||
{
|
||||
@@ -497,15 +521,101 @@ public class Pos
|
||||
internal override int Anchor (int width)
|
||||
{
|
||||
return side switch
|
||||
{
|
||||
Side.X => Target.Frame.X,
|
||||
Side.Y => Target.Frame.Y,
|
||||
Side.Right => Target.Frame.Right,
|
||||
Side.Bottom => Target.Frame.Bottom,
|
||||
_ => 0
|
||||
};
|
||||
{
|
||||
Side.X => Target.Frame.X,
|
||||
Side.Y => Target.Frame.Y,
|
||||
Side.Right => Target.Frame.Right,
|
||||
Side.Bottom => Target.Frame.Bottom,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Enables justification of a set of views.
|
||||
/// </summary>
|
||||
public class PosJustify : Pos
|
||||
{
|
||||
private readonly View [] _views;
|
||||
private readonly ViewAlignments _alignment;
|
||||
|
||||
/// <summary>
|
||||
/// Enables justification of a set of views.
|
||||
/// </summary>
|
||||
/// <param name="views">The set of views to justify according to <paramref name="alignment"/>.</param>
|
||||
/// <param name="alignment"></param>
|
||||
public PosJustify (View [] views, ViewAlignments alignment)
|
||||
{
|
||||
_alignment = alignment;
|
||||
_views = views;
|
||||
}
|
||||
|
||||
public override bool Equals (object other)
|
||||
{
|
||||
return other is PosJustify justify && justify._views == _views && justify._alignment == _alignment;
|
||||
}
|
||||
|
||||
public override int GetHashCode () { return _views.GetHashCode (); }
|
||||
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return $"Justify(views={_views},alignment={_alignment})";
|
||||
}
|
||||
|
||||
internal override int Anchor (int width)
|
||||
{
|
||||
if (_views.Length == 0 || !_views [0].IsInitialized)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int spacing = 0;
|
||||
switch (_alignment)
|
||||
{
|
||||
case ViewAlignments.Center:
|
||||
// Center spacing is sum of the widths of the views - width / number of views
|
||||
spacing = (width - _views.Select (v => v.Frame.Width).Sum ()) / _views.Length;
|
||||
|
||||
// How do I know which view we are?
|
||||
View us = _views.Where (v => v.X.Equals (this)).First();
|
||||
|
||||
if (_views [0] == us)
|
||||
{
|
||||
return spacing;
|
||||
}
|
||||
// Calculate the position of the previous (left or above us) view
|
||||
int previous = _views.Where (v => v.X.Equals (us)).First().Frame.Left;
|
||||
|
||||
return previous + spacing;
|
||||
//case ViewAlignments.Left:
|
||||
// return Left (width);
|
||||
//case ViewAlignments.Right:
|
||||
// return Right (width);
|
||||
//case ViewAlignments.Justify:
|
||||
// return Justify (width);
|
||||
default:
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//internal override int Calculate (int superviewDimension, Dim dim, int autosize, bool autoSize)
|
||||
//{
|
||||
// // Assuming autosize is the size that the View would have if it were to automatically adjust its size based on its content
|
||||
// // and autoSize is a boolean value that indicates whether the View should automatically adjust its size based on its content
|
||||
// if (autoSize)
|
||||
// {
|
||||
// return autosize;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Assuming dim.Calculate returns the calculated size of the View
|
||||
// return dim.Calculate (_views.Frame.Left, _views.Frame.Width, autosize, autoSize);
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -822,7 +932,7 @@ public class Dim
|
||||
internal override int Anchor (int width) { return _function (); }
|
||||
}
|
||||
|
||||
internal enum Side
|
||||
public enum Side
|
||||
{
|
||||
Height = 0,
|
||||
Width = 1
|
||||
@@ -850,11 +960,11 @@ public class Dim
|
||||
}
|
||||
|
||||
string sideString = _side switch
|
||||
{
|
||||
Side.Height => "Height",
|
||||
Side.Width => "Width",
|
||||
_ => "unknown"
|
||||
};
|
||||
{
|
||||
Side.Height => "Height",
|
||||
Side.Width => "Width",
|
||||
_ => "unknown"
|
||||
};
|
||||
|
||||
return $"View({sideString},{Target})";
|
||||
}
|
||||
@@ -862,11 +972,11 @@ public class Dim
|
||||
internal override int Anchor (int width)
|
||||
{
|
||||
return _side switch
|
||||
{
|
||||
Side.Height => Target.Frame.Height,
|
||||
Side.Width => Target.Frame.Width,
|
||||
_ => 0
|
||||
};
|
||||
{
|
||||
Side.Height => Target.Frame.Height,
|
||||
Side.Width => Target.Frame.Width,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public enum LayoutStyle
|
||||
Computed
|
||||
}
|
||||
|
||||
|
||||
public partial class View
|
||||
{
|
||||
#region Frame
|
||||
|
||||
@@ -15,21 +15,6 @@ namespace Terminal.Gui;
|
||||
/// </remarks>
|
||||
public class Dialog : Window
|
||||
{
|
||||
/// <summary>Determines the horizontal alignment of the Dialog buttons.</summary>
|
||||
public enum ButtonAlignments
|
||||
{
|
||||
/// <summary>Center-aligns the buttons (the default).</summary>
|
||||
Center = 0,
|
||||
|
||||
/// <summary>Justifies the buttons</summary>
|
||||
Justify,
|
||||
|
||||
/// <summary>Left-aligns the buttons</summary>
|
||||
Left,
|
||||
|
||||
/// <summary>Right-aligns the buttons</summary>
|
||||
Right
|
||||
}
|
||||
|
||||
// TODO: Reenable once border/borderframe design is settled
|
||||
/// <summary>
|
||||
@@ -109,7 +94,7 @@ public class Dialog : Window
|
||||
}
|
||||
|
||||
/// <summary>Determines how the <see cref="Dialog"/> <see cref="Button"/>s are aligned along the bottom of the dialog.</summary>
|
||||
public ButtonAlignments ButtonAlignment { get; set; }
|
||||
public ViewAlignments ButtonAlignment { get; set; }
|
||||
|
||||
/// <summary>Optional buttons to lay out at the bottom of the dialog.</summary>
|
||||
public Button [] Buttons
|
||||
@@ -129,11 +114,11 @@ public class Dialog : Window
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The default <see cref="ButtonAlignments"/> for <see cref="Dialog"/>.</summary>
|
||||
/// <summary>The default <see cref="ViewAlignments"/> for <see cref="Dialog"/>.</summary>
|
||||
/// <remarks>This property can be set in a Theme.</remarks>
|
||||
[SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
|
||||
[JsonConverter (typeof (JsonStringEnumConverter))]
|
||||
public static ButtonAlignments DefaultButtonAlignment { get; set; } = ButtonAlignments.Center;
|
||||
public static ViewAlignments DefaultButtonAlignment { get; set; } = ViewAlignments.Center;
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="Button"/> to the <see cref="Dialog"/>, its layout will be controlled by the
|
||||
@@ -200,7 +185,7 @@ public class Dialog : Window
|
||||
|
||||
switch (ButtonAlignment)
|
||||
{
|
||||
case ButtonAlignments.Center:
|
||||
case ViewAlignments.Center:
|
||||
// Center Buttons
|
||||
shiftLeft = (Viewport.Width - buttonsWidth - _buttons.Count - 1) / 2 + 1;
|
||||
|
||||
@@ -223,7 +208,7 @@ public class Dialog : Window
|
||||
|
||||
break;
|
||||
|
||||
case ButtonAlignments.Justify:
|
||||
case ViewAlignments.Justify:
|
||||
// Justify Buttons
|
||||
// leftmost and rightmost buttons are hard against edges. The rest are evenly spaced.
|
||||
|
||||
@@ -258,7 +243,7 @@ public class Dialog : Window
|
||||
|
||||
break;
|
||||
|
||||
case ButtonAlignments.Left:
|
||||
case ViewAlignments.Left:
|
||||
// Left Align Buttons
|
||||
Button prevButton = _buttons [0];
|
||||
prevButton.X = 0;
|
||||
@@ -274,7 +259,7 @@ public class Dialog : Window
|
||||
|
||||
break;
|
||||
|
||||
case ButtonAlignments.Right:
|
||||
case ViewAlignments.Right:
|
||||
// Right align buttons
|
||||
shiftLeft = _buttons [_buttons.Count - 1].Frame.Width;
|
||||
_buttons [_buttons.Count - 1].X = Pos.AnchorEnd (shiftLeft);
|
||||
|
||||
@@ -4180,7 +4180,10 @@ public class TextView : View
|
||||
}
|
||||
else
|
||||
{
|
||||
PositionCursor ();
|
||||
if (IsInitialized)
|
||||
{
|
||||
PositionCursor ();
|
||||
}
|
||||
}
|
||||
|
||||
OnUnwrappedCursorPosition ();
|
||||
|
||||
@@ -85,7 +85,7 @@ public class Wizard : Dialog
|
||||
{
|
||||
// Using Justify causes the Back and Next buttons to be hard justified against
|
||||
// the left and right edge
|
||||
ButtonAlignment = ButtonAlignments.Justify;
|
||||
ButtonAlignment = ViewAlignments.Justify;
|
||||
BorderStyle = LineStyle.Double;
|
||||
|
||||
//// Add a horiz separator
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terminal.Gui;
|
||||
using static Terminal.Gui.Dialog;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
|
||||
@@ -332,13 +333,13 @@ 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)).",
|
||||
Text = "This Label should be the 3rd to last line (AnchorEnd (3)).",
|
||||
TextAlignment = TextAlignment.Centered,
|
||||
ColorScheme = Colors.ColorSchemes ["Menu"],
|
||||
AutoSize = false,
|
||||
Width = Dim.Fill (5),
|
||||
X = 5,
|
||||
Y = Pos.AnchorEnd (2)
|
||||
Y = Pos.AnchorEnd (3)
|
||||
};
|
||||
app.Add (anchorEndLabel1);
|
||||
|
||||
@@ -347,20 +348,19 @@ public class ComputedLayout : Scenario
|
||||
var anchorEndLabel2 = new TextField
|
||||
{
|
||||
Text =
|
||||
"This TextField should be the 3rd to last line (AnchorEnd (2) - 1).",
|
||||
"This TextField should be the 4th to last line (AnchorEnd (3) - 1).",
|
||||
TextAlignment = TextAlignment.Left,
|
||||
ColorScheme = Colors.ColorSchemes ["Menu"],
|
||||
AutoSize = false,
|
||||
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
|
||||
var leftButton = new Button
|
||||
{
|
||||
Text = "Left", Y = Pos.AnchorEnd (0) - 1 // Pos.Combine
|
||||
Text = "Left", Y = Pos.AnchorEnd () - 1
|
||||
};
|
||||
|
||||
leftButton.Accept += (s, e) =>
|
||||
@@ -376,7 +376,7 @@ 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", Y = Pos.AnchorEnd (2) // Pos.AnchorEnd(1)
|
||||
};
|
||||
|
||||
centerButton.Accept += (s, e) =>
|
||||
@@ -402,14 +402,17 @@ 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);
|
||||
|
||||
|
||||
// Center three buttons with 5 spaces between them
|
||||
leftButton.X = Pos.Justify (buttons, ViewAlignments.Center);
|
||||
centerButton.X = Pos.Justify (buttons, ViewAlignments.Center);
|
||||
rightButton.X = Pos.Justify (buttons, ViewAlignments.Center);
|
||||
|
||||
Application.Run (app);
|
||||
app.Dispose ();
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ public class Dialogs : Scenario
|
||||
dialog = new Dialog
|
||||
{
|
||||
Title = titleEdit.Text,
|
||||
ButtonAlignment = (Dialog.ButtonAlignments)styleRadioGroup.SelectedItem,
|
||||
ButtonAlignment = (ViewAlignments)styleRadioGroup.SelectedItem,
|
||||
Buttons = buttons.ToArray ()
|
||||
};
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ public class ThemeScopeTests
|
||||
{
|
||||
Reset ();
|
||||
Assert.NotEmpty (Themes);
|
||||
Assert.Equal (Dialog.ButtonAlignments.Center, Dialog.DefaultButtonAlignment);
|
||||
Assert.Equal (ViewAlignments.Center, Dialog.DefaultButtonAlignment);
|
||||
|
||||
Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = Dialog.ButtonAlignments.Right;
|
||||
Themes ["Default"] ["Dialog.DefaultButtonAlignment"].PropertyValue = ViewAlignments.Right;
|
||||
|
||||
ThemeManager.Themes! [ThemeManager.SelectedTheme]!.Apply ();
|
||||
Assert.Equal (Dialog.ButtonAlignments.Right, Dialog.DefaultButtonAlignment);
|
||||
Assert.Equal (ViewAlignments.Right, Dialog.DefaultButtonAlignment);
|
||||
Reset ();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = ViewAlignments.Right;
|
||||
|
||||
string json = JsonSerializer.Serialize (theme, _jsonOptions);
|
||||
|
||||
var deserialized = JsonSerializer.Deserialize<ThemeScope> (json, _jsonOptions);
|
||||
|
||||
Assert.Equal (
|
||||
Dialog.ButtonAlignments.Right,
|
||||
(Dialog.ButtonAlignments)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue
|
||||
ViewAlignments.Right,
|
||||
(ViewAlignments)deserialized ["Dialog.DefaultButtonAlignment"].PropertyValue
|
||||
);
|
||||
Reset ();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class DialogTests
|
||||
Title = title,
|
||||
Width = width,
|
||||
Height = 1,
|
||||
ButtonAlignment = Dialog.ButtonAlignments.Center,
|
||||
ButtonAlignment = ViewAlignments.Center,
|
||||
Buttons = [new Button { Text = btn1Text }]
|
||||
};
|
||||
|
||||
@@ -57,7 +57,7 @@ public class DialogTests
|
||||
Title = title,
|
||||
Width = width,
|
||||
Height = 1,
|
||||
ButtonAlignment = Dialog.ButtonAlignments.Justify,
|
||||
ButtonAlignment = ViewAlignments.Justify,
|
||||
Buttons = [new Button { Text = btn1Text }]
|
||||
};
|
||||
|
||||
@@ -82,7 +82,7 @@ public class DialogTests
|
||||
Title = title,
|
||||
Width = width,
|
||||
Height = 1,
|
||||
ButtonAlignment = Dialog.ButtonAlignments.Right,
|
||||
ButtonAlignment = ViewAlignments.Right,
|
||||
Buttons = [new Button { Text = btn1Text }]
|
||||
};
|
||||
|
||||
@@ -107,7 +107,7 @@ public class DialogTests
|
||||
Title = title,
|
||||
Width = width,
|
||||
Height = 1,
|
||||
ButtonAlignment = Dialog.ButtonAlignments.Left,
|
||||
ButtonAlignment = ViewAlignments.Left,
|
||||
Buttons = [new Button { Text = btn1Text }]
|
||||
};
|
||||
|
||||
@@ -155,7 +155,7 @@ public class DialogTests
|
||||
(runstate, Dialog dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Center,
|
||||
ViewAlignments.Center,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -172,7 +172,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Justify,
|
||||
ViewAlignments.Justify,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -189,7 +189,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Right,
|
||||
ViewAlignments.Right,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -206,7 +206,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Left,
|
||||
ViewAlignments.Left,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -248,7 +248,7 @@ public class DialogTests
|
||||
(runstate, Dialog dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Center,
|
||||
ViewAlignments.Center,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -280,7 +280,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Justify,
|
||||
ViewAlignments.Justify,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -296,7 +296,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Right,
|
||||
ViewAlignments.Right,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -312,7 +312,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Left,
|
||||
ViewAlignments.Left,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -353,7 +353,7 @@ public class DialogTests
|
||||
(runstate, Dialog dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Center,
|
||||
ViewAlignments.Center,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -370,7 +370,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Justify,
|
||||
ViewAlignments.Justify,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -387,7 +387,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Right,
|
||||
ViewAlignments.Right,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -404,7 +404,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Left,
|
||||
ViewAlignments.Left,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -447,7 +447,7 @@ public class DialogTests
|
||||
(runstate, Dialog dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Center,
|
||||
ViewAlignments.Center,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -464,7 +464,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Justify,
|
||||
ViewAlignments.Justify,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -481,7 +481,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Right,
|
||||
ViewAlignments.Right,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -498,7 +498,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Left,
|
||||
ViewAlignments.Left,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text },
|
||||
@@ -530,7 +530,7 @@ public class DialogTests
|
||||
(runstate, Dialog dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Center,
|
||||
ViewAlignments.Center,
|
||||
new Button { Text = btnText }
|
||||
);
|
||||
|
||||
@@ -547,7 +547,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Justify,
|
||||
ViewAlignments.Justify,
|
||||
new Button { Text = btnText }
|
||||
);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
|
||||
@@ -562,7 +562,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Right,
|
||||
ViewAlignments.Right,
|
||||
new Button { Text = btnText }
|
||||
);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
|
||||
@@ -577,7 +577,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Left,
|
||||
ViewAlignments.Left,
|
||||
new Button { Text = btnText }
|
||||
);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
|
||||
@@ -594,7 +594,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Center,
|
||||
ViewAlignments.Center,
|
||||
new Button { Text = btnText }
|
||||
);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
|
||||
@@ -609,7 +609,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Justify,
|
||||
ViewAlignments.Justify,
|
||||
new Button { Text = btnText }
|
||||
);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
|
||||
@@ -624,7 +624,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Right,
|
||||
ViewAlignments.Right,
|
||||
new Button { Text = btnText }
|
||||
);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
|
||||
@@ -639,7 +639,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Left,
|
||||
ViewAlignments.Left,
|
||||
new Button { Text = btnText }
|
||||
);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
|
||||
@@ -673,7 +673,7 @@ public class DialogTests
|
||||
(runstate, Dialog dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Center,
|
||||
ViewAlignments.Center,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text }
|
||||
@@ -689,7 +689,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Justify,
|
||||
ViewAlignments.Justify,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text }
|
||||
@@ -705,7 +705,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Right,
|
||||
ViewAlignments.Right,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text }
|
||||
@@ -721,7 +721,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Left,
|
||||
ViewAlignments.Left,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text },
|
||||
new Button { Text = btn3Text }
|
||||
@@ -755,7 +755,7 @@ public class DialogTests
|
||||
(runstate, Dialog dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Center,
|
||||
ViewAlignments.Center,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text }
|
||||
);
|
||||
@@ -770,7 +770,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Justify,
|
||||
ViewAlignments.Justify,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text }
|
||||
);
|
||||
@@ -785,7 +785,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Right,
|
||||
ViewAlignments.Right,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text }
|
||||
);
|
||||
@@ -800,7 +800,7 @@ public class DialogTests
|
||||
(runstate, dlg) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Left,
|
||||
ViewAlignments.Left,
|
||||
new Button { Text = btn1Text },
|
||||
new Button { Text = btn2Text }
|
||||
);
|
||||
@@ -837,7 +837,7 @@ public class DialogTests
|
||||
// Default (Center)
|
||||
button1 = new Button { Text = btn1Text };
|
||||
button2 = new Button { Text = btn2Text };
|
||||
(runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, button1, button2);
|
||||
(runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Center, button1, button2);
|
||||
button1.Visible = false;
|
||||
RunIteration (ref runstate, ref firstIteration);
|
||||
buttonRow = $@"{CM.Glyphs.VLine} {btn2} {CM.Glyphs.VLine}";
|
||||
@@ -849,7 +849,7 @@ public class DialogTests
|
||||
Assert.Equal (width, buttonRow.Length);
|
||||
button1 = new Button { Text = btn1Text };
|
||||
button2 = new Button { Text = btn2Text };
|
||||
(runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, button1, button2);
|
||||
(runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Justify, button1, button2);
|
||||
button1.Visible = false;
|
||||
RunIteration (ref runstate, ref firstIteration);
|
||||
buttonRow = $@"{CM.Glyphs.VLine} {btn2}{CM.Glyphs.VLine}";
|
||||
@@ -861,7 +861,7 @@ public class DialogTests
|
||||
Assert.Equal (width, buttonRow.Length);
|
||||
button1 = new Button { Text = btn1Text };
|
||||
button2 = new Button { Text = btn2Text };
|
||||
(runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, button1, button2);
|
||||
(runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Right, button1, button2);
|
||||
button1.Visible = false;
|
||||
RunIteration (ref runstate, ref firstIteration);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
|
||||
@@ -872,7 +872,7 @@ public class DialogTests
|
||||
Assert.Equal (width, buttonRow.Length);
|
||||
button1 = new Button { Text = btn1Text };
|
||||
button2 = new Button { Text = btn2Text };
|
||||
(runstate, dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, button1, button2);
|
||||
(runstate, dlg) = RunButtonTestDialog (title, width, ViewAlignments.Left, button1, button2);
|
||||
button1.Visible = false;
|
||||
RunIteration (ref runstate, ref firstIteration);
|
||||
buttonRow = $@"{CM.Glyphs.VLine} {btn2} {CM.Glyphs.VLine}";
|
||||
@@ -1301,7 +1301,7 @@ public class DialogTests
|
||||
(runstate, Dialog _) = RunButtonTestDialog (
|
||||
title,
|
||||
width,
|
||||
Dialog.ButtonAlignments.Center,
|
||||
ViewAlignments.Center,
|
||||
new Button { Text = btnText }
|
||||
);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
|
||||
@@ -1347,7 +1347,7 @@ public class DialogTests
|
||||
int width = buttonRow.Length;
|
||||
d.SetBufferSize (buttonRow.Length, 3);
|
||||
|
||||
(runstate, Dialog _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, null);
|
||||
(runstate, Dialog _) = RunButtonTestDialog (title, width, ViewAlignments.Center, null);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
|
||||
|
||||
End (runstate);
|
||||
@@ -1356,7 +1356,7 @@ public class DialogTests
|
||||
private (RunState, Dialog) RunButtonTestDialog (
|
||||
string title,
|
||||
int width,
|
||||
Dialog.ButtonAlignments align,
|
||||
ViewAlignments align,
|
||||
params Button [] btns
|
||||
)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user