Profile Picture

How to assign own symbols and how to add shapes without user input

Posted By derHanz 14 Years Ago

How to assign own symbols and how to add shapes without user input

Author
Message
derHanz
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 3, Visits: 1
Forget my last post. 2 minutes more and I got it...

_nLibraryGroup.Document

Is the property I need.

Sorry for this.

derHanz
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 3, Visits: 1
Hallo,
thank you for your help. Now I have the problem, that I do not get access to the library itselfe.

_nLibraryGroup = _nLibraryBrowser.OpenLibraryGroup();

Gives me a library group, which is OK. But how can I get access the master shapes I created in this library by using the library group?

Thank you again.

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hi,

First of all - thank you for appreciating our efforts in diagramming!
Regarding your questions:

1) Adding shapes
The drawing is partitioned in layers. Of all layers in the diagram only one is active at a time and you will typically add shapes to the active layer. By default the drawing is created with a single layer which is at the same time the active one. You add shapes to the active layer like this:

drawing.ActiveLayer.AddChild(shape);

If you have a library, and you want to create a shape instance for a master contained in it you can use the NMaster CreateInstance method:

NMaster master = library.GetChildByName("My Shape") as NMaster;
master.CreateInstance(drawing.ActiveLayer, new NPointF(100, 100));

2) Attaching data to masters
A common misunderstanding is that the master contains only a single shapes - in fact it can contain several elements and even connected structures - so the master is in fact a drawing clipping. So when a master is dropped on a drawing it can actually create several shape instances in the drawing.

The best way to attach custom data to shapes contained in the library is to load the library and assign the Tag property of each shape that is contained within your master. If your library has only one shape per master - then you can use this code:

foreach (NMaster master in libraryDocument)
{
foreach (NDiagramElement element in master)
{
element.Name = master.Name;
element.Tag = "Shape of " + master.Name;
}
}

When the shape is dropped to the drawing its tag will remain the same (the name may be automatically changed if you drop for example two shapes named Car - the second will be automatically named Car_1).

3) More for tags

Since the diagram has no way of knowing what type of object you are assigning to the Tag property, the tag objects must obey to the following criterias:

a) have a default constructor
b) be marked as serialiable
c) implement the ICloneable interface

Hope this helps - questions or comments - please feel free...

Best Regards,
Nevron Support Team



derHanz
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 3, Visits: 1
Hallo,
I am evaluating your software to see if it matches our requirements and I must say, I am quite impressed. Two things are left I need to know:

We want that the user can create some kind of floor plans with the canvas and save it into a special interchange format based on XML. I allready created symbol libraries and saved them in a nxl file. If I create now a diagram with these symbols I have two problems:

1. How can I add a shape into the canvas? I tried nDrawingDocument.Add(myShape) but there is no Add Method.

2. How do I know which symbols the usere added to a canvas? I would like to attach a data container to the shapes class tag property before it is added to the canvas but first I need to know which type of symbol is added (is it a car, a tree or a dog?). I thought I can evaluate it by name but the name of my "Switch" symbole is allways "composite shape".

Thank you for your help.



Similar Topics


Reading This Topic