WholePercentages

This commit is contained in:
2023-06-21 07:24:32 -07:00
parent 8863fd763f
commit 1d0506d74c
22 changed files with 254 additions and 255 deletions

@ -8,61 +8,61 @@ internal abstract class Mapping
string[] segments = fileName.Split('.');
string? id;
string? extensionLowered;
string? wholePercentages;
bool? needsFacesFileNameExtension;
string? normalizedRectangle;
if (segments.Length < 4 || $".{segments[3]}" != facesFileNameExtension)
{
id = null;
extensionLowered = null;
normalizedRectangle = null;
wholePercentages = null;
needsFacesFileNameExtension = null;
}
else
{
id = segments[0];
extensionLowered = $".{segments[2]}";
normalizedRectangle = segments[1];
wholePercentages = segments[1];
needsFacesFileNameExtension = segments.Length == 3;
}
return new(id, normalizedRectangle, extensionLowered, needsFacesFileNameExtension);
return new(id, wholePercentages, extensionLowered, needsFacesFileNameExtension);
}
private static (int?, int?) GetConvertedFromSegments(string facesFileNameExtension, string fileName)
{
int? id;
int? normalizedRectangle;
(string? Id, string? NormalizedRectangle, string? ExtensionLowered, bool? Check) segments = GetSegments(facesFileNameExtension, fileName);
if (string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.NormalizedRectangle) || string.IsNullOrEmpty(segments.ExtensionLowered) || segments.Check is null)
int? wholePercentages;
(string? Id, string? WholePercentages, string? ExtensionLowered, bool? Check) segments = GetSegments(facesFileNameExtension, fileName);
if (string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.WholePercentages) || string.IsNullOrEmpty(segments.ExtensionLowered) || segments.Check is null)
{
id = null;
normalizedRectangle = null;
wholePercentages = null;
}
else if (!int.TryParse(segments.Id, out int idValue) || !int.TryParse(segments.NormalizedRectangle, out int normalizedRectangleValue))
else if (!int.TryParse(segments.Id, out int idValue) || !int.TryParse(segments.WholePercentages, out int wholePercentagesValue))
{
id = null;
normalizedRectangle = null;
wholePercentages = null;
}
else
{
id = idValue;
normalizedRectangle = normalizedRectangleValue;
wholePercentages = wholePercentagesValue;
}
return new(id, normalizedRectangle);
return new(id, wholePercentages);
}
internal static (int?, int?) GetConverted(string facesFileNameExtension, string file)
{
int? id;
int? normalizedRectangle;
int? wholePercentages;
string fileName = Path.GetFileName(file);
if (fileName.Length >= 2 && !fileName[1..].Contains('-'))
(id, normalizedRectangle) = GetConvertedFromSegments(facesFileNameExtension, fileName);
(id, wholePercentages) = GetConvertedFromSegments(facesFileNameExtension, fileName);
else
{
id = null;
normalizedRectangle = null;
wholePercentages = null;
}
return new(id, normalizedRectangle);
return new(id, wholePercentages);
}
internal static int GetAreaPermyriad(int faceAreaPermyriad, int bottom, int height, int left, int right, int top, int width)