Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Serialization/TextStyle.Serialization.cs @ 4068

Last change on this file since 4068 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 6.8 KB
Line 
1using System;
2using System.Diagnostics;
3using System.Drawing;
4using System.Runtime.Serialization;
5using System.Xml.Schema;
6using System.Xml.Serialization;
7using ToolBox.Formatting;
8
9
10namespace Netron.Diagramming.Core {
11  [Serializable]
12  public partial class TextStyle :
13     ISerializable,
14     IXmlSerializable,
15     IDeserializationCallback {
16    #region Deserialization constructor
17
18    // ------------------------------------------------------------------
19    /// <summary>
20    /// Deserialization constructor
21    /// </summary>
22    /// <param name="info">The info.</param>
23    /// <param name="context">The context.</param>
24    // ------------------------------------------------------------------
25    protected TextStyle(
26        SerializationInfo info,
27        StreamingContext context) {
28      if (Tracing.BinaryDeserializationSwitch.Enabled) {
29        Trace.WriteLine("Deserializing the fields of 'TextStyle'.");
30      }
31
32      double version = info.GetDouble("TextStyleVersion");
33
34      mDecimalPlaces = info.GetInt32("DecimalPlaces");
35
36      mTextFormat = (TextFormat)info.GetValue(
37          "TextFormat",
38          typeof(TextFormat));
39
40      mFont = (Font)info.GetValue(
41          "Font",
42          typeof(Font));
43
44      mFontColor = (Color)info.GetValue(
45          "FontColor",
46          typeof(Color));
47
48      mHorizontalAlignment = (StringAlignment)info.GetValue(
49          "HorizontalAlignment",
50          typeof(StringAlignment));
51
52      mVerticalAlignment = (StringAlignment)info.GetValue(
53          "VerticalAlignment",
54          typeof(StringAlignment));
55    }
56
57    #endregion
58
59    #region Serialization events
60    /*
61        [OnSerializing]
62        void OnSerializing(StreamingContext context)
63        {
64            Trace.WriteLine("Starting to serializing the 'PenStyle' class...");
65        }
66        [OnSerialized]
67        void OnSerialized(StreamingContext context)
68        {
69            Trace.WriteLine("...serialization of 'PenStyle' finished");
70        }
71        */
72    #endregion
73
74    #region Deserialization events
75    /*
76        [OnDeserializing]
77        void OnDeserializing(StreamingContext context)
78        {
79            Trace.Indent();
80            Trace.WriteLine("Starting deserializing the 'PenStyle' class...");
81        }
82        [OnDeserialized]
83        void OnDeserialized(StreamingContext context)
84         {
85             Trace.WriteLine("...deserialization of 'PenStyle' finished");
86             Trace.Unindent();
87        }
88       */
89    #endregion
90
91    #region Serialization
92    /// <summary>
93    /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> with the data needed to serialize the target object.
94    /// </summary>
95    /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> to populate with data.</param>
96    /// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"></see>) for this serialization.</param>
97    /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
98    public virtual void GetObjectData(SerializationInfo info, StreamingContext context) {
99      if (Tracing.BinarySerializationSwitch.Enabled)
100        Trace.WriteLine("Serializing the fields of 'PenStyle'.");
101
102      info.AddValue("TextStyleVersion", textStyleVersion);
103
104      info.AddValue("DecimalPlaces", this.mDecimalPlaces, typeof(int));
105
106      info.AddValue("TextFormat", this.mTextFormat, typeof(TextFormat));
107
108      // Note: we do not have to serialize the font style (i.e. IsBold,
109      // IsUnderline, etc.) because that's included in the font.
110      info.AddValue("Font", this.mFont, typeof(Font));
111
112      info.AddValue("FontColor", this.mFontColor, typeof(Color));
113
114      info.AddValue(
115          "HorizontalAlignment",
116          this.mHorizontalAlignment,
117          typeof(StringAlignment));
118
119      info.AddValue(
120          "VerticalAlignment",
121          this.mVerticalAlignment,
122          typeof(StringAlignment));
123    }
124    #endregion
125
126    #region Xml serialization
127
128    // ------------------------------------------------------------------
129    /// <summary>
130    /// This property is reserved, apply the
131    /// <see cref="T:System.Xml.Serialization.XmlSchemaProviderAttribute">
132    /// </see> to the class instead.
133    /// </summary>
134    /// <returns>
135    /// An <see cref="T:System.Xml.Schema.XmlSchema"></see> that describes
136    /// the XML representation of the object that is produced by the
137    /// <see cref="M:System.Xml.Serialization.IXmlSerializable.WriteXml(
138    /// System.Xml.XmlWriter)"></see> method and consumed by the
139    /// <see cref="M:System.Xml.Serialization.IXmlSerializable.ReadXml(
140    /// System.Xml.XmlReader)"></see> method.
141    /// </returns>
142    // ------------------------------------------------------------------
143    public virtual XmlSchema GetSchema() {
144      throw new NotImplementedException(
145          "The method or operation is not implemented.");
146    }
147
148    // ------------------------------------------------------------------
149    /// <summary>
150    /// Generates an object from its XML representation.
151    /// </summary>
152    /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see>
153    /// stream from which the object is deserialized.</param>
154    // ------------------------------------------------------------------
155    public virtual void ReadXml(System.Xml.XmlReader reader) {
156      throw new NotImplementedException(
157          "The method or operation is not implemented.");
158    }
159
160    // ------------------------------------------------------------------
161    /// <summary>
162    /// Converts an object into its XML representation.
163    /// </summary>
164    /// <param name="writer">The <see cref="T:System.Xml.XmlWriter">
165    /// </see> stream to which the object is serialized.</param>
166    // ------------------------------------------------------------------
167    public virtual void WriteXml(System.Xml.XmlWriter writer) {
168      throw new NotImplementedException(
169          "The method or operation is not implemented.");
170    }
171    #endregion
172
173    // ------------------------------------------------------------------
174    /// <summary>
175    /// Runs when the entire object graph has been deserialized.
176    /// </summary>
177    /// <param name="sender">The object that initiated the callback. The
178    /// functionality for this parameter is not currently implemented.
179    /// </param>
180    // ------------------------------------------------------------------
181    public virtual void OnDeserialization(object sender) {
182      if (Tracing.BinaryDeserializationSwitch.Enabled) {
183        Trace.WriteLine(
184            "IDeserializationCallback of 'PenStyle' called.");
185      }
186    }
187  }
188}
Note: See TracBrowser for help on using the repository browser.