ImportVsColor() static private method

static private ImportVsColor ( string colorString ) : Cairo.Color
colorString string
return Cairo.Color
Beispiel #1
0
        public static AmbientColor Import(Dictionary <string, ColorScheme.VSSettingColor> colors, string vsSetting)
        {
            var result = new AmbientColor();
            var attrs  = vsSetting.Split(',');

            foreach (var attr in attrs)
            {
                var info = attr.Split('=');
                if (info.Length != 2)
                {
                    continue;
                }
                var idx    = info [1].LastIndexOf('/');
                var source = info [1].Substring(0, idx);
                var dest   = info [1].Substring(idx + 1);

                ColorScheme.VSSettingColor color;
                if (!colors.TryGetValue(source, out color))
                {
                    continue;
                }
                result.Name = color.Name;
                string colorString;
                switch (dest)
                {
                case "Foreground":
                    colorString = color.Foreground;
                    break;

                case "Background":
                    colorString = color.Background;
                    break;

                default:
                    throw new InvalidDataException("Invalid attribute source: " + dest);
                }
                result.Colors.Add(Tuple.Create(info [0], ColorScheme.ImportVsColor(colorString)));
            }
            if (result.Colors.Count == 0)
            {
                return(null);
            }
            return(result);
        }
        public static ChunkStyle Import(string name, ColorScheme.VSSettingColor vsc)
        {
            var textColor = new ChunkStyle();

            textColor.Name = name;
            if (!string.IsNullOrEmpty(vsc.Foreground) && vsc.Foreground != "0x02000000")
            {
                textColor.Foreground = ColorScheme.ImportVsColor(vsc.Foreground);
                if (textColor.TransparentForeground && name != "Selected Text" && name != "Selected Text(Inactive)")
                {
                    textColor.Foreground = new Cairo.Color(0, 0, 0);
                }
            }
            if (!string.IsNullOrEmpty(vsc.Background) && vsc.Background != "0x02000000")
            {
                textColor.Background = ColorScheme.ImportVsColor(vsc.Background);
            }
            if (vsc.BoldFont)
            {
                textColor.FontWeight = FontWeight.Bold;
            }
            return(textColor);
        }