Hello Stefan,
In general, entity selection may be visual and non-visual.
CADImage.SelectedEntities collection is intended for managing the list of selected entities, regardless of the selection type. The SelectedEntities collection itself doesn't implement visual selection, it is supported through a
CADImport.Professional.Marker class. The Marker object represents a yellow square drawn at some point on the selected CADEntity.
Markers can be created with the following code:
Code: Select all
using CADImport.Professional;
...
Marker marker1 = new Marker(ent, 0, 0, ent.Box.TopLeft);
Marker marker2 = new Marker(ent, 0, 1, ent.Box.BottomRight);
where
ent is one of CADEntity objects in the SelectedEntities collection.
Normally you need to create multiple markers for a single entity, so it would be better to combine them in a CADCollection:
Code: Select all
private CADCollection<Marker> markers;
...
markers = new CADCollection<Marker>();
...
markers.Add(marker1);
markers.Add(marker2);
Once you have the markers collection, you can easily draw them on the
Graphics object associated with a certain drawing surface (for example, the Graphics object associated with a
CADPictureBox control) using a
Marker.Paint() method. The simplest way to get the Graphics object associated with a form or control is to use the
Paint event handler and
PaintEventArgs.Graphics property:
Code: Select all
cadPictureBox.Paint += CADPictureBox_Paint;
...
private void CADPictureBox_Paint(object sender, PaintEventArgs e)
{
if ((cadImage != null) && (markers != null))
{
markers.ForEach(marker => marker.Paint(e.Graphics, cadImage));
}
}
Mikhail