Esempio n. 1
0
        /// <summary>
        /// Gets the color of the theme.
        /// </summary>
        /// <param name="colorSchemeIndex">Index of the color scheme.</param>
        /// <returns></returns>
        public GcColor GetThemeColor(ColorSchemeIndex colorSchemeIndex)
        {
            int num = (int)colorSchemeIndex;

            if ((this.Theme == null) || (num > 11))
            {
                return(new GcColor());
            }
            while (true)
            {
                IExcelColor color = this.Theme.ColorScheme.SchemeColors[num];
                if (color.ColorType == ExcelColorType.RGB)
                {
                    return(ColorExtension.FromArgb(color.Value));
                }
                if (color.ColorType == ExcelColorType.Indexed)
                {
                    if (this.ColorPalette != null)
                    {
                        return(this.ColorPalette[(int)color.Value]);
                    }
                    return(ColorExtension.GetPaletteColor((int)color.Value));
                }
                if (color.ColorType == ExcelColorType.Theme)
                {
                    num = (int)this.Theme.ColorScheme.SchemeColors[num].Value;
                }
            }
        }
Esempio n. 2
0
 public ExcelPaletteColor GetPaletteColor(IExcelColor color)
 {
     if (color == null)
     {
         return(ExcelPaletteColor.SystemWindowTextColor);
     }
     return(this._workbook.GetPaletteColor(color));
 }
Esempio n. 3
0
 internal static int GetPaletteColorIndex(IThemeSupport themeSupport, IExcelColor excelColor, int startIndex = 0x40)
 {
     if (excelColor.IsThemeColor)
     {
         return(GetCloestColorIndex(GetRGBColor(themeSupport, new ExcelColor(ExcelColorType.Theme, excelColor.Value, 0.0)), 0x40));
     }
     return(GetCloestColorIndex(GetRGBColor(themeSupport, excelColor), startIndex));
 }
Esempio n. 4
0
 public void SetExcelSheetTabColor(int sheet, IExcelColor color)
 {
     if (color != null)
     {
         IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];
         worksheet.SheetTabColor = color;
     }
 }
Esempio n. 5
0
        public void SetGridlineColor(short sheet, IExcelColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }
            if (color.ColorType != ExcelColorType.Indexed)
            {
                throw new ArgumentException(ResourceHelper.GetResourceString("gridlineColorTypeError"));
            }
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            worksheet.GridLineColor = color;
        }
Esempio n. 6
0
        public IExcelColor GetGridlineColor(short sheet)
        {
            if (!this.ValidateWorkbook(sheet))
            {
                return(null);
            }
            IExcelColor gridLineColor = this._workbook.Worksheets[sheet].GridLineColor;

            if (gridLineColor == null)
            {
                return(null);
            }
            if (gridLineColor.ColorType == ExcelColorType.Indexed)
            {
                return(gridLineColor);
            }
            return(new ExcelColor(ExcelColorType.Indexed, (uint)this._workbook.GetPaletteColor(gridLineColor), 0.0));
        }
Esempio n. 7
0
 internal static Windows.UI.Color GetRGBColor(IThemeSupport themeSupport, IExcelColor excelColor)
 {
     if (excelColor != null)
     {
         if (excelColor.IsAutoColor)
         {
             return(SystemColors.WindowTextColor);
         }
         if (excelColor.IsIndexedColor)
         {
             return(UpdateTint(ColorFromIndex((int)excelColor.Value), (float)excelColor.Tint));
         }
         if (excelColor.IsRGBColor)
         {
             uint num = excelColor.Value | 0xff000000;
             return(UpdateTint(FromArgb(num), (float)excelColor.Tint));
         }
         if (excelColor.IsThemeColor && (themeSupport != null))
         {
             return(UpdateTint(themeSupport.GetThemeColor(excelColor.GetThemeColorName()), (float)excelColor.Tint));
         }
     }
     return(Colors.Transparent);
 }
Esempio n. 8
0
        internal static void WriteColor(XmlWriter writer, IExcelColor color, ExcelDrawingColorSettings drawingColorSettings)
        {
            if (color != null)
            {
                if (drawingColorSettings == null)
                {
                    drawingColorSettings = new ExcelDrawingColorSettings();
                }
                if (color.ColorType == ExcelColorType.RGB)
                {
                    using (writer.WriteElement("srgbClr", null, "a"))
                    {
                        writer.WriteAttributeString("val", ((uint)color.Value).ToString("X8").Substring(2));
                        uint num = 0xff;
                        uint.TryParse(((uint)color.Value).ToString("X8").Substring(0, 2), (NumberStyles)NumberStyles.HexNumber, (IFormatProvider)CultureInfo.InvariantCulture, out num);
                        double num2 = ((double)num) / 255.0;
                        if (!(num2 - 1.0).IsZero() && !num2.IsZero())
                        {
                            using (writer.WriteElement("alpha", null, "a"))
                            {
                                int num5 = (int)(num2 * 100000.0);
                                writer.WriteAttributeString("val", ((int)num5).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                                goto Label_0138;
                            }
                        }
                        if ((drawingColorSettings != null) && drawingColorSettings.Alpha.HasValue)
                        {
                            writer.WriteLeafElementWithAttribute("alpha", null, "a", "val", ((double)drawingColorSettings.Alpha.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                        }
Label_0138:
                        if (drawingColorSettings != null)
                        {
                            if (drawingColorSettings.Tint.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("tint", null, "a", "val", ((double)drawingColorSettings.Tint.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.Shade.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("shade", null, "a", "val", ((double)drawingColorSettings.Shade.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                        }
                        return;
                    }
                }
                if (color.ColorType == ExcelColorType.Theme)
                {
                    using (writer.WriteElement("schemeClr", null, "a"))
                    {
                        writer.WriteAttributeString("val", ((ColorSchemeIndex)color.Value).ToSchemeClrValue());
                        if (!color.Tint.IsZero())
                        {
                            if ((drawingColorSettings != null) && drawingColorSettings.LumMod.HasValue)
                            {
                                double num9 = color.Tint * 100000.0;
                                writer.WriteLeafElementWithAttribute("tint", null, "a", "val", ((double)num9).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            else if (color.Tint < 0.0)
                            {
                                double num10 = (1.0 + color.Tint) * 100000.0;
                                writer.WriteLeafElementWithAttribute("lumMod", null, "a", "val", ((double)num10).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            else
                            {
                                double num11 = color.Tint * 100000.0;
                                writer.WriteLeafElementWithAttribute("tint", null, "a", "val", ((double)num11).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                        }
                        else if ((drawingColorSettings != null) && drawingColorSettings.Tint.HasValue)
                        {
                            writer.WriteLeafElementWithAttribute("tint", null, "a", "val", ((double)drawingColorSettings.Tint.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                        }
                        if (drawingColorSettings != null)
                        {
                            if (drawingColorSettings.Alpha.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("alpha", null, "a", "val", ((double)drawingColorSettings.Alpha.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.Shade.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("shade", null, "a", "val", ((double)drawingColorSettings.Shade.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.Sat.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("sat", null, "a", "val", ((double)drawingColorSettings.Sat.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.SatMod.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("satMod", null, "a", "val", ((double)drawingColorSettings.SatMod.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.SatOff.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("satOff", null, "a", "val", ((double)drawingColorSettings.SatOff.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.Hue.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("hue", null, "a", "val", ((double)drawingColorSettings.Hue.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.HueMod.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("hueMod", null, "a", "val", ((double)drawingColorSettings.HueMod.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.HueOff.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("hueOff", null, "a", "val", ((double)drawingColorSettings.HueOff.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.Lum.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("lum", null, "a", "val", ((double)drawingColorSettings.Lum.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.LumMod.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("lumMod", null, "a", "val", ((double)drawingColorSettings.LumMod.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                            if (drawingColorSettings.LumOff.HasValue)
                            {
                                writer.WriteLeafElementWithAttribute("lumOff", null, "a", "val", ((double)drawingColorSettings.LumOff.Value).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                            }
                        }
                        return;
                    }
                }
                ExcelColorType colorType = color.ColorType;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Gets the closest palette color of specified color.
        /// </summary>
        /// <param name="color">An <see cref="T:Dt.Xls.IExcelColor" /> instance used to locate the palette color.</param>
        /// <returns>The closest palette color</returns>
        public ExcelPaletteColor GetPaletteColor(IExcelColor color)
        {
            if (color.ColorType == ExcelColorType.Indexed)
            {
                return((ExcelPaletteColor)color.Value);
            }
            if (color.ColorType != ExcelColorType.Theme)
            {
                return(this.GetCloestColorIndex(ColorExtension.FromArgb(color.Value)));
            }
            GcColor systemColor = new GcColor();

            if (this.Theme == null)
            {
                int num = (int)color.Value;
                if ((num < 0) || (num > 11))
                {
                    return(ExcelPaletteColor.SystemWindowBackgroundColor);
                }
                switch (color.Value)
                {
                case 0:
                    systemColor = GcSystemColors.GetSystemColor(GcSystemColorIndex.Window);
                    break;

                case 1:
                    systemColor = GcSystemColors.GetSystemColor(GcSystemColorIndex.WindowText);
                    break;

                case 2:
                    systemColor = ColorExtension.FromArgb(0xeeece1);
                    break;

                case 3:
                    systemColor = ColorExtension.FromArgb(0x1f497d);
                    break;

                case 4:
                    systemColor = ColorExtension.FromArgb(0x4f81bd);
                    break;

                case 5:
                    systemColor = ColorExtension.FromArgb(0xc0504d);
                    break;

                case 6:
                    systemColor = ColorExtension.FromArgb(0x9bbb59);
                    break;

                case 7:
                    systemColor = ColorExtension.FromArgb(0x8064a2);
                    break;

                case 8:
                    systemColor = ColorExtension.FromArgb(0x4bacc6);
                    break;

                case 9:
                    systemColor = ColorExtension.FromArgb(0xf79646);
                    break;

                case 10:
                    systemColor = ColorExtension.FromArgb(0xff);
                    break;

                case 11:
                    systemColor = ColorExtension.FromArgb(0x800080);
                    break;
                }
            }
            else
            {
                int num2 = (int)color.Value;
                if ((num2 < 0) || (num2 > 11))
                {
                    return(ExcelPaletteColor.SystemWindowBackgroundColor);
                }
                systemColor = this.GetThemeColor((ColorSchemeIndex)num2);
            }
            return(this.GetCloestColorIndex(systemColor));
        }