ImageEn, unit imageenview |
|
TImageEnView.OnNewLayer
Declaration
property OnNewLayer: TIENewLayerEvent;
Description
Occurs whenever a layer is added. It is useful to assign default properties to the layer.
Both programmatic methods (e.g. using
LayersAdd) and user methods (e.g.
using mlCreateShapeLayers) trigger this event.
LayerIdx is the index of the new layer.
LayerKind is the kind of layer that was added.
Note:
◼CurrentLayer will represent the new layer
◼You can also use
LayerDefaults to assign properties to new layers
◼To capture the new layer after user has completed sizing and positioning it, use the
OnLayerNotifyEx event
◼Unlike ielNewLayer of the
OnLayerNotifyEx event, OnNewLayer is called even for layers added programmatically
| Demos\LayerEditing\StampTextAndShapes\StampLayers.dpr |
procedure Tfmain.ImageEnView1NewLayer(Sender: TObject; LayerIdx: Integer; LayerKind: TIELayerKind);
begin
// Assign default properties for new objects
case LayerKind of
ielkImage : TIEImageLayer( ImageEnView1.CurrentLayer ).AspectRatioLocked := True;
ielkPolyline : if mlCreatePolylineLayers in ImageEnView1.MouseInteractLayers then // This ensures we don't fill the points when drawing our own polyline using miClickCreatePolylineLayer
TIEPolylineLayer( ImageEnView1.CurrentLayer ).SetPoints( iesExplosion, True );
ielkText : TIETextLayer( ImageEnView1.CurrentLayer ).Text := 'Double-click to edit text';
end;
end;
// Make new shape layer a red star
procedure TfrmMain.ImageEnView1NewLayer(Sender: TObject; LayerIdx: integer; LayerKind: TIELayerKind);
begin
if LayerKind = ielkShape then
begin
TIEShapeLayer( ImageEnView1.CurrentLayer ).Shape := iesStar5;
TIEShapeLayer( ImageEnView1.CurrentLayer ).FillColor := clRed;
end;
end;
// Use a default icon for image layers
procedure TfrmMain.ImageEnView1NewLayer(Sender: TObject; LayerIdx: integer; LayerKind: TIELayerKind);
begin
if LayerKind = ielkImage then
TIEImageLayer( ImageEnView1.CurrentLayer ).Bitmap.LoadFromFile( 'd:\MyIcon.ico' );
end;
See Also
◼OnLayerMoveSize
◼OnLayerNotifyEx
◼OnLayerSelectionChange
◼LayerDefaults