internal static IExcelColor ReadColor(XElement node, ExcelDrawingColorSettings drawingColorSettings) { if (node.Name.LocalName == "schemeClr") { string str = node.GetAttributeValueOrDefaultOfStringType("val", null).ToUpperInvariant(); foreach (XElement element in node.Elements()) { if (element.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "hue") { drawingColorSettings.Hue = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "hueOff") { drawingColorSettings.HueOff = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "hueMod") { drawingColorSettings.HueMod = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "sat") { drawingColorSettings.Sat = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "satOff") { drawingColorSettings.SatOff = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "satMod") { drawingColorSettings.SatMod = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "lum") { drawingColorSettings.Lum = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "lumOff") { drawingColorSettings.LumOff = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "lumMod") { drawingColorSettings.LumMod = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } if (!string.IsNullOrWhiteSpace(str)) { return(new ExcelColor(ExcelColorType.Theme, (uint)str.ToColorSchmeIndex(), 0.0)); } } else { if (node.Name.LocalName == "hslClr") { int num = node.GetAttributeValueOrDefaultOfInt32Type("hue", 0); int num2 = node.GetAttributeValueOrDefaultOfInt32Type("sat", 0); int num3 = node.GetAttributeValueOrDefaultOfInt32Type("lum", 0); foreach (XElement element2 in node.Elements()) { if (element2.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element2.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element2.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element2.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element2.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element2.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } return(new ExcelColor(ExcelColorType.RGB, ColorExtension.ConvertHLSToRGB((double)num, (double)num3, (double)num2).ToArgb(), 0.0)); } if (node.Name.LocalName == "prstClr") { string str2 = node.GetAttributeValueOrDefaultOfStringType("val", null); foreach (XElement element3 in node.Elements()) { if (element3.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element3.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element3.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element3.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element3.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element3.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } if (!string.IsNullOrWhiteSpace(str2)) { return(new ExcelColor(ExcelColorType.RGB, ColorExtension.FromPresetColorVal(str2).ToArgb(), 0.0)); } } else { if (node.Name.LocalName == "scrgbClr") { float val = node.GetAttributeValueOrDefaultOfFloatType("r", 0f); float num5 = node.GetAttributeValueOrDefaultOfFloatType("g", 0f); float num6 = node.GetAttributeValueOrDefaultOfFloatType("b", 0f); foreach (XElement element4 in node.Elements()) { if (element4.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element4.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element4.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element4.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element4.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element4.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } return(new ExcelColor(ExcelColorType.RGB, GcColor.FromArgb(0xff, ColorExtension.ScRgbTosRgb(val), ColorExtension.ScRgbTosRgb(num5), ColorExtension.ScRgbTosRgb(num6)).ToArgb(), 0.0)); } if (node.Name.LocalName == "srgbClr") { string str3 = node.GetAttributeValueOrDefaultOfStringType("val", null); foreach (XElement element5 in node.Elements()) { if (element5.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element5.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element5.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element5.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element5.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element5.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } if (!string.IsNullOrEmpty(str3)) { uint num7 = 0; if (uint.TryParse(str3, (NumberStyles)NumberStyles.HexNumber, (IFormatProvider)CultureInfo.InvariantCulture, out num7)) { return(new ExcelColor(ExcelColorType.RGB, num7, 0.0)); } } } else if (node.Name.LocalName == "sysClr") { GcColor color = new GcColor(); bool flag = ExcelSystemColor.TryGetSystemColor(node.GetAttributeValueOrDefaultOfStringType("val", null), out color); foreach (XElement element6 in node.Elements()) { if (element6.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element6.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element6.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element6.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element6.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element6.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element6.Name.LocalName == "lumMode") { drawingColorSettings.LumMod = new double?((double)element6.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } if (flag) { return(new ExcelColor(ExcelColorType.RGB, color.ToArgb(), 0.0)); } } } } return(null); }