1 | //To localize the descriptions see http://groups.google.be/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/3bb6895b49d7cbe/e3241b7fa085ba90?lnk=st&q=csharp+attribute+resource+file&rnum=4#e3241b7fa085ba90
|
---|
2 | namespace Netron.Diagramming.Core {
|
---|
3 | // ----------------------------------------------------------------------
|
---|
4 | /// <summary>
|
---|
5 | /// The document class represents the root of the controls' data
|
---|
6 | /// hierarchy. The document is the root of the serialization graph and
|
---|
7 | /// contains both the data of the diagram(s) and the metadata (or user
|
---|
8 | /// information).
|
---|
9 | /// </summary>
|
---|
10 | // ----------------------------------------------------------------------
|
---|
11 | public partial class Document : IVersion {
|
---|
12 | #region Fields
|
---|
13 |
|
---|
14 | // ------------------------------------------------------------------
|
---|
15 | /// <summary>
|
---|
16 | /// Implementation of IVersion - the current version of
|
---|
17 | /// Document.
|
---|
18 | /// </summary>
|
---|
19 | // ------------------------------------------------------------------
|
---|
20 | protected const double documentVersion = 1.0;
|
---|
21 |
|
---|
22 | // ------------------------------------------------------------------
|
---|
23 | /// <summary>
|
---|
24 | /// Pointer to the model.
|
---|
25 | /// </summary>
|
---|
26 | // ------------------------------------------------------------------
|
---|
27 | protected IModel mModel;
|
---|
28 |
|
---|
29 | // ------------------------------------------------------------------
|
---|
30 | /// <summary>
|
---|
31 | /// The Information field.
|
---|
32 | /// </summary>
|
---|
33 | // ------------------------------------------------------------------
|
---|
34 | protected DocumentInformation mInformation;
|
---|
35 |
|
---|
36 | #endregion
|
---|
37 |
|
---|
38 | #region Properties
|
---|
39 |
|
---|
40 | // ------------------------------------------------------------------
|
---|
41 | /// <summary>
|
---|
42 | /// Gets the current version.
|
---|
43 | /// </summary>
|
---|
44 | // ------------------------------------------------------------------
|
---|
45 | public virtual double Version {
|
---|
46 | get {
|
---|
47 | return documentVersion;
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | /// <summary>
|
---|
52 | /// Gets or sets the Information
|
---|
53 | /// </summary>
|
---|
54 | public DocumentInformation Information {
|
---|
55 | get {
|
---|
56 | return mInformation;
|
---|
57 | }
|
---|
58 | set {
|
---|
59 | mInformation = value;
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | /// <summary>
|
---|
65 | /// Gets the model.
|
---|
66 | /// </summary>
|
---|
67 | /// <value>The model.</value>
|
---|
68 | public IModel Model {
|
---|
69 | get {
|
---|
70 | return mModel;
|
---|
71 | }
|
---|
72 | }
|
---|
73 |
|
---|
74 | #endregion
|
---|
75 |
|
---|
76 | #region Constructor
|
---|
77 | ///<summary>
|
---|
78 | ///Default constructor. Creates a new document and, hence, a new model with one default page and one default layer.
|
---|
79 | ///</summary>
|
---|
80 | public Document() {
|
---|
81 | mModel = new Model();
|
---|
82 | mInformation = new DocumentInformation();
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | #endregion
|
---|
87 |
|
---|
88 | #region Methods
|
---|
89 |
|
---|
90 | // ------------------------------------------------------------------
|
---|
91 | /// <summary>
|
---|
92 | /// Loops through all pages and returns ALL entities that belong to
|
---|
93 | /// this Document.
|
---|
94 | /// </summary>
|
---|
95 | /// <returns>CollectionBase</returns>
|
---|
96 | // ------------------------------------------------------------------
|
---|
97 | public CollectionBase<IDiagramEntity> GetAllEntities() {
|
---|
98 | CollectionBase<IDiagramEntity> entities =
|
---|
99 | new CollectionBase<IDiagramEntity>();
|
---|
100 | foreach (IPage page in this.mModel.Pages) {
|
---|
101 | foreach (ILayer layer in page.Layers) {
|
---|
102 | entities.AddRange(layer.Entities);
|
---|
103 | }
|
---|
104 | }
|
---|
105 | return entities;
|
---|
106 | }
|
---|
107 |
|
---|
108 | #endregion
|
---|
109 |
|
---|
110 | }
|
---|
111 | }
|
---|