Exemplo n.º 1
0
        /// <summary>
        /// Read the LexerType XML tag with its attributes (if any) and return
        /// a resulting <seealso cref="HighlightingTheme"/> object.
        /// </summary>
        internal static HighlightingTheme ReadNode(XmlReader reader)
        {
            HighlightingTheme hlTheme = null;

            string name = string.Empty;
            string desc = string.Empty;

            reader.ReadToNextSibling(ReadLexerType.XMLName);
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case ReadLexerType.attr_name:
                    name = reader.Value;
                    break;

                case XMLNameSpace:
                    break;

                case ReadLexerType.attr_desc:
                    desc = (reader.Value == null ? string.Empty : reader.Value);
                    break;
                }
            }

            hlTheme        = new HighlightingTheme(name);
            hlTheme.HlDesc = desc;


            while (reader.Read())
            {
                if (reader.IsStartElement() == true)
                {
                    switch (reader.Name)
                    {
                    case ReadWordsStyle.XMLName:
                        WordsStyle t = ReadWordsStyle.ReadNode(reader.ReadSubtree());

                        hlTheme.AddWordStyle(t.Name, t);
                        break;

                    case XMLNameSpace:
                        break;

                    default:
                        if (reader.Name.Trim().Length > 0 && reader.Name != XMLComment)
                        {
                            logger.Warn("Parsing the XML child:'" + reader.Name + "' of '" + ReadLexerType.XMLName + "' is not implemented.");
                        }
                        break;
                    }
                }
            }

            return(hlTheme);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read the WordsStyle XML tag with its attributes (if any) and return
        /// a resulting <seealso cref="WordsStyle"/> object.
        /// </summary>
        internal static WordsStyle ReadNode(XmlReader reader)
        {
            WordsStyle          ret = null;
            FontWeightConverter FontWeightConverter = new FontWeightConverter();
            FontStyleConverter  FontStyleConverter  = new FontStyleConverter();

            string name       = string.Empty;
            string fgColor    = string.Empty;
            string bgColor    = string.Empty;
            string fontWeight = string.Empty;
            string FontStyle  = string.Empty;

            reader.ReadToNextSibling(ReadWordsStyle.XMLName);
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case ReadWordsStyle.attr_name:
                    name = reader.Value;
                    break;

                case ReadWordsStyle.attr_fgColor:
                    fgColor = (reader.Value == null ? string.Empty : reader.Value);
                    break;

                case ReadWordsStyle.attr_bgColor:
                    bgColor = (reader.Value == null ? string.Empty : reader.Value);
                    break;

                case ReadWordsStyle.attr_fontWeight:
                    fontWeight = (reader.Value == null ? string.Empty : reader.Value);
                    break;

                case ReadWordsStyle.attr_FontStyle:
                    FontStyle = (reader.Value == null ? string.Empty : reader.Value);
                    break;

                case XMLNameSpace:
                    break;

                default:
                    if (reader.Name.Trim().Length > 0 && reader.Name != XMLComment)
                    {
                        logger.Warn("Parsing the XML child:'" + reader.Name + "' of '" + ReadLexerType.XMLName + "' is not implemented.");
                    }
                    break;
                }
            }

            ret = new WordsStyle(name);

            if (fgColor != string.Empty)
            {
                ret.fgColor = ReadWordsStyle.SetColorFromString(ReadWordsStyle.attr_fgColor, fgColor);
            }

            if (bgColor != string.Empty)
            {
                ret.bgColor = ReadWordsStyle.SetColorFromString(ReadWordsStyle.attr_bgColor, bgColor);
            }

            if (fontWeight != string.Empty)
            {
                ret.fontWeight = ParseFontWeight(ReadWordsStyle.attr_fontWeight, fontWeight, FontWeightConverter);
            }

            if (FontStyle != string.Empty)
            {
                ret.fontStyle = ParseFontStyle(ReadWordsStyle.attr_FontStyle, FontStyle, FontStyleConverter);
            }

            return(ret);
        }