public IStyleProperty SetStyleProperty(string name, StyleColor color) { if (String.IsNullOrEmpty(name)) { return(null); } StyleColorProperty property = null; if (Contains(name)) { property = _styleProperties[name] as StyleColorProperty; if (property != null && !property.ColorValue.Equals(color)) { property.ColorValue = new StyleColor(color); } } if (property == null) { property = new StyleColorProperty(name, color); _styleProperties[name] = property; } return(property); }
/* * <StyleProperties> * <PropertyName> * <Value></Value> * </PropertyName> * <PropertyName> * <Color> * ... * </Color> * </PropertyName> * </StyleProperties> * */ internal override void SaveDataToXml(XmlDocument xmlDoc, XmlElement parentElement) { CheckTagName(parentElement); XmlElement propertiesElement = xmlDoc.CreateElement("StyleProperties"); parentElement.AppendChild(propertiesElement); foreach (StyleProperty property in _styleProperties.Values) { XmlElement propertyElement = xmlDoc.CreateElement(property.Name); propertiesElement.AppendChild(propertyElement); if (property is StyleColorProperty) { StyleColorProperty colorProperty = property as StyleColorProperty; SaveStyleColorToXml(colorProperty.ColorValue, xmlDoc, propertyElement); } else { SaveStringToChildElement("Value", property.Value, xmlDoc, propertyElement); } } }