unit thumbnail;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, IMAGETHUMBNAILCPLib_TLB;

type
  TForm1 = class(TForm)
    BtnAddFile: TButton;
    BtnBgColor: TButton;
    BtnClipColor: TButton;
    BtnHighlight: TButton;
    BtnBorder: TButton;
    BtnShadow: TButton;
    BtnText: TButton;
    BtnUpdate: TButton;
    BtnACDSee: TButton;
    BtnNormal: TButton;
    chkClipFont: TCheckBox;
    ClipFontItalic: TCheckBox;
    OpenDialog1: TOpenDialog;
    ColorDialog1: TColorDialog;
    Label1: TLabel;
    txtcurIndex: TEdit;
    Label2: TLabel;
    txtTopMargin: TEdit;
    Label3: TLabel;
    txtBottomMargin: TEdit;
    BtnMargin: TButton;
    Label4: TLabel;
    txtfilename: TEdit;
    Label5: TLabel;
    txtFontSize: TEdit;
    BtnFontSize: TButton;
    Label6: TLabel;
    txtFontTop: TEdit;
    BtnFontTop: TButton;
    ChkClipunder: TCheckBox;
    Label7: TLabel;
    txtWidth: TEdit;
    Label8: TLabel;
    txtHeight: TEdit;
    BtnWidthHeight: TButton;
    BtnDelAll: TButton;
    BtnDelSel: TButton;
    BtnDisplay: TButton;
    Label9: TLabel;
    ImageThumbnailCP1: TImageThumbnailCP;
    procedure BtnAddFileClick(Sender: TObject);
    procedure BtnBgColorClick(Sender: TObject);
    procedure BtnClipColorClick(Sender: TObject);
    procedure BtnHighlightClick(Sender: TObject);
    procedure BtnBorderClick(Sender: TObject);
    procedure BtnShadowClick(Sender: TObject);
    procedure BtnTextClick(Sender: TObject);
    procedure BtnUpdateClick(Sender: TObject);
    procedure BtnACDSeeClick(Sender: TObject);
    procedure BtnNormalClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure chkClipFontClick(Sender: TObject);
    procedure ClipFontItalicClick(Sender: TObject);
    procedure ChkClipunderClick(Sender: TObject);
    procedure BtnDelAllClick(Sender: TObject);
    procedure BtnDelSelClick(Sender: TObject);
    procedure BtnDisplayClick(Sender: TObject);
    procedure imageclick(Sender: TObject; iClipIndex: Integer; strFilePath: String);
    procedure LefPress(ASender: TObject; iClipIndex: Smallint;
      const strFilePath: WideString);
    procedure RightPress(ASender: TObject; iClipIndex: Smallint;
      const strFilePath: WideString);
    procedure Click(Sender: TObject);
    procedure ThumbnailClick(ASender: TObject; iClipIndex: Smallint;
      const strFilePath: WideString);
    procedure BtnWidthHeightClick(Sender: TObject);
    procedure BtnFontSizeClick(Sender: TObject);
    procedure BtnFontTopClick(Sender: TObject);
    procedure BtnMarginClick(Sender: TObject);
    procedure OnDrop(ASender: TObject; iFileCount: Smallint);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  var oldBackColor:variant;
  var oldBorderColor:variant;
  var oldShadowColor:variant;
  var oldClipColor:variant;

implementation

{$R *.dfm}

procedure TForm1.BtnAddFileClick(Sender: TObject);
begin
OpenDialog1.Filter :=
  'All Files (*.*)|*.*|JPEG (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp|Gif (*.gif)|*.gif |TIF (*.tif)|*.tif|PNG (*.png)|*.png |Icon (*.ico)|*.ico';

   if opendialog1.Execute then begin
    imagethumbnailcp1.AddClip(opendialog1.FileName,'');
    ImageThumbnailCP1.SelectClip(ImageThumbnailCP1.ClipCount - 1);
    ImageThumbnailCP1.VScroll(7);

    ImageThumbnailCP1.SetFocus;


   end;

end;

procedure TForm1.BtnBgColorClick(Sender: TObject);
begin

 if colordialog1.Execute then
 ImageThumbnailCP1.BackgroundColor :=colordialog1.Color;
 ImageThumbnailCP1.SetFocus;

end;

procedure TForm1.BtnClipColorClick(Sender: TObject);
begin

 if colordialog1.Execute then
  ImageThumbnailCP1.ClipColor := colordialog1.Color;

 ImageThumbnailCP1.SetFocus;

end;

procedure TForm1.BtnHighlightClick(Sender: TObject);
begin
 if colordialog1.Execute then
  ImageThumbnailCP1.ClipHighlightColor := colordialog1.Color;

 ImageThumbnailCP1.SetFocus;

end;

procedure TForm1.BtnBorderClick(Sender: TObject);
begin
 if colordialog1.Execute then
  ImageThumbnailCP1.ClipBorderColor := colordialog1.Color;

 ImageThumbnailCP1.SetFocus;

end;

procedure TForm1.BtnShadowClick(Sender: TObject);
begin
 if colordialog1.Execute then
  ImageThumbnailCP1.ClipShadowColor := colordialog1.Color;

 ImageThumbnailCP1.SetFocus;

end;

procedure TForm1.BtnTextClick(Sender: TObject);
begin
 if colordialog1.Execute then
  ImageThumbnailCP1.ClipTextColor := colordialog1.Color;

 ImageThumbnailCP1.SetFocus;

end;

procedure TForm1.BtnUpdateClick(Sender: TObject);
var iCount:Integer;
var i:Integer;
begin

iCount := ImageThumbnailCP1.ClipCount;

For i := 0 To iCount do
    ImageThumbnailCP1.SetClipInfo (i, '', ' Demo ' + inttostr(i));


 ImageThumbnailCP1.SetFocus;


end;

procedure TForm1.BtnACDSeeClick(Sender: TObject);
var iCount:Integer;
var i:Integer;

begin


 ImageThumbnailCP1.BackgroundColor := RGB(128, 128, 128);
 ImageThumbnailCP1.ClipBorderColor := RGB(128, 128, 128);
 ImageThumbnailCP1.ClipShadowColor := RGB(128, 128, 128);
 ImageThumbnailCP1.ClipColor := RGB(128, 128, 128);
 ImageThumbnailCP1.ClipFontSize := 10;

 ImageThumbnailCP1.ClipFontTopPos := 95;
 ImageThumbnailCP1.ClipTopMargin := 0;
 ImageThumbnailCP1.ClipBottomMargin := 15;

 ImageThumbnailCP1.ClipWidth := 110;
 ImageThumbnailCP1.ClipHeight := 120;


  iCount := ImageThumbnailCP1.ClipCount;

  For i := 0 To iCount do
      ImageThumbnailCP1.SetClipInfo (i, '', ' Demo ' + inttostr(i));

 ImageThumbnailCP1.SetFocus;

end;

procedure TForm1.BtnNormalClick(Sender: TObject);
begin

 ImageThumbnailCP1.BackgroundColor := oldBackcolor;
 ImageThumbnailCP1.ClipBorderColor := oldBorderColor;

 ImageThumbnailCP1.ClipShadowColor := oldShadowColor;
 ImageThumbnailCP1.ClipColor := oldClipColor;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
oldBackcolor := ImageThumbnailCP1.BackgroundColor;
oldBorderColor := ImageThumbnailCP1.ClipBorderColor;
oldShadowColor :=ImageThumbnailCP1.ClipShadowColor;
oldClipColor :=ImageThumbnailCp1.ClipColor;

ImageThumbnailCP1.ClipFontSize := 10;


end;

procedure TForm1.chkClipFontClick(Sender: TObject);
begin

  if chkClipFont.Checked then
      ImageThumbnailCP1.ClipFontBold := True
  else
      ImageThumbnailCP1.ClipFontBold := False;

  ImageThumbnailCp1.SetFocus;




end;

procedure TForm1.ClipFontItalicClick(Sender: TObject);
begin

  if ClipFontItalic.Checked then

      ImageThumbnailCP1.ClipFontItalic := True
  else
      ImageThumbnailCP1.ClipFontItalic := False;

  ImageThumbnailCp1.SetFocus;


end;

procedure TForm1.ChkClipunderClick(Sender: TObject);
begin
  if ChkClipunder.Checked then

      ImageThumbnailCP1.ClipFontUnderline  := True
  else
      ImageThumbnailCP1.ClipFontUnderline := False;

  ImageThumbnailCp1.SetFocus;

end;

procedure TForm1.BtnDelAllClick(Sender: TObject);
var iCount:Integer;
var i : Integer;
begin
 iCount := ImageThumbnailCP1.ClipCount;

For i := 0 To iCount do
     ImageThumbnailCP1.DeleteClipByIndex(0);


 ImageThumbnailCP1.SetFocus

end;

procedure TForm1.BtnDelSelClick(Sender: TObject);
begin
  ImageThumbnailCP1.DeleteSelectedClip;
 ImageThumbnailCP1.SetFocus;

end;

procedure TForm1.BtnDisplayClick(Sender: TObject);
var i : integer;
begin

For i := 0 To ImageThumbnailCP1.ClipCount do

    If ImageThumbnailCP1.GetSelect(i) Then
           ShowMessage(ImageThumbnailCP1.GetClipFilePath(i));



end;

procedure TForm1.imageclick(Sender: TObject; iClipIndex:Integer; strFilePath: String);

begin
    ShowMessage('a');
end;

procedure TForm1.LefPress(ASender: TObject; iClipIndex: Smallint;
  const strFilePath: WideString);
begin

  txtcurIndex.text  := Format('%d', [iClipIndex]);
  txtfilename.text := strFilePath;

  If iClipIndex Mod 3 = 0 Then
        ImageThumbnailCP1.VScroll (0);


  ImageThumbnailCP1.SetFocus;



end;

procedure TForm1.RightPress(ASender: TObject; iClipIndex: Smallint;
  const strFilePath: WideString);
begin

    txtcurIndex.text  := Format('%d', [iClipIndex]);
    txtfilename.text := strFilePath;
  If iClipIndex Mod 3 = 0 Then
        ImageThumbnailCP1.VScroll (1);


  ImageThumbnailCP1.SetFocus;

end;

procedure TForm1.Click(Sender: TObject);
begin


ImageThumbnailCP1.SetFocus;
end;

procedure TForm1.ThumbnailClick(ASender: TObject; iClipIndex: Smallint;
  const strFilePath: WideString);
begin

    txtcurIndex.text  := Format('%d', [iClipIndex]);
    txtfilename.text := strFilePath;

end;

procedure TForm1.BtnWidthHeightClick(Sender: TObject);
begin

imagethumbnailcp1.ClipWidth := strtoint(txtWidth.Text);
imagethumbnailcp1.ClipHeight := strtoint(txtHeight.Text);

end;

procedure TForm1.BtnFontSizeClick(Sender: TObject);
begin
imagethumbnailcp1.ClipFontSize := strtoint(txtFontSize.Text);

end;

procedure TForm1.BtnFontTopClick(Sender: TObject);
begin

imagethumbnailcp1.ClipFontTopPos := strtoint(txtFontTop.Text);


end;

procedure TForm1.BtnMarginClick(Sender: TObject);
begin

imagethumbnailcp1.ClipTopMargin := strtoint(txtTopMargin.Text);
imagethumbnailcp1.ClipBottomMargin := strtoint(txtBottomMargin.Text);


end;

procedure TForm1.OnDrop(ASender: TObject; iFileCount: Smallint);
begin
ImageThumbnailCP1.SelectClip (ImageThumbnailCP1.ClipCount - 1);
ImageThumbnailCP1.VScroll (7);
ImageThumbnailCP1.SetFocus;

end;

end.
