mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Refactor Dialog and MessageBox sizing logic to use the greater of percentage-based minimums or required subview size, ensuring dialogs are never too small for their content. Lower default minimum sizes for both Dialog and MessageBox. Implement IDesignable for Dialog, providing design-time sample content and buttons. Dialog appearance now switches styles based on modal/design mode. Refactor Dialogs demo for clarity, error handling, and modern C# usage. Update View content size calculations to include all subviews (including padding) for more accurate layout. General code modernization: use C# 9/10 features, improve readability, and maintainability.
81 lines
1.8 KiB
C#
81 lines
1.8 KiB
C#
#nullable enable
|
|
|
|
namespace UICatalog;
|
|
|
|
public static class NumberToWords
|
|
{
|
|
private static readonly string [] _tens =
|
|
[
|
|
"", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"
|
|
];
|
|
|
|
private static readonly string [] _units =
|
|
[
|
|
"Zero",
|
|
"One",
|
|
"Two",
|
|
"Three",
|
|
"Four",
|
|
"Five",
|
|
"Six",
|
|
"Seven",
|
|
"Eight",
|
|
"Nine",
|
|
"Ten",
|
|
"Eleven",
|
|
"Twelve",
|
|
"Thirteen",
|
|
"Fourteen",
|
|
"Fifteen",
|
|
"Sixteen",
|
|
"Seventeen",
|
|
"Eighteen",
|
|
"Nineteen"
|
|
];
|
|
|
|
public static string Convert (long i)
|
|
{
|
|
if (i < 20)
|
|
{
|
|
return _units [i];
|
|
}
|
|
|
|
if (i < 100)
|
|
{
|
|
return _tens [i / 10] + (i % 10 > 0 ? " " + Convert (i % 10) : "");
|
|
}
|
|
|
|
if (i < 1000)
|
|
{
|
|
return _units [i / 100]
|
|
+ " Hundred"
|
|
+ (i % 100 > 0 ? " And " + Convert (i % 100) : "");
|
|
}
|
|
|
|
if (i < 100000)
|
|
{
|
|
return Convert (i / 1000)
|
|
+ " Thousand "
|
|
+ (i % 1000 > 0 ? " " + Convert (i % 1000) : "");
|
|
}
|
|
|
|
if (i < 10000000)
|
|
{
|
|
return Convert (i / 100000)
|
|
+ " Lakh "
|
|
+ (i % 100000 > 0 ? " " + Convert (i % 100000) : "");
|
|
}
|
|
|
|
if (i < 1000000000)
|
|
{
|
|
return Convert (i / 10000000)
|
|
+ " Crore "
|
|
+ (i % 10000000 > 0 ? " " + Convert (i % 10000000) : "");
|
|
}
|
|
|
|
return Convert (i / 1000000000)
|
|
+ " Arab "
|
|
+ (i % 1000000000 > 0 ? " " + Convert (i % 1000000000) : "");
|
|
}
|
|
}
|