-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSettings.pas
More file actions
252 lines (225 loc) · 7 KB
/
Settings.pas
File metadata and controls
252 lines (225 loc) · 7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
unit Settings;
interface
uses
Winapi.Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, System.UITypes, Vcl.ComCtrls, System.Win.Registry,
Winapi.ShellAPI;
type
TFormSettings = class(TForm)
ColorPicker: TColorDialog;
ButtonApply: TButton;
ButtonCancel: TButton;
CheckBoxClose: TCheckBox;
Pages: TPageControl;
TabTable: TTabSheet;
LabelCellBg: TLabel;
LabelCellText: TLabel;
LabelFontName: TLabel;
LabelFontSize: TLabel;
BoxFonts: TComboBox;
ColorCellBg: TEdit;
ColorCellText: TEdit;
EditFontSize: TEdit;
UpDownFont: TUpDown;
TabGeneral: TTabSheet;
LabelSound: TLabel;
BoxSound: TComboBox;
TabFunctions: TTabSheet;
GroupFill: TGroupBox;
EditFillFrom: TEdit;
EditFillTo: TEdit;
UpDownFrom: TUpDown;
UpDownTo: TUpDown;
GroupFormat: TGroupBox;
LabelFillInterval: TLabel;
LabelFillFrom: TLabel;
LabelFillTo: TLabel;
LabelFormatDefault: TLabel;
EditFormatNumber: TEdit;
UpDownNum: TUpDown;
TabConfig: TTabSheet;
LabelResetConfig: TLabel;
SaveConfig: TSaveDialog;
OpenConfig: TOpenDialog;
LabelImport: TLabel;
LabelExport: TLabel;
GroupConfig: TGroupBox;
procedure ColorCellTextClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ColorCellBgClick(Sender: TObject);
procedure ButtonApplyClick(Sender: TObject);
procedure ButtonCancelClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure LabelResetConfigClick(Sender: TObject);
procedure LabelHover(Sender: TObject);
procedure LabelUnHover(Sender: TObject);
procedure LabelExportClick(Sender: TObject);
procedure LabelImportClick(Sender: TObject);
private
procedure WINDOWPOSCHANGING(var Msg: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
public
end;
var
FormSettings: TFormSettings;
implementation
{$R *.dfm}
{$SetPEFlags IMAGE_FILE_RELOCS_STRIPPED}
{$SetPEFlags IMAGE_FILE_LINE_NUMS_STRIPPED}
{$SetPEFlags IMAGE_FILE_LOCAL_SYMS_STRIPPED}
{$SetPEFlags IMAGE_FILE_DEBUG_STRIPPED}
{$SetPEFlags IMAGE_FILE_EXECUTABLE_IMAGE}
uses Main, Splash;
procedure TFormSettings.WINDOWPOSCHANGING(var Msg: TWMWindowPosMsg);
begin
inherited;
If Visible Then
begin
Msg.WindowPos.x:=Left;
Msg.WindowPos.y:=Top;
Msg.Result:=0;
end;
end;
procedure TFormSettings.LabelExportClick(Sender: TObject);
var
ConfigFile: File Of TConfig;
Filename: string;
begin
If SaveConfig.Execute Then
begin
Filename:=ChangeFileExt(SaveConfig.Filename, '.cxc');
AssignFile(ConfigFile, Filename);
Rewrite(ConfigFile);
Write(ConfigFile, Config);
CloseFile(ConfigFile);
MessageBeep(MB_ICONINFORMATION);
MessageDlg('Podešavanja aplikacije su uspešno izvezena.', mtInformation, [mbOK], 0, mbOK);
end;
end;
procedure TFormSettings.LabelHover(Sender: TObject);
begin
Cursor:=crHandPoint;
TLabel(Sender).Font.Style:=[fsBold];
TLabel(Sender).Font.Size:=10;
end;
procedure TFormSettings.LabelImportClick(Sender: TObject);
var
ConfigFile: File Of TConfig;
begin
If OpenConfig.Execute Then
begin
AssignFile(ConfigFile, OpenConfig.FileName);
Reset(ConfigFile);
Read(ConfigFile, Config);
CloseFile(ConfigFile);
Main.FormMain.WriteConfig;
Main.FormMain.Grid.Repaint;
MessageBeep(MB_ICONINFORMATION);
MessageDlg('Podešavanja aplikacije su uspešno uvezena.', mtInformation, [mbOK], 0, mbOK);
Close;
end;
end;
procedure TFormSettings.LabelUnHover(Sender: TObject);
begin
Cursor:=crDefault;
TLabel(Sender).Font.Style:=[];
TLabel(Sender).Font.Size:=9;
end;
procedure TFormSettings.ButtonApplyClick(Sender: TObject);
var
RegistryObj: TRegistry;
begin
RegistryObj:=TRegistry.Create;
try
RegistryObj.RootKey:=HKEY_LOCAL_MACHINE;
RegistryObj.OpenKey('SOFTWARE', False);
RegistryObj.OpenKey('NeoVisio', True);
RegistryObj.OpenKey('CalculusEx', True);
RegistryObj.WriteString('BgColor', ColorToString(ColorCellBg.Color));
RegistryObj.WriteString('TextColor', ColorToString(ColorCellText.Color));
RegistryObj.WriteString('FontName', BoxFonts.Items[BoxFonts.ItemIndex]);
RegistryObj.WriteInteger('FontSize', StrToInt(EditFontSize.Text));
RegistryObj.WriteInteger('FormatNum', StrToInt(EditFormatNumber.Text));
RegistryObj.WriteInteger('FillFrom', UpDownFrom.Position);
RegistryObj.WriteInteger('FillTo', UpDownTo.Position);
If (BoxSound.ItemIndex=0) Then
RegistryObj.WriteInteger('Sound', 0)
Else
RegistryObj.WriteInteger('Sound', 1);
RegistryObj.CloseKey;
finally
RegistryObj.Free;
end;
Main.FormMain.LoadConfig;
If (Main.FormMain.Grid.Visible) Then
begin
Main.FormMain.Grid.Repaint;
Main.FormMain.AdaptToWidth;
end;
If (CheckBoxClose.Checked) Then
Close;
end;
procedure TFormSettings.ButtonCancelClick(Sender: TObject);
begin
Close;
end;
procedure TFormSettings.ColorCellBgClick(Sender: TObject);
begin
ColorPicker.Color:=ColorCellBg.Color;
If (ColorPicker.Execute) Then
ColorCellBg.Color:=ColorPicker.Color;
end;
procedure TFormSettings.ColorCellTextClick(Sender: TObject);
begin
ColorPicker.Color:=ColorCellText.Color;
If (ColorPicker.Execute) Then
ColorCellText.Color:=ColorPicker.Color;
end;
procedure TFormSettings.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
If Main.FormMain.Grid.Visible Then
begin
Main.Config.SelCol:=-1;
Main.Config.SelRow:=-1;
Main.FormMain.Grid.Repaint;
end;
end;
procedure TFormSettings.FormCreate(Sender: TObject);
begin
UpDownFrom.Max:=MaxInt;
UpDownTo.Max:=MaxInt;
end;
procedure TFormSettings.FormShow(Sender: TObject);
var
PCReg: TRegistry;
begin
PCReg:=TRegistry.Create;
BoxFonts.Items.Assign(Screen.Fonts);
ColorCellBg.Color:=Main.Config.Bg;
ColorCellText.Color:=Main.Config.Font;
BoxFonts.ItemIndex:=BoxFonts.Items.IndexOf(String(Main.Config.FontName));
try
PCReg.RootKey:=HKEY_LOCAL_MACHINE;
PCReg.OpenKey('SOFTWARE\NeoVisio\CalculusEx', False);
BoxSound.ItemIndex:=PCReg.ReadInteger('Sound');
UpDownFont.Position:=PCReg.ReadInteger('FontSize');
UpDownNum.Position:=PCReg.ReadInteger('FormatNum');
UpDownFrom.Position:=PCReg.ReadInteger('FillFrom');
UpDownTo.Position:=PCReg.ReadInteger('FillTo');
PCReg.CloseKey;
finally
PCReg.Free;
end;
end;
procedure TFormSettings.LabelResetConfigClick(Sender: TObject);
begin
Main.Config.ForceClose:=True;
MessageBeep(MB_ICONINFORMATION);
MessageDlg('Aplikacija će sada biti zatvorena i njena podešavanja će biti vraćena na podrazumevana.', mtInformation, [mbOK], 0, mbOK);
ShellExecute(Handle, 'open', PWideChar(ParamStr(0)), PWideChar('-setup'), Nil, SW_HIDE);
Sleep(100);
ShellExecute(Handle, 'open', PWideChar(ParamStr(0)), PWideChar('-reset'), Nil, SW_SHOW);
Application.MainForm.Close;
end;
end.