ImageEn, unit imageenview

TIELayerNotify

TIELayerNotify


Declaration


TIELayerNotify = procedure(Sender: TObject; layer: integer; event: TIELayerEvent) of object;


Description


layer is the layer index that is affected. WARNING: layer may not be a valid index (-1 or removed)
event specifies the event type:
Value Description
ielSelected User selected the layer
ielMoved User moved the layer
ielResized User resized the layer
ielMoving User is moving the layer
ielResizing User is resizing the layer
ielRotating User is rotating the layer
ielRotated User rotated the layer
ielBeginResizing * User began to resize the layer (click down)
ielBeginRotating * User began to resize the layer (click down)
ielBeginMoving * User began to move the layer (click down)
ielDeselected User deselected the layer
ielEdited User edited the text of a layer
ielBeginCreating * Occurs as the user starts to create a layer using the mouse (dragging or clicking points). Layer index will be -1
ielCreating User is creating a layer using the mouse (dragging or clicking points)
ielCreated User had added a new layer
ielAction User has used an ImageEn Action that has changed the layers
ielLeftClicked User has clicked on a layer with the left mouse button (mouse up)
ielRightClicked User has clicked on a layer with the right mouse button (mouse up)
ielDblClicked User has double-clicked on a layer
ielMouseOver User has moved the cursor over a layer (Other than layer 0)
ielEditedPoints User has edited the points of a line or polyline layer
ielAddedPoint User has added a point to a polyline layer
ielMovedPoint User is moving a point of a line or polyline layer
ielArranged User is changing the arrangement of layers (e.g. bring a layer in front of another)
ielBeforeRemove * Occurs before a layer is deleted due to a user action
ielRemoved * User has deleted a layer
ielEditedProps User edited the properties of a layer, e.g. using the Layer Properties dialog
ielTextEditorClick User has clicked the mouse or keyboard in the text editor for a TIETextLayer or TIELineLayer
ielTextEditorChange User has changed the mouse or keyboard in the text editor for a TIETextLayer or TIELineLayer (called for every change. Use ielEdited to detect once editing has completed).

* Does not occur with OnLayerNotify

Notes:
- This event only occurs once for each change, even if multiple layers are selected. You should review the list of selected layers to determine which changed
- ielBeginCreating will return -1 as an index
- ielBeforeRemove may return layer as LYR_ALL_LAYERS or LYR_SELECTED_LAYERS
- ielRemoved will return an index for a layer that has been removed


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;