public static void ApplyUnityTextOutline(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            CompileTextOutline(reader, out Color unityTextOutlineColor, out float unityTextOutlineWidth);

            computedStyle.inheritedData.unityTextOutlineColor = unityTextOutlineColor;
            computedStyle.inheritedData.unityTextOutlineWidth = unityTextOutlineWidth;
        }
예제 #2
0
        private bool ApplyGlobalKeyword(StylePropertyReader reader, ComputedStyle parentStyle)
        {
            var handle = reader.GetValue(0).handle;

            if (handle.valueType == StyleValueType.Keyword)
            {
                if ((StyleValueKeyword)handle.valueIndex == StyleValueKeyword.Initial)
                {
                    ApplyInitialValue(reader);
                    return(true);
                }
                if ((StyleValueKeyword)handle.valueIndex == StyleValueKeyword.Unset)
                {
                    if (parentStyle == null)
                    {
                        ApplyInitialValue(reader);
                    }
                    else
                    {
                        ApplyUnsetValue(reader, parentStyle);
                    }
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public static BuilderScale GetScale(this StyleSheet styleSheet, StyleProperty styleProperty)
        {
            int valCount = styleProperty.values.Length;

            if (valCount > 0)
            {
                var val1 = new StylePropertyValue()
                {
                    handle = styleProperty.values[0], sheet = styleSheet
                };
                var val2 = valCount > 1 ? new StylePropertyValue()
                {
                    handle = styleProperty.values[1], sheet = styleSheet
                } : default;
                var zval = valCount > 2 ? new StylePropertyValue()
                {
                    handle = styleProperty.values[2], sheet = styleSheet
                } : default;

                return(new BuilderScale(StylePropertyReader.ReadScale(valCount, val1, val2, zval)));
            }
            else
            {
                return(new BuilderScale
                {
                    value = Vector3.one
                });
            }
        }
예제 #4
0
        public static BuilderRotate GetRotate(this StyleSheet styleSheet, StyleProperty styleProperty)
        {
            int valCount = styleProperty.values.Length;

            if (valCount > 0)
            {
                var val1 = new StylePropertyValue()
                {
                    handle = styleProperty.values[0], sheet = styleSheet
                };
                var val2 = valCount > 1 ? new StylePropertyValue()
                {
                    handle = styleProperty.values[1], sheet = styleSheet
                } : default;
                var val3 = valCount > 2 ? new StylePropertyValue()
                {
                    handle = styleProperty.values[2], sheet = styleSheet
                } : default;
                var val4 = valCount > 3 ? new StylePropertyValue()
                {
                    handle = styleProperty.values[3], sheet = styleSheet
                } : default;

                return(new BuilderRotate(StylePropertyReader.ReadRotate(valCount, val1, val2, val3, val4)));
            }
            else
            {
                return(new BuilderRotate
                {
                    x = new Dimension(0f, Dimension.Unit.Degree)
                });
            }
        }
예제 #5
0
        public static BuilderTranslate GetTranslate(this StyleSheet styleSheet, StyleProperty styleProperty)
        {
            int valCount = styleProperty.values.Length;

            if (valCount > 0)
            {
                var xval = new StylePropertyValue()
                {
                    handle = styleProperty.values[0], sheet = styleSheet
                };
                var yval = valCount > 1 ? new StylePropertyValue()
                {
                    handle = styleProperty.values[1], sheet = styleSheet
                } : default;
                var zval = valCount > 2 ? new StylePropertyValue()
                {
                    handle = styleProperty.values[2], sheet = styleSheet
                } : default;

                return(new BuilderTranslate(StylePropertyReader.ReadTranslate(valCount, xval, yval, zval)));
            }
            else
            {
                return(new BuilderTranslate
                {
                    x = new Dimension(0f, Dimension.Unit.Percent),
                    y = new Dimension(0f, Dimension.Unit.Percent)
                });
            }
        }
예제 #6
0
        public static BuilderTransformOrigin GetTransformOrigin(this StyleSheet styleSheet, StyleProperty styleProperty)
        {
            int valCount = styleProperty.values.Length;

            if (valCount > 0)
            {
                var val1 = new StylePropertyValue()
                {
                    handle = styleProperty.values[0], sheet = styleSheet
                };
                var val2 = valCount > 1 ? new StylePropertyValue()
                {
                    handle = styleProperty.values[1], sheet = styleSheet
                } : new StylePropertyValue();
                var zval = valCount > 2 ? new StylePropertyValue()
                {
                    handle = styleProperty.values[2], sheet = styleSheet
                } : new StylePropertyValue();

                return(new BuilderTransformOrigin(StylePropertyReader.ReadTransformOrigin(valCount, val1, val2, zval)));
            }
            else
            {
                return(new BuilderTransformOrigin
                {
                    x = new Dimension(0f, Dimension.Unit.Percent),
                    y = new Dimension(0f, Dimension.Unit.Percent)
                });
            }
        }
        public static void ApplyFlex(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            CompileFlexShorthand(reader, out float flexGrow, out float flexShrink, out Length flexBasis);

            computedStyle.nonInheritedData.flexGrow   = flexGrow;
            computedStyle.nonInheritedData.flexShrink = flexShrink;
            computedStyle.nonInheritedData.flexBasis  = flexBasis;
        }
        public static void ApplyMargin(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            CompileBoxArea(reader, out Length marginTop, out Length marginRight, out Length marginBottom, out Length marginLeft);

            computedStyle.nonInheritedData.marginTop    = marginTop;
            computedStyle.nonInheritedData.marginRight  = marginRight;
            computedStyle.nonInheritedData.marginBottom = marginBottom;
            computedStyle.nonInheritedData.marginLeft   = marginLeft;
        }
        public static void ApplyBorderRadius(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            CompileBorderRadius(reader, out Length borderTopLeftRadius, out Length borderTopRightRadius, out Length borderBottomRightRadius, out Length borderBottomLeftRadius);

            computedStyle.nonInheritedData.borderTopLeftRadius     = borderTopLeftRadius;
            computedStyle.nonInheritedData.borderTopRightRadius    = borderTopRightRadius;
            computedStyle.nonInheritedData.borderBottomRightRadius = borderBottomRightRadius;
            computedStyle.nonInheritedData.borderBottomLeftRadius  = borderBottomLeftRadius;
        }
        public static void ApplyBorderWidth(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            CompileBoxArea(reader, out float borderTopWidth, out float borderRightWidth, out float borderBottomWidth, out float borderLeftWidth);

            computedStyle.nonInheritedData.borderTopWidth    = borderTopWidth;
            computedStyle.nonInheritedData.borderRightWidth  = borderRightWidth;
            computedStyle.nonInheritedData.borderBottomWidth = borderBottomWidth;
            computedStyle.nonInheritedData.borderLeftWidth   = borderLeftWidth;
        }
        public static void ApplyPadding(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            CompileBoxArea(reader, out Length paddingTop, out Length paddingRight, out Length paddingBottom, out Length paddingLeft);

            computedStyle.nonInheritedData.paddingTop    = paddingTop;
            computedStyle.nonInheritedData.paddingRight  = paddingRight;
            computedStyle.nonInheritedData.paddingBottom = paddingBottom;
            computedStyle.nonInheritedData.paddingLeft   = paddingLeft;
        }
        public static void ApplyBorderColor(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            CompileBoxArea(reader, out Color borderTopColor, out Color borderRightColor, out Color borderBottomColor, out Color borderLeftColor);

            computedStyle.nonInheritedData.borderTopColor    = borderTopColor;
            computedStyle.nonInheritedData.borderRightColor  = borderRightColor;
            computedStyle.nonInheritedData.borderBottomColor = borderBottomColor;
            computedStyle.nonInheritedData.borderLeftColor   = borderLeftColor;
        }
예제 #13
0
        private void RemoveCustomStyleProperty(StylePropertyReader reader)
        {
            var name = reader.property.name;

            if (customProperties == null || !customProperties.ContainsKey(name))
            {
                return;
            }

            customProperties.Remove(name);
        }
예제 #14
0
        public void ProcessStylePropertyTestAlignVert()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "VerticalAlignment", "C1.Win.C1TrueDBGrid.AlignVertEnum.Bottom");
            string expectedResult = "Bottom";
            //Act
            string actualResult = style.Properties["AlignVert"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #15
0
        public void ProcessStylePropertyTestWrapText()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "Wrap", "C1.Win.C1TrueDBGrid.TextWrapping.Wrap");
            string expectedResult = "Wrap";
            //Act
            string actualResult = style.Properties["WrapText"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #16
0
        public void ProcessStylePropertyTestPaddingObject()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "Padding", "new System.Drawing.Printing.Margins(3, 2, 3, 7)");
            string expectedResult = "7";
            //Act
            string actualResult = style.Padding.Properties["Bottom"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #17
0
        public void ProcessStylePropertyTestBorders()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "Borders.BorderType", "C1.Win.C1TrueDBGrid.BorderTypeEnum.Groove");
            string expectedResult = "Groove";
            //Act
            string actualResult = style.Borders.Properties["BorderType"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #18
0
        public void ProcessStylePropertyTestAlignHorz()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "HorizontalAlignment", "C1.Win.C1TrueDBGrid.AlignHorzEnum.Far");
            string expectedResult = "Far";
            //Act
            string actualResult = style.Properties["AlignHorz"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #19
0
        public void ProcessStylePropertyTestForegroundImagePos()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "ForegroundPicturePosition", "C1.Win.C1TrueDBGrid.ForeGroundPicturePositionEnum.LeftOfText");
            string expectedResult = "LeftOfText";
            //Act
            string actualResult = style.Properties["ForegroundImagePos"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #20
0
        public void ProcessStylePropertyTestFont()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "Font", "new System.Drawing.Font(\"Arial\", 8.75f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 177)");
            string expectedResult = "Arial, 8.75pt";
            //Act
            string actualResult = style.Properties["Font"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #21
0
        public void ProcessStylePropertyTestBackGroundPictureDrawMode()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "BackGroundPictureDrawMode", "C1.Win.C1TrueDBGrid.BackgroundPictureDrawModeEnum.Center");
            string expectedResult = "Center";
            //Act
            string actualResult = style.Properties["AlignImage"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #22
0
        public void ProcessStylePropertyTestLocked()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "Locked", "true");
            string expectedResult = "True";
            //Act
            string actualResult = style.Properties["Locked"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #23
0
        public void ApplyUnsetValue(StylePropertyReader reader, ComputedStyle parentStyle)
        {
            switch (reader.propertyId)
            {
            case StylePropertyId.Custom:
                RemoveCustomStyleProperty(reader);
                break;

            default:
                ApplyUnsetValue(reader.propertyId, parentStyle);
                break;
            }
        }
예제 #24
0
        public void ProcessStylePropertyTestForeColor()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "BackColor", "System.Drawing.Color.FromArgb(255, 0, 128)");
            string expectedResult = "255, 0, 128";
            //Act
            string actualResult = style.Properties["BackColor"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #25
0
        public void ProcessStylePropertyTestPaddingProperty()
        {
            //Arrange
            Style style = new Style("Style");

            StylePropertyReader.ProcessStyleProperty(style, "Padding.Right", "6");
            string expectedResult = "6";
            //Act
            string actualResult = style.Padding.Properties["Right"];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #26
0
        public void ApplyInitialValue(StylePropertyReader reader)
        {
            switch (reader.propertyId)
            {
            case StylePropertyId.Custom:
                RemoveCustomStyleProperty(reader);
                break;

            default:
                ApplyInitialValue(reader.propertyId);
                break;
            }
        }
예제 #27
0
        private void ApplyCustomStyleProperty(StylePropertyReader reader)
        {
            dpiScaling = reader.dpiScaling;
            if (customProperties == null)
            {
                customProperties = new Dictionary <string, StylePropertyValue>();
            }

            var styleProperty = reader.property;

            // Custom property only support one value
            StylePropertyValue customProp = reader.GetValue(0);

            customProperties[styleProperty.name] = customProp;
        }
예제 #28
0
        public bool TryGetValue(CustomStyleProperty <VectorImage> property, out VectorImage value)
        {
            if (m_CustomProperties != null && m_CustomProperties.TryGetValue(property.name, out var customProp))
            {
                var source = new ImageSource();
                if (StylePropertyReader.TryGetImageSourceFromValue(customProp, dpiScaling, out source) && source.vectorImage != null)
                {
                    value = source.vectorImage;
                    return(true);
                }
            }

            value = null;
            return(false);
        }
예제 #29
0
        public bool TryGetValue(CustomStyleProperty <Texture2D> property, out Texture2D value)
        {
            StylePropertyValue customProp;

            if (m_CustomProperties != null && m_CustomProperties.TryGetValue(property.name, out customProp))
            {
                var source = new ImageSource();
                if (StylePropertyReader.TryGetImageSourceFromValue(customProp, dpiScaling, out source) && source.texture != null)
                {
                    value = source.texture;
                    return(true);
                }
            }

            value = null;
            return(false);
        }
예제 #30
0
        private void ApplyCustomStyleProperty(StylePropertyReader reader)
        {
            if (m_CustomProperties == null)
            {
                m_CustomProperties = new Dictionary <string, StylePropertyValue>();
            }

            var styleProperty = reader.property;

            StylePropertyValue customProp = default(StylePropertyValue);

            if (!m_CustomProperties.TryGetValue(styleProperty.name, out customProp))
            {
                // Custom property only support one value
                customProp = reader.GetValue(0);
            }
            m_CustomProperties[styleProperty.name] = customProp;
        }