public ChunkStyle (ChunkStyle baseStyle)
		{
			this.Name = baseStyle.Name;
			this.Foreground = baseStyle.Foreground;
			this.Background = baseStyle.Background;
			this.FontWeight = baseStyle.FontWeight;
			this.FontStyle = baseStyle.FontStyle;
			this.Underline = baseStyle.Underline;
		}
Exemple #2
0
        internal static ChunkStyle Create(XElement element, Dictionary <string, HslColor> palette)
        {
            var result = new ChunkStyle();

            foreach (var node in element.DescendantNodes())
            {
                if (node.NodeType == System.Xml.XmlNodeType.Element)
                {
                    var el = (XElement)node;
                    switch (el.Name.LocalName)
                    {
                    case "name":
                        result.Name = el.Value;
                        break;

                    case "fore":
                        result.Foreground = ColorScheme.ParsePaletteColor(palette, el.Value);
                        break;

                    case "back":
                        result.Background = ColorScheme.ParsePaletteColor(palette, el.Value);
                        break;

                    case "weight":
                        Xwt.Drawing.FontWeight weight;
                        if (!Enum.TryParse <Xwt.Drawing.FontWeight> (el.Value, true, out weight))
                        {
                            throw new InvalidDataException(el.Value + " is no valid text weight values are: " + string.Join(",", Enum.GetNames(typeof(Xwt.Drawing.FontWeight))));
                        }
                        result.FontWeight = weight;
                        break;

                    case "style":
                        Xwt.Drawing.FontStyle style;
                        if (!Enum.TryParse <Xwt.Drawing.FontStyle> (el.Value, true, out style))
                        {
                            throw new InvalidDataException(el.Value + " is no valid text weight values are: " + string.Join(",", Enum.GetNames(typeof(Xwt.Drawing.FontStyle))));
                        }
                        result.FontStyle = style;
                        break;

                    default:
                        throw new InvalidDataException("Invalid element in text color:" + el.Name);
                    }
                }
            }

            return(result);
        }
        internal override MonoDevelop.Ide.Editor.Highlighting.ChunkStyle GetStyle(MonoDevelop.Ide.Editor.Highlighting.ChunkStyle baseStyle)
        {
            if (baseStyle == null)
            {
                return(null);
            }

            var style = new MonoDevelop.Ide.Editor.Highlighting.ChunkStyle(baseStyle);

            if (forground != null && editor != null)
            {
                style.Foreground = forground(editor).Foreground;
            }
            return(style);
        }
Exemple #4
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (obj.GetType() != typeof(ChunkStyle))
            {
                return(false);
            }
            ChunkStyle other = (ChunkStyle)obj;

            return(Name == other.Name && Foreground.Equals(other.Foreground) && Background.Equals(other.Background) && FontWeight == other.FontWeight && FontStyle == other.FontStyle);
        }
Exemple #5
0
        internal 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 HslColor(0, 0, 0);
                }
            }
            if (!string.IsNullOrEmpty(vsc.Background) && vsc.Background != "0x02000000")
            {
                textColor.Background = ColorScheme.ImportVsColor(vsc.Background);
            }
            if (vsc.BoldFont)
            {
                textColor.FontWeight = Xwt.Drawing.FontWeight.Bold;
            }
            return(textColor);
        }
Exemple #6
0
		internal HslColor GetForeground (ChunkStyle chunkStyle)
		{
			if (chunkStyle.TransparentForeground)
				return PlainText.Foreground;
			return chunkStyle.Foreground;
		}
		internal static ChunkStyle Create (XElement element, Dictionary<string, HslColor> palette)
		{
			var result = new ChunkStyle ();

			foreach (var node in element.DescendantNodes ()) {
				if (node.NodeType == System.Xml.XmlNodeType.Element) {
					var el = (XElement)node;
					switch (el.Name.LocalName) {
					case "name":
						result.Name = el.Value;
						break;
					case "fore":
						result.Foreground = ColorScheme.ParsePaletteColor (palette, el.Value);
						break;
					case "back":
						result.Background = ColorScheme.ParsePaletteColor (palette, el.Value);
						break;
					case "weight":
						Xwt.Drawing.FontWeight weight;
						if (!Enum.TryParse<Xwt.Drawing.FontWeight> (el.Value, true, out weight)) 
							throw new InvalidDataException (el.Value + " is no valid text weight values are: " + string.Join (",", Enum.GetNames (typeof(Xwt.Drawing.FontWeight))) );
						result.FontWeight = weight;
						break;
					case "style":
						Xwt.Drawing.FontStyle style;
						if (!Enum.TryParse<Xwt.Drawing.FontStyle> (el.Value, true, out style)) 
							throw new InvalidDataException (el.Value + " is no valid text weight values are: " + string.Join (",", Enum.GetNames (typeof(Xwt.Drawing.FontStyle))) );
						result.FontStyle = style;
						break;
					default:
						throw new InvalidDataException ("Invalid element in text color:" + el.Name);
					}
				}
			}

			return result;
		}
		internal 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 HslColor (0, 0, 0);
			}
			if (!string.IsNullOrEmpty (vsc.Background) && vsc.Background != "0x02000000")
				textColor.Background = ColorScheme.ImportVsColor (vsc.Background);
			if (vsc.BoldFont)
				textColor.FontWeight = Xwt.Drawing.FontWeight.Bold;
			return textColor;
		}
		string HighlightSemantically (string str, ChunkStyle style)
		{
			if (!DefaultSourceEditorOptions.Instance.EnableSemanticHighlighting)
				return str;
			return Highlight (str, style);
		}
		string Highlight (string str, ChunkStyle style)
		{
			var color = (Gdk.Color)((HslColor)colorStyle.GetForeground (style));

			if (grayOut) {
				color = AlphaBlend (color, (Gdk.Color)((HslColor)colorStyle.PlainText.Background), optionalAlpha);
			}

			var colorString = MonoDevelop.Components.HelperMethods.GetColorString (color);
			return "<span foreground=\"" + colorString + "\">" + str + "</span>";
		}