source: branches/test1/Client/Forms/UFormSetting.pas

Last change on this file was 46, checked in by chronos, 13 years ago
File size: 1.5 KB
Line 
1unit UFormSetting;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 CoolTranslator, ULanguages;
10
11type
12
13 { TSettingForm }
14
15 TSettingForm = class(TForm)
16 ButtonSave: TButton;
17 ButtonCancel: TButton;
18 ComboBoxLanguage: TComboBox;
19 Label2: TLabel;
20 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
21 procedure FormShow(Sender: TObject);
22 private
23 procedure Save;
24 procedure Load;
25 public
26 { public declarations }
27 end;
28
29var
30 SettingForm: TSettingForm;
31
32implementation
33
34{$R *.lfm}
35
36uses
37 UCore, UFormMain;
38
39{ TSettingForm }
40
41procedure TSettingForm.FormShow(Sender: TObject);
42begin
43 MainForm.PersistentForm.Load(Self);
44
45 Load;
46end;
47
48procedure TSettingForm.FormClose(Sender: TObject; var CloseAction: TCloseAction
49 );
50begin
51 if ModalResult = mrOK then Save;
52 MainForm.PersistentForm.Save(Self);
53end;
54
55procedure TSettingForm.Save;
56begin
57 with Core.CoolTranslator1 do
58 Language := TLanguage(Languages[ComboBoxLanguage.ItemIndex]);
59end;
60
61procedure TSettingForm.Load;
62begin
63 with Core.CoolTranslator1 do begin
64 LanguageListToStrings(ComboBoxLanguage.Items);
65 if Assigned(Language) then begin
66 ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Language);
67 // Select automatic if no other match
68 if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
69 end else ComboBoxLanguage.ItemIndex := 0;
70 end;
71end;
72
73end.
74
Note: See TracBrowser for help on using the repository browser.