Пример #1
0
        private static void AddProperty(StyleSheetBuilderHelper helper, string name, string suffix, RectOffset offset, RectOffset defaultValue, string comment = "")
        {
            // Note: Same order as CSS which is NOT the same order as the RectOffset constructor

            if (helper.options.exportDefaultValues || offset.left != defaultValue.left)
            {
                helper.AddProperty(ConverterUtils.ToUssPropertyName(name, "left", suffix), offset.left, comment);
                comment = "";
            }

            if (helper.options.exportDefaultValues || offset.right != defaultValue.right)
            {
                helper.AddProperty(ConverterUtils.ToUssPropertyName(name, "right", suffix), offset.right, comment);
                comment = "";
            }

            if (helper.options.exportDefaultValues || offset.top != defaultValue.top)
            {
                helper.AddProperty(ConverterUtils.ToUssPropertyName(name, "top", suffix), offset.top, comment);
                comment = "";
            }

            if (helper.options.exportDefaultValues || offset.bottom != defaultValue.bottom)
            {
                helper.AddProperty(ConverterUtils.ToUssPropertyName(name, "bottom", suffix), offset.bottom, comment);
            }
        }
Пример #2
0
        private static void ReadRectOffset(StyleSheetCache cache, StyleRule rule, string name, string suffix, bool throwIfNotFound, RectOffset offset)
        {
            var sheet = cache.sheet;

            GetProperty(rule, ConverterUtils.ToUssPropertyName(name, "left", suffix), throwIfNotFound, property =>
            {
                offset.left = (int)sheet.ReadFloat(property.values[0]);
            });
            GetProperty(rule, ConverterUtils.ToUssPropertyName(name, "right", suffix), throwIfNotFound, property =>
            {
                offset.right = (int)sheet.ReadFloat(property.values[0]);
            });
            GetProperty(rule, ConverterUtils.ToUssPropertyName(name, "top", suffix), throwIfNotFound, property =>
            {
                offset.top = (int)sheet.ReadFloat(property.values[0]);
            });
            GetProperty(rule, ConverterUtils.ToUssPropertyName(name, "bottom", suffix), throwIfNotFound, property =>
            {
                offset.bottom = (int)sheet.ReadFloat(property.values[0]);
            });
        }