internal ExcelDxfStyleConditionalFormatting(XmlNamespaceManager nameSpaceManager, XmlNode topNode, ExcelStyles styles) : base(styles) { NumberFormat = new ExcelDxfNumberFormat(_styles); Font = new ExcelDxfFontBase(_styles); Border = new ExcelDxfBorderBase(_styles); Fill = new ExcelDxfFill(_styles); if (topNode != null) { _helper = new XmlHelperInstance(nameSpaceManager, topNode); NumberFormat.NumFmtID = _helper.GetXmlNodeInt("d:numFmt/@numFmtId"); NumberFormat.Format = _helper.GetXmlNodeString("d:numFmt/@formatCode"); if (NumberFormat.NumFmtID < 164 && string.IsNullOrEmpty(NumberFormat.Format)) { NumberFormat.Format = ExcelNumberFormat.GetFromBuildInFromID(NumberFormat.NumFmtID); } Font.Bold = _helper.GetXmlNodeBoolNullable("d:font/d:b/@val"); Font.Italic = _helper.GetXmlNodeBoolNullable("d:font/d:i/@val"); Font.Strike = _helper.GetXmlNodeBoolNullable("d:font/d:strike"); Font.Underline = GetUnderLineEnum(_helper.GetXmlNodeString("d:font/d:u/@val")); Font.Color = GetColor(_helper, "d:font/d:color"); Border.Left = GetBorderItem(_helper, "d:border/d:left"); Border.Right = GetBorderItem(_helper, "d:border/d:right"); Border.Bottom = GetBorderItem(_helper, "d:border/d:bottom"); Border.Top = GetBorderItem(_helper, "d:border/d:top"); Fill.PatternType = GetPatternTypeEnum(_helper.GetXmlNodeString("d:fill/d:patternFill/@patternType")); Fill.BackgroundColor = GetColor(_helper, "d:fill/d:patternFill/d:bgColor/"); Fill.PatternColor = GetColor(_helper, "d:fill/d:patternFill/d:fgColor/"); } else { _helper = new XmlHelperInstance(nameSpaceManager); } _helper.SchemaNodeOrder = new string[] { "font", "numFmt", "fill", "border" }; }
private ExcelDxfColor GetColor(XmlHelperInstance helper, string path) { ExcelDxfColor ret = new ExcelDxfColor(_styles); ret.Theme = (eThemeSchemeColor?)helper.GetXmlNodeIntNull(path + "/@theme"); ret.Index = helper.GetXmlNodeIntNull(path + "/@indexed"); string rgb = helper.GetXmlNodeString(path + "/@rgb"); if (rgb != "") { ret.Color = Color.FromArgb(int.Parse(rgb.Replace("#", ""), NumberStyles.HexNumber)); } ret.Auto = helper.GetXmlNodeBoolNullable(path + "/@auto"); ret.Tint = helper.GetXmlNodeDoubleNull(path + "/@tint"); return(ret); }
private ExcelDxfColor GetColor(XmlHelperInstance helper, string path) { ExcelDxfColor ret = new ExcelDxfColor(_styles); ret.Theme = helper.GetXmlNodeIntNull(path + "/@theme"); ret.Index = helper.GetXmlNodeIntNull(path + "/@index"); string rgb = helper.GetXmlNodeString(path + "/@rgb"); if (rgb != "") { ret.Color = Color.FromArgb(int.Parse(rgb.Substring(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier), int.Parse(rgb.Substring(2, 2), System.Globalization.NumberStyles.AllowHexSpecifier), int.Parse(rgb.Substring(4, 2), System.Globalization.NumberStyles.AllowHexSpecifier), int.Parse(rgb.Substring(6, 2), System.Globalization.NumberStyles.AllowHexSpecifier)); } ret.Auto = helper.GetXmlNodeBoolNullable(path + "/@auto"); ret.Tint = helper.GetXmlNodeDoubleNull(path + "/@tint"); return(ret); }