public override void WriteXml(XmlWriter xmlWriter)
 {
     xmlWriter.WriteElementString("Value", value.ToString().ToLower());
     xmlWriter.WriteElementString("Variant", variant.ToString());
 }
        public override void ReadXML(XmlReader xmlReader)
        {
            xmlReader.ReadStartElement();       // <Toggle>

            while (xmlReader.NodeType == XmlNodeType.Element)
            {
                switch (xmlReader.Name)
                {
                case "Value":
                    value = XmlHelper.ParseBoolean(xmlReader.ReadElementContentAsString());
                    break;

                case "Variant":
                    variant = (StyleToggleVariant)Enum.Parse(typeof(StyleToggleVariant), xmlReader.ReadElementContentAsString());
                    break;

                default:
                    string unparsed = xmlReader.ReadOuterXml();
                    log.DebugFormat("Unparsed content in style element toggle XML: {0}", unparsed);
                    break;
                }
            }

            xmlReader.ReadEndElement();

            // If the variant is unknown, the most likely cause is that it's an older file where "Curved" was assumed.
            // Worst case scenario from doing this is that we show "Curved" instead of "Unknown" in the mini editor.
            if (variant == StyleToggleVariant.Unknown)
            {
                variant = StyleToggleVariant.Curved;
                log.ErrorFormat("Unknown variant in style element toggle. Assumed: {0}", variant.ToString());
            }

            UpdateVariant(variant);
        }