ImageEn, unit imageenview




property OnLayerNotifyEx: TIELayerNotify;


Occurs whenever layer actions occur, e.g selecting, moving or resizing. This event only fires on user actions (not programmatic changes).

OnLayerNotifyEx is the same as OnLayerNotify except that it returns extra events where the layer index may be invalid (for layers that are not yet created or have already been removed). For example, with the ielBeginCreating event, the layer index will be -1.
With OnLayerNotify, the layer index is guaranteed to be valid because it skips any events for invalid layers. For events that are returned by OnLayerNotify, the layer index will be the same as OnLayerNotifyEx.

Note: If you use the layer parameter, you must check that it a valid index, i.e. >=0 and LayersCount


Demo  Demos\LayerEditing\StampTextAndShapes\StampLayers.dpr


// Log all resizing of layers
procedure TfrmMain.IEView1LayerNotifyEx(Sender: TObject; layer: integer; event: TIELayerEvent);
  ALayer: TIELayer;
  i: Integer;
  sChangedLayers: string;
  if event = ielResized then
    sChangedLayers := '';
    for i := 0 to IEView1.LayersCount - 1 do
      ALayer := IEView1.Layers[ I ];
      if ( ALayer.Locked = False ) and ALayer.Selected then
        sChangedLayers := sChangedLayers + IntToStr( i ) +',';
    if sChangedLayers <> '' then
      SetLength( sChangedLayers, Length( sChangedLayers ) - 1 );  // Remove final comma
      memLog.Lines.Add( 'Layers Resized: ' + sChangedLayers );

// Auto-size text only after rotation
procedure TMainForm.ImageEnView1LayerNotifyEx(Sender: TObject; layer: Integer;
    event: TIELayerEvent);
  if ( ImageEnView1.Layers[ layer ] is TIETextLayer ) and ( event is ielRotated ) then
    TIETextLayer( ImageEnView1.Layers[ layer ]).SizeToText();

// Refresh layer viewer (see TImageEnMView.AssignLayers) for any events that change the layers list, or the way layers look
procedure TMainForm.ImageEnView1LayerNotifyEx(Sender: TObject; layer: Integer; event: TIELayerEvent);
  if event in [ ielSelected, ielDeselected, ielMoved, ielResized, ielRotated, ielCreated, ielMerged, ielGrouped, ielAction, ielEdited, ielEditedProps, ielEditedPoints, ielRemoved, ielArranged ] then

// Automatically merge added layers to the background (e.g. "Select to draw" shapes onto image)
procedure Tfmain.ImageEnView1LayerNotifyEx(Sender: TObject; layer: Integer; event: TIELayerEvent);
  if AutoMergeLayers and ( layer >= 0 ) and ( layer < ImageEnView1.LayersCount ) then  // Ensure it is a valid layer
    // For text layers with automatic text editing (loAutoTextEditing in LayerOptions) don't merge till we complete editing
    if (( ImageEnView1.Layers[layer].Kind = ielkText ) and ( event = ielEdited )) or
       (( ImageEnView1.Layers[layer].Kind <> ielkText ) and ( event = ielCreated )) then
      ImageEnView1.LayersMerge( 0, layer );

See Also