public SerializablePen Clone()
        {
            SerializablePen pen = new SerializablePen(this.Color);

            pen.DashStyle = this.DashStyle;
            pen.Width     = this.Width;
            pen.Index     = this.Index;
            return(pen);
        }
        public SerializablePen GetPrimitivePenByIndex(int index)
        {
            for (int i = 0; i < this.m_PrimitivePens.Count; i++)
            {
                SerializablePen pen = (SerializablePen)this.m_PrimitivePens[i];
                if (pen.Index == index)
                {
                    return(pen);
                }
            }

            if (index < this.m_PrimitivePens.Count)
            {
                return((SerializablePen)this.m_PrimitivePens[index]);
            }

            return(null);
        }
        /// <summary>
        /// Parse all the pens, and add them into the PrimitivePens List in BackgroundTemplate
        /// </summary>
        private void ParsePrimitivePens(XmlNode primitivePensNode, BackgroundTemplate template)
        {
            for (int i = 0; i < primitivePensNode.ChildNodes.Count; i++)
            {
                XmlNode penNode = primitivePensNode.ChildNodes[i];
                SerializablePen pen;

                //Get the pen color
                Color color = Color.Black;

                XmlAttribute attribute = penNode.Attributes["color"];

                if (attribute != null)
                {
                    String colorStr = attribute.Value;
                    color = ParseColor(colorStr);
                }

                pen = new SerializablePen(color);

                //Get the pen dashstyle
                attribute = penNode.Attributes["dashstyle"];
                if(attribute!=null)
                {
                    switch (attribute.Value)
                    {
                        case "Solid": pen.DashStyle = DashStyle.Solid; break;
                        case "Dot": pen.DashStyle = DashStyle.Dot; break;
                        case "Dash": pen.DashStyle = DashStyle.Dash; break;
                        case "DashDot": pen.DashStyle = DashStyle.DashDot; break;
                        case "DashDotDot": pen.DashStyle = DashStyle.DashDotDot; break;
                        default: pen.DashStyle = DashStyle.Solid; break;
                    }
                }

                //get the pen width
                float width = 1f;
                attribute = penNode.Attributes["width"];
                if (attribute != null)
                {
                    try
                    {
                        width = float.Parse(attribute.Value);
                    }
                    catch { width = 1f; }
                }
                pen.Width = width;

                //get the pen index
                int index=i;

                attribute = penNode.Attributes["index"];
                if(attribute!=null)
                {
                    try{
                     index=Int32.Parse(attribute.Value);
                    }
                    catch{
                        index = i;
                    }
                }
                pen.Index = index;

                template.PrimitivePens.Add(pen);
            }
        }
 public SerializablePen Clone()
 {
     SerializablePen pen = new SerializablePen(this.Color);
     pen.DashStyle = this.DashStyle;
     pen.Width = this.Width;
     pen.Index = this.Index;
     return pen;
 }