-
Notifications
You must be signed in to change notification settings - Fork 3
/
uParameter.pas
7566 lines (6718 loc) · 247 KB
/
uParameter.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
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit uParameter;
(*
C.Gülker, M. Schmidt
Basisunit für die komfortable Verwaltung von Programmparametern:
Diese Unit "uParameter" muss in FrmOptionen (und in Global.pas wenn die Parameter dort deklariert sind) eingebunden werden.
*****************************************************************************************************************
*****************************************************************************************************************
26.09.2019 - ms - ParameterSynchronizer: Update Parameter-Inis w/o fully loading them (Logging/MD5 Support)
Structural Remake
T_PARAM_INT64
Check for used/inaccessable Files
18.09.2019 - ms - Change: Additional Parameter for STR_PARAM, indicating the Value will be a Folder (Auto-Enforcing of Folder-Structures)
26.06.2019 - ms - Change: ParameterUebernehmen CleanUp (14.01.2015) not automatic anymore, CleanUp-Switch for 'ParameterUebernehmen'
12.06.2019 - ms - FrmParameterBackup.ExecuteAndLoad
26.03.2019 - ms - uTiming Additions
04.02.2019 - ms - Internal ValueExists to speed things up with regular Ini
Change: EPS 1.0E-15 to 1.0E-8
RegistryIniFile Support
05.10.2018 - ms - BugFix T_INI_DATEI.Create: Empty FileName caused ForceDirectories-Exception
04.09.2018 - ms - BugFix: T_PARAM_STR: not default-initialized if not Password-type
BugFix: T_PARAM_STR_List: Save behaves like other parameter-types (was auto-saved in OnExit .. (Kamplade))
BugFix: T_PARAM_*.Save: result not initialized when using un-initialized instances
10.08.2018 - ms - BugFix: RangeCheckError on empty Parameter-Record
INIT_CHECK define
03.07.2018 - ms - BugFix: missing Exceptions for unsupported Propertys
T_PARAM_REAL/T_PARAM_INT: min/max 0 uses MinDouble/Low( Integer ) to MaxDouble/High( Integer ) (full range)
T_PARAM_REAL: Date-/Time-Property Support (JvDateEdit, JvTimeEdit)
Removed: anzParameterInited
CloseIniDatei: returns Name(D2006+) or Number(Logical Order in Record) of not initialized Parameters
BugFix: fLoaded false since IniSection, IniName need to be trimmed to work same as Ini.Read...
16.05.2018 - ms - BugFix: MD5 didn't work without FastIniFiles
23.03.2018 - ms - GetIsAllDefault-property shows if INI was fully loaded
06.03.2018 - ms - BugFix: ForceDirectorys for new ParameterFiles/Paths
04.10.2017 - ms - BugFix: missing fChanged:=false in Load-procedures
05.04.2017 - ms - BugFix: EGerade/EPunkt Load/Save: now using uParam_StrToFloat_Int
Change: Real Load/Save: now using uParam_StrToFloat_Int
23.03.2017 - ms - DUPECHECK added (Check for duplicate use of same VCL-Objects)
12.03.2017 - ms - BugFix: UnHighlightChangedValues only called if there are changes to unhighlight ..
BugFix: HighlightItem only executed if called by MainThread
09.01.2017 - ms - BugFix: BackupList crashed on empty MD5-Files
BugFix: Backup Cleanup ignored MD5-Files
BugFix: Backup Cleanup: delete-exception showed wrong filenames
22.11.2016 - ms - BugFix: 'Changed' isnt set during Init-Phase
10.11.2016 - ms - BugFix: Exception if MAXPARAMETER_ is exceeded
BugFix: Calling Init_Param's not creating array-dups anymore
MasterBackup not bound to 'AutoBackup' define anymore
Backup Formular (On MD5 Fail & ListBackups)
Reload-procedure (INI->Array&VCL)
SetValue checks for NoVCL
BugFix: OnChange sets 'changed' before calling follow events
SetValue raises OnChange (if SetValueRaiseOnChange is defined)
StrToFloat_Int improved
04.10.2016 - ms - BugFix: BackUp MD5 wasnt checked, not found/missing folder
12.09.2016 - ms - BugFix: ePunkt X not saved, logging format-exception
eGerade X/Y not saved
StrList filesection desynch
28.08.2016 - ms - BugFix: Param_Bool.Save partialy ignored TRadioButton-Changes (passive)
08.08.2016 - ms - ParameterUebernehmen: UserName & Comment for Logging
01.07.2016 - ms - During Application.Terminate 'Save' doesnt refresh from Propertys
24.06.2016 - ms - StringList Param BugFix (FastIniFiles)
06.06.2016 - ms - BugFix: AutoBackup CleanUp
MD5-Check Stream-based / Support for LARGE Inis
02.05.2016 - ms - AutoBackup (CompilerSwitch)
Creates one backup per day (IniName_yyyy_mm_dd.bak) with max of PARAMETER_MAX_BACKUPS_
MD5-Check Final/Bugfixes
ParameterUebernehmen MasterBackup switch
Creates backup (IniName_Master.bak) which is seperated from AutoBackUp
19.02.2016 - ms - Inited-Flag verhindert speichern während Parameter-Laden (Zwischen OpenFile und CloseFile)
BugFix: WriteLog
MD5-Check (Beta)
01.02.2016 - ms - SetValue löst keine OnChanges mehr aus
28.01.2016 - ms - BugFix: NoVCL
BugFix: BackUp-Values: EPunkt
BackUp-Values in PARAM-Objekte verschoben
BugFix: StackOverflow (RestoreEvents (T_PARAM_STR))
05.12.2015 - ms - Delphi 10 Seattle support
Komponentenabhängigkeit gelöst, alles property basiert
21.10.2015 - ms - PARAM_INT & PARAM_STR: TLabeledEdit support
SerialDialog support (TSerComboBox, TSerPortComboBox, TSerBaudComboBox, TSerDataBitsComboBox, TSerStopBitsComboBox, TSerParityBitComboBox, TSerHandshakeComboBox)
JvIPAddress support
07.09.2015 - ms - Logging: Passwörter werden nicht mehr geloggt, nur änderungshinweis
18.06.2015 - ms - Object-Descendant-Support
19.05.2015 - ms - BugFix: Stackoverflow (Parameter mehrfach neu laden: OnChange->OriginalOnChange->OnChange ...)
07.04.2015 - ms - Unnötige Get-Funktionen entfernt
Parameterstruktur Optimiert
StringList-ParamTyp debuggt (Destroy/OnExit-Redirect)
Typecasts Debugger-Freundlich umgestellt
Propertys für Default-/Min-/Max-Werte (Direktzugriff, keine Plausibilitätsprüfungen)
Werte_geandert basiert jetzt auf BackUp-Werten
14.01.2015 - ms - ParameterUebernehmen CleanUp (Entfernt beim Speichern nicht mehr benötigte Einträge aus der INI)
18.12.2014 - ms - HighlightChangedValues/HighlightChangedValuesFromOtherIni jetzt funktionen mit ÄnderungsCount als rückgabe
16.12.2014 - ms - TMemIniFile/FastIniFiles support
Doppelte Section-Var entfernt
Section übergabe-Parameter aus den Save-proceduren entfernt
09.09.2014 - ms - PARAM_AOI implementiert
BugFix: Clone/Log/Highlight ROIs wurden ignoriert
31.07.2014 - ms - BugFix: Overflow im Real/Integer OnKeyPress // ePunkt OnKeyPress hinzugefügt
04.07.2014 - ms - Destructor erweitert (SpeicherLeak)
27.06.2014 - ms - MathRout per Compilerdirektive
OnExit / OnKeyPress weiterleiten zu ggf vorhandenen OriginalEvents
BugFix: Copy/Paste fehler in Destroy
27.05.2014 - ms - Dateiname als public property
NoVCL property um beim Mehrfach-Instanz-Laden ohne weitere Lade-funktion die VCL abzukoppeln
20.05.2014 - ms - Destroy eingeführt um StackOverflow/Loop beim mehrfachen erstellen von Parametern mit VCL zugriff zu beheben
Compilerwarnungen verschwinden lassen
fCountInt & fCountROI getrennt
GetTok, NumTok, StrToFloat int mit uParam_ prefixed (Kompatibilität mit uStrUtil)
02.04.2014 - ms - Werte_noch_nicht_gespeichert wieder entfernt, werte_geandert boolean wieder private, property werte_geandert (readOnly) als ersatz
Logging funktion beim Parameter_Uebernehmen (NUR beim Speichern in Datei)
HighlightChangedValues( showOldValuesAsHint ) Färbt alle komponenten deren Werte sich seit dem letzten Speichern geändert haben (Übernommen aber NICHT gespeichert) (Alter wert als Hint falls gewünscht)
HighlightChangedValuesFromOtherIni( parameter_compare, showOldValuesAsHint ) Färbt alle komponenten deren Werte sich gegenüber der alternativen INI geändert haben (Alter wert als Hint falls gewünscht)
T_PARAM_STR_LIST.StringsUebernehmen - Assign stat 0..Count-1 Durchlauf, schneller..
T_PARAM_BOOL - OnChange(Click) hinzugefügt um änderungen zu bemerken
SetValue: Setzt überall bei änderung werte_geandert auf True, damit auch non-VCL änderungen bemerkt werden
29.10.2013 - ms - Erweiterung um TColorBox.Selected
11.09.2013 - ms - ReImplementation von änderung '16.08.2005'
11.06.2013 - ms - Kleinere übergabe-absicherungen
- SectionLoeschen hinzugefügt
- Bugfix: StrToFloat bei Sprachumstellung(Inkl. Dezimalseperator) problematisch, auf StrToFloat_Int umgestellt
09.05.2013 - ms - PARAM_REAL/PARAM_EPUNKT StrToFloatDEF stat StrToFloat verwendet um exceptions - auch mit compiler - zu dezimieren
30.11.2012 - ms - PARAM_REAL try/error mode beim parsen um support für . , als Dezimalseperator hinzuzufügen
ms/rk - List/ComboBoxen hinzugefügt
rk - ParamReal hat nachKomma-Stellen-Value
16.08.2005 - mw - Erweiterung um T_PARAM_eGerade
21.04.2005 - cg - Verwaltung von verschlüsselten Strings für z.B. Passworte bei T_PARAM_STR. Automatische Aktivierung
durch die Zuweisung eines EditFelds mit der Eigenschaft PasswordChar <> ''.
Die Strings werden in der IniDatei verschlüsselt -Asciikodiert gespeichert.
z.B. aus Passwort "meer" wird "108100100113018000024020023021017006021018029019030007020009"
04.04.2005 - cg - T_PARAM_BOOL können jetzt auch als RadioButton verwendet werden ( nicht nur Checkbox )
07.03.2005 - cg - Der "Wert" der Parameter kann wieder direkt gelesen und geschrieben werden,
da er jetzt intern als Property deklariert ist.
- Unterstüung von Typ_ePunkt
04.03.2005 - cg - Abfragemöglichkeit für PARAMETER_TYP "Werte_noch_nicht_gespeichert": gibt true zurück, wenn
Parameter geändert worden sind, aber noch nicht gespeichert wurden.
(z.B. Sinnvoll beim Umschalten von mehreren Parametersätzen oder beim Verlassen
der Parametermaske mit einem Abbrechen-Button)
03.03.2005 - cg - Umstellung des records PARAMETER_TYP in eine Instanz der Classe T_INI_DATEI
Dadurch sind jetzt mehrere Parameter-Dateien in einem Programm verwendbar ( z.B. Parameter+ Kopfdaten )
- Mehrfaches einladen der ini-Datei möglich ( um z.B. die geänderten Parameter zu verwerfen )
- Der Name der Inidatei kann durch die Methode ".DateinameAendern( '...' )" zu Laufzeit noch geändert werden,
um andere Parametersätze nachzuladen
z.B. verschiedene Parameter für Kalt- Warmteile. oder ältere Parameter
- Der "Wert" der Parameter kann nur noch über Methoden gelesen und geschrieben werden
z.B. Lesen: x:=testparam.Wert / Schreiben: testparam.Wert( 1234 )
28.2.2005 - cg - Initialisierung der Zähler (fCountInt_ ...) bei jedem Aufruf von uPARAM_OpenIniDatei
- uPARAM_OpenIniDatei kann nicht mehrfach aufgerufen werden -> Exception!
21.2.2005 - cg - Typ T_PARAM_NR kann jetzt neben RadioGroup auch SpinEdit und Scrollbar Objekte
- Überprüfung nach Initialisierung der Parameter, ob keiner vergessen wurde
18.2.2005 - cg - Basisversion
*****************************************************************************************************************
*****************************************************************************************************************
Unterstützt werden folgende Parameter - Typen:
Integer für EditFelder mit zusätzlicher Kontrolle auf Zeichen-Gültigkeit und Wertebereich
Floatingpoint für EditFelder mit zusätzlicher Kontrolle auf Zeichen-Gültigkeit und Wertebereich
Aufzählungstypen für Radiogroup / Spinedit / Scrollbar / Trackbar
Boolsche für CheckBoxen oder Radiobuttons
Strings für EditFelder
String-Liste für Comboboxen oder Listboxen
Rechtecktypen für RECHTECK_TYP = 4 Integer/EditFelder (Es werden intern automatisch 4 Integertypen definiert)
ePunktTypen für Typ_ePunkt = 2-Extended Werte (Es werden intern automatisch 2 Doubletypen definiert)
ROI für ( alte ) ROIs = 4-Integer Werte (TopLeft, BottomRight jeweils X/Y )
AOI für ( neue ) ROIs = 8-Extended Werte (TopLeft, TopRight, BottomLeft, BottomRight jeweils X/Y)
Beispiel:
1 ) z.B. in Unit "global.pas" werden im Interface-Teil die Parameter deklariert:
interface
uses uParameter;
type
PARAMETER_TYP = class( T_INI_DATEI ) // globale Instanz der T_INI_Datei-Class
intParam : T_PARAM_INT;
boolParam : T_PARAM_BOOL;
doubleParam : T_PARAM_REAL;
roi : T_PARAM_ROI;
index : T_PARAM_NR;
strList : T_PARAM_STR_LIST;
ePunkt : T_PARAM_ePunkt;
eGerade : T_PARAM_eGerade;
AOI : T_PARAM_AOI;
end;
2 ) in Unit "global.pas" einen Zeiger auf die globalen Parameter erzeugen:
var
parameter__ : PARAMETER_TYP; // (muss noch in z.B. Main.FrmShow initialisiert werden)
3 ) in z.B. Unit "main.pas" den Zeiger mit Pfad und Dateiname der ini-Datei initialisieren
und anschließend den Befehl zum Laden aufrufen. siehe 4 )
parameter__ := PARAMETER_TYP.Create( programPfad__ + PARAMETER_DIR__ + PROGRAMM_PARAMETER_DATEI__ );
FrmOptionen.Parameter_laden;
4 ) Im Formular mit den Parametern z.B. FrmOptionen werden die Parameter mit Defaultwerten initialisiert
oder falls schon vorhanden aus der Ini-datei geladen.
(Der Aufruf dieser Funktion sollte z.B. in FrmMain.FormShow erfolgen, siehe 3)
Jeder Parameter erhält:
- einen Defaultwert
- bei Integer und Float-Typen zusätzlich Minimum und Maximum
- eine Bezeichnung unter der er in der Ini-Datei geführt wird
- ein Objekt ( TEdit, TCheckBox, TRadiogroup ) aus dem Formular mit dem er geändert werden kann.
( Nur der Rechteck-Typ erhält 4 EditFelder, da hier auf einmal eine ROI angelegt werden kann )
- Wird optional als Objekt "nil" übergeben, so kann der Parameter nur in der Ini-Datei mit
einem Texteditor oder direkt vom Programm aus geändert werden.
Procedure TFrmOptionen.Parameter_laden;
begin
with parameter__ do
begin
OpenIniDatei; // WICHTIG !
SetzteSection( 'Allgemein' );
Init_StrParam( name, 'Testkopfdaten','name', EditKopfdatenName );
Init_RealParam( durchmesserInnenkreis, 50, 30, 200, 'durchmesserInnenkreis', EditKopfdatenParam1 );
SetzteSection( 'BV' );
Init_IntParam( anzPunkteModelle, 4, 3, 4, 'anzPunkteModelle', EditKopfdatenAnzMessp );
for i := 0 to 3 do
Init_ROIParam( roi[ i ], 0,0, uVH_IMAGE_SIZE_X-1, uVH_IMAGE_SIZE_Y-1, 'roi'+IntToStr( i ),nil, nil, nil, nil );
CloseIniDatei; // WICHTIG !
if IsDefault then
ShowMessage( 'Warnung, INI mit default-parametern initialisiert' )
end;
end;
5 ) Jetzt müssen die Parameter nur noch gespeichert werden:
z.B. in procedure TFrmOptionen.BitBtnCloseClick beim Verlassen des Formulars
Dazu braucht man nur EINEN EINZIGEN Aufruf:
parameter__.ParameterUebernehmen( true{Save}, false{logging} );
Save
true = Werte aus Maske in globale-Parameter-Struktur übernehmen und in Ini-datei speichern
false = Werte aus Maske nur in globale-Parameter-Struktur übernehmen ( nicht speichern )
Logging
true = Änderungen werden als ParameterDateiName.log gespeichert ( NUR WENN SAVE=TRUE )
false = Kein logging
6 ) Der Lese-Zugriff im Programm auf die Parameter erfolgt wie gewohnt,
nur ".Wert" muss angehängt werden (.Wert ist eine Methode!)
z.B:
parameter__.intParam.Wert
parameter__.boolParam.Wert
parameter__.doubleParam.Wert
parameter__.roi.x1.Wert
parameter__.roi.x2.Wert
parameter__.index.Wert
7 ) Der Schreib-Zugriff im Programm auf die Parameter erfolgt durch direkte Zuweisung
Die Werte werden bei Bedarf auf Grenzwerte geprüft und in die entsprechenden z.B. EditFelder geschrieben
z.B:
parameter__.intParam.Wert := 45
parameter__.boolParam.Wert := true
parameter__.doubleParam.Wert := 1.234
8 ) Im FormCloseQuery oder ähnlichem kann abgefangen werden ob die änderungen gespeichert werden sollen:
..
if parameter__.Werte_geandert then
begin
if ( Messagedlg( 'Werte wurden geändert! Abspeichern?', mtConfirmation, [ mbYES, mbNO ], 0 ) = mrYes ) then
parameter__.ParameterUebernehmen( true{Save}, false{Log} )
else
parameter_laden;
end;
*)
interface
{.$i *.inc} // MS
// IniType
{.$DEFINE useFastIni} // Requires FastIniFiles.pas
{.$DEFINE useMemIni}
{.$DEFINE useRegistryIni} // Not done
{.$DEFINE useTLH_Math} // eRect, [ePunkt, eGerade]
{$DEFINE useMATHROUT} // ePunkt, eGerade
{$DEFINE JVCL} // JvTimeEdit hasnt published 'Time' ..
// Config
{$DEFINE AutoBackup}
{.$DEFINE MD5}
{$IFDEF MD5} // Better with FastIni
{.$DEFINE INDY90}
{$DEFINE INDY100}
{$ENDIF}
{$DEFINE SetValueRaiseOnChange}
{$DEFINE DUPECHECK} // Check for already used VCL-Objects
{$DEFINE INIT_CHECK} // Raise Exception on not initialized Parameters
{.$DEFINE ASSIGN_VCL} // Assign involves VCL
{.$DEFINE CriticalSections}
{$WARN UNSAFE_CAST OFF}
{$WARN UNSAFE_CODE OFF}
{$WARN UNSAFE_TYPE OFF}
{$WARN SYMBOL_PLATFORM OFF}
{$IF CompilerVersion >= 17}
{$LEGACYIFEND ON}
{$IFEND}
uses
Classes, SysUtils, Graphics, Math,
Forms, StdCtrls
{$IF Defined( useFastIni )}
,FastIniFiles
{$ELSEIF Defined( useRegistryIni )}
,Registry
{$ELSE}
,IniFiles
{$IFEND}
{$IFDEF useTLH_Math}, uTLH.Math{$ENDIF}
{$IFDEF useMATHROUT}, MathRout{$ENDIF}
{$IFDEF CriticalSections}, SyncObjs{$ENDIF}
;
type
TKeyPressEvent = procedure( Sender: TObject; var Key: Char ) of object;
{$IF Defined( useFastIni )}
TIniFileType = TFIniFile;
{$ELSEIF Defined( useMemIni )}
TIniFileType = TMemIniFile;
{$ELSEIF Defined( useRegistryIni )}
TIniFileType = TRegistryIniFile;
{$ELSE}
TIniFileType = TIniFile;
{$IFEND}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type
TOnKeyPressMode_ = ( kpmString, kpmSigned, kpmUnsigned, kpmFloat, kpmFloatUnsigned, kpmExtended, kpmExtendedUnsigned, kpmDateTime, kpmHex, kpmHexBigEndian, kpmDirectoryOrFileName, kpmAlpha, kpmAlphaNumeric );
T_INI_DATEI = class;
tHighLightBackup = Record
Color : TColor;
Hint : String;
ParentFont : boolean;
ParentColor : boolean;
Inited : boolean;
end;
T_PARAM_BASE = class
end;
P_PARAM_BASE = ^T_PARAM_BASE;
T_PARAM_ALLGEMEIN = class( T_PARAM_BASE )
private
fSection : string;
fName : string;
originalOnChange : TNotifyEvent;
fObject : TObject;
fChanged : Boolean;
fOwner : T_INI_DATEI;
fLoaded : Boolean;
HighLight : tHighLightBackup;
{$IFDEF CriticalSections}
fCrit : TCriticalSection;
{$ENDIF}
Procedure OnChange( Sender: TObject );
function GetNoVCL : boolean;
function GetID : Integer;
function ValueExists( IniFile : TIniFileType; const Section, Ident: string ) : boolean;
function IsMyObject( aObject : TObject ) : Boolean;
{$IFNDEF SetValueRaiseOnChange}
Procedure UnsetOnChange( var Method : System.TMethod );
Procedure ResetOnChange( Method : System.TMethod );
{$ENDIF}
procedure OnKeyPressCheckChar( Sender: TObject; var Key: Char; vMode : TOnKeyPressMode_ );
function MethodIsEqual( const MethodPointer1, MethodPointer2 ) : Boolean;
function VCLAccessAllowed : Boolean;
procedure Save;
public
constructor Create( AOwner : T_INI_DATEI; iniSection: string; iniName: string; vObject: TObject = nil );
destructor Destroy; override;
procedure Assign( Param : T_PARAM_ALLGEMEIN );
property Changed : boolean read fChanged default False;
property Owner : T_INI_DATEI read fOwner;
property NoVCL : boolean read GetNoVCL;
property Name : string read fName;
property Section : string read fSection;
property ID : Integer read GetID;
end;
P_PARAM_ALLGEMEIN = ^T_PARAM_ALLGEMEIN;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_INT = class( T_PARAM_ALLGEMEIN )
private
fMinimum : integer;
fMaximum : integer;
fDefault : integer;
fValue : integer;
fBackupValue : integer;
originalOnExit : TNotifyEvent;
originalOnKeyPress : TKeyPressEvent;
Procedure CheckGrenzwerte( Sender:TObject );
Procedure EditIntZahlKeyPress( Sender:TObject; var Key:char );
function GetValue : Integer;
Procedure SetValue( Value: Integer );
procedure Load;
function Save : string;
public
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; def, min, max: integer; iniName: string; vObject: TObject = nil );
destructor Destroy; override;
procedure Assign( Param : T_PARAM_ALLGEMEIN );
procedure VCLToValue;
procedure ValueToVCL;
property Wert : integer read GetValue write SetValue;
property Default: Integer read fDefault write fDefault;
property Minimum: Integer read fMinimum write fMinimum;
property Maximum: Integer read fMaximum write fMaximum;
end;
P_PARAM_INT = ^T_PARAM_INT;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_INT64 = class( T_PARAM_ALLGEMEIN )
private
fMinimum : Int64;
fMaximum : Int64;
fDefault : Int64;
fValue : Int64;
fBackupValue : Int64;
originalOnExit : TNotifyEvent;
originalOnKeyPress : TKeyPressEvent;
Procedure CheckGrenzwerte( Sender:TObject );
Procedure EditIntZahlKeyPress( Sender:TObject; var Key:char );
function GetValue : Int64;
Procedure SetValue( Value: Int64 );
procedure Load;
function Save : string;
public
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; def, min, max: Int64; iniName: string; vObject: TObject = nil );
destructor Destroy; override;
procedure Assign( Param : T_PARAM_ALLGEMEIN );
procedure VCLToValue;
procedure ValueToVCL;
property Wert : Int64 read GetValue write SetValue;
property Default: Int64 read fDefault write fDefault;
property Minimum: Int64 read fMinimum write fMinimum;
property Maximum: Int64 read fMaximum write fMaximum;
end;
P_PARAM_INT64 = ^T_PARAM_INT64;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_NR = class( T_PARAM_ALLGEMEIN )
private
fDefault : integer;
fValue : integer;
fBackupValue : integer;
function GetValue : Integer;
Procedure SetValue( Value: Integer );
procedure Load;
function Save : string;
public
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; def: integer; iniName: string; vObject: TObject = nil );
procedure Assign( Param : T_PARAM_ALLGEMEIN );
procedure VCLToValue;
procedure ValueToVCL;
property Wert : integer read GetValue write SetValue;
property Default: Integer read fDefault write fDefault;
end;
P_PARAM_NR = ^T_PARAM_NR;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_REAL = class( T_PARAM_ALLGEMEIN )
private
fDecimalPlaces : Byte;
fMinimum : double;
fMaximum : double;
fDefault : double;
fValue : double;
fBackupValue : double;
originalOnExit : TNotifyEvent;
originalOnKeyPress : TKeyPressEvent;
Procedure CheckGrenzwerte( Sender:TObject );
Procedure EditFloatZahlKeyPress( Sender:TObject; var Key:char );
function GetValue : double;
Procedure SetValue( Value: double );
procedure Load;
function Save : string;
procedure SetDecimalPlaces( Value : Byte );
public
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; def, min, max: double; iniName: string; vObject: TObject = nil );
destructor Destroy; override;
procedure Assign( Param : T_PARAM_ALLGEMEIN );
procedure VCLToValue;
procedure ValueToVCL;
property Wert : double read GetValue write SetValue;
property Default : Double read fDefault write fDefault;
property Minimum : Double read fMinimum write fMinimum;
property Maximum : Double read fMaximum write fMaximum;
property DecimalPlaces : Byte read fDecimalPlaces write SetDecimalPlaces;
end;
P_PARAM_REAL = ^T_PARAM_REAL;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_BOOL = class( T_PARAM_ALLGEMEIN )
private
fDefault : Boolean;
fValue : Boolean;
fBackupValue : Boolean;
function GetValue : Boolean;
Procedure SetValue( Value: Boolean );
procedure Load;
function Save : string;
public
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; def: Boolean; iniName: string; vObject: TObject = nil );
procedure Assign( Param : T_PARAM_ALLGEMEIN );
procedure VCLToValue;
procedure ValueToVCL;
property Wert : Boolean read GetValue write SetValue;
property Default: boolean read fDefault write fDefault;
end;
P_PARAM_BOOL = ^T_PARAM_BOOL;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_ROI = class( T_PARAM_BASE )
private
function IsMyObject( aObject : TObject ) : Boolean;
{$IFDEF useTLH_Math}
function GetValue : tERect;
Procedure SetValue( Value: tERect );
{$ENDIF}
{$IF Defined( useMATHROUT ) OR Defined( useTLH_Math )}
function GetTopLeft : TYP_ePunkt;
Procedure SetTopLeft( Value: TYP_ePunkt );
function GetTopRight : TYP_ePunkt;
Procedure SetTopRight( Value: TYP_ePunkt );
function GetBottomLeft : TYP_ePunkt;
Procedure SetBottomLeft( Value: TYP_ePunkt );
function GetBottomRight : TYP_ePunkt;
Procedure SetBottomRight( Value: TYP_ePunkt );
{$IFEND}
public
x1 : T_PARAM_INT;
y1 : T_PARAM_INT;
x2 : T_PARAM_INT;
y2 : T_PARAM_INT;
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; minX, minY, maxX, maxY: Integer; iniName: string; editX1 : TObject = nil; editY1 : TObject = nil; editX2 : TObject = nil; editY2: TObject = nil );
destructor Destroy; override;
procedure Assign( Param : T_PARAM_ROI );
function GetSection : String;
procedure Load;
function Save : String;
{$IFDEF useTLH_Math}
property Wert : tERect read GetValue write SetValue;
{$ENDIF}
{$IF Defined( useMATHROUT ) OR Defined( useTLH_Math )}
property TopLeft : TYP_ePunkt read GetTopLeft write SetTopLeft;
property TopRight : TYP_ePunkt read GetTopRight write SetTopRight;
property BottomLeft : TYP_ePunkt read GetBottomLeft write SetBottomLeft;
property BottomRight : TYP_ePunkt read GetBottomRight write SetBottomRight;
{$IFEND}
property Section : String read GetSection;
procedure VCLToValue;
procedure ValueToVCL;
end;
P_PARAM_ROI = ^T_PARAM_ROI;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_AOI = class( T_PARAM_BASE )
private
function IsMyObject( aObject : TObject ) : Boolean;
{$IFDEF useTLH_Math}
function GetValue : tERect;
Procedure SetValue( Value: tERect );
{$ENDIF}
{$IF Defined( useMATHROUT ) OR Defined( useTLH_Math )}
function GetTopLeft : TYP_ePunkt;
Procedure SetTopLeft( Value: TYP_ePunkt );
function GetTopRight : TYP_ePunkt;
Procedure SetTopRight( Value: TYP_ePunkt );
function GetBottomLeft : TYP_ePunkt;
Procedure SetBottomLeft( Value: TYP_ePunkt );
function GetBottomRight : TYP_ePunkt;
Procedure SetBottomRight( Value: TYP_ePunkt );
{$IFEND}
function GetDecimalPlaces : Byte;
procedure SetDecimalPlaces( Value : Byte );
function GetSection : String;
procedure Load;
function Save : String;
public
TopLeftX, TopLeftY : T_PARAM_REAL;
TopRightX, TopRightY : T_PARAM_REAL;
BottomLeftX, BottomLeftY : T_PARAM_REAL;
BottomRightX, BottomRightY : T_PARAM_REAL;
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; minX, minY, maxX, maxY: Double; iniName: string; editTopLeftX : TObject = nil; editTopLeftY : TObject = nil; editTopRightX : TObject = nil; editTopRightY : TObject = nil; editBottomLeftX : TObject = nil; editBottomLeftY : TObject = nil; editBottomRightX : TObject = nil; editBottomRightY : TObject = nil );
destructor Destroy; override;
procedure Assign( Param : T_PARAM_AOI );
{$IFDEF useTLH_Math}
property Wert : tERect read GetValue write SetValue;
{$ENDIF}
{$IF Defined( useMATHROUT ) OR Defined( useTLH_Math )}
property TopLeft : TYP_ePunkt read GetTopLeft write SetTopLeft;
property TopRight : TYP_ePunkt read GetTopRight write SetTopRight;
property BottomLeft : TYP_ePunkt read GetBottomLeft write SetBottomLeft;
property BottomRight : TYP_ePunkt read GetBottomRight write SetBottomRight;
{$IFEND}
property Section : String read GetSection;
property DecimalPlaces : Byte read GetDecimalPlaces write SetDecimalPlaces;
procedure VCLToValue;
procedure ValueToVCL;
end;
P_PARAM_AOI = ^T_PARAM_AOI;
{$IF Defined( useMATHROUT ) OR Defined( useTLH_Math )}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_ePunkt = class( T_PARAM_ALLGEMEIN )
private
fDefault : Typ_ePunkt;
fObjectY : TObject;
fValue : Typ_ePunkt;
fBackupValue : Typ_ePunkt;
originalOnChangeY : TNotifyEvent;
originalOnKeyPressX,
originalOnKeyPressY : TKeyPressEvent;
HighLightY : tHighLightBackup;
Procedure EditFloatZahlKeyPress( Sender:TObject; var Key:char );
function GetValue : Typ_ePunkt;
Procedure SetValue( Value: Typ_ePunkt );
function IsMyObject( aObject : TObject ) : Boolean; reintroduce;
procedure Load;
function Save : string;
public
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; defX, defY: double; iniName: string; editX : TObject = nil; editY : TObject = nil ); overload;
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; def: TYP_ePunkt; iniName: string; editX : TObject = nil; editY : TObject = nil ); overload;
destructor Destroy; override;
procedure Assign( Param : T_PARAM_ALLGEMEIN );
procedure VCLToValue;
procedure ValueToVCL;
property Wert : Typ_ePunkt read GetValue write SetValue;
property Default: Typ_ePunkt read fDefault write fDefault;
end;
P_PARAM_ePUNKT = ^T_PARAM_ePunkt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_eGerade = class( T_PARAM_ALLGEMEIN )
private
fDefault : Typ_eGerade;
fObjectNY : TObject;
fObjectC : TObject;
fValue : Typ_eGerade;
fBackupValue : Typ_eGerade;
originalOnChangeY,
originalOnChangeC : TNotifyEvent;
originalOnKeyPressX,
originalOnKeyPressY,
originalOnKeyPressC : TKeyPressEvent;
HighLightY : tHighLightBackup;
HighLightC : tHighLightBackup;
Procedure EditFloatZahlKeyPress( Sender:TObject; var Key:char );
function GetValue : Typ_eGerade;
Procedure SetValue( Value: Typ_eGerade );
function IsMyObject( aObject : TObject ) : Boolean; reintroduce;
procedure Load;
function Save : string;
public
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; defNX, defNY, defC : double; iniName: string; editNX : TObject = nil; editNY: TObject = nil; editC : TObject = nil ); overload;
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; def : Typ_eGerade; iniName: string; editNX : TObject = nil; editNY: TObject = nil; editC : TObject = nil ); overload;
destructor Destroy; override;
procedure Assign( Param : T_PARAM_ALLGEMEIN );
procedure VCLToValue;
procedure ValueToVCL;
property Wert : Typ_eGerade read GetValue write SetValue;
property Default: Typ_eGerade read fDefault write fDefault;
end;
P_PARAM_eGerade = ^T_PARAM_eGerade;
{$IFEND}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_STR = class( T_PARAM_ALLGEMEIN )
private
fDefault : String;
fValue : string;
fBackupValue : string;
fPassword : Boolean;
fIsPath : Boolean;
function GetValue : string;
Procedure SetValue( Value: String );
function CheckPath( var Value : string; Changed : PBoolean = nil ) : boolean;
procedure Load;
function Save : string;
public
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; Default: string; iniName: string; vObject: TObject = nil; IsPath : boolean = false );
procedure Assign( Param : T_PARAM_ALLGEMEIN );
procedure VCLToValue;
procedure ValueToVCL;
property Wert : String read GetValue write SetValue;
property Default: string read fDefault write fDefault;
end;
P_PARAM_STR = ^T_PARAM_STR;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_PARAM_STR_LIST = class( T_PARAM_ALLGEMEIN )
private
originalOnExit : TNotifyEvent;
fValue : TStringList;
fBackupValue : TStringList;
function GetValue : TStringList;
Procedure SetValue( StrL: TStringList );
procedure Load;
function Save : string;
public
Constructor Create( AOwner : T_INI_DATEI; iniSection: string; vObject: TObject = nil );
destructor Destroy; override;
procedure Assign( Param : T_PARAM_ALLGEMEIN );
procedure VCLToValue;
procedure ValueToVCL;
property Wert : TStringList read GetValue write SetValue;
end;
P_PARAM_STR_LIST = ^T_PARAM_STR_LIST;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
T_INI_DATEI = Class
private
fIniFile : TIniFileType;
{$IF NOT Defined( useMemIni ) AND NOT Defined( useFastIni ) }
fValueExists : TStringList;
{$IFEND}
fFileName : string;
fSection : string; // aktuell eingestellte Ini-Datei Sektion
fInited : Boolean;
fNoVCL : Boolean;
fHighlighted : Boolean;
fCount : Integer;
function GetID( Param : T_PARAM_BASE ): Integer;
Function GetItemPointer( ID : Cardinal ) : P_PARAM_BASE;
Function GetItem( ID : Cardinal ) : T_PARAM_BASE;
// procedure SetItem( ID : Cardinal; Value : T_PARAM_BASE );
{$IF CompilerVersion >= 18}
function GetParameterName( ID : Cardinal ) : string;
{$IFEND}
function GetChanged : boolean;
procedure BackupLog( val : string );
function IsComponentInUse( vObject: TObject ) : boolean;
function GetIsAllDefault : boolean;
function GetInited : boolean;
Procedure SetFileName( Value: string );
function HasVCL : Boolean;
public
Constructor Create( pfad_datname: string );
destructor Destroy; override;
procedure Assign( Source: T_INI_DATEI );
Procedure OpenIniDatei;
Function CloseIniDatei: boolean;
Procedure SetzteSection( sectionName: string );
Procedure SectionLoeschen( sectionName: string );
Procedure ListBackups;
procedure Reload;
procedure VCLToValue;
procedure ValueToVCL;
Function ParameterUebernehmen( save: boolean = false; logging : boolean = false; vCleanUp : boolean = false; UserName : String = ''; Comment : String = ''; MasterBackup : boolean = false{$IFDEF AutoBackup}; NoAutoBackup : boolean = false{$ENDIF} ): integer;
function HighlightChangedValues( showOldValuesAsHint : Boolean = false ): Cardinal; overload;
function HighlightChangedValues( FileName : string; showOldValuesAsHint : Boolean = false ): Cardinal; overload;
procedure UnHighlightChangedValues;
function Compare( FileName : string; ColorObjects : boolean = false; showOldValuesAsHint : Boolean = false; StrL : TStringList = nil ): Cardinal; overload;
function Compare( params : T_INI_DATEI = NIL; ColorObjects : boolean = false; showOldValuesAsHint : Boolean = false; StrL : TStringList = nil ): Cardinal; overload;
property Werte_geandert : boolean read GetChanged;
property Dateiname : string read fFileName write SetFileName;
property NoVCL : boolean read fNoVCL write fNoVCL Default false;
property IsDefault : boolean read GetIsAllDefault;
property Inited : boolean read GetInited;
// Instance-Items
property Count : Integer read fCount;
property Items[ ID : Cardinal ] : T_PARAM_BASE read GetItem; {write SetItem;} default;
{$IF CompilerVersion >= 18}
property Names[ ID : Cardinal ] : string read GetParameterName;
{$IFEND}
// Init/Create
Procedure Init_IntParam( var param : T_PARAM_INT; def, min, max: integer; iniName: string; vObject: TObject = nil );
Procedure Init_Int64Param( var param : T_PARAM_INT64; def, min, max: Int64; iniName: string; vObject: TObject = nil );
Procedure Init_NrParam( var param : T_PARAM_NR; def: integer; iniName: string; vObject: TObject = nil );
Procedure Init_RealParam( var param : T_PARAM_REAL;def, min, max: double; iniName: string; vObject: TObject = nil );
{$IF Defined( useMATHROUT ) OR Defined( useTLH_Math )}
Procedure Init_ePunktParam( var param : T_PARAM_ePunkt; defX, defY: double; iniName: string; editX : TObject = nil; editY : TObject = nil );
Procedure Init_eGeradeParam( var param : T_PARAM_eGerade; defNX, defNY, defC : double; iniName: string; editNX : TObject = nil; editNY : TObject = nil; editC : TObject = nil );
{$IFEND}
Procedure Init_BoolParam( var param : T_PARAM_BOOL;def: boolean; iniName: string; vObject : TObject = nil );
Procedure Init_ROIParam( var param : T_PARAM_ROI; minX, minY, maxX, maxY: Integer; iniName: string; editX1 : TObject = nil; editY1 : TObject = nil; editX2 : TObject = nil; editY2 : TObject = nil );
Procedure Init_AOIParam( var param : T_PARAM_AOI; minX, minY, maxX, maxY: Integer; iniName: string; editTopLeftX : TObject = nil; editTopLeftY : TObject = nil; editTopRightX : TObject = nil; editTopRightY : TObject = nil; editBottomLeftX : TObject = nil; editBottomLeftY : TObject = nil; editBottomRightX : TObject = nil; editBottomRightY : TObject = nil );
Procedure Init_StrParam( var param : T_PARAM_STR; def: string; iniName: string; vObject : TObject = nil; IsPath : boolean = false );
Procedure Init_StrListParam( var param : T_PARAM_STR_LIST; fSection: string; vObject : TObject = nil );
end;
P_INI_DATEI = ^T_INI_DATEI;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TFrmParameterBackup = class(TForm)
lblFileName: TLabel;
lblText: TLabel;
lblAction: TLabel;
btnIgnore: TButton;
grpBackups: TGroupBox;
cbbBackups: TComboBox;
btnLoadDifferent: TButton;
btnCompare: TButton;
mmoCompare: TMemo;
procedure btnLoadDifferentClick(Sender: TObject);
procedure cbbBackupsOnChange(Sender : TObject);
procedure btnCompareClick(Sender: TObject);
private
{ Private-Deklarationen }
fSender : T_INI_DATEI;
fFilePath : String;
public
{ Public-Deklarationen }
constructor CreateNew( AOwner: TComponent ); reintroduce;
function Execute( Sender : T_INI_DATEI; MD5Fail : boolean = True ) : string;
function ExecuteAndLoad( Sender : T_INI_DATEI ) : string;
end;
var
FrmParameterBackup: TFrmParameterBackup;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type
tParameterSynchronizer = class
private
fIni : TIniFileType;
fLog : TStringList;
fStrL : TStringList;
fLogging : Boolean;
public
function Open( FileName : string; Logging : boolean = false ) : boolean;
function Close : boolean;
function Update( Parameter : T_INI_DATEI; Section : string; Create : boolean = false ) : boolean; overload;
function Update( Parameter : T_PARAM_BASE; Create : boolean = false ) : boolean; overload;
constructor Create;
destructor Destroy; override;
end;
var
ParameterSynchronizer : tParameterSynchronizer;
const
PARAMETER_LOGDATEI_EXT_ = 'log';
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{$IFDEF MD5}
{$IF Defined(INDY90) OR Defined(INDY100)}
function GetMD5( const StrL : TStringList ) : string;
{$IFEND}
{$ENDIF}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
implementation
uses
TypInfo, StrUtils, Windows, Dialogs, Controls
{$IF CompilerVersion >= 18},Rtti{$IFEND}
{$IFDEF JVCL},JvSpin{$ENDIF} // JvTimeEdit
{$IFDEF MD5}
{$IF Defined(INDY90) OR Defined(INDY100)},IdHashMessageDigest{$IFEND} // MD5 - Indy9/10
{$ENDIF}
;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const
PASSWORT_VERSCHLUESSELUNGS_WERT_ = 31;
PASSWORT_SPEICHERLAENGE_ = 20;//Anzahl Zeichen in Datei ( mit "PASSWORT_AUFFUELL_ZEICHEN_" aufgefüllt )
PARAMETER_LOGDATEI_MAX_LINES_ = 1000;
PARAMETER_MAX_SAVE_ATTEMP_ = 5;
{$IFDEF AutoBackup}
PARAMETER_MAX_BACKUPS_ = 10;
{$ENDIF}
DEFAULT_SECTION_ : string = 'Verschiedene Parameter';
EPUNKT_SUB_EXTENSION_1_ : string = '.X';
EPUNKT_SUB_EXTENSION_2_ : string = '.Y';
EGERADE_SUB_EXTENSION_1_ : string = '.NX';
EGERADE_SUB_EXTENSION_2_ : string = '.NY';
EGERADE_SUB_EXTENSION_3_ : string = '.C';
PARAMETER_BackupCaption_ : string = 'BackupList';
PARAMETER_BackupText_ : string = 'BackupList for: ';
PARAMETER_BackupActionLabel_ : string = 'Action:';
PARAMETER_BackupButtonCaption_ : string = '&Cancel';
PARAMETER_BackupFailCaption_ : string = 'MD5 Missmatch';
PARAMETER_BackupFailText_ : string = 'MD5 check failed for: ';
PARAMETER_BackupFailButtonCaption_ : string = '&Ignore';
PARAMETER_BackupButtonLoad_ : string = '&Load';
PARAMETER_BackupButtonCompare_ : string = 'C&ompare';
LOG_FORMAT_ : string = '[ %s ] %s';
LOG_INTEGER_ : string = '%s: %s from %d to %d';
LOG_STRING_ : string = '%s: %s from "%s" to "%s"';
LOG_PASSWORD_1_ : string = 'Password: %s';
LOG_PASSWORD_2_ : string = 'Passwort: %s was changed';
LOG_REAL_ : string = 'Real: %s from %.8f to %.8f';
{$IF Defined( useMATHROUT ) OR Defined( useTLH_Math )}
LOG_EPUNKT_ : string = 'EPunkt: %s from X/Y %.8f/%.8f to %.8f/%.8f';
LOG_EGERADE_ : string = 'EGerade: %s from NX/NY/C %.8f/%.8f/%.8f to %.8f/%.8f/%.8f';
{$IFEND}
LOG_BACKUP_ : string = 'Loaded BackUp: %s';
LOG_USERNAME_ : string = 'UserName: %s';
LOG_COMMENT_ : string = 'Comment: %s';
BEAUTIFIED_NAME_NR_ : string = 'Nr';
BEAUTIFIED_NAME_BOOL_ : string = 'Boolean';
BEAUTIFIED_NAME_INT_ : string = 'Integer';
BEAUTIFIED_NAME_INT64_ : string = 'Int64';
BEAUTIFIED_NAME_REAL_ : string = 'Real';
BEAUTIFIED_NAME_STR_ : string = 'String';
BEAUTIFIED_NAME_STR_LIST_ : string = 'StringList';
BEAUTIFIED_NAME_ROI_ : string = 'ROI';
BEAUTIFIED_NAME_AOI_ : string = 'AOI';
BEAUTIFIED_NAME_ePunkt_ : string = 'EPunkt';
BEAUTIFIED_NAME_eGerade_ : string = 'EGerade';
ERROR_NOT_INITIALIZED_1_ : string = #13#10 + ' Fehler bei Init / Laden der Datei:' + #13#10;
ERROR_NOT_INITIALIZED_2_ : string = ' "%s" (Typ: %s)' + #13#10;
ERROR_NOT_INITIALIZED_3_ : string = ' %d Wert(e) wurde(n) nicht initialisiert:' + #13#10;
ERROR_NOT_INITIALIZED_ITEM_1_ : string = '%s %d (%s), ' + #13#10;
EEROR_NOT_INITIALIZED_ITEM_2_ : string = 'nach "%s" (%s)';
ERROR_NOT_INITIALIZED_ITEM_3_ : string = '%s %d, ' + #13#10;
ERROR_NOT_INITIALIZED_ITEM_4_ : string = '%s %s, ' + #13#10;
ERROR_RECORD_ENUMERATION_1_ : string = #13#10 + ' Fehler bei Recordenumeration:' + #13#10;
ERROR_RECORD_ENUMERATION_2_ : string = ' "%s" (Typ: %s)' + #13#10;
ERROR_WRONG_PROPERTY_1_ : string = #13#10#13#10 + 'Fehler bei "%s.Create":' + #13#10;
ERROR_WRONG_PROPERTY_2_ : string = 'Für Parameter vom Typ "%s" sind nur' + #13#10;
ERROR_WRONG_PROPERTY_3_ : string = 'Objekttypen mit %sProperty erlaubt!'+ #13#10#13#10;
ERROR_DUPE_CHECK_ : string = #13#10 + '%s: %s (%s) is using an already used VCL-Object (%s)' + #13#10;
ERROR_CHECKSUM_MISMATCH_ : string = 'Failed loading: %s (MD5 mismatch)';
ERROR_BACKUP_CLEANUP_ : string = 'BackupCleanup failed on file:'+ #13#10 + '%s' + #13#10#13#10 + '%s';
ERROR_NO_BACKUP_SELECTED_ : string = 'You need to select a backup!';
ERROR_FILE_IN_USE_ : string = 'Error: Unable to Save to File: "%s". It''s currently in use by another Process.';
BACKUP_COMPARE_1_ : string = 'Backup -> Current';
BACKUP_COMPARE_2_ : string = '%s -> %s';