unit plgDial;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Buttons,PcTypesUtils;

Type TCommandEvent = procedure ( comId: integer; values: string; valueI: integer ) of object;
type
  TfrmPlugin = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    SpeedButton1: TSpeedButton;
    Bevel1: TBevel;
    SpeedButton2: TSpeedButton;
    ListBox1: TListBox;
    Memo1: TMemo;
    SpeedButton3: TSpeedButton;
    Label2: TLabel;
    Label3: TLabel;
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    InfoList: TstringList;
  end;

var
  frmPlugin: TfrmPlugin;
  OnCommand : TCommandEvent;

implementation

{$R *.DFM}

procedure TfrmPlugin.SpeedButton3Click(Sender: TObject);
begin
  self.ModalResult := mrOk;
end;

procedure TfrmPlugin.SpeedButton1Click(Sender: TObject);
var folder: String;
begin
  folder :=  FolderDialog('Select Plugins Directory');
  if folder <> '' then begin
    edit1.Text := folder;
    Listbox1.Items.clear;
    memo1.Lines.clear;
    onCommand(0,folder,0);
    if listbox1.Items.Count > 0 then begin
      listbox1.ItemIndex := 0;
      ListBox1Click(nil);
    end;
    RegWrite('PlgDir',edit1.Text);
  end;
end;

procedure TfrmPlugin.FormCreate(Sender: TObject);
begin
  InfoList := TStringList.Create;
end;

procedure TfrmPlugin.FormDestroy(Sender: TObject);
begin
  InfoList.Free;
end;

procedure TfrmPlugin.ListBox1Click(Sender: TObject);
begin
  if ListBox1.ItemIndex > -1 then begin
    memo1.Lines.Text := InfoList[ListBox1.ItemIndex];
  end;
end;

procedure TfrmPlugin.SpeedButton2Click(Sender: TObject);
begin

   Listbox1.Items.clear;
   memo1.Lines.clear;
   onCommand(1,'',0);
   if listbox1.Items.Count > 0 then begin
     listbox1.ItemIndex := 0;
     ListBox1Click(nil);
   end;
end;

end.
