Exemplo n.º 1
0
 public DrawProperty Copy()
 {
     DrawProperty displayProperties = new DrawProperty();
     displayProperties.backColor = this.backColor;
     displayProperties.font = this.font;
     displayProperties.foreColor = this.foreColor;
     displayProperties.nameItem = this.nameItem;
     displayProperties.variableName = this.variableName;
     displayProperties.type = this.type;
     return displayProperties;
 }
        public override System.Xml.XmlNode ReadFrom(XmlNode parent)
        {
            values = new List<DrawProperty>();

            XmlElement themesElement = parent.SelectSingleNode("child::" + name) as XmlElement;
            if (themesElement != null)
            {
                XmlNodeList drawPropertyElements = themesElement.SelectNodes("child::param");

                foreach (XmlNode drawPropertyNode in drawPropertyElements)
                {
                    if (drawPropertyNode is XmlElement)
                    {
                        XmlElement drawPropertyElement = drawPropertyNode as XmlElement;

                        string variableName = drawPropertyElement.Attributes.GetNamedItem("variableName").Value;
                        string nameItem = drawPropertyElement.Attributes.GetNamedItem("name").Value;
                        string fontName = drawPropertyElement.Attributes.GetNamedItem("font").Value;
                        bool fontBold = Convert.ToBoolean(drawPropertyElement.Attributes.GetNamedItem("bold").Value);
                        float fontSize = Convert.ToSingle(drawPropertyElement.Attributes.GetNamedItem("size").Value);
                        Font font;
                        if (fontBold)
                            font = new Font(fontName, fontSize, FontStyle.Bold);
                        else
                            font = new Font(fontName, fontSize, FontStyle.Regular);
                        string[] backColorStr = drawPropertyElement.Attributes.GetNamedItem("backColor").Value.Split(';');
                        Color backColor;
                        if (string.Compare(backColorStr[0], "Custom", true) != 0)
                            backColor = Color.FromName(backColorStr[0]);
                        else
                            backColor = Color.FromArgb(Convert.ToInt32(backColorStr[1]), Convert.ToInt32(backColorStr[2]), Convert.ToInt32(backColorStr[3]));
                        string[] foreColorStr = drawPropertyElement.Attributes.GetNamedItem("foreColor").Value.Split(';');
                        Color foreColor;
                        if (string.Compare(foreColorStr[0], "Custom", true) != 0)
                            foreColor = Color.FromName(foreColorStr[0]);
                        else
                            foreColor = Color.FromArgb(Convert.ToInt32(foreColorStr[1]), Convert.ToInt32(foreColorStr[2]), Convert.ToInt32(foreColorStr[3]));

                        DrawProperty drawProperty = new DrawProperty(variableName, nameItem, font, backColor, foreColor);

                        values.Add(drawProperty);
                    }
                }
            }

            return null;
        }