ImageEn, unit imageenview

TImageEnView.OnLayerNotifyEx

TImageEnView.OnLayerNotifyEx


Declaration


property OnLayerNotifyEx: TIELayerNotify;


Description


Occurs whenever layer actions occur, e.g selecting, moving or resizing. This event only fires on user actions (not programatic 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.


Example


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

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

// 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);
begin
  if event in [ ielSelected, ielDeselected, ielMoved, ielResized, ielRotated, ielCreated, ielAction, ielEdited, ielEditedProps, ielEditedPoints, ielRemoved, ielArranged ] then
    RefreshLayerViewer();
end;


See Also


- OnLayerNotify
- OnLayerSelectionChange
- OnLayerMoveSize
- OnNewLayer