-
Notifications
You must be signed in to change notification settings - Fork 2
/
prefs.pas
135 lines (112 loc) · 3.21 KB
/
prefs.pas
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
unit prefs;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;
type
TPrefsFrm = class(TForm)
pcPrefs: TPageControl;
bOk: TButton;
bCancel: TButton;
TabSheet1: TTabSheet;
Label1: TLabel;
UpDown1: TUpDown;
eInterval: TEdit;
Label2: TLabel;
Label3: TLabel;
UpDown2: TUpDown;
eTimeout: TEdit;
Label4: TLabel;
TabSheet3: TTabSheet;
GroupBox1: TGroupBox;
cbShowLatency: TCheckBox;
cbInterpolate: TCheckBox;
cbSysTray: TCheckBox;
cbPromptOnExit: TCheckBox;
cbStartMinimized: TCheckBox;
cbAutoStartMonitoring: TCheckBox;
TabSheet2: TTabSheet;
pDump: TPanel;
cbDumpXml: TCheckBox;
Label5: TLabel;
eDumpXmlFilename: TEdit;
bXmlFileLookup: TButton;
sdXml: TSaveDialog;
Label6: TLabel;
udInterval: TUpDown;
eDumpInterval: TEdit;
procedure FormShow(Sender: TObject);
procedure bOkClick(Sender: TObject);
procedure bXmlFileLookupClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure cbDumpXmlClick(Sender: TObject);
public
procedure ReadConfig;
procedure ApplyConfig;
end;
var
PrefsFrm: TPrefsFrm;
implementation
uses
mainfrm, tools;
{$R *.dfm}
procedure TPrefsFrm.FormShow(Sender: TObject);
begin
ReadConfig;
end;
procedure TPrefsFrm.ReadConfig;
begin
cbSysTray.Checked := MinimizeToTray;
cbShowLatency.Checked := ShowLatency;
cbInterpolate.Checked := ShowInterpolated;
cbPromptOnExit.Checked := PromptOnExit;
cbStartMinimized.Checked := StartMinimized;
cbAutoStartMonitoring.Checked := AutoStartMonitoring;
eInterval.Text := IntToStr(MonitoringInterval div 1000);
eTimeout.Text := IntToStr(MonitoringTimeout div 1000);
cbDumpXml.Checked := DumpXml;
pDump.Enabled := cbDumpXml.Checked;
eDumpXmlFilename.Text := DumpXmlFilename;
udInterval.Position := DumpXmlInterval;
// eDumpInterval.Text := IntToStr(DumpXmlInterval);
end;
procedure TPrefsFrm.bOkClick(Sender: TObject);
begin
ApplyConfig;
ModalResult := mrOK;
end;
procedure TPrefsFrm.ApplyConfig;
begin
MinimizeToTray := cbSysTray.Checked;
ShowLatency := cbShowLatency.Checked;
ShowInterpolated := cbInterpolate.Checked;
PromptOnExit := cbPromptOnExit.Checked;
StartMinimized := cbStartMinimized.Checked;
AutoStartMonitoring := cbAutoStartMonitoring.Checked;
MonitoringInterval := StrToIntDef(eInterval.Text,0)*1000;
MonitoringTimeout := StrToIntDef(eTimeout.Text,0)*1000;
if MonitoringInterval < 1000 then MonitoringInterval := DefaultInterval;
if MonitoringTimeout < 1000 then MonitoringTimeout := DefaultTimeout;
Main.RefreshList;
// timer stuff
DumpXml := cbDumpXml.Checked;
DumpXmlFilename := eDumpXmlFilename.Text;
DumpXmlInterval := udInterval.Position;
Main.dumpTimer.Interval := DumpXmlInterval;
Main.dumpTimer.Enabled := DumpXml;
end;
procedure TPrefsFrm.bXmlFileLookupClick(Sender: TObject);
begin
if sdXml.Execute then begin
eDumpXmlFilename.Text := sdXml.FileName;
end;
end;
procedure TPrefsFrm.FormCreate(Sender: TObject);
begin
pcPrefs.ActivePageIndex := 0;
end;
procedure TPrefsFrm.cbDumpXmlClick(Sender: TObject);
begin
pDump.Enabled := cbDumpXml.Checked;
end;
end.