/// <summary>
        /// Saves the current configuration to CONFIGFILE.
        /// </summary>
        public virtual void Save()
        {
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = "  ";

            // init writer
            XmlWriter writer = XmlWriter.Create(CONFIGFILE, settings);

            // begin
            writer.WriteStartDocument();
            writer.WriteStartElement(XMLTAG_CONFIGURATION);

            /******************************************************************************/
            // PART I: RESOURCES

            writer.WriteStartElement(XMLTAG_RESOURCES);
            writer.WriteAttributeString(XMLATTRIB_VERSION, ResourcesVersion.ToString());
            writer.WriteAttributeString(XMLATTRIB_PATH, ResourcesPath.ToString().ToLower());
            writer.WriteAttributeString(XMLATTRIB_PRELOADROOMS, PreloadRooms.ToString().ToLower());
            writer.WriteAttributeString(XMLATTRIB_PRELOADOBJECTS, PreloadObjects.ToString().ToLower());
            writer.WriteAttributeString(XMLATTRIB_PRELOADROOMTEXTURES, PreloadRoomTextures.ToString().ToLower());
            writer.WriteAttributeString(XMLATTRIB_PRELOADSOUND, PreloadSound.ToString().ToLower());
            writer.WriteAttributeString(XMLATTRIB_PRELOADMUSIC, PreloadMusic.ToString().ToLower());
            writer.WriteEndElement();

            /******************************************************************************/
            // PART II: Connections

            writer.WriteStartElement(XMLTAG_CONNECTIONS);
            writer.WriteAttributeString(XMLATTRIB_SELECTEDINDEX, SelectedConnectionIndex.ToString());

            for (int i = 0; i < connections.Count; i++)
            {
                // connection
                writer.WriteStartElement(XMLTAG_CONNECTION);
                writer.WriteAttributeString(XMLATTRIB_NAME, connections[i].Name);
                writer.WriteAttributeString(XMLATTRIB_HOST, connections[i].Host);
                writer.WriteAttributeString(XMLATTRIB_PORT, connections[i].Port.ToString());
                writer.WriteAttributeString(XMLATTRIB_USEIPV6, connections[i].UseIPv6.ToString());
                writer.WriteAttributeString(XMLATTRIB_STRINGDICTIONARY, connections[i].StringDictionary);
                writer.WriteAttributeString(XMLATTRIB_USERNAME, connections[i].Username);
                writer.WriteAttributeString(XMLATTRIB_PASSWORD, String.Empty);
                writer.WriteAttributeString(XMLATTRIB_CHARACTER, connections[i].Character);

                // ignorelist
                writer.WriteStartElement(XMLTAG_IGNORELIST);
                for (int j = 0; j < connections[i].IgnoreList.Count; j++)
                {
                    writer.WriteStartElement(XMLTAG_IGNORE);
                    writer.WriteAttributeString(XMLATTRIB_NAME, connections[i].IgnoreList[j]);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                writer.WriteEndElement();
            }

            writer.WriteEndElement();

            /******************************************************************************/
            // PART III: Aliases

            writer.WriteStartElement(XMLTAG_ALIASES);

            for (int i = 0; i < aliases.Count; i++)
            {
                // alias
                writer.WriteStartElement(XMLTAG_ALIAS);
                writer.WriteAttributeString(XMLATTRIB_KEY, aliases[i].Key);
                writer.WriteAttributeString(XMLATTRIB_VALUE, aliases[i].Value);
                writer.WriteEndElement();
            }

            writer.WriteEndElement();

            /******************************************************************************/

            // let deriving classes write their stuff
            WriteXml(writer);

            // end
            writer.WriteEndElement();
            writer.WriteEndDocument();

            // close writer
            writer.Close();
        }