Exemplo n.º 1
0
        static XshdColor GetColorFromElement(XmlElement element)
        {
            if (!element.HasAttribute("bold") && !element.HasAttribute("italic") && !element.HasAttribute("color") && !element.HasAttribute("bgcolor"))
            {
                return(null);
            }
            XshdColor color = new XshdColor();

            if (element.HasAttribute("bold"))
            {
                color.FontWeight = XmlConvert.ToBoolean(element.GetAttribute("bold")) ? FontWeights.Bold : FontWeights.Normal;
            }
            if (element.HasAttribute("italic"))
            {
                color.FontStyle = XmlConvert.ToBoolean(element.GetAttribute("italic")) ? FontStyles.Italic : FontStyles.Normal;
            }
            if (element.HasAttribute("color"))
            {
                color.Foreground = ParseColor(element.GetAttribute("color"));
            }
            if (element.HasAttribute("bgcolor"))
            {
                color.Background = ParseColor(element.GetAttribute("bgcolor"));
            }
            return(color);
        }
Exemplo n.º 2
0
            public object VisitColor(XshdColor color)
            {
                HighlightingColor c;

                if (color.Name != null)
                {
                    c = def.colorDict[color.Name];
                }
                else if (color.Foreground == null && color.FontStyle == null && color.FontWeight == null)
                {
                    return(null);
                }
                else
                {
                    c = new HighlightingColor();
                }

                c.Name       = color.Name;
                c.Foreground = color.Foreground;
                c.Background = color.Background;
                c.Underline  = color.Underline;
                c.FontStyle  = color.FontStyle;
                c.FontWeight = color.FontWeight;
                return(c);
            }
Exemplo n.º 3
0
        static XshdColor ParseColorAttributes(XmlReader reader)
        {
            XshdColor color = new XshdColor();

            SetPosition(color, reader);
            color.Foreground = ParseForeground(reader as IXmlLineInfo, reader.GetAttribute("foreground"));
            color.FontWeight = ParseFontWeight(reader.GetAttribute("fontWeight"));
            color.FontStyle  = ParseFontStyle(reader.GetAttribute("fontStyle"));
            return(color);
        }
		public NamedColorHighlightingItem(IHighlightingItem defaultText, XshdColor color)
		{
			if (defaultText == null)
				throw new ArgumentNullException("defaultText");
			if (color == null)
				throw new ArgumentNullException("color");
			
			this.defaultText = defaultText;
			this.color = color;
		}
Exemplo n.º 5
0
 object IXshdVisitor.VisitColor(XshdColor color)
 {
     writer.WriteStartElement("Color", Namespace);
     if (color.Name != null)
     {
         writer.WriteAttributeString("name", color.Name);
     }
     WriteColorAttributes(color);
     writer.WriteEndElement();
     return(null);
 }
 object IXshdVisitor.VisitColor(XshdColor color)
 {
     writer.WriteStartElement("Color", Namespace);
     if (color.Name != null)
         writer.WriteAttributeString("name", color.Name);
     WriteColorAttributes(color);
     if (color.ExampleText != null)
         writer.WriteAttributeString("exampleText", color.ExampleText);
     writer.WriteEndElement();
     return null;
 }
        static XshdColor ParseNamedColor(XmlReader reader)
        {
            XshdColor color = ParseColorAttributes(reader);

            // check removed: invisible named colors may be useful now that apps can read highlighting data
            //if (color.Foreground == null && color.FontWeight == null && color.FontStyle == null)
            //	throw Error(reader, "A named color must have at least one element.");
            color.Name = reader.GetAttribute("name");
            CheckElementName(reader, color.Name);
            return(color);
        }
Exemplo n.º 8
0
        static XshdColor ParseNamedColor(XmlReader reader)
        {
            XshdColor color = ParseColorAttributes(reader);

            if (color.Foreground == null && color.FontWeight == null && color.FontStyle == null)
            {
                throw Error(reader, "A named color must have at least one element.");
            }
            color.Name = reader.GetAttribute("name");
            CheckElementName(reader, color.Name);
            return(color);
        }
Exemplo n.º 9
0
			public object VisitColor(XshdColor color)
			{
				if (color.Name != null) {
					if (color.Name.Length == 0)
						throw Error(color, "Name must not be the empty string");
					if (def.colorDict.ContainsKey(color.Name))
						throw Error(color, "Duplicate color name '" + color.Name + "'.");
					
					def.colorDict.Add(color.Name, new HighlightingColor());
				}
				return null;
			}
Exemplo n.º 10
0
            public object VisitColor(XshdColor color)
            {
                if (color.Name != null) {
                    if (color.Name.Length == 0)
                        throw Error(color, "Name must not be the empty string");
                    if (def.colorDict.ContainsKey(color.Name))
                        throw Error(color, "Duplicate color name '" + color.Name + "'.");

                    def.colorDict.Add(color.Name, new HighlightingColor());
                }
                return null;
            }
Exemplo n.º 11
0
        static XshdReference <XshdColor> GetColorReference(XmlElement element)
        {
            XshdColor color = GetColorFromElement(element);

            if (color != null)
            {
                return(new XshdReference <XshdColor>(color));
            }
            else
            {
                return(new XshdReference <XshdColor>());
            }
        }
Exemplo n.º 12
0
        private static XshdColor ParseColorAttributes(XmlReader reader)
        {
            XshdColor color = new XshdColor();

            SetPosition(color, reader);
            IXmlLineInfo position = reader as IXmlLineInfo;

            color.Foreground = ParseColor(position, reader.GetAttribute("foreground"));
            color.Background = ParseColor(position, reader.GetAttribute("background"));
            color.FontWeight = ParseFontWeight(reader.GetAttribute("fontWeight"));
            color.FontStyle  = ParseFontStyle(reader.GetAttribute("fontStyle"));
            color.Underline  = reader.GetBoolAttribute("underline");
            return(color);
        }
Exemplo n.º 13
0
 void WriteColorAttributes(XshdColor color)
 {
     if (color.Foreground != null)
     {
         writer.WriteAttributeString("foreground", color.Foreground.ToString());
     }
     if (color.FontWeight != null)
     {
         writer.WriteAttributeString("fontWeight", V2Loader.FontWeightConverter.ConvertToInvariantString(color.FontWeight.Value).ToLowerInvariant());
     }
     if (color.FontStyle != null)
     {
         writer.WriteAttributeString("fontStyle", V2Loader.FontStyleConverter.ConvertToInvariantString(color.FontStyle.Value).ToLowerInvariant());
     }
 }
Exemplo n.º 14
0
 static XshdColor GetColorFromElement(XmlElement element)
 {
     if (!element.HasAttribute("bold") && !element.HasAttribute("italic") && !element.HasAttribute("color") && !element.HasAttribute("bgcolor"))
         return null;
     XshdColor color = new XshdColor();
     if (element.HasAttribute("bold"))
         color.FontWeight = XmlConvert.ToBoolean(element.GetAttribute("bold")) ? FontWeights.Bold : FontWeights.Normal;
     if (element.HasAttribute("italic"))
         color.FontStyle = XmlConvert.ToBoolean(element.GetAttribute("italic")) ? FontStyles.Italic : FontStyles.Normal;
     if (element.HasAttribute("color"))
         color.Foreground = ParseColor(element.GetAttribute("color"));
     if (element.HasAttribute("bgcolor"))
         color.Background = ParseColor(element.GetAttribute("bgcolor"));
     return color;
 }
Exemplo n.º 15
0
            public object VisitColor(XshdColor color)
            {
                HighlightingColor c;
                if (color.Name != null)
                    c = def.colorDict[color.Name];
                else if (color.Foreground == null && color.FontStyle == null && color.FontWeight == null)
                    return null;
                else
                    c = new HighlightingColor();

                c.Name = color.Name;
                c.Foreground = color.Foreground;
                c.Background = color.Background;
                c.Underline = color.Underline;
                c.FontStyle = color.FontStyle;
                c.FontWeight = color.FontWeight;
                c.FontFamily = color.FontFamily;
                c.FontSize = color.FontSize;
                return c;
            }
Exemplo n.º 16
0
		static XshdColor ParseColorAttributes(XmlReader reader)
		{
			XshdColor color = new XshdColor();
			SetPosition(color, reader);
			IXmlLineInfo position = reader as IXmlLineInfo;
			color.Foreground = ParseColor(position, reader.GetAttribute("foreground"));
			color.Background = ParseColor(position, reader.GetAttribute("background"));
			color.FontWeight = ParseFontWeight(reader.GetAttribute("fontWeight"));
			color.FontStyle = ParseFontStyle(reader.GetAttribute("fontStyle"));
			return color;
		}
Exemplo n.º 17
0
		void WriteColorAttributes(XshdColor color)
		{
			if (color.Foreground != null)
				writer.WriteAttributeString("foreground", color.Foreground.ToString());
			if (color.Background != null)
				writer.WriteAttributeString("background", color.Background.ToString());
			if (color.FontWeight != null)
				writer.WriteAttributeString("fontWeight", V2Loader.FontWeightConverter.ConvertToInvariantString(color.FontWeight.Value).ToLowerInvariant());
			if (color.FontStyle != null)
				writer.WriteAttributeString("fontStyle", V2Loader.FontStyleConverter.ConvertToInvariantString(color.FontStyle.Value).ToLowerInvariant());
		}
Exemplo n.º 18
0
            public object VisitColor(XshdColor color)
            {
                HighlightingColor c;
                if (color.Name != null)
                    c = def.colorDict[color.Name];
                else if (color.Foreground == null && color.FontStyle == null && color.FontWeight == null)
                    return null;
                else
                    c = new HighlightingColor();

                c.Name = color.Name;
                c.Foreground = color.Foreground;
                c.Background = color.Background;
                c.Underline = color.Underline;
                c.FontStyle = color.FontStyle;
                c.FontWeight = color.FontWeight;
                c.FontFamily = color.FontFamily;
                c.FontSize = color.FontSize;
                return c;
            }
Exemplo n.º 19
0
			public object VisitColor(XshdColor color)
			{
				foundColors.Add(color);
				return null;
			}