Beispiel #1
0
        /// <summary>
        /// Converts an object into its XML representation.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"/> stream to which the object is serialized. </param>
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement("BackStyle");
            BackStyle.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteStartElement("ClickStyle");
            ClickStyle.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteStartElement("HoverStyle");
            HoverStyle.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteStartElement("SelectedStyle");
            SelectedStyle.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteStartElement("DisabledStyle");
            DisabledStyle.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteStartElement("SelectedHoverStyle");
            SelectedHoverStyle.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteElementString("NormalBorder", PaintUtility.GetString(NormalBorder));
            writer.WriteElementString("HoverBorder", PaintUtility.GetString(HoverBorder));
            writer.WriteElementString("NormalForeGround", PaintUtility.GetString(NormalForeGround));
            writer.WriteElementString("SelectedBorder", PaintUtility.GetString(SelectedBorder));
            writer.WriteElementString("HoverForeGround", PaintUtility.GetString(HoverForeGround));

            writer.WriteStartElement("AppearenceText");
            AppearenceText.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteElementString("SelectedForeGround", PaintUtility.GetString(SelectedForeGround));
            writer.WriteElementString("DisabledBorder", PaintUtility.GetString(DisabledBorder));
            writer.WriteElementString("DisabledForeGround", PaintUtility.GetString(DisabledForeGround));

            writer.WriteElementString("Gradient", Gradient.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        public object Clone()
        {
            var app = new AppearanceItem();

            app.BackStyle.Assign((ColorPair)BackStyle.Clone());
            app.ClickStyle.Assign((ColorPair)ClickStyle.Clone());
            app.DisabledBorder     = DisabledBorder;
            app.DisabledForeGround = DisabledForeGround;
            app.DisabledStyle.Assign((ColorPair)DisabledStyle.Clone());
            app.Gradient        = Gradient;
            app.HoverBorder     = HoverBorder;
            app.HoverForeGround = HoverForeGround;
            app.HoverStyle.Assign((ColorPair)HoverStyle.Clone());
            app.NormalBorder       = NormalBorder;
            app.NormalForeGround   = NormalForeGround;
            app.SelectedBorder     = SelectedBorder;
            app.SelectedForeGround = SelectedForeGround;
            app.SelectedHoverStyle.Assign((ColorPair)SelectedHoverStyle.Clone());
            app.SelectedStyle.Assign((ColorPair)SelectedStyle.Clone());
            app.AppearenceText.Assign((AppearenceText)AppearenceText.Clone());
            return(app);
        }
Beispiel #3
0
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the object is deserialized. </param>
        public void ReadXml(XmlReader reader)
        {
            var doc = new XmlDocument();

            doc.Load(reader);

            if (doc.GetElementsByTagName("BackStyle").Count > 0)
            {
                var xml = "<ColorPair>" + doc.GetElementsByTagName("BackStyle")[0].InnerXml + "</ColorPair>";
                BackStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null));
            }
            if (doc.GetElementsByTagName("ClickStyle").Count > 0)
            {
                var xml = "<ColorPair>" + doc.GetElementsByTagName("ClickStyle")[0].InnerXml + "</ColorPair>";
                ClickStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null));
            }
            if (doc.GetElementsByTagName("HoverStyle").Count > 0)
            {
                var xml = "<ColorPair>" + doc.GetElementsByTagName("HoverStyle")[0].InnerXml + "</ColorPair>";
                HoverStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null));
            }
            if (doc.GetElementsByTagName("SelectedStyle").Count > 0)
            {
                var xml = "<ColorPair>" + doc.GetElementsByTagName("SelectedStyle")[0].InnerXml + "</ColorPair>";
                SelectedStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null));
            }
            if (doc.GetElementsByTagName("DisabledStyle").Count > 0)
            {
                var xml = "<ColorPair>" + doc.GetElementsByTagName("DisabledStyle")[0].InnerXml + "</ColorPair>";
                DisabledStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null));
            }
            if (doc.GetElementsByTagName("SelectedHoverStyle").Count > 0)
            {
                var xml = "<ColorPair>" + doc.GetElementsByTagName("SelectedHoverStyle")[0].InnerXml + "</ColorPair>";
                SelectedHoverStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null));
            }


            if (doc.GetElementsByTagName("NormalBorder").Count > 0)
            {
                NormalBorder = PaintUtility.GetColor(doc.GetElementsByTagName("NormalBorder")[0].InnerText);
            }
            if (doc.GetElementsByTagName("HoverBorder").Count > 0)
            {
                HoverBorder = PaintUtility.GetColor(doc.GetElementsByTagName("HoverBorder")[0].InnerText);
            }
            if (doc.GetElementsByTagName("SelectedBorder").Count > 0)
            {
                SelectedBorder = PaintUtility.GetColor(doc.GetElementsByTagName("SelectedBorder")[0].InnerText);
            }
            if (doc.GetElementsByTagName("NormalForeGround").Count > 0)
            {
                NormalForeGround = PaintUtility.GetColor(doc.GetElementsByTagName("NormalForeGround")[0].InnerText);
            }
            if (doc.GetElementsByTagName("HoverForeGround").Count > 0)
            {
                HoverForeGround = PaintUtility.GetColor(doc.GetElementsByTagName("HoverForeGround")[0].InnerText);
            }

            if (doc.GetElementsByTagName("AppearenceText").Count > 0)
            {
                var xml = "<AppearenceText>" + doc.GetElementsByTagName("AppearenceText")[0].InnerXml +
                          "</AppearenceText>";
                AppearenceText.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null));
            }

            if (doc.GetElementsByTagName("SelectedForeGround").Count > 0)
            {
                SelectedForeGround = PaintUtility.GetColor(doc.GetElementsByTagName("SelectedForeGround")[0].InnerText);
            }
            if (doc.GetElementsByTagName("DisabledBorder").Count > 0)
            {
                DisabledBorder = PaintUtility.GetColor(doc.GetElementsByTagName("DisabledBorder")[0].InnerText);
            }
            if (doc.GetElementsByTagName("DisabledForeGround").Count > 0)
            {
                DisabledForeGround = PaintUtility.GetColor(doc.GetElementsByTagName("DisabledForeGround")[0].InnerText);
            }
            if (doc.GetElementsByTagName("Gradient").Count > 0)
            {
                Gradient = Convert.ToInt32(doc.GetElementsByTagName("Gradient")[0].InnerText);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Indicates wether <see cref="DisabledStyle"/> needs to be serialized by designer or not.
 /// </summary>
 /// <returns>true if designer needs to serialize</returns>
 protected virtual bool ShouldSerializeDisabledStyle()
 {
     return(DisabledStyle.DefaultChanged());
 }