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 FolderMaterial : ISerializable, IXmlSerializable, IDeserializationCallback { #region Deserialization constructor /// /// Deserialization constructor /// /// The info. /// The context. protected FolderMaterial(SerializationInfo info, StreamingContext context) { if (Tracing.BinaryDeserializationSwitch.Enabled) Trace.WriteLine("Deserializing the fields of 'FolderMaterial'."); double version = info.GetDouble("FolderMaterialVersion"); this.Gliding = info.GetBoolean("Gliding"); this.Resizable = info.GetBoolean("Resizable"); this.Visible = info.GetBoolean("Visible"); header = info.GetValue("Header", typeof(ClickableLabelMaterial)) as ClickableLabelMaterial; plusminus = info.GetValue("PlusMinus", typeof(SwitchIconMaterial)) as SwitchIconMaterial; mEntries = info.GetValue("Entries", typeof(CollectionBase)) as CollectionBase; mEntries.OnItemAdded += new EventHandler>(mEntries_OnItemAdded); Rectangle = (Rectangle)info.GetValue("Rectangle", typeof(Rectangle)); mCollapsed = info.GetBoolean("Collapsed"); } #endregion #region Serialization events /* [OnSerializing] void OnSerializing(StreamingContext context) { Trace.Indent(); Trace.WriteLine("Starting to serializing the 'FolderMaterial' class..."); } [OnSerialized] void OnSerialized(StreamingContext context) { Trace.WriteLine("...serialization of 'FolderMaterial' finished"); Trace.Unindent(); } */ #endregion #region Deserialization events /* [OnDeserializing] void OnDeserializing(StreamingContext context) { Trace.Indent(); Trace.WriteLine("IDeserializationCallback of 'FolderMaterial' called."); } * */ [OnDeserialized] void OnDeserialized(StreamingContext context) { if (Tracing.BinaryDeserializationSwitch.Enabled) Trace.WriteLine("...deserialization of 'FolderMaterial' finished"); foreach (IShapeMaterial material in mEntries) { material.Shape = this.Shape; } plusminus.OnExpand += new EventHandler(plusminus_OnExpand); plusminus.OnCollapse += new EventHandler(plusminus_OnCollapse); plusminus.Collapsed = mCollapsed;//this will call the Expand/Collapse of the folder via the event in the lines above Transform(Rectangle); } #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 override void GetObjectData(SerializationInfo info, StreamingContext context) { if (Tracing.BinarySerializationSwitch.Enabled) Trace.WriteLine("Serializing the fields of 'FolderMaterial'."); base.GetObjectData(info, context); info.AddValue("FolderMaterialVersion", folderMaterialVersion); info.AddValue("Header", this.header, typeof(ClickableLabelMaterial)); info.AddValue("PlusMinus", this.plusminus, typeof(SwitchIconMaterial)); info.AddValue("Entries", this.mEntries, typeof(CollectionBase)); info.AddValue("Collapsed", mCollapsed); } #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 override 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 override 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 override void WriteXml(System.Xml.XmlWriter writer) { throw new NotImplementedException("The method or operation is not implemented."); } #endregion /// /// 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 override void OnDeserialization(object sender) { base.OnDeserialization(sender); if (Tracing.BinaryDeserializationSwitch.Enabled) Trace.WriteLine("IDeserializationCallback of 'FolderMaterial' called."); } } }