using System; using System.Diagnostics; using System.Drawing; using System.Runtime.Serialization; using System.Xml.Schema; using System.Xml.Serialization; namespace Netron.Diagramming.Core { /// /// Complementary partial class related to (de)serialization. /// [Serializable] public partial class Ambience : ISerializable, IXmlSerializable, IDeserializationCallback { //about xml serialization of color //http://dotnetified.com/PermaLink.aspx?guid=E86B447E-AA95-49B6-909F-CDA36ACF481F #region Deserialization constructor /// /// Deserialization constructor /// /// The info. /// The context. protected Ambience(SerializationInfo info, StreamingContext context) { if (Tracing.BinaryDeserializationSwitch.Enabled) Trace.WriteLine("Deserializing the fields of 'Ambience'."); double version = info.GetDouble("AmbienceVersion"); this.BackgroundColor = (Color)info.GetValue("BackgroundColor", typeof(Color)); this.PageColor = (Color)info.GetValue("PageBackgroundColor", typeof(Color)); } #endregion #region Serialization events /* [OnSerializing] void OnSerializing(StreamingContext context) { Trace.Indent(); Trace.WriteLine("Starting to serializing the 'Ambience' class..."); } [OnSerialized] void OnSerialized(StreamingContext context) { Trace.WriteLine("...serialization of 'Ambience' finished"); Trace.Unindent(); } */ #endregion #region Deserialization events /* [OnDeserializing] void OnDeserializing(StreamingContext context) { Trace.Indent(); Trace.WriteLine("Starting deserializing the 'Ambience' class..."); } [OnDeserialized] void OnDeserialized(StreamingContext context) { Trace.WriteLine("...deserialization of 'Ambience' finished"); Trace.Unindent(); } */ #endregion #region Serialization /// /// Populates a with the data needed to serialize the target object. /// /// The to populate with data. /// The destination (see ) for this serialization. /// The caller does not have the required permission. public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { if (Tracing.BinarySerializationSwitch.Enabled) Trace.WriteLine("Serializing the fields of 'Ambience'."); info.AddValue("AmbienceVersion", ambienceVersion); info.AddValue( "BackgroundColor", this.BackgroundColor, typeof(Color)); info.AddValue( "BackgroundType", BackgroundType, typeof(CanvasBackgroundTypes)); info.AddValue( "BackgroundGradientColor1", this.BackgroundGradientColor1, typeof(Color)); info.AddValue( "BackgroundGradientColor2", this.BackgroundGradientColor2, typeof(Color)); info.AddValue( "PageBackgroundColor", this.PageColor, typeof(Color)); info.AddValue( "PageBackgroundType", PageBackgroundType, typeof(CanvasBackgroundTypes)); info.AddValue( "PageBackgroundGradientColor1", this.PageGradientColor1, typeof(Color)); info.AddValue( "PageBackgroundGradientColor2", this.PageGradientColor2, typeof(Color)); } #endregion #region Xml serialization /// /// This property is reserved, apply the to the class instead. /// /// /// An that describes the XML representation of the object that is produced by the method and consumed by the method. /// public XmlSchema GetSchema() { throw new NotImplementedException("The method or operation is not implemented."); } /// /// Generates an object from its XML representation. /// /// The stream from which the object is deserialized. public void ReadXml(System.Xml.XmlReader reader) { throw new NotImplementedException("The method or operation is not implemented."); } /// /// Converts an object into its XML representation. /// /// The stream to which the object is serialized. public void WriteXml(System.Xml.XmlWriter writer) { throw new NotImplementedException("The method or operation is not implemented."); } #endregion #region IDeserializationCallback Members /// /// Runs when the entire object graph has been deserialized. /// /// The object that initiated the callback. The functionality for this parameter is not currently implemented. public void OnDeserialization(object sender) { if (Tracing.BinaryDeserializationSwitch.Enabled) Trace.WriteLine("IDeserializationCallback of 'Ambience' called."); } #endregion } }