示例#1
0
        /// <summary>
        /// Processes the style properties.
        /// </summary>
        /// <param name="styleStr">The style.</param>
        private HtslCellStyle ProcessStyleProperties(string styleStr)
        {
            string[]      cssProperties = styleStr.Split(';');
            HtslCellStyle slStyle       = new HtslCellStyle();

            foreach (var prop in cssProperties)
            {
                var stylePair = prop.Split(':');

                switch (stylePair[0].Trim())
                {
                case "width":
                    slStyle.Width = Convert.ToDouble(Regex.Replace(stylePair[1], HtslConstants.NumberOnlyRegex, ""));
                    break;

                case "height":
                    slStyle.Height = Convert.ToDouble(Regex.Replace(stylePair[1], HtslConstants.NumberOnlyRegex, ""));
                    break;

                case "border":
                    this.SetSLBorder(stylePair[1], slStyle);
                    break;

                default:
                    break;
                }
            }

            return(slStyle);
        }
示例#2
0
        /// <summary>
        /// Sets the Cell border.
        /// </summary>
        /// <param name="borderStr">The border string.</param>
        /// <param name="slStyle">The Cell style.</param>
        private void SetSLBorder(string borderStr, HtslCellStyle slStyle)
        {
            var borderSplit = borderStr.Split(' ');

            if (borderSplit.Length == 3)
            {
                slStyle.Border.SetHorizontalBorder(BorderStyleValues.Thin, (System.Drawing.Color)System.Drawing.ColorTranslator.FromHtml(borderSplit[2]));
                slStyle.Border.SetVerticalBorder(BorderStyleValues.Thin, (System.Drawing.Color)System.Drawing.ColorTranslator.FromHtml(borderSplit[2]));
            }
        }
        /// <summary>
        /// Processes the style properties.
        /// </summary>
        /// <param name="styleStr">The style string.</param>
        /// <returns></returns>
        private HtslCellStyle ProcessStyleProperties(string styleStr)
        {
            HtslCellStyle cellStyle = new HtslCellStyle();

            this.GenerateRawStyleLookup(styleStr);

            //Process the styles with styleAffixer.
            this.StyleAffixer
            .BindStyle(new BackgroundColorStyleProcessor(cellStyle), this.GetStyleValueForProperty(HtslConstants.CssBackgroundColor))
            .BindStyle(new BorderStyleProcessor(cellStyle), this.GetStyleValueForProperty(HtslConstants.CssBorder));

            return(cellStyle);
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StyleProcessor"/> class.
 /// </summary>
 public StyleProcessor(HtslCellStyle cellStyle)
 {
     this.CellStyle = cellStyle;
 }