ImageEn, unit imageenview

TIELayerMoveSizeEvent


Declaration

TIELayerMoveSizeEvent = procedure(Sender: TObject; layer: integer; event: TIELayerEvent; var PosX, PosY, Width, Height: Double) of object;


Description

Value Description
layer The layer index that is moved or resized
event The event type (will be ielMoving, ielResizing or ielCreating)
PosX, PosY The new left and top position of the layer
Width, Height The new width and height of the layer


Examples

// Force all layers to be created at 200 x 200
procedure TfrmMain.ImageEnView1MoveSizeLayer(Sender: TObject; layer: integer; event: TIELayerEvent; var PosX, PosY, Width, Height: Double);
begin
  if event = ielCreating then
  begin
    Width  := 200;
    Height := 200;
  end;
end;


// Force all layers to be centered on the image horizon
procedure TfMain.ImageEnView1MoveSizeLayer(Sender: TObject; layer: integer; event: TIELayerEvent; var PosX, PosY, Width, Height: Double);
begin
  PosY := ( ImageEnView1.Layers[0].Height - Height ) / 2;
end;


// Allow line layers to be made longer (horizontally or vertically), but not sized
procedure TForm1.ImageEnView1LayerMoveSize(Sender: TObject; layer: Integer;
    event: TIELayerEvent; var PosX, PosY, Width, Height: Double);
var
  isHorz: Boolean;
begin
  if ( event = ielResizing ) and ( ImageEnView1.Layers[layer] is TIELineLayer ) then
  begin
    isHorz := ImageEnView1.Layers[layer].Width > ImageEnView1.Layers[layer].Height;
    if isHorz then
    begin
      PosY   := ImageEnView1.Layers[layer].PosY;
      Height := ImageEnView1.Layers[layer].Height
    end
    else
    begin
      PosX   := ImageEnView1.Layers[layer].PosX;
      Width  := ImageEnView1.Layers[layer].Width;
    end;
  end;
end;