source: trunk/Forms/UFormSettings.pas

Last change on this file was 18, checked in by chronos, 11 years ago
  • Přidáno: Možnost nastavit jazyk rozhraní v okně nastavení.
File size: 2.2 KB
Line 
1unit UFormSettings;
2
3{$mode delphi}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
9 StdCtrls, ULanguages;
10
11type
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
35var
36 FormSettings: TFormSettings;
37
38implementation
39
40{$R *.lfm}
41
42uses
43 UFioAPI, UCore;
44
45resourcestring
46 SSelectFolder = 'Select destination folder';
47
48{ TFormSettings }
49
50procedure TFormSettings.FormCreate(Sender: TObject);
51var
52 I: TFioDataFormat;
53begin
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];
60end;
61
62procedure TFormSettings.Button1Click(Sender: TObject);
63var
64 Output: string;
65begin
66 if SelectDirectory(SSelectFolder, LabeledEditFolder.Text, Output) then
67 LabeledEditFolder.Text := Output;
68end;
69
70procedure TFormSettings.Load;
71begin
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;
77end;
78
79procedure TFormSettings.Save;
80begin
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;
88end;
89
90end.
91
Note: See TracBrowser for help on using the repository browser.