add NumericUIntUpDown

This commit is contained in:
heartacker
2024-03-20 15:48:33 +08:00
parent 795abc9929
commit 21e6a2e996

View File

@@ -18,7 +18,10 @@ public class NumericIntUpDown : NumericUpDownBase<int>
protected override bool ParseText(string? text, out int number) => protected override bool ParseText(string? text, out int number) =>
int.TryParse(text, ParsingNumberStyle, NumberFormat, out number); int.TryParse(text, ParsingNumberStyle, NumberFormat, out number);
protected override string? ValueToString(int? value) => value?.ToString(FormatString, NumberFormat); protected override string? ValueToString(int? value)
{
return value?.ToString(FormatString, NumberFormat);
}
protected override int Zero => 0; protected override int Zero => 0;
@@ -27,6 +30,34 @@ public class NumericIntUpDown : NumericUpDownBase<int>
protected override int? Minus(int? a, int? b) => a - b; protected override int? Minus(int? a, int? b) => a - b;
} }
public class NumericUIntUpDown : NumericUpDownBase<uint>
{
protected override Type StyleKeyOverride { get; } = typeof(NumericUpDown);
static NumericUIntUpDown()
{
MaximumProperty.OverrideDefaultValue<NumericUIntUpDown>(uint.MaxValue);
MinimumProperty.OverrideDefaultValue<NumericUIntUpDown>(uint.MinValue);
StepProperty.OverrideDefaultValue<NumericUIntUpDown>(0);
}
protected override bool ParseText(string? text, out uint number)
{
return uint.TryParse(text, ParsingNumberStyle, NumberFormat, out number);
}
protected override string? ValueToString(uint? value)
{
return value?.ToString(FormatString, NumberFormat);
}
protected override uint Zero => 0;
protected override uint? Add(uint? a, uint? b) => a + b;
protected override uint? Minus(uint? a, uint? b) => a - b;
}
public class NumericDoubleUpDown : NumericUpDownBase<double> public class NumericDoubleUpDown : NumericUpDownBase<double>
{ {
protected override Type StyleKeyOverride { get; } = typeof(NumericUpDown); protected override Type StyleKeyOverride { get; } = typeof(NumericUpDown);
@@ -233,4 +264,3 @@ public class NumericDecimalUpDown : NumericUpDownBase<decimal>
protected override decimal? Minus(decimal? a, decimal? b) => a - b; protected override decimal? Minus(decimal? a, decimal? b) => a - b;
} }