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);
        }
예제 #2
0
        private void UpdateVariant(StyleToggleVariant variant)
        {
            // Update the appearance of the mini editor based on the variant.
            switch (variant)
            {
            case StyleToggleVariant.Perspective:
                icon        = Properties.Drawings.plane;
                displayName = ScreenManagerLang.Generic_Perspective;
                break;

            case StyleToggleVariant.Curved:
            default:
                icon        = Properties.Drawings.curve;
                displayName = ScreenManagerLang.Generic_Curved;
                break;
            }
        }
 public StyleElementToggle(bool initialValue, StyleToggleVariant variant)
 {
     this.value   = initialValue;
     this.variant = variant;
     UpdateVariant(variant);
 }