public SerializableBrush Clone() { SerializableBrush sbrush = null; if (this.BrushType == BrushType.SolidBrush) { sbrush = new SerializableBrush(this.SolidBrushColor); } else if (this.BrushType == BrushType.LinearGradientBrush) { sbrush = new SerializableBrush(this.m_LinearGradientPoint1, this.m_LinearGradientPoint2, this.LinearGradientBrushColor1, this.LinearGradientBrushColor2); } return(sbrush); }
/// <summary> /// Parse BackgroundBrush for the template from BackgroundBrush Node /// </summary> /// <param name="backgroundBrushNode">XmlNode for the BackgroundBrush</param> /// <param name="template"> BackgroundTemplate model</param> private void ParseBackgroundBrush(XmlNode backgroundBrushNode, BackgroundTemplate template) { if (backgroundBrushNode.HasChildNodes) { XmlNode brushNode = backgroundBrushNode.ChildNodes[0]; //if the brush is solid brush, then create SerializableBrush, and set it to BackgroundTemplate if (brushNode.Name.Equals("SolidBrush")) { XmlAttribute attribute=brushNode.Attributes["color"]; if (attribute != null) { String colorStr = attribute.Value; Color color = ParseColor(colorStr); if (color != Color.Empty) { SerializableBrush brush = new SerializableBrush(color); template.BackgroundBrush = brush; } } } //if the brush is LinearGradientBrush, then create SerializableBrush, and set it to BackgroundTemplate else if (brushNode.Name.Equals("LinearGradientBrush")) { XmlAttribute attribute = brushNode.Attributes["color1"]; if (attribute == null) return; String value = attribute.Value; Color color1 = ParseColor(value); attribute = brushNode.Attributes["color2"]; if (attribute == null) return; value = attribute.Value; Color color2=ParseColor(value); attribute = brushNode.Attributes["point1"]; if (attribute == null) return; value = attribute.Value; PointF point1 = ParsePoint(value); attribute = brushNode.Attributes["point2"]; if (attribute == null) return; value = attribute.Value; PointF point2 = ParsePoint(value); if (color1 != Color.Empty && color2 != Color.Empty && (point1 != Point.Empty || point2 != Point.Empty)) { SerializableBrush brush = new SerializableBrush(point1, point2, color1, color2); template.BackgroundBrush = brush; } } } }
public SerializableBrush Clone() { SerializableBrush sbrush=null; if (this.BrushType == BrushType.SolidBrush) { sbrush = new SerializableBrush(this.SolidBrushColor); } else if (this.BrushType == BrushType.LinearGradientBrush) { sbrush = new SerializableBrush(this.m_LinearGradientPoint1,this.m_LinearGradientPoint2, this.LinearGradientBrushColor1, this.LinearGradientBrushColor2); } return sbrush; }