mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
This commit is contained in:
@@ -252,7 +252,7 @@ internal class NumericUpDownEditor<T> : View where T : notnull
|
||||
{
|
||||
X = Pos.Center (),
|
||||
Y = Pos.Bottom (_increment) + 1,
|
||||
Increment = (dynamic)1,
|
||||
Increment = NumericUpDown<int>.TryConvert (1, out T? increment) ? increment : default,
|
||||
};
|
||||
|
||||
_numericUpDown.ValueChanged += NumericUpDownOnValueChanged;
|
||||
|
||||
@@ -410,7 +410,7 @@ public class TextAlignmentAndDirection : Scenario
|
||||
// Save Alignment in Data
|
||||
foreach (View t in multiLineLabels)
|
||||
{
|
||||
t.Data = new { h = t.TextAlignment, v = t.VerticalTextAlignment };
|
||||
t.Data = new TextAlignmentData (t.TextAlignment, t.VerticalTextAlignment);
|
||||
}
|
||||
|
||||
container.Add (txtLabelTL);
|
||||
@@ -594,8 +594,9 @@ public class TextAlignmentAndDirection : Scenario
|
||||
|
||||
foreach (View t in multiLineLabels)
|
||||
{
|
||||
t.TextAlignment = (Alignment)((dynamic)t.Data).h;
|
||||
t.VerticalTextAlignment = (Alignment)((dynamic)t.Data).v;
|
||||
var data = (TextAlignmentData)t.Data;
|
||||
t.TextAlignment = data!.h;
|
||||
t.VerticalTextAlignment = data.v;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -607,24 +608,23 @@ public class TextAlignmentAndDirection : Scenario
|
||||
justifyOptions.Enabled = true;
|
||||
}
|
||||
|
||||
var data = (TextAlignmentData)t.Data;
|
||||
|
||||
if (TextFormatter.IsVerticalDirection (t.TextDirection))
|
||||
{
|
||||
switch (justifyOptions.SelectedItem)
|
||||
{
|
||||
case 0:
|
||||
t.VerticalTextAlignment = Alignment.Fill;
|
||||
t.TextAlignment = ((dynamic)t.Data).h;
|
||||
|
||||
t.TextAlignment = data!.h;
|
||||
break;
|
||||
case 1:
|
||||
t.VerticalTextAlignment = (Alignment)((dynamic)t.Data).v;
|
||||
t.VerticalTextAlignment = data!.v;
|
||||
t.TextAlignment = Alignment.Fill;
|
||||
|
||||
break;
|
||||
case 2:
|
||||
t.VerticalTextAlignment = Alignment.Fill;
|
||||
t.TextAlignment = Alignment.Fill;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -634,18 +634,15 @@ public class TextAlignmentAndDirection : Scenario
|
||||
{
|
||||
case 0:
|
||||
t.TextAlignment = Alignment.Fill;
|
||||
t.VerticalTextAlignment = ((dynamic)t.Data).v;
|
||||
|
||||
t.VerticalTextAlignment = data!.v;
|
||||
break;
|
||||
case 1:
|
||||
t.TextAlignment = (Alignment)((dynamic)t.Data).h;
|
||||
t.TextAlignment = data!.h;
|
||||
t.VerticalTextAlignment = Alignment.Fill;
|
||||
|
||||
break;
|
||||
case 2:
|
||||
t.TextAlignment = Alignment.Fill;
|
||||
t.VerticalTextAlignment = Alignment.Fill;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -653,4 +650,10 @@ public class TextAlignmentAndDirection : Scenario
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class TextAlignmentData (Alignment h, Alignment v)
|
||||
{
|
||||
public Alignment h { get; } = h;
|
||||
public Alignment v { get; } = v;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user