示例#1
0
        public void ParseStyleString(string styleLine)
        {
            GroupCollection groups    = RegularExpressions.StyleSheet.Matches(styleLine)[0].Groups;
            string          styleName = groups[1].Value;

            string[] properties = groups[3].Value.Split(';');
            foreach (string property in properties.Where(x => x != ""))
            {
                string[] propertyParts = property.Split(':');
                string   propertyName  = propertyParts[0];
                string   propertyValue = propertyParts[1];
                if (propertyName == "Border")
                {
                    this.Borders = GridBorders.ParseValueString(propertyValue);
                }
                else if (propertyName == "Padding")
                {
                    this.Padding = Margins.ParseStyleMarginsValue(propertyValue);
                }
                else if (propertyName != "BackgroundImage" && propertyName != "BackgroundImage")
                {
                    this.Properties[propertyName] = propertyValue;
                }
            }
        }
        public static GridBorders ParseValueString(string value)
        {
            GridBorders     borders = new GridBorders();
            GroupCollection groups  = RegularExpressions.BordersStringValue.Matches(value)[0].Groups;

            borders.Properties["BorderType"] = groups[1].Value.Trim();
            borders.Properties["Color"]      = groups[2].Value.Trim();
            borders.Properties["Left"]       = groups[3].Value.Trim();
            borders.Properties["Right"]      = groups[4].Value.Trim();
            borders.Properties["Top"]        = groups[5].Value.Trim();
            borders.Properties["Bottom"]     = groups[6].Value.Trim();
            return(borders);
        }
        public static void ProcessBordersProperty(GridBorders borders, string property, string value)
        {
            switch (property.ToUpper())
            {
            case nameof(BorderProperties.COLOR):
                borders.Properties[property] = Utilities.ProcessColorProperty(value);
                break;

            case nameof(BorderProperties.BORDERTYPE):
                borders.Properties[property] = Utilities.EnumValueToString(value);
                if (borders.HasDefaultColorAndSize())
                {
                    borders.UpdatePropertiesAccordingToType();
                }
                break;

            default:
                borders.Properties[property] = value;
                break;
            }
        }