public static Rectangle ToRectangle()

in src/Core/Misc/ExtensionMethods.cs [549:589]


        public static Rectangle ToRectangle(this A11yProperty property)
        {
            if (property == null) return Rectangle.Empty;

            switch (property.Value)
            {
                case double[] rectangle:
                    {
                        if (rectangle.Length != 4)
                            return Rectangle.Empty;

                        return new Rectangle(
                x: (int)rectangle[0],
                y: (int)rectangle[1],
                width: rectangle[2] > 0 ? (int)rectangle[2] : 0,
                height: rectangle[3] > 0 ? (int)rectangle[3] : 0);
                    }
                case Newtonsoft.Json.Linq.JArray jArray:
                    {
                        if (jArray.Count != 4)
                            return Rectangle.Empty;

                        foreach (var token in jArray)
                        {
                            if (token.Type != Newtonsoft.Json.Linq.JTokenType.Float)
                                return Rectangle.Empty;
                        }

                        int width = jArray[2].ToObject<int>();
                        int height = jArray[3].ToObject<int>();

                        return new Rectangle(
                            x: jArray[0].ToObject<int>(),
                            y: jArray[1].ToObject<int>(),
                            width: width > 0 ? width : 0,
                            height: height > 0 ? height : 0);
                    }
            } // switch

            return Rectangle.Empty;
        }