1 | unit UFormSettings;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | Menus, Spin, ULanguages;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormSettings }
|
---|
14 |
|
---|
15 | TFormSettings = class(TForm)
|
---|
16 | ButtonOk: TButton;
|
---|
17 | ButtonCancel: TButton;
|
---|
18 | CheckBoxAutomaticDPI: TCheckBox;
|
---|
19 | CheckBoxStartMinimizedToTray: TCheckBox;
|
---|
20 | CheckBoxStartOnLogon: TCheckBox;
|
---|
21 | CheckBoxAlwaysOnTop: TCheckBox;
|
---|
22 | ComboBoxLanguage: TComboBox;
|
---|
23 | Label1: TLabel;
|
---|
24 | Label2: TLabel;
|
---|
25 | SpinEditDPI: TSpinEdit;
|
---|
26 | procedure ButtonOkClick(Sender: TObject);
|
---|
27 | procedure CheckBoxAutomaticDPIChange(Sender: TObject);
|
---|
28 | procedure CheckBoxStartOnLogonChange(Sender: TObject);
|
---|
29 | procedure FormCreate(Sender: TObject);
|
---|
30 | procedure FormShow(Sender: TObject);
|
---|
31 | private
|
---|
32 | { private declarations }
|
---|
33 | public
|
---|
34 | procedure Load;
|
---|
35 | procedure Save;
|
---|
36 | procedure UpdateInterface;
|
---|
37 | end;
|
---|
38 |
|
---|
39 | var
|
---|
40 | FormSettings: TFormSettings;
|
---|
41 |
|
---|
42 | implementation
|
---|
43 |
|
---|
44 | {$R *.lfm}
|
---|
45 |
|
---|
46 | uses
|
---|
47 | UCore;
|
---|
48 |
|
---|
49 | { TFormSettings }
|
---|
50 |
|
---|
51 | procedure TFormSettings.FormShow(Sender: TObject);
|
---|
52 | begin
|
---|
53 | Core.CoolTranslator1.LanguageListToStrings(ComboBoxLanguage.Items);
|
---|
54 | ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.CoolTranslator1.Language);
|
---|
55 | if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
|
---|
56 | end;
|
---|
57 |
|
---|
58 | procedure TFormSettings.ButtonOkClick(Sender: TObject);
|
---|
59 | begin
|
---|
60 | if ComboBoxLanguage.ItemIndex <> -1 then
|
---|
61 | Core.CoolTranslator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
|
---|
62 | end;
|
---|
63 |
|
---|
64 | procedure TFormSettings.CheckBoxAutomaticDPIChange(Sender: TObject);
|
---|
65 | begin
|
---|
66 | UpdateInterface;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | procedure TFormSettings.CheckBoxStartOnLogonChange(Sender: TObject);
|
---|
70 | begin
|
---|
71 | UpdateInterface;
|
---|
72 | end;
|
---|
73 |
|
---|
74 | procedure TFormSettings.FormCreate(Sender: TObject);
|
---|
75 | begin
|
---|
76 | Core.CoolTranslator1.TranslateComponentRecursive(Self);
|
---|
77 | end;
|
---|
78 |
|
---|
79 | procedure TFormSettings.Load;
|
---|
80 | begin
|
---|
81 | CheckBoxAlwaysOnTop.Checked := Core.AlwaysOnTop;
|
---|
82 | CheckBoxStartOnLogon.Checked := Core.StartOnLogon;
|
---|
83 | CheckBoxStartMinimizedToTray.Checked := Core.StartMinimizedToTray;
|
---|
84 | CheckBoxAutomaticDPI.Checked := Core.ScaleDPI1.AutoDetect;
|
---|
85 | SpinEditDPI.Value := Core.ScaleDPI1.DPI.X;
|
---|
86 | UpdateInterface;
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TFormSettings.Save;
|
---|
90 | begin
|
---|
91 | Core.AlwaysOnTop := CheckBoxAlwaysOnTop.Checked;
|
---|
92 | Core.StartOnLogon := CheckBoxStartOnLogon.Checked;
|
---|
93 | Core.StartMinimizedToTray := CheckBoxStartMinimizedToTray.Checked;
|
---|
94 | Core.ScaleDPI1.AutoDetect := CheckBoxAutomaticDPI.Checked;
|
---|
95 | Core.ScaleDPI1.DPI := Point(SpinEditDPI.Value, SpinEditDPI.Value);
|
---|
96 | end;
|
---|
97 |
|
---|
98 | procedure TFormSettings.UpdateInterface;
|
---|
99 | begin
|
---|
100 | CheckBoxStartMinimizedToTray.Enabled := CheckBoxStartOnLogon.Checked;
|
---|
101 | SpinEditDPI.Enabled := not CheckBoxAutomaticDPI.Checked;
|
---|
102 | Label2.Enabled := not CheckBoxAutomaticDPI.Checked;
|
---|
103 | end;
|
---|
104 |
|
---|
105 | end.
|
---|
106 |
|
---|