1 | using System;
|
---|
2 | using System.Diagnostics;
|
---|
3 | using System.Drawing;
|
---|
4 | using System.Runtime.Serialization;
|
---|
5 | namespace Netron.GraphLib.IO.Binary
|
---|
6 | {
|
---|
7 | /// <summary>
|
---|
8 | /// Encapsulates the GraphAbstract and additional ambient properties of the GraphControl
|
---|
9 | /// for binary (de)serialization.
|
---|
10 | /// </summary>
|
---|
11 | [Serializable] class BinaryCapsule : ISerializable
|
---|
12 | {
|
---|
13 | #region Fields
|
---|
14 | /// <summary>
|
---|
15 | /// the actual diagram
|
---|
16 | /// </summary>
|
---|
17 | private GraphAbstract mGraphAbstract;
|
---|
18 | /// <summary>
|
---|
19 | /// the ambiant properties
|
---|
20 | /// </summary>
|
---|
21 | private BinaryAmbiance mBinaryAmbiance;
|
---|
22 | /// <summary>
|
---|
23 | /// the thumbnail
|
---|
24 | /// </summary>
|
---|
25 | private Image mThumbnail;
|
---|
26 | #endregion
|
---|
27 |
|
---|
28 | #region Properties
|
---|
29 |
|
---|
30 | /// <summary>
|
---|
31 | /// Gets or sets the thumbnail of the diagram
|
---|
32 | /// </summary>
|
---|
33 | public Image Thumbnail
|
---|
34 | {
|
---|
35 | get{return mThumbnail;}
|
---|
36 | set{mThumbnail = value;}
|
---|
37 | }
|
---|
38 | /// <summary>
|
---|
39 | /// Gets or sets the GraphAbstract
|
---|
40 | /// </summary>
|
---|
41 | public GraphAbstract Abstract
|
---|
42 | {
|
---|
43 | get{return mGraphAbstract;}
|
---|
44 | set{mGraphAbstract = value;}
|
---|
45 | }
|
---|
46 | /// <summary>
|
---|
47 | /// Gets or sets the ambiance properties
|
---|
48 | /// </summary>
|
---|
49 | public BinaryAmbiance Ambiance
|
---|
50 | {
|
---|
51 | get{return mBinaryAmbiance;}
|
---|
52 | set{mBinaryAmbiance = value;}
|
---|
53 | }
|
---|
54 | #endregion
|
---|
55 |
|
---|
56 | #region Constructor
|
---|
57 | /// <summary>
|
---|
58 | /// Default Constructor
|
---|
59 | /// </summary>
|
---|
60 | public BinaryCapsule()
|
---|
61 | {
|
---|
62 |
|
---|
63 | }
|
---|
64 | protected BinaryCapsule(SerializationInfo info, StreamingContext context) |
---|
65 | {
|
---|
66 | try
|
---|
67 | {
|
---|
68 | this.mBinaryAmbiance = info.GetValue("mBinaryAmbiance", typeof(BinaryAmbiance)) as BinaryAmbiance;
|
---|
69 | }
|
---|
70 | catch(Exception exc)
|
---|
71 | {
|
---|
72 | Trace.WriteLine(exc.Message, "BinaryCapsule.DeserializationConstructor");
|
---|
73 | //trying to recover the old binaries
|
---|
74 | this.mBinaryAmbiance = info.GetValue("mBinaryAmbience", typeof(BinaryAmbiance)) as BinaryAmbiance;
|
---|
75 | }
|
---|
76 | this.mGraphAbstract = info.GetValue("mGraphAbstract", typeof(GraphAbstract)) as GraphAbstract;
|
---|
77 | this.mThumbnail = info.GetValue("mThumbnail", typeof(Image)) as Image;
|
---|
78 | }
|
---|
79 | /// <summary>
|
---|
80 | /// Constructor
|
---|
81 | /// </summary>
|
---|
82 | /// <param name="graphAbstract"></param>
|
---|
83 | /// <param name="ambiance"></param>
|
---|
84 | public BinaryCapsule(GraphAbstract graphAbstract, BinaryAmbiance ambiance)
|
---|
85 | {
|
---|
86 | this.mGraphAbstract = graphAbstract;
|
---|
87 | this.mBinaryAmbiance = ambiance;
|
---|
88 | }
|
---|
89 | #endregion
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 | public void GetObjectData(SerializationInfo info, StreamingContext context)
|
---|
94 | {
|
---|
95 | info.AddValue("mGraphAbstract",this.mGraphAbstract);
|
---|
96 | info.AddValue("mBinaryAmbiance", this.mBinaryAmbiance);
|
---|
97 | info.AddValue("mThumbnail", this.mThumbnail);
|
---|
98 |
|
---|
99 | }
|
---|
100 |
|
---|
101 | }
|
---|
102 | }
|
---|