I made a small demo that shows how to create a line layer with TImageEnVect. Each time you click on the TImageEnVect a new line layer is created if the AddLine button is down. If the AddLine button is not down each time you select a layer the properties of the line layer is obtained and the color controls and the line layer height is set to the properties of the selected layer.
This demo does not include rotating the line layer but you should be able to easily add that function.
Here is the code:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, hyieutils, iexBitmaps, hyiedefs, iesettings, iexLayers, iexRulers, ieview,
imageenview, ievect, Vcl.Buttons, Vcl.ExtCtrls, Vcl.ComCtrls, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
AddLine1: TSpeedButton;
ImageEnVect1: TImageEnVect;
Label1: TLabel;
LineLayerBorderColor1: TColorBox;
Label2: TLabel;
LineLayerFillColor1: TColorBox;
Label3: TLabel;
LineLayerGradientFillColor1: TColorBox;
Label4: TLabel;
LineLayerBorderWidth1: TEdit;
UpDown1: TUpDown;
procedure ImageEnVect1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure AddLine1Click(Sender: TObject);
procedure LineLayerBorderColor1Click(Sender: TObject);
procedure LineLayerFillColor1Click(Sender: TObject);
procedure LineLayerGradientFillColor1Click(Sender: TObject);
procedure LineLayerBorderWidth1Change(Sender: TObject);
private
{ Private declarations }
procedure GetLineLayerParameters;
procedure SetLineLayerParameters;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.AddLine1Click(Sender: TObject);
begin
if AddLine1.Down then
ImageEnVect1.MouseInteract := ImageEnVect1.MouseInteract + [miMoveLayers, miResizeLayers]
else
ImageEnVect1.MouseInteract := [miMoveLayers, miResizeLayers];
end;
procedure TForm1.GetLineLayerParameters;
begin
if (ImageEnVect1.CurrentLayer is TIELineLayer) then
begin
LineLayerBorderColor1.Selected := TIELineLayer(ImageEnVect1.CurrentLayer).BorderColor;
LineLayerFillColor1.Selected := TIELineLayer(ImageEnVect1.CurrentLayer).FillColor;
LineLayerGradientFillColor1.Selected := TIELineLayer(ImageEnVect1.CurrentLayer).FillColor2;
LineLayerBorderWidth1.Text := IntToStr(TIELineLayer(ImageEnVect1.CurrentLayer).BorderWidth);
end;
end;
procedure TForm1.SetLineLayerParameters;
begin
if (ImageEnVect1.CurrentLayer is TIELineLayer) then
begin
TIELineLayer(ImageEnVect1.CurrentLayer).BorderColor := LineLayerBorderColor1.Selected;
TIELineLayer(ImageEnVect1.CurrentLayer).FillColor := LineLayerFillColor1.Selected;
TIELineLayer(ImageEnVect1.CurrentLayer).FillColor2 := LineLayerGradientFillColor1.Selected;
TIELineLayer(ImageEnVect1.CurrentLayer).BorderWidth := StrToInt(LineLayerBorderWidth1.Text);
ImageEnVect1.Layers[ImageEnVect1.LayersCurrent].Height := StrToInt(LineLayerBorderWidth1.Text);
ImageEnVect1.Update;
ImageEnVect1.IEBitmap.Modified := True;
end;
end;
procedure TForm1.ImageEnVect1LayerNotify(Sender: TObject; layer: Integer; event: TIELayerEvent);
begin
if (ImageEnVect1.CurrentLayer is TIELineLayer) then
GetLineLayerParameters;
end;
procedure TForm1.ImageEnVect1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
iLayer: Integer;
begin
if (AddLine1.Down) and (ImageEnVect1.MouseCapture) then
begin
Screen.Cursor := crHourglass;
try
iLayer := ImageEnVect1.LayersAdd(ielkLine);
ImageEnVect1.Layers[iLayer].Name := 'Line Layer';
ImageEnVect1.Layers[iLayer].PosX := X;
ImageEnVect1.Layers[iLayer].PosY := Y;
ImageEnVect1.Layers[iLayer].Height := StrToInt(LineLayerBorderWidth1.Text);
ImageEnVect1.Layers[iLayer].Selectable := True;
SetLineLayerParameters;
ImageEnVect1.IEBitmap.Modified := True;
finally
Screen.Cursor := crDefault;
end;
end
else
begin
if (ImageEnVect1.CurrentLayer is TIELineLayer) then
GetLineLayerParameters;
end;
end;
procedure TForm1.LineLayerBorderColor1Click(Sender: TObject);
begin
SetLineLayerParameters;
end;
procedure TForm1.LineLayerBorderWidth1Change(Sender: TObject);
begin
SetLineLayerParameters;
end;
procedure TForm1.LineLayerFillColor1Click(Sender: TObject);
begin
SetLineLayerParameters;
end;
procedure TForm1.LineLayerGradientFillColor1Click(Sender: TObject);
begin
SetLineLayerParameters;
end;
end.
Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development