root / UFConfig.pas @ 5
Historique | Voir | Annoter | Télécharger (27,38 ko)
1 |
unit UFConfig;
|
---|---|
2 |
|
3 |
interface
|
4 |
|
5 |
uses
|
6 |
Windows, Forms, Classes, Controls, Messages, Dialogs, ComCtrls, StdCtrls, |
7 |
Buttons, ExtCtrls, ExtDlgs, PBNumEdit, PBEdit, PBSuperSpin; |
8 |
|
9 |
type
|
10 |
TFConfig = class(TForm)
|
11 |
PC: TPageControl; |
12 |
TSAliment: TTabSheet; |
13 |
PBoutons: TPanel; |
14 |
BBOk: TBitBtn; |
15 |
BBCancel: TBitBtn; |
16 |
GBFolder: TGroupBox; |
17 |
TSGeneral: TTabSheet; |
18 |
LGal: TLabel; |
19 |
GBTeneur: TGroupBox; |
20 |
GBDigest: TGroupBox; |
21 |
CBRap: TComboBox; |
22 |
CBTCompo: TComboBox; |
23 |
CBTAA: TComboBox; |
24 |
CBTAG: TComboBox; |
25 |
CBTMacro: TComboBox; |
26 |
CBTOligo: TComboBox; |
27 |
CBTFibres: TComboBox; |
28 |
CBDig: TComboBox; |
29 |
CBdCompo: TComboBox; |
30 |
CBdAA: TComboBox; |
31 |
CBAffMP: TCheckBox; |
32 |
LCompo: TLabel; |
33 |
LAA: TLabel; |
34 |
LAG: TLabel; |
35 |
LMacro: TLabel; |
36 |
LOligo: TLabel; |
37 |
LFibres: TLabel; |
38 |
GBExpr: TGroupBox; |
39 |
GBWindow: TGroupBox; |
40 |
PBHeight: TPBNumEdit; |
41 |
LWidth: TLabel; |
42 |
SBWindow: TSpeedButton; |
43 |
PBWidth: TPBNumEdit; |
44 |
LHeight: TLabel; |
45 |
PBTop: TPBNumEdit; |
46 |
LTop: TLabel; |
47 |
PBLeft: TPBNumEdit; |
48 |
LLeft: TLabel; |
49 |
TSTruie: TTabSheet; |
50 |
GBAliGest: TGroupBox; |
51 |
LAliDuree: TLabel; |
52 |
LAliQuantite: TLabel; |
53 |
GBAli1: TGroupBox; |
54 |
PBDuree1: TPBSuperSpin; |
55 |
PBQuantite1: TPBSuperSpin; |
56 |
GBAli3: TGroupBox; |
57 |
PBDuree3: TPBSuperSpin; |
58 |
PBQuantite3: TPBSuperSpin; |
59 |
CBTypeAliGest: TComboBox; |
60 |
PBAugment: TPBSuperSpin; |
61 |
LAugment: TLabel; |
62 |
GBAli2: TGroupBox; |
63 |
PBDuree2: TPBNumEdit; |
64 |
PBQuantite2: TPBSuperSpin; |
65 |
TSMessages: TTabSheet; |
66 |
CBAffCorrCUD: TCheckBox; |
67 |
TSPorc: TTabSheet; |
68 |
GBXCrois: TGroupBox; |
69 |
GBCarcasse: TGroupBox; |
70 |
GBXTruie: TGroupBox; |
71 |
CBXCrois: TComboBox; |
72 |
LXCrois: TLabel; |
73 |
CBXTruie: TComboBox; |
74 |
LXTruie: TLabel; |
75 |
CBTete: TCheckBox; |
76 |
CBLangue: TCheckBox; |
77 |
CBPieds: TCheckBox; |
78 |
CBQueue: TCheckBox; |
79 |
CBHampe: TCheckBox; |
80 |
CBPanne: TCheckBox; |
81 |
CBAffUnitProfilP: TCheckBox; |
82 |
CBAffPDMoy: TCheckBox; |
83 |
CBAffPrecocite: TCheckBox; |
84 |
CBAffEntretien: TCheckBox; |
85 |
GBProfilP: TGroupBox; |
86 |
GBAliMat: TGroupBox; |
87 |
CBAffCalcAli: TCheckBox; |
88 |
CBAffGraphAli: TCheckBox; |
89 |
GBLocal: TGroupBox; |
90 |
LLanguage: TLabel; |
91 |
LMonnaie: TLabel; |
92 |
PBMonnaie: TPBEdit; |
93 |
EFolder: TEdit; |
94 |
SBFolder: TSpeedButton; |
95 |
GBSimulT: TGroupBox; |
96 |
CBAffOptInit: TCheckBox; |
97 |
CBAffSimulT: TCheckBox; |
98 |
GBLogo: TGroupBox; |
99 |
SBLogo: TSpeedButton; |
100 |
ELogo: TEdit; |
101 |
OPDLogo: TOpenPictureDialog; |
102 |
GBExcelFile: TGroupBox; |
103 |
SBExcelFile: TSpeedButton; |
104 |
EExcelFile: TEdit; |
105 |
ODExcelFile: TOpenDialog; |
106 |
GBWarning: TGroupBox; |
107 |
SBWarning: TSpeedButton; |
108 |
CBLanguage: TComboBox; |
109 |
GBIntake: TGroupBox; |
110 |
GBFat: TGroupBox; |
111 |
GBLean: TGroupBox; |
112 |
RBIC: TRadioButton; |
113 |
RBEA: TRadioButton; |
114 |
RBP2: TRadioButton; |
115 |
RBUserFat: TRadioButton; |
116 |
RBTMP: TRadioButton; |
117 |
RBUserLean: TRadioButton; |
118 |
SBUserFat: TSpeedButton; |
119 |
SBUserLean: TSpeedButton; |
120 |
CheckBoxUpdates: TCheckBox; |
121 |
procedure FormShow(Sender: TObject);
|
122 |
procedure CBLanguageChange(Sender: TObject);
|
123 |
procedure CBRapChange(Sender: TObject);
|
124 |
procedure CBDigChange(Sender: TObject);
|
125 |
procedure CBTCompoChange(Sender: TObject);
|
126 |
procedure CBTAAChange(Sender: TObject);
|
127 |
procedure CBTAGChange(Sender: TObject);
|
128 |
procedure CBTMacroChange(Sender: TObject);
|
129 |
procedure CBTOligoChange(Sender: TObject);
|
130 |
procedure CBTFibresChange(Sender: TObject);
|
131 |
procedure CBdCompoChange(Sender: TObject);
|
132 |
procedure CBdAAChange(Sender: TObject);
|
133 |
procedure CBAffMPClick(Sender: TObject);
|
134 |
procedure PBMonnaieChange(Sender: TObject);
|
135 |
procedure SBWindowClick(Sender: TObject);
|
136 |
procedure CBTypeAliGestChange(Sender: TObject);
|
137 |
procedure PBDuree1Change(Sender: TObject);
|
138 |
procedure PBDuree3Change(Sender: TObject);
|
139 |
procedure PBQuantite1Change(Sender: TObject);
|
140 |
procedure PBQuantite2Change(Sender: TObject);
|
141 |
procedure PBQuantite3Change(Sender: TObject);
|
142 |
procedure PBAugmentChange(Sender: TObject);
|
143 |
procedure CBXTruieChange(Sender: TObject);
|
144 |
procedure CBXCroisChange(Sender: TObject);
|
145 |
procedure CBTeteClick(Sender: TObject);
|
146 |
procedure CBLangueClick(Sender: TObject);
|
147 |
procedure CBPiedsClick(Sender: TObject);
|
148 |
procedure CBQueueClick(Sender: TObject);
|
149 |
procedure CBHampeClick(Sender: TObject);
|
150 |
procedure CBPanneClick(Sender: TObject);
|
151 |
procedure SBFolderClick(Sender: TObject);
|
152 |
procedure FormCreate(Sender: TObject);
|
153 |
procedure CBLanguageDrawItem(Control: TWinControl; Index: Integer;
|
154 |
Rect: TRect; State: TOwnerDrawState); |
155 |
procedure SBLogoClick(Sender: TObject);
|
156 |
procedure EFolderChange(Sender: TObject);
|
157 |
procedure ELogoChange(Sender: TObject);
|
158 |
procedure SBExcelFileClick(Sender: TObject);
|
159 |
procedure EExcelFileChange(Sender: TObject);
|
160 |
procedure SBWarningClick(Sender: TObject);
|
161 |
procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND; |
162 |
procedure RBFeedInfoClick(Sender: TObject);
|
163 |
procedure RBFatInfoClick(Sender: TObject);
|
164 |
procedure RBLeanInfoClick(Sender: TObject);
|
165 |
procedure SBUserFatClick(Sender: TObject);
|
166 |
procedure SBUserLeanClick(Sender: TObject);
|
167 |
procedure CheckBoxUpdatesClick(Sender: TObject);
|
168 |
private
|
169 |
{ D?clarations priv?es }
|
170 |
Update: boolean; |
171 |
function StrEquation(Name: String; PVV: Boolean; a, b, c: Double): String; |
172 |
public
|
173 |
{ D?clarations publiques }
|
174 |
end;
|
175 |
|
176 |
var
|
177 |
FConfig: TFConfig; |
178 |
|
179 |
implementation
|
180 |
|
181 |
uses
|
182 |
FileCtrl, Graphics, SysUtils, gnugettext, UVariables, UStrings, UUtil, |
183 |
UFUserEquation, UFMenu; |
184 |
|
185 |
{$R *.dfm}
|
186 |
|
187 |
{ TFConfig }
|
188 |
|
189 |
procedure TFConfig.FormCreate(Sender: TObject);
|
190 |
var
|
191 |
BorderSize: Integer; |
192 |
begin
|
193 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
194 |
then
|
195 |
Font.Name := 'Arial Unicode MS';
|
196 |
TranslateComponent(Self); |
197 |
Constraints.MinWidth := 480 + (Width - ClientWidth);
|
198 |
Width := Constraints.MinWidth; |
199 |
Constraints.MinHeight := 436 + (Height - ClientHeight);
|
200 |
Height := Constraints.MinHeight; |
201 |
// Initialisation
|
202 |
BorderSize := (FMenu.Width - FMenu.ClientWidth) div 2; |
203 |
PBWidth.MaxValue := Screen.WorkAreaWidth + BorderSize * 2;
|
204 |
PBWidth.MinValue := FMenu.Constraints.MinWidth; |
205 |
PBHeight.MaxValue := Screen.WorkAreaHeight + BorderSize * 2;
|
206 |
PBHeight.MinValue := FMenu.Constraints.MinHeight; |
207 |
PBLeft.MaxValue := PBWidth.MaxValue - PBWidth.MinValue; |
208 |
PBLeft.MinValue := - BorderSize; |
209 |
PBTop.MaxValue := PBHeight.MaxValue - PBHeight.MinValue; |
210 |
PBTop.MinValue := - BorderSize; |
211 |
DefaultInstance.GetListOfLanguages('default', CBLanguage.Items);
|
212 |
CBLanguage.Items.Add('en_US');
|
213 |
RBIC.Caption := Format('%s = %s / %s', [_('F:G'), _('Feed usage'), _('Body weight gain')]); |
214 |
RBEA.Caption := Format('%s = %s / %s', [_('G:F'), _('Body weight gain'), _('Feed usage')]); |
215 |
RBP2.Caption := StrEquation(StrP2, False, 6.96, 0, 0.375); |
216 |
if Length(UserFatShortName) = 0 |
217 |
then
|
218 |
RBUserFat.Caption := StrEquation(_('UserP2'), UserFatPVV, UserFatA, UserFatB, UserFatC)
|
219 |
else
|
220 |
RBUserFat.Caption := StrEquation(UserFatShortName, UserFatPVV, UserFatA, UserFatB, UserFatC); |
221 |
if Length(UserFatLongName) = 0 |
222 |
then
|
223 |
RBUserFat.Hint := _('User backfat thickness')
|
224 |
else
|
225 |
RBUserFat.Hint := UserFatLongName; |
226 |
RBTMP.Caption := StrEquation(StrTMP, True, 57.43, 95.68, -62.68); |
227 |
if Length(UserLeanShortName) = 0 |
228 |
then
|
229 |
RBUserLean.Caption := StrEquation(_('UserLean'), UserLeanPVV, UserLeanA, UserLeanB, UserLeanC)
|
230 |
else
|
231 |
RBUserLean.Caption := StrEquation(UserLeanShortName, UserLeanPVV, UserLeanA, UserLeanB, UserLeanC); |
232 |
if Length(UserLeanLongName) = 0 |
233 |
then
|
234 |
RBUserLean.Hint := _('User lean')
|
235 |
else
|
236 |
RBUserLean.Hint := UserLeanLongName; |
237 |
PC.ActivePageIndex := 0;
|
238 |
end;
|
239 |
|
240 |
procedure TFConfig.FormShow(Sender: TObject);
|
241 |
begin
|
242 |
NewFolder := Folder; |
243 |
NewLogo := Logo; |
244 |
NewLanguageCode := LanguageCode; |
245 |
Update := TRUE; |
246 |
// G?n?ral
|
247 |
EFolder.Text := Folder; |
248 |
EExcelFile.Text := ExcelFile; |
249 |
PBWidth.AsInteger := FMenu.Width; |
250 |
PBHeight.AsInteger := FMenu.Height; |
251 |
PBLeft.AsInteger := FMenu.Left; |
252 |
PBTop.AsInteger := FMenu.Top; |
253 |
ELogo.Text := Logo; |
254 |
CBLanguage.ItemIndex := CBLanguage.Items.IndexOf(LanguageCode); |
255 |
PBMonnaie.Text := CurrencySign; |
256 |
CheckBoxUpdates.Checked := CheckForUpdates; |
257 |
// Mati?res premi?res et aliments
|
258 |
CBRap.ItemIndex := ConfRap; |
259 |
CBDig.ItemIndex := ConfDig; |
260 |
CBDigChange(nil);
|
261 |
CBTCompo.ItemIndex := ConfTCompo; |
262 |
CBTAA.ItemIndex := ConfTAA; |
263 |
CBTAG.ItemIndex := ConfTAG; |
264 |
CBTMacro.ItemIndex := ConfTMacro; |
265 |
CBTOligo.ItemIndex := ConfTOligo; |
266 |
CBTFibres.ItemIndex := ConfTFibres; |
267 |
CBdCompo.ItemIndex := ConfdCompo; |
268 |
CBdAA.ItemIndex := ConfdAA; |
269 |
CBAffMP.Checked := ConfAffMP; |
270 |
// Truie
|
271 |
CBXTruie.ItemIndex := XTruie; |
272 |
CBTypeAliGest.ItemIndex := TypeAliGest; |
273 |
CBTypeAliGestChange(nil);
|
274 |
// Porc croissance
|
275 |
CBXCrois.ItemIndex := XCrois; |
276 |
CBTete.Checked := CarTete; |
277 |
CBTeteClick(nil);
|
278 |
CBLangue.Checked := CarLangue; |
279 |
CBPieds.Checked := CarPieds; |
280 |
CBQueue.Checked := CarQueue; |
281 |
CBHampe.Checked := CarHampe; |
282 |
CBPanne.Checked := CarPanne; |
283 |
if FeedInfo = 0 |
284 |
then // Indice de consommation |
285 |
RBIC.Checked := True |
286 |
else // Efficacit? alimentaire |
287 |
RBEA.Checked := True; |
288 |
if FatInfo = 0 |
289 |
then // P2 |
290 |
RBP2.Checked := True |
291 |
else // User defined |
292 |
RBUserFat.Checked := True; |
293 |
if LeanInfo = 0 |
294 |
then // TMP |
295 |
RBTMP.Checked := True |
296 |
else // User defined |
297 |
RBUserLean.Checked := True; |
298 |
Update := False; |
299 |
PC.ActivePageIndex := 0;
|
300 |
end ;
|
301 |
|
302 |
procedure TFConfig.WMSysCommand(var Message: TWMSysCommand); |
303 |
begin
|
304 |
if Message.CmdType = SC_MINIMIZE
|
305 |
then
|
306 |
Application.Minimize |
307 |
else
|
308 |
inherited;
|
309 |
end;
|
310 |
|
311 |
// G?n?ral
|
312 |
|
313 |
procedure TFConfig.SBFolderClick(Sender: TObject);
|
314 |
var
|
315 |
NewDir: String;
|
316 |
begin
|
317 |
NewDir := NewFolder; |
318 |
if SelectDirectory(StrSelectDir, '', NewDir) |
319 |
and DirectoryExists(NewDir)
|
320 |
and (NewDir <> NewFolder)
|
321 |
then
|
322 |
EFolder.Text := NewDir; |
323 |
end;
|
324 |
|
325 |
procedure TFConfig.EFolderChange(Sender: TObject);
|
326 |
begin
|
327 |
ConfigChanged := TRUE; |
328 |
NewFolder := EFolder.Text; |
329 |
end;
|
330 |
|
331 |
procedure TFConfig.SBExcelFileClick(Sender: TObject);
|
332 |
begin
|
333 |
ODExcelFile.FileName := ExcelFile; |
334 |
if ODExcelFile.Execute and (ODExcelFile.FileName <> ExcelFile) |
335 |
then
|
336 |
EExcelFile.Text := ODExcelFile.FileName; |
337 |
end;
|
338 |
|
339 |
procedure TFConfig.EExcelFileChange(Sender: TObject);
|
340 |
begin
|
341 |
ConfigChanged := TRUE; |
342 |
ExcelFile := EExcelFile.Text; |
343 |
end;
|
344 |
|
345 |
procedure TFConfig.SBWindowClick(Sender: TObject);
|
346 |
begin
|
347 |
ConfigChanged := TRUE; |
348 |
MainLeft := PBLeft.AsInteger; |
349 |
MainTop := PBTop.AsInteger; |
350 |
MainWidth := PBWidth.AsInteger; |
351 |
MainHeight := PBHeight.AsInteger; |
352 |
with FMenu do |
353 |
if (PBWidth.AsInteger <> Width)
|
354 |
or (PBHeight.AsInteger <> Height)
|
355 |
or (PBLeft.AsInteger <> Left)
|
356 |
or (PBTop.AsInteger <> Top)
|
357 |
then // Taille et position de la fen?tre principale |
358 |
begin
|
359 |
SetBounds(MainLeft, MainTop, MainWidth, MainHeight); |
360 |
FormResize(nil);
|
361 |
end;
|
362 |
end;
|
363 |
|
364 |
procedure TFConfig.SBLogoClick(Sender: TObject);
|
365 |
begin
|
366 |
OPDLogo.FileName := NewLogo; |
367 |
if OPDLogo.Execute and (OPDLogo.FileName <> NewLogo) |
368 |
then
|
369 |
ELogo.Text := OPDLogo.FileName; |
370 |
end;
|
371 |
|
372 |
procedure TFConfig.ELogoChange(Sender: TObject);
|
373 |
begin
|
374 |
ConfigChanged := TRUE; |
375 |
NewLogo := ELogo.Text; |
376 |
end;
|
377 |
|
378 |
procedure TFConfig.CBLanguageDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
379 |
var
|
380 |
LanguageName: String;
|
381 |
begin
|
382 |
with Control as TComboBox do |
383 |
begin
|
384 |
// Conversion du code ISO en nom (d?j? traduit)
|
385 |
LanguageName := dgettext('languagecodes', Items[Index]);
|
386 |
// Cadre
|
387 |
Canvas.FillRect(Rect); |
388 |
// Texte
|
389 |
Canvas.TextOut(Rect.Left + 2, Rect.Top, LanguageName);
|
390 |
end;
|
391 |
end;
|
392 |
|
393 |
procedure TFConfig.CBLanguageChange(Sender: TObject);
|
394 |
begin
|
395 |
if not Update |
396 |
then
|
397 |
begin
|
398 |
NewLanguageCode := CBLanguage.Items[CBLanguage.ItemIndex]; |
399 |
ConfigChanged := TRUE; |
400 |
end;
|
401 |
end;
|
402 |
|
403 |
procedure TFConfig.PBMonnaieChange(Sender: TObject);
|
404 |
begin
|
405 |
if not Update |
406 |
then
|
407 |
begin
|
408 |
CurrencySign := PBMonnaie.Text; |
409 |
ConfigChanged := TRUE; |
410 |
end;
|
411 |
end;
|
412 |
|
413 |
procedure TFConfig.SBWarningClick(Sender: TObject);
|
414 |
begin
|
415 |
// R?activation pour la session courante
|
416 |
AffCorrCUD := True; |
417 |
AffCalcAli := True; |
418 |
AffGraphAli := True; |
419 |
AffUnitProfilP := True; |
420 |
AffPDMoy := True; |
421 |
AffPrecocite := True; |
422 |
AffEntretien := True; |
423 |
AffOptInit := True; |
424 |
AffSimulT := True; |
425 |
AffBesoin := True; |
426 |
// R?activation globale
|
427 |
BdRWriteBoolean('\Software\InraPorc\Config\Messages', 'CorrCUD', True); |
428 |
BdRWriteBoolean('\Software\InraPorc\Config\Messages', 'CalcAli', True); |
429 |
BdRWriteBoolean('\Software\InraPorc\Config\Messages', 'GraphAli', True); |
430 |
BdRWriteBoolean('\Software\InraPorc\Config\Messages', 'UnitProfilP', True); |
431 |
BdRWriteBoolean('\Software\InraPorc\Config\Messages', 'PDMoy', True); |
432 |
BdRWriteBoolean('\Software\InraPorc\Config\Messages', 'Precocite', True); |
433 |
BdRWriteBoolean('\Software\InraPorc\Config\Messages', 'Entretien', True); |
434 |
BdRWriteBoolean('\Software\InraPorc\Config\Messages', 'OptInit', True); |
435 |
BdRWriteBoolean('\Software\InraPorc\Config\Messages', 'SimulT', True); |
436 |
BdRWriteBoolean('\Software\InraPorc\Config\Messages', 'Besoin', True); |
437 |
end;
|
438 |
|
439 |
// Mati?res premi?res et aliments
|
440 |
|
441 |
procedure TFConfig.CBRapChange (Sender : TObject) ;
|
442 |
begin
|
443 |
if not Update |
444 |
then
|
445 |
begin
|
446 |
ConfRap := CBRap.ItemIndex ; |
447 |
ConfigChanged := TRUE ; |
448 |
end ;
|
449 |
end ;
|
450 |
|
451 |
procedure TFConfig.CBDigChange (Sender : TObject) ;
|
452 |
begin
|
453 |
if CBDig.ItemIndex = 0 |
454 |
then // CUD |
455 |
begin
|
456 |
CBDCompo.Enabled := FALSE ; |
457 |
CBDAA.Enabled := FALSE ; |
458 |
end
|
459 |
else // Teneur digestible |
460 |
begin
|
461 |
CBDCompo.Enabled := TRUE ; |
462 |
CBDAA.Enabled := TRUE ; |
463 |
end ;
|
464 |
if not Update |
465 |
then
|
466 |
begin
|
467 |
ConfDig := CBDig.ItemIndex ; |
468 |
if CBDig.ItemIndex = 0 |
469 |
then // CUD |
470 |
begin
|
471 |
Update := TRUE ; |
472 |
CBdCompo.ItemIndex := 1; // % |
473 |
CBdAA.ItemIndex := 1; // % |
474 |
Update := FALSE ; |
475 |
end ;
|
476 |
ConfDCompo := CBDCompo.ItemIndex ; |
477 |
ConfDAA := CBDAA.ItemIndex ; |
478 |
ConfigChanged := TRUE ; |
479 |
end ;
|
480 |
end ;
|
481 |
|
482 |
procedure TFConfig.CBTCompoChange (Sender : TObject) ;
|
483 |
begin
|
484 |
if not Update |
485 |
then
|
486 |
begin
|
487 |
ConfTCompo := CBTCompo.ItemIndex ; |
488 |
ConfigChanged := TRUE ; |
489 |
end ;
|
490 |
end ;
|
491 |
|
492 |
procedure TFConfig.CBTAAChange (Sender : TObject) ;
|
493 |
begin
|
494 |
if not Update |
495 |
then
|
496 |
begin
|
497 |
ConfTAA := CBTAA.ItemIndex ; |
498 |
ConfigChanged := TRUE ; |
499 |
end ;
|
500 |
end ;
|
501 |
|
502 |
procedure TFConfig.CBTAGChange (Sender : TObject) ;
|
503 |
begin
|
504 |
if not Update |
505 |
then
|
506 |
begin
|
507 |
ConfTAG := CBTAG.ItemIndex ; |
508 |
ConfigChanged := TRUE ; |
509 |
end ;
|
510 |
end ;
|
511 |
|
512 |
procedure TFConfig.CBTMacroChange (Sender : TObject) ;
|
513 |
begin
|
514 |
if not Update |
515 |
then
|
516 |
begin
|
517 |
ConfTMacro := CBTMacro.ItemIndex ; |
518 |
ConfigChanged := TRUE ; |
519 |
end ;
|
520 |
end ;
|
521 |
|
522 |
procedure TFConfig.CBTOligoChange (Sender : TObject) ;
|
523 |
begin
|
524 |
if not Update |
525 |
then
|
526 |
begin
|
527 |
ConfTOligo := CBTOligo.ItemIndex ; |
528 |
ConfigChanged := TRUE ; |
529 |
end ;
|
530 |
end ;
|
531 |
|
532 |
procedure TFConfig.CBTFibresChange (Sender : TObject) ;
|
533 |
begin
|
534 |
if not Update |
535 |
then
|
536 |
begin
|
537 |
ConfTFibres := CBTFibres.ItemIndex ; |
538 |
ConfigChanged := TRUE ; |
539 |
end ;
|
540 |
end ;
|
541 |
|
542 |
procedure TFConfig.CBdCompoChange (Sender : TObject) ;
|
543 |
begin
|
544 |
if not Update |
545 |
then
|
546 |
begin
|
547 |
ConfdCompo := CBdCompo.ItemIndex ; |
548 |
ConfigChanged := TRUE ; |
549 |
end ;
|
550 |
end ;
|
551 |
|
552 |
procedure TFConfig.CBdAAChange (Sender : TObject) ;
|
553 |
begin
|
554 |
if not Update |
555 |
then
|
556 |
begin
|
557 |
ConfdAA := CBdAA.ItemIndex ; |
558 |
ConfigChanged := TRUE ; |
559 |
end ;
|
560 |
end ;
|
561 |
|
562 |
procedure TFConfig.CBAffMPClick (Sender : TObject) ;
|
563 |
begin
|
564 |
if not Update |
565 |
then
|
566 |
begin
|
567 |
ConfAffMP := CBAffMP.Checked ; |
568 |
ConfigChanged := TRUE ; |
569 |
end ;
|
570 |
end ;
|
571 |
|
572 |
// Truie
|
573 |
|
574 |
procedure TFConfig.CBXTruieChange(Sender: TObject);
|
575 |
begin
|
576 |
if not Update |
577 |
then
|
578 |
begin
|
579 |
XTruie := CBXTruie.ItemIndex ; |
580 |
ConfigChanged := TRUE ; |
581 |
end ;
|
582 |
end;
|
583 |
|
584 |
procedure TFConfig.CheckBoxUpdatesClick(Sender: TObject);
|
585 |
begin
|
586 |
if not Update |
587 |
then
|
588 |
begin
|
589 |
CheckForUpdates := CheckBoxUpdates.Checked; |
590 |
ConfigChanged := TRUE; |
591 |
end;
|
592 |
end;
|
593 |
|
594 |
procedure TFConfig.CBTypeAliGestChange(Sender: TObject);
|
595 |
var
|
596 |
etat : boolean ; |
597 |
begin
|
598 |
etat := Update ; |
599 |
Update := TRUE ; |
600 |
case CBTypeAliGest.ItemIndex of |
601 |
0 : // Une p?riode - Quantit? constante |
602 |
begin
|
603 |
PBDuree1.Visible := FALSE ; |
604 |
PBDuree3.Visible := FALSE ; |
605 |
PBQuantite1.Visible := FALSE ; |
606 |
PBQuantite2.Visible := FALSE ; |
607 |
PBQuantite3.Visible := FALSE ; |
608 |
PBAugment.Visible := FALSE ; |
609 |
PBDuree2.AsInteger := DureeGest ; |
610 |
end ;
|
611 |
1 : // Deux p?riodes - Quantit? finale fix?e |
612 |
begin
|
613 |
PBDuree1.Visible := FALSE ; |
614 |
PBDuree3.Visible := TRUE ; |
615 |
PBQuantite1.Visible := FALSE ; |
616 |
PBQuantite2.Visible := FALSE ; |
617 |
PBQuantite3.Visible := TRUE ; |
618 |
PBAugment.Visible := FALSE ; |
619 |
PBDuree2.AsInteger := DureeGest - Duree3 ; |
620 |
if ActiveControl <> PBDuree3
|
621 |
then
|
622 |
PBDuree3.AsInteger := Duree3 ; |
623 |
if ActiveControl <> PBQuantite3
|
624 |
then
|
625 |
PBQuantite3.AsFloat := Quantite3 ; |
626 |
end ;
|
627 |
2 : // Deux p?riodes - Augmentation fix?e |
628 |
begin
|
629 |
PBDuree1.Visible := FALSE ; |
630 |
PBDuree3.Visible := TRUE ; |
631 |
PBQuantite1.Visible := FALSE ; |
632 |
PBQuantite2.Visible := FALSE ; |
633 |
PBQuantite3.Visible := FALSE ; |
634 |
PBAugment.Visible := TRUE ; |
635 |
PBDuree2.AsInteger := DureeGest - Duree3 ; |
636 |
if ActiveControl <> PBDuree3
|
637 |
then
|
638 |
PBDuree3.AsInteger := Duree3 ; |
639 |
if ActiveControl <> PBAugment
|
640 |
then
|
641 |
PBAugment.AsFloat := Augment ; |
642 |
end ;
|
643 |
3 : // Trois p?riodes - Augmentation et quantit? finale fix?es |
644 |
begin
|
645 |
PBDuree1.Visible := TRUE ; |
646 |
PBDuree3.Visible := TRUE ; |
647 |
PBQuantite1.Visible := FALSE ; |
648 |
PBQuantite2.Visible := FALSE ; |
649 |
PBQuantite3.Visible := TRUE ; |
650 |
PBAugment.Visible := TRUE ; |
651 |
if ActiveControl <> PBDuree1
|
652 |
then
|
653 |
PBDuree1.AsInteger := Duree1 ; |
654 |
PBDuree2.AsInteger := DureeGest - Duree1 - Duree3 ; |
655 |
if ActiveControl <> PBDuree3
|
656 |
then
|
657 |
PBDuree3.AsInteger := Duree3 ; |
658 |
if ActiveControl <> PBAugment
|
659 |
then
|
660 |
PBAugment.AsFloat := Augment ; |
661 |
if ActiveControl <> PBQuantite3
|
662 |
then
|
663 |
PBQuantite3.AsFloat := Quantite3 ; |
664 |
end ;
|
665 |
4 : // Trois p?riodes - Quantit?s des p?riodes 2 et 3 fix?es |
666 |
begin
|
667 |
PBDuree1.Visible := TRUE ; |
668 |
PBDuree3.Visible := TRUE ; |
669 |
PBQuantite1.Visible := FALSE ; |
670 |
PBQuantite2.Visible := TRUE ; |
671 |
PBQuantite3.Visible := TRUE ; |
672 |
PBAugment.Visible := FALSE ; |
673 |
if ActiveControl <> PBDuree1
|
674 |
then
|
675 |
PBDuree1.AsInteger := Duree1 ; |
676 |
PBDuree2.AsInteger := DureeGest - Duree1 - Duree3 ; |
677 |
if ActiveControl <> PBDuree3
|
678 |
then
|
679 |
PBDuree3.AsInteger := Duree3 ; |
680 |
if ActiveControl <> PBQuantite2
|
681 |
then
|
682 |
PBQuantite2.AsFloat := Quantite2 ; |
683 |
if ActiveControl <> PBQuantite3
|
684 |
then
|
685 |
PBQuantite3.AsFloat := Quantite3 ; |
686 |
end ;
|
687 |
5 : // Trois p?riodes - Augmentation et quantit? initiale fix?es |
688 |
begin
|
689 |
PBDuree1.Visible := TRUE ; |
690 |
PBDuree3.Visible := TRUE ; |
691 |
PBQuantite1.Visible := TRUE ; |
692 |
PBQuantite2.Visible := FALSE ; |
693 |
PBQuantite3.Visible := FALSE ; |
694 |
PBAugment.Visible := TRUE ; |
695 |
if ActiveControl <> PBDuree1
|
696 |
then
|
697 |
PBDuree1.AsInteger := Duree1 ; |
698 |
PBDuree2.AsInteger := DureeGest - Duree1 - Duree3 ; |
699 |
if ActiveControl <> PBDuree3
|
700 |
then
|
701 |
PBDuree3.AsInteger := Duree3 ; |
702 |
if ActiveControl <> PBAugment
|
703 |
then
|
704 |
PBAugment.AsFloat := Augment ; |
705 |
if ActiveControl <> PBQuantite1
|
706 |
then
|
707 |
PBQuantite1.AsFloat := Quantite1 ; |
708 |
end ;
|
709 |
end ;
|
710 |
Update := etat ; |
711 |
if not Update |
712 |
then
|
713 |
begin
|
714 |
TypeAliGest := CBTypeAliGest.ItemIndex ; |
715 |
ConfigChanged := TRUE ; |
716 |
end ;
|
717 |
end;
|
718 |
|
719 |
procedure TFConfig.PBDuree1Change(Sender: TObject);
|
720 |
begin
|
721 |
if not Update |
722 |
then
|
723 |
begin
|
724 |
Duree1 := PBDuree1.AsInteger ; |
725 |
CBTypeALiGestChange (nil) ;
|
726 |
ConfigChanged := TRUE ; |
727 |
end ;
|
728 |
end;
|
729 |
|
730 |
procedure TFConfig.PBDuree3Change(Sender: TObject);
|
731 |
begin
|
732 |
if not Update |
733 |
then
|
734 |
begin
|
735 |
Duree3 := PBDuree3.AsInteger ; |
736 |
CBTypeALiGestChange (nil) ;
|
737 |
ConfigChanged := TRUE ; |
738 |
end ;
|
739 |
end;
|
740 |
|
741 |
procedure TFConfig.PBQuantite1Change(Sender: TObject);
|
742 |
begin
|
743 |
if not Update |
744 |
then
|
745 |
begin
|
746 |
Quantite1 := PBQuantite1.AsFloat ; |
747 |
CBTypeALiGestChange (nil) ;
|
748 |
ConfigChanged := TRUE ; |
749 |
end ;
|
750 |
end;
|
751 |
|
752 |
procedure TFConfig.PBQuantite2Change(Sender: TObject);
|
753 |
begin
|
754 |
if not Update |
755 |
then
|
756 |
begin
|
757 |
Quantite2 := PBQuantite2.AsFloat ; |
758 |
CBTypeALiGestChange (nil) ;
|
759 |
ConfigChanged := TRUE ; |
760 |
end ;
|
761 |
end;
|
762 |
|
763 |
procedure TFConfig.PBQuantite3Change(Sender: TObject);
|
764 |
begin
|
765 |
if not Update |
766 |
then
|
767 |
begin
|
768 |
Quantite3 := PBQuantite3.AsFloat ; |
769 |
CBTypeALiGestChange (nil) ;
|
770 |
ConfigChanged := TRUE ; |
771 |
end ;
|
772 |
end;
|
773 |
|
774 |
procedure TFConfig.PBAugmentChange(Sender: TObject);
|
775 |
begin
|
776 |
if not Update |
777 |
then
|
778 |
begin
|
779 |
Augment := PBAugment.AsFloat ; |
780 |
CBTypeAliGestChange (nil) ;
|
781 |
ConfigChanged := TRUE ; |
782 |
end ;
|
783 |
end;
|
784 |
|
785 |
// Porc croissance
|
786 |
|
787 |
procedure TFConfig.CBXCroisChange(Sender: TObject);
|
788 |
begin
|
789 |
if not Update |
790 |
then
|
791 |
begin
|
792 |
XCrois := CBXCrois.ItemIndex ; |
793 |
ConfigChanged := TRUE ; |
794 |
end ;
|
795 |
end;
|
796 |
|
797 |
procedure TFConfig.CBTeteClick(Sender: TObject);
|
798 |
begin
|
799 |
if CBTete.Checked
|
800 |
then
|
801 |
CBLangue.Enabled := TRUE |
802 |
else
|
803 |
begin
|
804 |
CarLangue := FALSE ; |
805 |
CBLangue.Checked := FALSE ; |
806 |
CBLangue.Enabled := FALSE ; |
807 |
end ;
|
808 |
if not Update |
809 |
then
|
810 |
begin
|
811 |
CarTete := CBTete.Checked ; |
812 |
ConfigChanged := TRUE ; |
813 |
end ;
|
814 |
end;
|
815 |
|
816 |
procedure TFConfig.CBLangueClick(Sender: TObject);
|
817 |
begin
|
818 |
if not Update |
819 |
then
|
820 |
begin
|
821 |
CarLangue := CBLangue.Checked ; |
822 |
ConfigChanged := TRUE ; |
823 |
end ;
|
824 |
end;
|
825 |
|
826 |
procedure TFConfig.CBPiedsClick(Sender: TObject);
|
827 |
begin
|
828 |
if not Update |
829 |
then
|
830 |
begin
|
831 |
CarPieds := CBPieds.Checked ; |
832 |
ConfigChanged := TRUE ; |
833 |
end ;
|
834 |
end;
|
835 |
|
836 |
procedure TFConfig.CBQueueClick(Sender: TObject);
|
837 |
begin
|
838 |
if not Update |
839 |
then
|
840 |
begin
|
841 |
CarQueue := CBQueue.Checked ; |
842 |
ConfigChanged := TRUE ; |
843 |
end ;
|
844 |
end;
|
845 |
|
846 |
procedure TFConfig.CBHampeClick(Sender: TObject);
|
847 |
begin
|
848 |
if not Update |
849 |
then
|
850 |
begin
|
851 |
CarHampe := CBHampe.Checked ; |
852 |
ConfigChanged := TRUE ; |
853 |
end ;
|
854 |
end;
|
855 |
|
856 |
procedure TFConfig.CBPanneClick(Sender: TObject);
|
857 |
begin
|
858 |
if not Update |
859 |
then
|
860 |
begin
|
861 |
CarPanne := CBPanne.Checked ; |
862 |
ConfigChanged := TRUE ; |
863 |
end ;
|
864 |
end;
|
865 |
|
866 |
procedure TFConfig.RBFeedInfoClick(Sender: TObject);
|
867 |
begin
|
868 |
if not Update |
869 |
then
|
870 |
begin
|
871 |
ConfigChanged := True; |
872 |
if RBIC.Checked
|
873 |
then // Indice de consommation |
874 |
FeedInfo := 0
|
875 |
else // Efficacit? alimentaire |
876 |
FeedInfo := 1;
|
877 |
end;
|
878 |
end;
|
879 |
|
880 |
procedure TFConfig.RBFatInfoClick(Sender: TObject);
|
881 |
begin
|
882 |
if not Update |
883 |
then
|
884 |
begin
|
885 |
ConfigChanged := True; |
886 |
if RBP2.Checked
|
887 |
then // P2 |
888 |
FatInfo := 0
|
889 |
else // User defined |
890 |
FatInfo := -1;
|
891 |
end;
|
892 |
end;
|
893 |
|
894 |
procedure TFConfig.SBUserFatClick(Sender: TObject);
|
895 |
begin
|
896 |
FUserEquation := TFUserEquation.Create(Self); |
897 |
with FUserEquation do |
898 |
begin
|
899 |
EShortName.Text := UserFatShortName; |
900 |
ELongName.Text := UserFatLongName; |
901 |
if UserFatPVV then RBRatioPVV.Checked := True; |
902 |
VEA.AsFloat := UserFatA; |
903 |
VEB.AsFloat := UserFatB; |
904 |
VEC.AsFloat := UserFatC; |
905 |
if ShowModal = mrOk
|
906 |
then
|
907 |
begin
|
908 |
ConfigChanged := True; |
909 |
UserFatShortName := Trim(EShortName.Text); |
910 |
UserFatLongName := Trim(ELongName.Text); |
911 |
UserFatPVV := RBRatioPVV.Checked; |
912 |
UserFatA := VEA.AsFloat; |
913 |
UserFatB := VEB.AsFloat; |
914 |
UserFatC := VEC.AsFloat; |
915 |
if Length(UserFatShortName) = 0 |
916 |
then
|
917 |
RBUserFat.Caption := StrEquation(_('UserP2'), UserFatPVV, UserFatA, UserFatB, UserFatC)
|
918 |
else
|
919 |
RBUserFat.Caption := StrEquation(UserFatShortName, UserFatPVV, UserFatA, UserFatB, UserFatC); |
920 |
if Length(UserFatLongName) = 0 |
921 |
then
|
922 |
RBUserFat.Hint := _('User backfat thickness')
|
923 |
else
|
924 |
RBUserFat.Hint := UserFatLongName; |
925 |
end;
|
926 |
Release; |
927 |
end;
|
928 |
end;
|
929 |
|
930 |
procedure TFConfig.RBLeanInfoClick(Sender: TObject);
|
931 |
begin
|
932 |
if not Update |
933 |
then
|
934 |
begin
|
935 |
ConfigChanged := True; |
936 |
if RBTMP.Checked
|
937 |
then // TMP |
938 |
LeanInfo := 0
|
939 |
else // User defined |
940 |
LeanInfo := -1;
|
941 |
end;
|
942 |
end;
|
943 |
|
944 |
procedure TFConfig.SBUserLeanClick(Sender: TObject);
|
945 |
begin
|
946 |
FUserEquation := TFUserEquation.Create(Self); |
947 |
with FUserEquation do |
948 |
begin
|
949 |
EShortName.Text := UserLeanShortName; |
950 |
ELongName.Text := UserLeanLongName; |
951 |
if UserLeanPVV then RBRatioPVV.Checked := True; |
952 |
VEA.AsFloat := UserLeanA; |
953 |
VEB.AsFloat := UserLeanB; |
954 |
VEC.AsFloat := UserLeanC; |
955 |
if ShowModal = mrOk
|
956 |
then
|
957 |
begin
|
958 |
ConfigChanged := True; |
959 |
UserLeanShortName := Trim(EShortName.Text); |
960 |
UserLeanLongName := Trim(ELongName.Text); |
961 |
UserLeanPVV := RBRatioPVV.Checked; |
962 |
UserLeanA := VEA.AsFloat; |
963 |
UserLeanB := VEB.AsFloat; |
964 |
UserLeanC := VEC.AsFloat; |
965 |
if Length(UserLeanShortName) = 0 |
966 |
then
|
967 |
RBUserLean.Caption := StrEquation(_('UserLean'), UserLeanPVV, UserLeanA, UserLeanB, UserLeanC)
|
968 |
else
|
969 |
RBUserLean.Caption := StrEquation(UserLeanShortName, UserLeanPVV, UserLeanA, UserLeanB, UserLeanC); |
970 |
if Length(UserLeanLongName) = 0 |
971 |
then
|
972 |
RBUserLean.Hint := _('User lean')
|
973 |
else
|
974 |
RBUserLean.Hint := UserLeanLongName; |
975 |
end;
|
976 |
Release; |
977 |
end;
|
978 |
end;
|
979 |
|
980 |
function TFConfig.StrEquation(Name: String; PVV: Boolean; a, b, c: Double): String; |
981 |
var
|
982 |
BUnit, CUnit: String;
|
983 |
begin
|
984 |
if PVV
|
985 |
then
|
986 |
BUnit := Format('%s/%s', [StrP, StrPVV])
|
987 |
else
|
988 |
BUnit := StrP; |
989 |
if PVV
|
990 |
then
|
991 |
CUnit := Format('%s/%s', [StrL, StrPVV])
|
992 |
else
|
993 |
CUnit := StrL; |
994 |
if c = 0 |
995 |
then
|
996 |
if b = 0 |
997 |
then
|
998 |
Result := Format('%s = %s', [Name, DblToStr(a, 5)]) |
999 |
else
|
1000 |
if a = 0 |
1001 |
then
|
1002 |
Result := Format('%s = %s %s', [Name, DblToStr(b, 5), BUnit]) |
1003 |
else
|
1004 |
if b < 0 |
1005 |
then
|
1006 |
Result := Format('%s = %s - %s %s', [Name, DblToStr(a, 5), DblToStr(Abs(b), 5), BUnit]) |
1007 |
else
|
1008 |
Result := Format('%s = %s + %s %s', [Name, DblToStr(a, 5), DblToStr(b, 5), BUnit]) |
1009 |
else
|
1010 |
if b = 0 |
1011 |
then
|
1012 |
if a = 0 |
1013 |
then
|
1014 |
Result := Format('%s = %s %s', [Name, DblToStr(c, 5), CUnit]) |
1015 |
else
|
1016 |
if c < 0 |
1017 |
then
|
1018 |
Result := Format('%s = %s - %s %s', [Name, DblToStr(a, 5), DblToStr(Abs(c), 5), CUnit]) |
1019 |
else
|
1020 |
Result := Format('%s = %s + %s %s', [Name, DblToStr(a, 5), DblToStr(c, 5), CUnit]) |
1021 |
else
|
1022 |
if a = 0 |
1023 |
then
|
1024 |
if c < 0 |
1025 |
then
|
1026 |
Result := Format('%s = %s %s - %s %s', [Name, DblToStr(b, 5), BUnit, DblToStr(Abs(c), 5), CUnit]) |
1027 |
else
|
1028 |
Result := Format('%s = %s %s + %s %s', [Name, DblToStr(b, 5), BUnit, DblToStr(c, 5), CUnit]) |
1029 |
else
|
1030 |
if c < 0 |
1031 |
then
|
1032 |
if b < 0 |
1033 |
then
|
1034 |
Result := Format('%s = %s - %s %s - %s %s', [Name, DblToStr(a, 5), DblToStr(Abs(b), 5), BUnit, DblToStr(Abs(c), 5), CUnit]) |
1035 |
else
|
1036 |
Result := Format('%s = %s + %s %s - %s %s', [Name, DblToStr(a, 5), DblToStr(b, 5), BUnit, DblToStr(Abs(c), 5), CUnit]) |
1037 |
else
|
1038 |
if b < 0 |
1039 |
then
|
1040 |
Result := Format('%s = %s - %s %s + %s %s', [Name, DblToStr(a, 5), DblToStr(Abs(b), 5), BUnit, DblToStr(c, 5), CUnit]) |
1041 |
else
|
1042 |
Result := Format('%s = %s + %s %s + %s %s', [Name, DblToStr(a, 5), DblToStr(b, 5), BUnit, DblToStr(c, 5), CUnit]); |
1043 |
end;
|
1044 |
|
1045 |
end.
|