| 1 | unit UFormSettings;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}{$H+}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
|---|
| 9 | StdCtrls, ULanguages;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 |
|
|---|
| 13 | { TFormSettings }
|
|---|
| 14 |
|
|---|
| 15 | TFormSettings = class(TForm)
|
|---|
| 16 | Button1: TButton;
|
|---|
| 17 | ButtonCancel: TButton;
|
|---|
| 18 | ButtonOk: TButton;
|
|---|
| 19 | ComboBoxFormat: TComboBox;
|
|---|
| 20 | ComboBoxLang: TComboBox;
|
|---|
| 21 | Label1: TLabel;
|
|---|
| 22 | Label2: TLabel;
|
|---|
| 23 | Label3: TLabel;
|
|---|
| 24 | LabeledEditFolder: TLabeledEdit;
|
|---|
| 25 | LabeledEditFileNameFormat: TLabeledEdit;
|
|---|
| 26 | procedure Button1Click(Sender: TObject);
|
|---|
| 27 | procedure FormCreate(Sender: TObject);
|
|---|
| 28 | private
|
|---|
| 29 | { private declarations }
|
|---|
| 30 | public
|
|---|
| 31 | procedure Load;
|
|---|
| 32 | procedure Save;
|
|---|
| 33 | end;
|
|---|
| 34 |
|
|---|
| 35 | var
|
|---|
| 36 | FormSettings: TFormSettings;
|
|---|
| 37 |
|
|---|
| 38 | implementation
|
|---|
| 39 |
|
|---|
| 40 | {$R *.lfm}
|
|---|
| 41 |
|
|---|
| 42 | uses
|
|---|
| 43 | UFioAPI, UCore;
|
|---|
| 44 |
|
|---|
| 45 | resourcestring
|
|---|
| 46 | SSelectFolder = 'Select destination folder';
|
|---|
| 47 |
|
|---|
| 48 | { TFormSettings }
|
|---|
| 49 |
|
|---|
| 50 | procedure TFormSettings.FormCreate(Sender: TObject);
|
|---|
| 51 | var
|
|---|
| 52 | I: TFioDataFormat;
|
|---|
| 53 | begin
|
|---|
| 54 | while ComboBoxFormat.Items.Count < Length(DataFormatText) do
|
|---|
| 55 | ComboBoxFormat.Items.Add('');
|
|---|
| 56 | while ComboBoxFormat.Items.Count > Length(DataFormatText) do
|
|---|
| 57 | ComboBoxFormat.Items.Delete(ComboBoxFormat.Items.Count - 1);
|
|---|
| 58 | for I := Low(DataFormatText) to High(DataFormatText) do
|
|---|
| 59 | ComboBoxFormat.Items.Strings[Integer(I)] := DataFormatText[I];
|
|---|
| 60 | end;
|
|---|
| 61 |
|
|---|
| 62 | procedure TFormSettings.Button1Click(Sender: TObject);
|
|---|
| 63 | var
|
|---|
| 64 | Output: string;
|
|---|
| 65 | begin
|
|---|
| 66 | if SelectDirectory(SSelectFolder, LabeledEditFolder.Text, Output) then
|
|---|
| 67 | LabeledEditFolder.Text := Output;
|
|---|
| 68 | end;
|
|---|
| 69 |
|
|---|
| 70 | procedure TFormSettings.Load;
|
|---|
| 71 | begin
|
|---|
| 72 | Core.CoolTranslator1.LanguageListToStrings(ComboBoxLang.Items);
|
|---|
| 73 | ComboBoxLang.ItemIndex := ComboBoxLang.Items.IndexOfObject(Core.CoolTranslator1.Language);
|
|---|
| 74 | LabeledEditFileNameFormat.Text := Core.OutputFormat;
|
|---|
| 75 | ComboBoxFormat.ItemIndex := Integer(Core.DataFormat);
|
|---|
| 76 | LabeledEditFolder.Text := Core.TargetDirectory;
|
|---|
| 77 | end;
|
|---|
| 78 |
|
|---|
| 79 | procedure TFormSettings.Save;
|
|---|
| 80 | begin
|
|---|
| 81 | if ComboBoxLang.Items.Objects[ComboBoxLang.ItemIndex] <> Core.CoolTranslator1.Language then begin
|
|---|
| 82 | Core.CoolTranslator1.Language := TLanguage(ComboBoxLang.Items.Objects[ComboBoxLang.ItemIndex]);
|
|---|
| 83 |
|
|---|
| 84 | end;
|
|---|
| 85 | Core.OutputFormat := LabeledEditFileNameFormat.Text;
|
|---|
| 86 | Core.DataFormat := TFioDataFormat(ComboBoxFormat.ItemIndex);
|
|---|
| 87 | Core.TargetDirectory := LabeledEditFolder.Text;
|
|---|
| 88 | end;
|
|---|
| 89 |
|
|---|
| 90 | end.
|
|---|
| 91 |
|
|---|