namespace View_by_Distance.Shared.Models.Stateless.Methods; internal abstract class Location { internal static int GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount) { int result; double value; double total = width * height; Check(bottom, left, right, top, zCount); double xCenter = left + ((right - left) / 2); double yCenter = top + ((bottom - top) / 2); double at = ((yCenter - 1) * width) + xCenter; value = at / total; if (value < 0) value = 3; result = (int)(Math.Round(value, locationDigits) * locationFactor); string rightPadded = ILocation.GetRightPadded(locationDigits, result); if (result.ToString() != rightPadded) result = int.Parse(rightPadded); return result; } internal static void Check(int bottom, int left, int right, int top, int zCount) { if (left < 0) throw new Exception(); if (right < 0) throw new Exception(); if (right < left) throw new Exception(); if (top < 0) throw new Exception(); if (bottom < 0) throw new Exception(); if (bottom < top) throw new Exception(); if (zCount < 0) throw new Exception(); } internal static void Check(int bottom, int height, int left, int right, int top, int width, int zCount) { if (bottom > height) throw new Exception(); if (left > width) throw new Exception(); if (right > width) throw new Exception(); if (top > height) throw new Exception(); if (zCount < 0) throw new Exception(); } internal static void Check(int bottom, int left, int? normalizedPixelPercentage, int right, int top, int zCount) { Check(bottom, left, right, top, zCount); if (normalizedPixelPercentage.HasValue && normalizedPixelPercentage.Value < 0) throw new Exception(); } internal static void Check(int bottom, int height, int left, int? normalizedPixelPercentage, int right, int top, int width, int zCount) { Check(bottom, left, right, top, zCount); Check(bottom, height, left, right, top, width, zCount); if (normalizedPixelPercentage.HasValue && normalizedPixelPercentage.Value < 0) throw new Exception(); } }