1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Text;
|
---|
4 | using System.Diagnostics;
|
---|
5 |
|
---|
6 | namespace Netron.Diagramming.Core
|
---|
7 | {
|
---|
8 | // ----------------------------------------------------------------------
|
---|
9 | /// <summary>
|
---|
10 | /// Manages the collection of libraries.
|
---|
11 | /// </summary>
|
---|
12 | // ----------------------------------------------------------------------
|
---|
13 | public class LibraryManager
|
---|
14 | {
|
---|
15 | // ------------------------------------------------------------------
|
---|
16 | /// <summary>
|
---|
17 | /// The collection of shapes for this library.
|
---|
18 | /// </summary>
|
---|
19 | // ------------------------------------------------------------------
|
---|
20 | private CollectionBase<Library> myLibraries;
|
---|
21 |
|
---|
22 | // ------------------------------------------------------------------
|
---|
23 | /// <summary>
|
---|
24 | /// Gets the collection of all libraries.
|
---|
25 | /// </summary>
|
---|
26 | // ------------------------------------------------------------------
|
---|
27 | public CollectionBase<Library> Libraries
|
---|
28 | {
|
---|
29 | get
|
---|
30 | {
|
---|
31 | return myLibraries;
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | // ------------------------------------------------------------------
|
---|
36 | /// <summary>
|
---|
37 | /// Constructor.
|
---|
38 | /// </summary>
|
---|
39 | // ------------------------------------------------------------------
|
---|
40 | public LibraryManager()
|
---|
41 | {
|
---|
42 | myLibraries = new CollectionBase<Library>();
|
---|
43 | }
|
---|
44 |
|
---|
45 | // ------------------------------------------------------------------
|
---|
46 | /// <summary>
|
---|
47 | /// Creates a new instance of the shape that has the GUID specified.
|
---|
48 | /// </summary>
|
---|
49 | /// <param name="guid">string</param>
|
---|
50 | /// <returns>IShape</returns>
|
---|
51 | // ------------------------------------------------------------------
|
---|
52 | public IShape CreateNewInstance(string guid)
|
---|
53 | {
|
---|
54 | foreach (Library lib in myLibraries)
|
---|
55 | {
|
---|
56 | if (lib.ContainsShape(guid))
|
---|
57 | {
|
---|
58 | return lib.CreateNewInstance(guid);
|
---|
59 | }
|
---|
60 | }
|
---|
61 | return null;
|
---|
62 | }
|
---|
63 | }
|
---|
64 | }
|
---|