Masters are collections of diagram elements, which can be reused in multiple drawings. Masters are stored in libraries. Masters store all the needed information, which is required for the proper duplication of the elements they contain. Currently this includes:
-
Measurement Unit - the logical measurement unit associated with the elements of the master. Accessible from the MeasurementUnit property.
-
Connection Container - the connections between the elements in the master. Accessible from the ConnectionContainer property.
In order for masters to be displayed in library views, each master must provide three images:
-
List image - typically a 16x16 bitmap. Used to display the master in list view style.
-
Icon image - typically a 32x32 bitmap. Used to display the master in icons view style.
-
Thumbnail image - typically a 64x64 bitmap. Used to display the master in thumbnails view style.
If one of these images is not specified (which is the most common case) it will be automatically generated for the master, from an instance of the NMasterImageGenerator class, which is an attribute of every library.
You can easily create a master from any set of diagram elements. The following example creates a master, which contains a rectangle shape, measured in millimeters:
C# |
Copy Code
|
---|---|
NRectangleShape rect = new NRectangleShape(0, 0, 30, 30); NMaster master = new NMaster(rect, NGraphicsUnit.Millimeter, "My first master", "Drag me on the drawing"); library.AddChild(master); |
Visual Basic |
Copy Code
|
---|---|
Dim rect As New NRectangleShape(0, 0, 30, 30) Dim master As New NMaster(rect, NGraphicsUnit.Millimeter, "My first master", "Drag me on the drawing") library.AddChild(master) |