Beispiel #1
0
 private static void InitSystemColorTable()
 {
     _systemColors.Add("3DDKSHADOW", GcSystemColors.GetSystemColor(GcSystemColorIndex.ThreeDDarkShadow));
     _systemColors.Add("3DLIGHT", GcSystemColors.GetSystemColor(GcSystemColorIndex.ThreeDLight));
     _systemColors.Add("ACTIVEBORDER", GcSystemColors.GetSystemColor(GcSystemColorIndex.ActiveBorder));
     _systemColors.Add("ACTIVECAPTION", GcSystemColors.GetSystemColor(GcSystemColorIndex.ActiveCaption));
     _systemColors.Add("APPWORKSPACE", GcSystemColors.GetSystemColor(GcSystemColorIndex.AppWorkspace));
     _systemColors.Add("BACKGROUND", GcSystemColors.GetSystemColor(GcSystemColorIndex.Desktop));
     _systemColors.Add("BTNFACE", GcSystemColors.GetSystemColor(GcSystemColorIndex.ButtonFace));
     _systemColors.Add("BTNHIGHLIGHT", GcSystemColors.GetSystemColor(GcSystemColorIndex.ButtonHightlight));
     _systemColors.Add("BTNSHADOW", GcSystemColors.GetSystemColor(GcSystemColorIndex.ButtonShadow));
     _systemColors.Add("BTNTEXT", GcSystemColors.GetSystemColor(GcSystemColorIndex.ButtonText));
     _systemColors.Add("CAPTIONTEXT", GcSystemColors.GetSystemColor(GcSystemColorIndex.ActiveCaptionText));
     _systemColors.Add("GRAYTEXT", GcSystemColors.GetSystemColor(GcSystemColorIndex.GrayText));
     _systemColors.Add("HIGHLIGHT", GcSystemColors.GetSystemColor(GcSystemColorIndex.Highlight));
     _systemColors.Add("HIGHLIGHTTEXT", GcSystemColors.GetSystemColor(GcSystemColorIndex.HighlightText));
     _systemColors.Add("INACTIVEBORDER", GcSystemColors.GetSystemColor(GcSystemColorIndex.InactiveBorder));
     _systemColors.Add("INACTIVECAPTION", GcSystemColors.GetSystemColor(GcSystemColorIndex.InactiveCaption));
     _systemColors.Add("INACTIVECAPTIONTEXT", GcSystemColors.GetSystemColor(GcSystemColorIndex.InactiveCaptionText));
     _systemColors.Add("INFOBK", GcSystemColors.GetSystemColor(GcSystemColorIndex.Info));
     _systemColors.Add("INFOTEXT", GcSystemColors.GetSystemColor(GcSystemColorIndex.InfoText));
     _systemColors.Add("MENU", GcSystemColors.GetSystemColor(GcSystemColorIndex.Menu));
     _systemColors.Add("GRADIENTACTIVECAPTION", GcSystemColors.GetSystemColor(GcSystemColorIndex.GradientActiveCaption));
     _systemColors.Add("HOTLIGHT", GcSystemColors.GetSystemColor(GcSystemColorIndex.HotTrack));
     _systemColors.Add("GRADIENTINACTIVECAPTION", GcSystemColors.GetSystemColor(GcSystemColorIndex.GradientInactiveCaption));
     _systemColors.Add("MENUBAR", GcSystemColors.GetSystemColor(GcSystemColorIndex.MenuBar));
     _systemColors.Add("MENUHIGHLIGHT", GcSystemColors.GetSystemColor(GcSystemColorIndex.MenuHighlight));
     _systemColors.Add("MENUTEXT", GcSystemColors.GetSystemColor(GcSystemColorIndex.MenuText));
     _systemColors.Add("SCROLLBAR", GcSystemColors.GetSystemColor(GcSystemColorIndex.ScrollBar));
     _systemColors.Add("WINDOW", GcSystemColors.GetSystemColor(GcSystemColorIndex.Window));
     _systemColors.Add("WINDOWFRAME", GcSystemColors.GetSystemColor(GcSystemColorIndex.WindowFrame));
     _systemColors.Add("WINDOWTEXT", GcSystemColors.GetSystemColor(GcSystemColorIndex.WindowText));
 }
Beispiel #2
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));
        }