unit cxIntlPS3_Editor;
{
  Design ime Editor for the TcxIntlPrintSys3 component:
  Desciption: Saves and loads strings from INI files at design time
   by a the context menu of the component (right-clik on the component icon)
  Editor Added by Fabio Maulo
  fabiomaulo@yahoo.com.ar

  Refer to
  Programmed by Jörg Pfander for Dev Express
  http://www.FreeDevExpressAddons.com
}

{$I dxPSVer.inc}

interface

uses
{$IFDEF DELPHI6}
  DesignIntF, DesignEditors,
  VCLEditors,
{$ELSE}
  DsgnIntf,
{$ENDIF}
 cxIntlPrintSys3, Dialogs, IniFiles;

type

  TcxIntlPS3_Editor = class(TComponentEditor)
  private
   procedure SaveToFile;
   procedure LoadFromFile;
  protected
  public
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

procedure Register;


implementation

procedure Register;
begin
  RegisterComponentEditor(TcxIntlPrintSys3, TcxIntlPS3_Editor);
end;
{ TcxIntl_Editor }

procedure TcxIntlPS3_Editor.ExecuteVerb(Index: Integer);
begin
  inherited;
  case Index of
  0: LoadFromFile;
  1: SaveToFile;
  end;
end;

function TcxIntlPS3_Editor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := 'Load strings from Ini File...';
    1: Result := 'Save strings to Ini File...';
  end;
end;

function TcxIntlPS3_Editor.GetVerbCount: Integer;
begin
 Result := 2;
end;

procedure TcxIntlPS3_Editor.LoadFromFile;
var LoadFromFileDlg:TOpenDialog;
begin
 LoadFromFileDlg := TOpenDialog.Create(nil);
 LoadFromFileDlg.DefaultExt := 'ini';
 LoadFromFileDlg.Filter := 'INI Files (*.ini)|*.ini|'+
                           'LNG Files (*.lng)|*.txt|'+
                           'ASCII Text Files (*.txt)|*.txt|'+
                           'All files (*.*)|*.*';
 LoadFromFileDlg.FilterIndex := 1;
 LoadFromFileDlg.Options := [ofExtensionDifferent, ofPathMustExist,
                             ofFileMustExist, ofEnableSizing];
 LoadFromFileDlg.Title := 'Load strings from file...';
 if LoadFromFileDlg.Execute then
 begin
    TcxIntlPrintSys3(Component).LoadFromFile(LoadFromFileDlg.FileName);
 end;
 LoadFromFileDlg.Free;
end;

procedure TcxIntlPS3_Editor.SaveToFile;
var SaveToFileDlg:TSaveDialog;
begin
 SaveToFileDlg := TSaveDialog.Create(nil);
 SaveToFileDlg.DefaultExt := 'ini';
 SaveToFileDlg.Filter := 'INI Files (*.ini)|*.ini|'+
                         'LNG Files (*.lng)|*.txt|'+
                         'ASCII Text Files (*.txt)|*.txt|'+
                         'All files (*.*)|*.*';
 SaveToFileDlg.FilterIndex := 1;
 SaveToFileDlg.Options := [ofExtensionDifferent, ofPathMustExist,
                           ofEnableSizing, ofOverwritePrompt];
 SaveToFileDlg.Title := 'Save strings to file...';
 if SaveToFileDlg.Execute then
 begin
    TcxIntlPrintSys3(Component).SaveToFile(SaveToFileDlg.FileName);
 end;
 SaveToFileDlg.Free;
end;

end.
