Example #1
0
        /// <summary>
        /// Read the GlobalStyles XML tag with its attributes (if any) and insert
        /// a resulting <seealso cref="HighlightingTheme"/> object into the <seealso cref="HighlightingThemes"/> root object.
        /// </summary>
        internal static void ReadNode(XmlReader reader, HighlightingThemes HlThemeRoot)
        {
            reader.ReadToNextSibling(ReadGlobalStyles.XMLName);
              while (reader.Read())
              {
            if (reader.IsStartElement() == true)
            {
              switch (reader.Name)
              {
            case ReadWidgetStyle.XMLName_Hyperlink:
            case ReadWidgetStyle.XMLName_DefaultStyle:
              WidgetStyle t = ReadWidgetStyle.ReadForegroundBackgroundColorNode(reader.ReadSubtree(), reader.Name);

              try
              {
                HlThemeRoot.AddWidgetStyle(t.Name, t);
              }
              catch (Exception e)   // Reading one errornous style node should not crash the whole process
              {
                logger.Error("Error reading DefaultStyle node", e);
              }
              break;

            case ReadWidgetStyle.XMLName_CurrentLineBackground:
              t = ReadWidgetStyle.ReadCurrentLineBackgroundNode(reader.ReadSubtree());

              try
              {
                HlThemeRoot.AddWidgetStyle(t.Name, t);
              }
              catch (Exception e)   // Reading one errornous style node should not crash the whole process
              {
                logger.Error("Error reading CurrentLineBackground node", e);
              }
              break;

            case ReadWidgetStyle.XMLName_LineNumbersForeground:
            case ReadWidgetStyle.XMLName_NonPrintableCharacter:
              t = ReadWidgetStyle.ReadForegroundColorNode(reader.ReadSubtree(), reader.Name);

              try
              {
                HlThemeRoot.AddWidgetStyle(t.Name, t);
              }
              catch (Exception e)   // Reading one errornous style node should not crash the whole process
              {
                logger.Error("Error reading LineNumbersForeground node", e);
              }
              break;

            case ReadWidgetStyle.XMLName_Selection:
              t = ReadWidgetStyle.ReadSelectionNode(reader.ReadSubtree());

              try
              {
                HlThemeRoot.AddWidgetStyle(t.Name, t);
              }
              catch (Exception e)   // Reading one errornous style node should not crash the whole process
              {
                logger.Error("Error reading Selection node", e);
              }
              break;

            case XMLNameSpace:
              break;

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