-
Notifications
You must be signed in to change notification settings - Fork 0
/
GFA-Grünflächen-Configurator.ahk
1723 lines (1666 loc) · 80.5 KB
/
GFA-Grünflächen-Configurator.ahk
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
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Requires AutoHotkey v1.1.35+ ;; version at which script was written.
#SingleInstance Force
#MaxHotkeysPerInterval 99999999
#Warn All, Outputdebug
;#Persistent
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
DetectHiddenWindows On
SetKeyDelay -1, -1
SetBatchLines -1
SetTitleMatchMode 2
CodeTimer("")
FileGetTime ModDate, %A_ScriptFullPath%, M
FileGetTime CrtDate, %A_ScriptFullPath%, C
CrtDate := SubStr(CrtDate, 7, 2) "." SubStr(CrtDate, 5, 2) "." SubStr(CrtDate, 1, 4)
, ModDate := SubStr(ModDate, 7, 2) "." SubStr(ModDate, 5, 2) "." SubStr(ModDate, 1, 4)
global script := new script_()
, bRunFromVSC:=(WinActive("ahk_class Chrome_WidgetWin_1") && WinActive("ahk_exe Code.exe"))
, DEBUG := IsDebug()
, globalLogicSwitches := {}
script := { base: script.base
, name: regexreplace(A_ScriptName, "\.\w+")
, crtdate: CrtDate
, moddate: ModDate
, offdoclink: A_ScriptDir "\assets\Documentation\GFA_Renamer_Readme.html"
, resfolder: A_ScriptDir "\res"
, iconfile: ""
, version: ""
, config: []
, scriptconfigfile: A_ScriptDir "\INI-Files\" regexreplace(A_ScriptName, "\.\w+") ".ini"
, gfcGUIconfigfile: A_ScriptDir "\INI-Files\GFC_DA.ini"
, configfolder: A_ScriptDir "\INI-Files"
, aboutPath: A_ScriptDir "\res\About.html"
, reqInternet: false
, rfile: "https://github.com/Gewerd-Strauss/Gr-nfl-chen-Utilities/archive/refs/heads/master.zip"
, vfile_raw: "https://raw.githubusercontent.com/Gewerd-Strauss/Gr-nfl-chen-Utilities/master/version_check.txt"
, vfile: "https://raw.githubusercontent.com/Gewerd-Strauss/Gr-nfl-chen-Utilities/master/version_check.txt"
, rfile_dev: "https://github.com/Gewerd-Strauss/Gr-nfl-chen-Utilities/archive/refs/heads/dev.zip"
, vfile_raw_dev: "https://raw.githubusercontent.com/Gewerd-Strauss/Gr-nfl-chen-Utilities/dev/version_check.txt"
, vfile_dev: "https://raw.githubusercontent.com/Gewerd-Strauss/Gr-nfl-chen-Utilities/dev/version_check.txt"
, EL: "359b3d07acd54175a1257e311b5dfaa8370467c95f869d80dba32f4afdcae19f4485d67815d9c1f4fe9a024586584b3a0e37489e7cfaad8ce4bbc657ed79bd74"
, authorID: "Laptop-C"
, author: "Gewerd Strauss"
, Computername: A_ComputerName
, license: A_ScriptDir "\res\LICENSE.txt" ;; do not edit the variables above if you don't know what you are doing.
, blank: "" }
globalLogicSwitches.Debug:=DEBUG
#Include <OnError>
main()
if (A_IsCompiled) {
CodeTimer()
} else if ((globalLogicSwitches.bIsAuthor && !A_IsCompiled)) {
CodeTimer("Startup Time")
} else {
CodeTimer()
}
sleep 3500
tooltip
return
main() {
bUpdateGeneratedFiles:=false
Loop, % A_Args.Length() {
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
, bUpdateGeneratedFiles:=param
if bUpdateGeneratedFiles {
break
}
}
globalLogicSwitches.bIsAuthor:=(script.computername=script.authorID) + 0
, globalLogicSwitches.Debug:=DEBUG
if !FileExist(script.scriptconfigfile) || ((DEBUG && globalLogicSwitches.bIsAuthor) || bUpdateGeneratedFiles) {
if (FileExist(script.scriptconfigfile)) {
if (globalLogicSwitches.bIsAuthor) {
ttip("Resetting program-configuration.")
}
} else {
ttip("Initialising program-configuration.")
}
setupdefaultconfig(1)
}
if !FileExist(script.gfcGUIconfigfile) || ((DEBUG && globalLogicSwitches.bIsAuthor) || bUpdateGeneratedFiles) {
if (FileExist(script.gfcGUIconfigfile)) {
if (globalLogicSwitches.bIsAuthor) {
ttip("Resetting GUI-configuration.")
}
} else {
ttip("Initialising GUI-configuration.")
}
setupdefaultconfig(2)
}
script.Load(script.scriptconfigfile, 1)
if (script.config.Configurator_settings.bRunAsAdmin && !A_IsAdmin) {
answer := AppError("Do you want to elevate the program ?", "Do you want to reload the program with administrator-privilages without saving any data? `n`nAny currently unsaved changes will not be saved.",0x34," - ")
if (answer = "Yes") {
RunAsAdmin()
} else {
answer := AppError("Do you want to exit the program ?", "You chose not to run the program with administrator-privileges.`nYou may either uncheck the configuration option 'bRunAsAdmin' in the program's settings, or elevate the program with administrator-privileges the next time it starts.`n`nDo you want to continue loading the program?",0x34," - ")
if (answer = "No") {
exitApp()
}
}
}
if !script.requiresInternet() {
answer := AppError("The program requires an internet connection.", "The program requires an internet connection, which is not available. You may continue without one, but functionality may be severely impaired.`nDo you want to exit the program?",0x34," - ")
if (answer = "Yes") {
exitApp()
}
} else { ;; handle testimage downloading
if (!(DEBUG && globalLogicSwitches.bIsAuthor) && !bUpdateGeneratedFiles) {
test_folder:=script.resfolder "\Examples\Example 5 - Image-Renamer, full dataset"
test_folder2:=script.resfolder "\Examples\Example 5 - Image-Renamer, example with missing images"
if (!InStr(FileExist(test_folder),"D") || !InStr(FileExist(test_folder2),"D")) {
if !InStr(FileExist(test_folder),"D") {
Title:="Download Image-Testset 1/2?"
Message:="The full test dataset for the image-renamer does not exist.`nDo you want to download it?"
answer := AppError(Title, Message, Options := 0x34, TitlePrefix := " - ")
if (answer = "Yes") {
ttip("Downloading & Extracting Image Example Files (1/2)",5)
lp:=downloadTestset(script.config.testset.URLFull,test_folder)
setupTestset(lp,test_folder,script.config.testset.IDFull)
ttip("Finished setting up Image Example Files (1/2)",5)
}
}
if !InStr(FileExist(test_folder2),"D") {
Title:="Download Image-Testset 2/2?"
Message:="The partial test dataset for the image-renamer does not exist.`nDo you want to download it?"
answer := AppError(Title, Message, Options := 0x34, TitlePrefix := " - ")
if (answer = "Yes") {
ttip("Downloading & Extracting Image Example Files (2/2)",5)
lp:=downloadTestset(script.config.testset.URLMissing,test_folder2)
setupTestset(lp,test_folder2,script.config.testset.IDMissing)
ttip("Finished setting up Image Example Files (2/2)")
}
}
}
}
}
globalLogicSwitches.bIsDebug:=script.config.Configurator_settings.bDebugSwitch + 0
script.version:=script.config.version.GFC_version
, script.loadCredits(script.resfolder "\credits.txt")
, script.loadMetadata(script.resfolder "\meta.txt")
, IconString:=A_ScriptDir "\res\icon.ico"
try {
script_TraySetup(IconString)
}
if (script.requiresInternet(script.vfile,true) && script.config.Configurator_settings.CheckUpdatesOnScriptStart) {
if ((script.config.Configurator_settings.UpdateChannel="stable") && !DEBUG) {
script.Update(script.vfile,script.rfile,1,,,1)
} else if ((script.config.Configurator_settings.UpdateChannel="development") && !DEBUG) {
script.Update(script.vfile_dev,script.rfile_dev,1,,,1)
}
}
if (bUpdateGeneratedFiles) {
FileDelete % script.AboutPath
script.About(1)
exitApp()
}
global guiObject:=guiCreate()
guiObject.RCodeTemplate:=set_template()
if !FileExist(script.gfcGUIconfigfile) || ((DEBUG && globalLogicSwitches.bIsAuthor) || bUpdateGeneratedFiles) {
if (DEBUG && globalLogicSwitches.bIsAuthor) {
ttip("Generating parameter documentation string.")
String:=guiObject.dynGUI.generateDocumentationString()
Clipboard:=String
}
}
guiShow(guiObject)
, f5:=Func("guiShow2").Bind(guiObject)
, f6:=Func("prepare_release")
, f7:=Func("run_unit_tests")
, f8:=func("copyGFA_EvaluationFolder").Bind(script.config.Configurator_settings.GFA_Evaluation_InstallationPath)
, f9:=func("openCommandline_EvaluationFolder").Bind(script.config.Configurator_settings.GFA_Evaluation_InstallationPath)
guiResize(guiObject)
Menu Tray, Add, Show GUI, % f5
if (globalLogicSwitches.bIsAuthor) {
menu Tray, Add, Recompile, % f6
menu Tray, Add, Unit Tests, % f7
}
Menu Tray, Add, Copy GFA_Evaluation-Path, % f8
Menu Tray, Add, Open CMD, % f9
handleCheckboxes()
handleConfig(guiObject.dynGUI,false)
fillRC1(guiObject.RCodeTemplate)
fillRC2(guiObject.dynGUI.ConfigString)
return
}
;@ahk-neko-ignore 1 line; Function too big
guiCreate() {
;; Funktion erstellt die Benutzeroberfläche. Sehr basic, aber reicht für das was gemacht werden muss.
gui GC: destroy
bShowDebugPanelINMenuBar:=""
if (script.config.Configurator_settings.SizeSetting="auto") { ; auto
SysGet A, MonitorWorkArea
guiHeight:=ABottom - 2*30
, guiWidth:=A_ScreenWidth - 2*30
} else if (script.config.Configurator_settings.SizeSetting="1440p") { ; 1440p
guiWidth:=2560 - 2*30
, guiHeight:=1392 - 2*30
} else if (script.config.Configurator_settings.SizeSetting="1080p") { ; 1080p
guiWidth:=1920 - 2*30
, guiHeight:=1032 - 2*30
}
DPIAdjustmentFactor:=(1/(A_ScreenDPI/96))
guiWidth:=guiWidth * DPIAdjustmentFactor
guiHeight:=guiHeight * DPIAdjustmentFactor
;guiHeight:=990
if (globalLogicSwitches.DEBUG) {
ttip(["guiWidth: " guiWidth
,"guiHeight: " guiHeight
,"A_ScreenHeight " A_ScreenHeight
,"A_ScreenWidth " A_ScreenWidth
, "A_DPI " A_ScreenDPI
,script.config.SizeSetting
,"is1080: " (script.config.Configurator_settings.SizeSetting="1080p")
,"is1440: " (script.config.Configurator_settings.SizeSetting="1440p")
,"isauto: " (script.config.Configurator_settings.SizeSetting="auto")
,"height-mwa 1440p: " 1392 - 2*30
,"guiWidth 1440p: " 2560 - 2*30
,"guiWidth 1080p: " 1920 - 2*30
,"height-mwa 1080p: " 1032 - 2*30,["bIsAuthor: " globalLogicSwitches.bIsAuthor,"bisDEBUG: " globalLogicSwitches.bIsDebug,globalLogicSwitches.DEBUG]],1,2300)
}
YMarginWidth:=XMarginWidth:=15
, NumberofSections:=3
, WidthMinusMargins:=guiWidth - 4*XMarginWidth + 0
, SectionWidth:=WidthMinusMargins/NumberofSections + 0
, SectionHeight:=guiHeight
, Sections:=[]
, middleanchor:=guiWidth-4*15
loop, % NumberofSections {
if (A_Index>1) {
Sections[A_Index]:={XAnchor:XMarginWidth*A_Index + SectionWidth*(A_Index-1),YAnchor:3,Width:SectionWidth*1,Height:SectionHeight*1}
} else {
Sections[A_Index]:={XAnchor:XMarginWidth*A_Index,YAnchor:3,Width:SectionWidth*1,Height:SectionHeight*1}
}
}
Sections[4]:={XAnchor:Sections[3].XAnchor,YAnchor:Sections[3].YAnchor,Width:Sections[3].Width,Height:Sections[3].Height}
if (script.config.Configurator_settings.SizeSetting="1080p") {
ShiftSection1:=0
} else if (script.config.Configurator_settings.SizeSetting="1440p") {
ShiftSection1:=50
} else {
ShiftSection1:=0
}
ShiftSection2:=250
, Sections[1].Width:=Sections[1].Width-ShiftSection1
, Sections[2].XAnchor:=Sections[2].XAnchor-ShiftSection1
, Sections[2].Width:=Sections[2].Width-ShiftSection2
, Sections[4].XAnchor:=Sections[4].XAnchor-ShiftSection1-ShiftSection2
, Sections[4].Width:=Sections[4].Width+ShiftSection1+ShiftSection2
, Sections[2].Height:=230
, middleanchor:=guiWidth-4*15
Sections[3].YAnchor:=Sections[2].Height-15
, Sections[3].XAnchor:=Sections[2].XAnchor
, Sections[3].Height:=(guiHeight-Sections[3].YAnchor)+3
, Sections[3].Width:=Sections[2].Width
global StatusBarMainWindow
, vUsedConfigLocation
, vStarterRScriptLocation
, vreturnDays
, vSaveFigures
, vsaveRDATA
, vSaveExcel
, vRCRScript
, vRCConfiguration
, hwndLV_ConfigHistory
, hwndLV_RScriptHistory
, generateRScriptBtn
, recompileBtn
, vToggleLVReport
, vToggleLVReport2
gui GC: new
gui GC: +LabelGC +HWNDGCHWND
gui GC: +Resize
if (globalLogicSwitches.DEBUG) {
gui -AlwaysOnTop
}
Names:=["1. Configuration File","2. R-Script- && CLI-Execution Configuration","4. Auxiliary Utilities","3. Preview"]
;gui GC: Show, % "w" guiWidth " h" guiHeight
for each, section in Sections {
Sections[each].Name:=Names[A_Index]
gui add, text,% " y0 h0 w" 0 " x" 0, % section.name
}
;; left side
gui add, text,% "y15 x" Sections[1].XAnchor+5 " h0 w0",leftanchor
gui add, text,% "y20 x" Sections[1].XAnchor+5 " h40 w350",% "Select the configuration file you want to use. Alternatively, choose a folder containing your data - where you want your configuration file to sit. All '.xlsx'/'.csv'-files in any subfolder will be used."
;gui add, button, y60 xp w80 hwndselectConfigLocation,% "Select &Folder"
gui add, button,% "y60 w80 hwndnewConfigurationBtn x" Sections[1].XAnchor+5,% "New Config in Folder"
gui add, button,% "yp w80 hwndeditConfigurationBtn x" Sections[1].XAnchor+95,% "Edit existing Config"
gui add, edit,% "yp w160 hwnddropFilesEdit disabled -vscroll -hscroll x" Sections[1].XAnchor+180,% "Drop config file or config destination folder here"
gui add, text,% "y100 x" Sections[1].XAnchor+5 "w0 h0"
global dynGUI:= new gfcGUI("Experiment::blank",script.gfcGUIconfigfile,"-<>-",FALSE)
dynGUI.GFA_Evaluation_Configfile_Location:=""
dynGUI.GFA_Evaluation_RScript_Location:=""
dynGUI.guiVisible:=false
, dynGUI.GCHWND:=GCHWND
, dynGUI.GenerateGUI(,,False,"GC:",false,Sections[1].Width-15,,9)
;; middle
gui add, text,% "y15 x" Sections[2].XAnchor+5 " h0 w0", middleanchor
gui add, text,% "y20 x" Sections[2].XAnchor+5 " h40 w350", % "Configure the R-Script used for running the GF-Analysis-Skript"
gui add, button,% "y60 w80 hwndnewStarterScriptBtn x" Sections[2].XAnchor+5, % "New R-StarterScript"
gui add, button,% "y60 w80 hwndeditStarterScriptBtn x" Sections[2].XAnchor+95, % "Edit existing R-StarterScript"
gui add, edit,% "y60 w160 hwnddropFilesEdit2 disabled -vscroll -hscroll x" Sections[2].XAnchor+180,% "Drop RScript-file or RScript-destination folder here"
gui add, text,% "y100 x" Sections[2].XAnchor+5 "w0 h0"
gui add, checkbox, y125 xp hwndCheckreturnDays vvreturnDays, Do you want to evaluate every day on its own?
gui add, checkbox, y145 xp hwndCheckSaveFigures vvSaveFigures, Do you want to save 'Figures' to disk?
gui add, checkbox, y165 xp hwndChecksaveRDATA vvsaveRDATA, Do you want to save 'RData' to disk?
gui add, checkbox, y185 xp hwndCheckSaveExcel vvSaveExcel, Do you want to save 'Excel' to disk?
gui add, text, % "x" Sections[3].XAnchor+5 " y" Sections[3].YAnchor+15 " h0 w0", middlebottomanchor
gui add, tab3, % "hwndhwndTab3_2 x" Sections[3].XAnchor+5 " y" Sections[3].YAnchor+20 " h" (Sections[3].Height-(1*3 + 20)-2*15) " w" (Sections[3].Width - 3*5), Configurations and Image-renaming||R Scripts
gui tab, Configurations and Image-renaming
gui add, checkbox, % "hwndCheckToggleLVReport gtoggle_ReportTip x+5 y+5 vvToggleLVReport", % "Toggle Report-View?"
gui add, button, % "hwndcsv2xlsxBtn yp-5 xp+120", % "csv&2xlsx"
gui add, button, % "hwndrenameImagesBtn yp xp+55", % "rename &Images"
gui add, button, % "hwndexecuteCLIBtn yp xp+87", % "CLI"
gui add, Listview, % "hwndhwndLV_ConfigHistory +LV0x400 +LV0x10000 xp-262 y+5 h" (Sections[3].Height-(1*3 + 20)-2*15-3*5-5-35-20) " w" (Sections[3].Width - 3*5 - 3*5), Experiment's Name in Config|File Name|Full Path
updateLV(hwndLV_ConfigHistory,script.config.LastConfigsHistory)
;; right
RESettings2 :=
( LTrim Join Comments
{
"TabSize": 4,
"Indent": "`t",
"FGColor": 0xEDEDCD,
"BGColor": 0x3F3F3F,
"Font": {"Typeface": "Consolas", "Size": 11},
"WordWrap": True,
"UseHighlighter": True,
"HighlightDelay": 200,
"Colors": {
"Comments": 0x7F9F7F,
"Functions": 0x7CC8CF,
"Keywords": 0xE4EDED,
"Multiline": 0x7F9F7F,
"Numbers": 0xF79B57,
"Punctuation": 0x97C0EB,
"Strings": 0xCC9893,
; AHK
"A_Builtins": 0xF79B57,
"Commands": 0xCDBFA3,
"Directives": 0x7CC8CF,
"Flow": 0xE4EDED,
"KeyNames": 0xCB8DD9,
; CSS
"ColorCodes": 0x7CC8CF,
"Properties": 0xCDBFA3,
"Selectors": 0xE4EDED,
; HTML
"Attributes": 0x7CC8CF,
"Entities": 0xF79B57,
"Tags": 0xCDBFA3,
; JS
"Builtins": 0xE4EDED,
"Constants": 0xF79B57,
"Declarations": 0xCDBFA3
; INI
}
}
)
gui tab, R Scripts
gui add, checkbox, % "hwndCheckToggleLVReport2 gtoggle_ReportTip2 x+5 y+5 vvToggleLVReport2", % "Toggle Report-View?"
gui add, Listview, % "hwndhwndLV_RScriptHistory +LV0x400 +LV0x10000 xp y+11 h" (Sections[3].Height-(1*3 + 20)-2*15-3*5-5-35-20) " w" (Sections[3].Width - 3*5 - 3*5), File Name|Full Path
updateLV(hwndLV_RScriptHistory,script.config.LastRScriptHistory)
GuiControl Choose, vTab3, % "Configurations and Image-renaming"
gui tab,
gui add, text, % "y15 x" Sections[4].XAnchor+5 " h0 w0", rightanchor
gui add, text, % "y20 x" Sections[4].XAnchor+5 " h40 w" Sections[4].Width - 3*5, curr. loaded R-Script
gui add, edit,% "y" (20)-3 " x" Sections[4].XAnchor+5 + Sections[4].Width - (3*5) - (Sections[4].Width*0.85) + -1*2 " r1 disabled hwndhwndStarterRScriptLocation vvStarterRScriptLocation w" Sections[4].Width*0.85+4, % "<Location of Starter-'.R'-Script>"
global RC:=new GC_RichCode(RESettings2, "y45" " x" Sections[4].XAnchor+5 " w" Sections[4].Width - 3*5 " h489" , Func("HighlightR"))
gui add, text, % "y" (45+489+5) " x" Sections[4].XAnchor+5 " h40 w" Sections[4].Width - (3*5) - (Sections[4].Width*0.85), curr. loaded Config
gui add, edit,% "y" (45+489+5)-3 " x" Sections[4].XAnchor+5 + Sections[4].Width - (3*5) - (Sections[4].Width*0.85) + -1*2 " r1 disabled hwndhwndUsedConfigLocation vvUsedConfigLocation w" Sections[4].Width*0.85+4, % "<Location of Configuration-'.ini'-File>"
buttonHeight:=40
global RC2:=new GC_RichCode(RESettings2,"y" (45+489+5+25) " x" Sections[4].XAnchor+5 " h" (guiHeight-(45+489+5+40+5+5+buttonHeight+5)) " w" Sections[4].Width - 3*5, Func("HighlightR"))
gui add, button,% "y" (45+489+5+25+(guiHeight-(45+489+5+40+5+5+buttonHeight+5))+5) " w80 hwndgenerateRScriptBtn x" Sections[4].XAnchor+5, % "Generate R-Script"
gui add, button,% "y" (45+489+5+25+(guiHeight-(45+489+5+40+5+5+buttonHeight+5))+5) " w80 hwndpreviewConfigurationBtn x" Sections[4].XAnchor+95, % "Preview Configuration"
gui add, button,% "y" (45+489+5+25+(guiHeight-(45+489+5+40+5+5+buttonHeight+5))+5) " w80 hwndgenerateConfigurationBtn x" Sections[4].XAnchor+185, % "Generate Configuration"
gui add, button,% "y" (45+489+5+25+(guiHeight-(45+489+5+40+5+5+buttonHeight+5))+5) " w80 hwndEditSettingsBtn gfEditSettings x" Sections[4].XAnchor+275, % "Open &program settings"
gui add, button,% "y" (45+489+5+25+(guiHeight-(45+489+5+40+5+5+buttonHeight+5))+5) " w80 hwndOpenRScriptBtn x" Sections[4].XAnchor+365, % "Open current &script"
gui add, button,% "y" (45+489+5+25+(guiHeight-(45+489+5+40+5+5+buttonHeight+5))+5) " w80 hwndOpenConfigBtn x" Sections[4].XAnchor+455, % "Open current &config"
gui add, button,% "y" (45+489+5+25+(guiHeight-(45+489+5+40+5+5+buttonHeight+5))+5) " w80 hwndExitProgramBtn gexitApp x" Sections[4].XAnchor+545, % "Exit Program"
if (globalLogicSwitches.bIsAuthor) {
gui add, button,% "y" (45+489+5+25+(guiHeight-(45+489+5+40+5+5+buttonHeight+5))+5) " w80 gprepare_release hwndrecompileBtn x" Sections[4].XAnchor+635, % "Recompile"
}
gui add, statusbar, -Theme vStatusBarMainWindow gfCallBack_StatusBarMainWindow
if ((bShowDebugPanelINMenuBar) && (script.authorID=A_ComputerName)) {
SB_SetParts(0,240,100,280,125,70,80,170)
} Else {
SB_SetParts(0,240,100,270,125,70,80)
}
SB_SetText(script.name " v." script.config.version.GFC_version A_Space script.config.version.build,2)
SB_SetText(" by " script.author,3)
if (globalLogicSwitches.bIsDebug) {
SB_SetText("Author/Debug Mode Engaged. Click to exit debug-mode",4)
} else {
SB_SetText("Standard Mode Engaged. Click to enter debug-mode",4)
}
SB_SetText((A_IsAdmin?"Admin Privileges":"Standard privileges"),5)
SB_SetText("Report a bug",6)
SB_SetText("Documentation",7)
guiObject:={guiWidth:guiWidth
,guiHeight:guiHeight
,dynGUI:dynGUI
,Sections:Sections
,XMarginWidth:XMarginWidth
,YMarginWidth:YMarginWidth}
onEditConfiguration := Func("editConfiguration").Bind("")
, onEditStarterScript := Func("editRScript").Bind("")
, onPreviewConfiguration := Func("handleConfig").Bind(dynGUI,false)
, onGenerateConfiguration := Func("handleConfig").Bind(dynGUI,true)
, onCheckreturnDays:=Func("handleCheckboxesWrapper")
, onCheckSaveFigures:=Func("handleCheckboxesWrapper")
, onChecksaveRDATA:=Func("handleCheckboxesWrapper")
, onCheckSaveExcel:=Func("handleCheckboxesWrapper")
, onGenerateRScript:=Func("createRScript").Bind("D:/")
, onLoadConfigFromLV:=Func("loadConfigFromLV").Bind(dynGUI)
, onLoadRScriptFromLV:=Func("loadRScriptFromLV").Bind(dynGUI,guiObject)
, oncsv2xlsx := Func("convertCSV2XLSX").Bind(dynGUI)
, onrenameImages := Func("renameImages").Bind(dynGUI)
, onexecuteCLI := Func("runCLI").Bind(dynGUI)
, onOpencurrentScript := Func("runRScript").Bind(dynGUI)
, onOpencurrentConfig := Func("runConfig").Bind(dynGUI)
if (globalLogicSwitches.DEBUG) {
onNewConfiguration := Func("createConfiguration").Bind(A_ScriptDir,guiObject)
oncreateRScript := Func("createRScript").Bind(A_ScriptDir)
} else {
onNewConfiguration := Func("createConfiguration").Bind("D:/",guiObject)
oncreateRScript := Func("createRScript").Bind("D:/")
}
if (globalLogicSwitches.bIsAuthor) {
onRecompile := Func("prepare_release")
}
guiControl GC:+g, %generateRScriptBtn%, % onGenerateRScript
guiControl GC:+g, %PreviewConfigurationBtn%, % onPreviewConfiguration
guiControl GC:+g, %generateConfigurationBtn%, % onGenerateConfiguration
guiControl GC:+g, %EditConfigurationBtn%, % onEditConfiguration
guiControl GC:+g, %NewConfigurationBtn%, % onNewConfiguration
guiControl GC:+g, %newStarterScriptBtn%, % oncreateRScript
guiControl GC:+g, %editStarterScriptBtn%, % onEditStarterScript
guiControl GC:+g, %hwndLV_ConfigHistory%, % onLoadConfigFromLV
guiControl GC:+g, %hwndLV_RScriptHistory%, % onLoadRScriptFromLV
guiControl GC:+g, %csv2xlsxBtn%, % oncsv2xlsx
guiControl GC:+g, %renameImagesBtn%, % onrenameImages
guiControl GC:+g, %executeCLIBtn%, % onexecuteCLI
guiControl GC:+g, %openRScriptBtn%, % onOpencurrentScript
guiControl GC:+g, %openConfigBtn%, % onOpencurrentConfig
guiControl GC:+g, %CheckreturnDays%, % onCheckreturnDays
guiControl GC:+g, %CheckSaveFigures%, % onCheckSaveFigures
guiControl GC:+g, %ChecksaveRDATA%, % onChecksaveRDATA
guiControl GC:+g, %CheckSaveExcel%, % onCheckSaveExcel
if (globalLogicSwitches.bIsAuthor) {
guiControl GC:+g, %recompileBtn%, % onRecompile
}
AddToolTip(newConfigurationBtn,"Create a new configuration-file in a desired folder.")
AddToolTip(editConfigurationBtn,"Edit an existing configuration-file.")
AddToolTip(newStarterScriptBtn,"Create a new RScript-file in a desired folder.")
AddToolTip(editStarterScriptBtn,"Edit an existing RScript-file.")
AddToolTip(CheckreturnDays,"Do you want to generate statistical data and a close-up plot for each individual day?")
AddToolTip(CheckSaveFigures,"Do you want to save generated figures to file?")
AddToolTip(ChecksaveRDATA,"Do you want to save the R-Workspace to file after the **function 'GFA_Evaluation'** has run?`n`nNote: This will not save data not generated during the execution of this function.")
AddToolTip(CheckSaveExcel,"Do you want to save statistical data to an xlsx-file?")
AddToolTip(CheckToggleLVReport,"Change the view-type for the listview below between report and the traditional list view.`nList view is more compact, but Report-view may give more details on a specific file. Also people have preferences.")
AddToolTip(CheckToggleLVReport2,"Change the view-type for the listview below between report and the traditional list view.`nList view is more compact, but Report-view may give more details on a specific file. Also people have preferences.")
AddToolTip(renameImagesBtn,"It is recommended to rename images prior to analysis,`nand to do so with consistent naming scheme so that the resulting data is always sorted in the same manner.")
AddToolTip(csv2xlsxBtn,"If a config-file has been selected (by the ListView below, or any other means), you`ncan use this button to automatically create xlsx-files for any csv-file which does not`nn have an xlsx-version. CSV-files are supported, but heavily discouraged by the author.",, GCHWND)
AddToolTip(executeCLIBtn,"After selecting a configuration file and execution options, you`nmay run the GFA_Evaluation-Script with these parameters via R's command line.",, GCHWND)
AddToolTip(generateRScriptBtn,"Write the RScript to the selected file.")
AddToolTip(PreviewConfigurationBtn,"Preview the configuration options selected in section 1 without writing them to a file.")
AddToolTip(generateConfigurationBtn,"Write the configuration options selected in section 1 to a file.")
AddToolTip(EditSettingsBtn,"Open the settings for this program itself.")
AddToolTip(openRScriptBtn,"Open the currently selected R-Script (see section 3, top). This program will`nattempt to open the script via the program associated with '.R'-files. If this`ndoes not work, it will recover by opening the containing folder instead.")
AddToolTip(openConfigBtn,"Open the currently selected configuration-file (see section 3, bottom). This program will`nattempt to open the configuration via the program associated with '-ini'-files. If this`ndoes not work, it will recover by opening the containing folder instead.")
AddToolTip(ExitProgramBtn,"Exit this program.")
return guiObject
}
guiShow3(guiObject,ShowThirdPane:=true) {
if (ShowThirdPane) {
gui GC: show,% "w" guiObject["guiWidth"] " h" guiObject["guiHeight"] " x0 y0" , % script.name " - Complementary program for GFA_Evaluation.R"
} else {
gui GC: show,% "w" (guiObject["guiWidth"]-(guiObject["Sections"][4]["Width"]+guiObject.XMarginWidth*2)) " h" guiObject["guiHeight"] "x0 y0" , % script.name " - Complementary program for GFA_Evaluation.R"
}
return
}
guiShow2(guiObject) {
if (WinActive("ahk_id " guiObject.dynGUI.GCHWND)) {
guiShow(guiObject)
guiObject.dynGUI.guiVisible:=true
} else {
guiShow(guiObject)
guiObject.dynGUI.guiVisible:=true
}
return
}
guiShow(guiObject) {
gui GC: default
useGroupbox:=1
for each, section in guiObject.Sections {
if (useGroupbox) {
if section.HasKey("YAnchor") {
gui add, groupbox,% "hwndgb" each " y" section.YAnchor " h" section.Height-2*15 " w" section.Width " x" section.XAnchor-5, % section.name
} else {
gui add, groupbox,% "hwndgb" each " y3 h" section.Height-2*15 " w" section.Width " x" section.XAnchor-5, % section.name
}
} else {
if section.HasKey("YAnchor") {
gui add, text,% " y" section.YAnchor " h15 w" section.Width " x" section.XAnchor-5, % section.name
} else {
gui add, text,% " y3 h15 w" section.Width " x" section.XAnchor-5, % section.name
}
}
}
if (guiObject.dynGUI.GFA_Evaluation_Configfile_Location="") {
gui GC: show,% "AutoSize x0 y0" , % script.name " - Complementary program for GFA_Evaluation.R"
} else {
gui GC: show,% "w" guiObject["guiWidth"] " h" guiObject["guiHeight"] " Center" , % script.name " - Complementary program for GFA_Evaluation.R"
}
guicontrol GC: hide, % "vExcelSheetPreview"
guiObject.dynGUI.guiVisible:=true
handleCheckboxes()
handleConfig(guiObject.dynGUI,false)
;handleExcelSheets(dynGUI.Arguments)
Tabs:=[]
TabName:="Example-Excel-File No. "
loop, 12 {
Tabs[A_Index]:=TabName A_Index
}
gui gc: default
gui % "GC: " ((script.config.Configurator_settings.AlwaysOnTop)?"+":"-") "AlwaysOnTop"
if (globalLogicSwitches.DEBUG) {
gui -AlwaysOnTop
}
return
}
guiHide() {
GCEscape()
return
}
guiResize(guiObject,normalOperation:=true) {
if (normalOperation) {
if (guiObject.dynGUI.GFA_Evaluation_Configfile_Location="") && (guiObject.dynGUI.GFA_Evaluation_RScript_Location="") {
guiShow3(guiObject,false)
} else {
guiShow3(guiObject,true)
}
}
return
}
WinGetPos(title) {
WinGetPos x, y, w, h, % title
return {x: x, y: y, w: w, h: h}
}
GCSize() {
;global
global gb3
global gb4
global hwndStarterRScriptLocation
global hwndUsedConfigLocation
global EditSettingsBtn
global ExitProgramBtn
global OpenRScriptBtn
global OpenConfigBtn
global recompileBtn
global RC
global RC2
global hwndLV_ConfigHistory
global hwndLV_RScriptHistory
global hwndTab3_2
global guiObject
gui GC: default
wgp := WinGetPos("ahk_id " guiObject.dynGUI.GCHWND)
gui GC: default
SB_SetText("x" wgp.x " y" wgp.y " w" wgp.w " h" wgp.H " " (A_IsCompiled?"Compiled":"Not Compiled"),8)
AutoXYWH("h*", gb3)
AutoXYWH("wh*", gb4)
AutoXYWH("w", hwndStarterRScriptLocation)
AutoXYWH("w", hwndUsedConfigLocation)
AutoXYWH("y", EditSettingsBtn, ExitProgramBtn)
AutoXYWH("y", OpenRScriptBtn)
AutoXYWH("y", OpenConfigBtn)
AutoXYWH("y", "Open current &script")
AutoXYWH("y", "Open current &config")
AutoXYWH("y", "Open &program settings")
AutoXYWH("y", "Exit Program")
AutoXYWH("y", "Generate Configuration")
AutoXYWH("y", "Generate R-Script")
AutoXYWH("y", "Preview Configuration")
if (globalLogicSwitches.bIsAuthor) {
AutoXYWH("y", recompileBtn)
}
AutoXYWH("w", RC.HWND)
AutoXYWH("wh", RC2.HWND)
AutoXYWH("h", hwndLV_ConfigHistory)
AutoXYWH("h", hwndLV_RScriptHistory)
AutoXYWH("h", hwndTab3_2)
return
}
GCDropFiles(_GuiHwnd, File, _*) {
global guiObject
global hwndLV_RScriptHistory
global hwndLV_ConfigHistory
if (A_GuiControl="Drop config file or config destination folder here") { ;; ini-file
if (File.Count()>1) {
AppError("2+ files/folders dropped", "You have dropped more than either 1 .ini-file or 1 folder on the GUI. This will not work. Please drop either a single file`, or a single folder onto the GUI.")
return
}
if (InStr(FileExist(File[1]),"D")) { ; directory
; if directory, check first if ini-files exist
; multiple ini-files exist. if true, open a fileselectfile dialogue on that folder prompting to ask
iniCount:=0
loop, Files, % File[1] "\*.ini" ;; check number of ini-files
{
iniCount:=A_Index
confPath:=A_LoopFileFullPath
}
if (iniCount>1) { ;; multiple files, select one
FileSelectFile configPath, 3, % File[1], % "Please select the ini-file you want to edit.", *.ini
} else if (iniCount=1) { ;; select the only one available
configPath:=confPath
} else if (iniCount=0) { ;; create a new one
FileSelectFile configPath, S8, % File[1], % "Please create the ini-file you want to use.", *.ini
}
} else { ; file
configPath:=File[1]
}
loadConfig_Main(configPath,guiObject.dynGUI)
} else if (A_GuiControl="Drop RScript-file or RScript-destination folder here") { ;; Rscript-file
if (File.Count()>1) {
AppError("2+ files/folders dropped", "You have dropped more than either 1 .Rscript-file or 1 folder on the GUI. This will not work. Please drop either a single file`, or a single folder onto the GUI.")
return
}
if (InStr(FileExist(File[1]),"D")) { ; directory
; if directory, check first if Rscript-files exist
; multiple Rscript-files exist. if true, open a fileselectfile dialogue on that folder prompting to ask
rCount:=0
loop, Files, % File[1] "\*.R" ;; check number of Rscript-files
{
rCount:=A_Index
R_Path:=A_LoopFileFullPath
}
if (rCount>1) { ;; multiple files, select one
FileSelectFile rPath, 3, % File[1], % "Please select the Rscript-file you want to edit.", *.R
} else if (rCount=1) { ;; select the only one available
rPath:=R_Path
} else if (rCount=0) { ;; create a new one
FileSelectFile rPath, S8, % File[1], % "Please create the Rscript-file you want to use.", *.R
}
} else { ; file
rPath:=File[1]
}
if (rPath="") {
AppError("Selection-GUI got cancelled", "You have closed the selection-window without selecting an existing or creating a new Rscript-file. Please do either.")
return
}
if RegexMatch(rPath,"\.ini$") {
AppError("Dropped config-file on rscript-dropper", "You have dropped the config-file`n`n'" rPath "'`n`n on the right selection-window. Please drag-and-drop an Rscript-file here instead.")
return
}
if !RegexMatch(rPath,"\.R$") {
rPath.= ".R"
}
guicontrol % "GC:",vStarterRScriptLocation, % rPath
if (rPath!="") {
guiObject.dynGUI.GFA_Evaluation_RScript_Location:=rPath
if (!InStr(rPath,A_ScriptDir)) {
script.config.LastRScriptHistory:=buildHistory(script.config.LastRScriptHistory,script.config.Configurator_settings.ConfigHistoryLimit,rPath)
updateLV(hwndLV_RScriptHistory,script.config.LastRScriptHistory)
script.save(script.scriptconfigfile,,true)
}
}
} else { ;; anywhere else
AppError("Files dropped somewhere", "You have dropped files outside the designated areas of the GUI. That is not permitted. Please drop them in their designated locations.")
return
}
if (rPath!="") {
guiObject.dynGUI.GFA_Evaluation_RScript_Location:=rPath
guiResize(guiObject)
}
if (configPath!="") {
guiObject.dynGUI.GFA_Evaluation_Configfile_Location:=configPath
guiResize(guiObject)
}
return
}
fillRC1(Code) {
global RC
gui GC: default
Code:=FormatEx(Code,{GFA_EVALUATIONUTILITY:strreplace(script.config.Configurator_settings.GFA_Evaluation_InstallationPath,"\","/")})
RC.Settings.Highlighter:= "HighlightR"
, RC.Value:= Code
return
}
fillRC2(INI) {
global RC2
gui GC: default
RC2.Settings.Highlighter:= "HighlightINI"
, RC2.Value:= INI
return
}
loadConfig_Main(configPath,dynGUI) {
global hwndLV_ConfigHistory
global guiObject
if (configPath="") {
AppError("Selection-GUI got cancelled", "You have closed the selection-window without selecting an existing or creating a new config-file. Please do either.")
return
}
if RegexMatch(configPath,"\.R$") {
AppError("Dropped RScript-file on config-dropper", "You have dropped the RScript-file`n`n'" configPath "'`n`n on the left selection-window. Please drag-and-drop a configuration-file (.ini) here instead.")
return
}
if !RegexMatch(configPath,"\.ini$") {
configPath.= ".ini"
}
if !FileExist(configPath) { ;; create a new config file in the folder, use the current config selections existing in the GUI and write them to file
dynGUI.generateConfig(0)
written_config:=dynGUI.ConfigObject
t_script:=new script_()
t_script.Save(configPath,written_config)
} else { ;; a config-file exists - load the selections into the dynGUI; while doing so validate that all values are valid and that the ini is not corrupted.
dynGUI.loadConfigFromFile(configPath)
dynGUI.validateLoadedConfig()
dynGUI.populateLoadedConfig()
handleConfig(dynGUI,false)
IniRead ExperimentName_Key, % configPath, Experiment, Name, % "Name not specified"
SplitPath % configPath,,,, FileName
itemLocation:=LV_EX_FindStringEx( hwndLV_ConfigHistory, configPath)
if !itemLocation && !IsObject(itemLocation){
gui listview,% hwndLV_ConfigHistory
LV_Add("",ExperimentName_Key,FileName,configPath)
}
}
guicontrol % "GC:",vUsedConfigLocation, % configPath
if (configPath!="") {
dynGUI.GFA_Evaluation_Configfile_Location:=configPath
guiResize(guiObject)
SplitPath % configPath,, Chosen
if ((subStr(Chosen,-1)!="\") && (subStr(Chosen,-1)!="/")) {
Chosen.="\"
}
Chosen:=configPath
WINDOWS:=strreplace(Chosen,"/","\")
MAC:=strreplace(Chosen,"/","\")
String:=guiObject.RCodeTemplate
;needle:="GFA_main\((folder_path = r.+""),"
;rep1:="GFA_main(folder_path = r""("
;rep2:=")"","
;Matches:=RegexMatchAll(String, "iU)" needle)
;for _, match in Matches { ;; star, top
; match_ := match[0]
; if (_<2) {
; String:=strreplace(String,match_,rep1 WINDOWS rep2)
; } else {
; String:=strreplace(String,match_,rep1 MAC rep2)
; }
;}
if (script.config.Configurator_settings.UseRelativeConfigPaths) {
SplitPath WINDOWS, WINDOWS
SplitPath MAC, MAC
}
RC1Object:={GFA_CONFIGLOCATIONFOLDER_WINDOWS:WINDOWS
, GFA_CONFIGLOCATIONFOLDER_MAC:MAC
,GFA_EVALUATIONUTILITY:strreplace(script.config.Configurator_settings.GFA_Evaluation_InstallationPath,"\","/")}
String:=FormatEx(String,RC1Object)
if (!InStr(String,WINDOWS) || !InStr(String,MAC,,,2)) {
needle:="GFA_main\((folder_path = r.+""),"
rep1:="GFA_main(folder_path = r""("
rep2:=")"","
Matches:=RegexMatchAll(String, "iU)" needle)
for _, match in Matches { ;; star, top
match_ := match[0]
if (_<2) {
String:=strreplace(String,match_,rep1 WINDOWS rep2)
} else {
String:=strreplace(String,match_,rep1 MAC rep2)
}
}
}
guiObject.RCodeTemplate:=String
handleCheckboxesWrapper()
}
return
}
handleCheckboxesWrapper() {
fillRC1(handleCheckboxes())
}
handleCheckboxes() {
global guiObject
global vreturnDays
global vSaveFigures
global vsaveRDATA
global vSaveExcel
gui GC: submit, nohide
template:=guiObject.RCodeTemplate
template:=strreplace(template,"returnDays = %breturnDays%","returnDays = " vreturnDays)
template:=strreplace(template,"saveFigures = %bSaveFigures%","saveFigures = " vSaveFigures)
template:=strreplace(template,"saveRDATA = %bsaveRDATA%","saveRDATA = " vsaveRDATA)
template:=strreplace(template,"saveExcel = %bSaveExcel%","saveExcel = " vSaveExcel)
template:=strreplace(template,"returnDays = 1","returnDays = " vreturnDays)
template:=strreplace(template,"saveFigures = 1","saveFigures = " vSaveFigures)
template:=strreplace(template,"saveRDATA = 1","saveRDATA = " vsaveRDATA)
template:=strreplace(template,"saveExcel = 1","saveExcel = " vSaveExcel)
template:=strreplace(template,"returnDays = 0","returnDays = " vreturnDays)
template:=strreplace(template,"saveFigures = 0","saveFigures = " vSaveFigures)
template:=strreplace(template,"saveRDATA = 0","saveRDATA = " vsaveRDATA)
template:=strreplace(template,"saveExcel = 0","saveExcel = " vSaveExcel)
return template
}
handleConfig(dynGUI,writetoFile:=false) {
dynGUI.generateConfig(0)
if (dynGUI.ConfigString!="") {
fillRC2(dynGUI.ConfigString)
}
if (writetoFile) {
SplitPath % dynGUI.GFA_Evaluation_Configfile_Location,,,,, OutDrive ;; we do it this way because we can also write a new, so-far nonexistant, file to disk. In that case, doing FileExist() on its whole path would fail.
if (!FileExist(OutDrive) || dynGUI.GFA_Evaluation_Configfile_Location="") { ;; can't believe this is necessary...
ttip("You have not yet selected a location for your configuration file. Please do so before attempting to save your configuration.")
return
}
try {
if (!InStr(dynGUI.GFA_Evaluation_Configfile_Location,A_ScriptDir)) {
writeFile(dynGUI.GFA_Evaluation_Configfile_Location,dynGUI.ConfigString,script.config.Configurator_settings.INI_Encoding,,1)
script.config.LastConfigsHistory:=buildHistory(script.config.LastConfigsHistory,script.config.Configurator_settings.ConfigHistoryLimit,dynGUI.GFA_Evaluation_Configfile_Location)
script.save(script.scriptconfigfile,,true)
} else { ;; only update the config file, but do not update the script data
writeFile(dynGUI.GFA_Evaluation_Configfile_Location,dynGUI.ConfigString,script.config.Configurator_settings.INI_Encoding,,1)
}
} catch {
throw Exception( "Failed to write config with encoding '" script.config.Configurator_Settings.INI_Encoding "' to path '" dynGUI.GFA_Evaluation_Configfile_Location "'`n`n" CallStack(),-1)
}
}
return
}
GCSubmit() {
gui GC: submit
return
}
GCEscape() {
gui GC: hide
return
}
fCallBack_StatusBarMainWindow() {
gui GC: Submit, NoHide
gui GC: -AlwaysOnTop
if ((A_GuiEvent="DoubleClick") && (A_EventInfo=1)) { ; part 0 - ??
} else if ((A_GuiEvent="DoubleClick") && (A_EventInfo=2)) { ; part 1 - build/version - check for updates
if (script.config.Configurator_settings.UpdateChannel="stable") {
script.Update(script.vfile,script.rfile,1,,,1)
} else if (script.config.Configurator_settings.UpdateChannel="development") {
script.Update(script.vfile_dev,script.rfile_dev,1,,,1)
}
gui % "GC: "((script.config.Configurator_settings.AlwaysOnTop)?"+":"-") "AlwaysOnTop"
gui % "GC: Default"
gui % "GC: +OwnDialogs"
} else if ((A_GuiEvent="DoubleClick") && (A_EventInfo=3)) { ; part 2 - Author
script.About()
} else if ((A_GuiEvent="DoubleClick") && (A_EventInfo=4)) { ; part 3 - Mode Toggle
globalLogicSwitches.bIsDebug:=!globalLogicSwitches.bIsDebug
; (not author + not debug) || author + not debug
if (!(script.authorID!=A_ComputerName) & !globalLogicSwitches.bIsDebug) || ((script.authorID!=A_ComputerName) & !globalLogicSwitches.bIsDebug)
{ ;; public display
SB_SetText("Standard Mode Engaged. Click to enter debug-mode",4)
SoundBeep 150, 150
SoundBeep 150, 150
SoundBeep 150, 150
ListLines Off
}
else if (!(script.authorID!=A_ComputerName)) || ((script.authorID!=A_ComputerName) && globalLogicSwitches.bIsDebug)
{
SoundBeep 1750, 150
SoundBeep 1750, 150
SoundBeep 1750, 150
SB_SetText("Author/Debug Mode Engaged. Click to exit debug-mode",4)
Clipboard:=ttip(["guiWidth: " guiWidth
,"guiHeight: " guiHeight
,"A_ScreenHeight " A_ScreenHeight
,"A_ScreenWidth " A_ScreenWidth
, "A_DPI " A_ScreenDPI
, "Size Setting " script.config.SizeSetting
,"height-mwa 1440p: " 1392 - 2*30
,"guiWidth 1440p: " 2560 - 2*30
,"guiWidth 1080p: " 1920 - 2*30
,"height-mwa 1080p: " 1032 - 2*30,["bIsAuthor: " globalLogicSwitches.bIsAuthor,"bisDEBUG: " globalLogicSwitches.bIsDebug,"DEBUG " globalLogicSwitches.DEBUG]
, ["Loaded script Configuration: ",script.config]],1,2300)
ListLines On
}
} else if ((A_GuiEvent="DoubleClick") && (A_EventInfo=5)) { ; part 4 - script privileges
if (!A_IsAdmin) {
answer := AppError("Do you want to elevate the program ?", "Do you want to reload the program with administrator-privilages without saving any data? `n`nAny currently unsaved changes will not be saved.",0x34," - ")
if (answer = "Yes") {
RunAsAdmin()
}
}
} else if ((A_GuiEvent="DoubleClick") && (A_EventInfo=6)) { ; part 5 - report bug
if script.requiresInternet(script.metadataArr.Issues) {
script.About(1)
run % "https://www." script.metadataArr.Issues
}
} else if ((A_GuiEvent="DoubleClick") && (A_EventInfo=7)) { ; part 6 - documentation
if script.requiresInternet(script.metadataArr["GH-Repo"]) {
run % "https://htmlpreview.github.io/?https://" script.metadataArr.Documentation2
script.About(1)
}
} else if ((A_GuiEvent="DoubleClick") && (A_EventInfo=8)) { ; part 7
} else if ((A_GuiEvent="DoubleClick") && (A_EventInfo=9)) { ; part 8
}
gui % "GC: " ((script.config.Configurator_settings.AlwaysOnTop)?"+":"-") "AlwaysOnTop"
gui GC: Default
gui GC: +OwnDialogs
return
}
createConfiguration(Path,guiObject) {
global hwndLV_ConfigHistory
global dynGUI
if (!globalLogicSwitches.DEBUG) {
SearchPath:="C://"
}
if (!FileExist(Path)) {
SearchPath:="C://"
} else {
SearchPath:=Path
}
gui -AlwaysOnTop
FileSelectFile Chosen, S8, % SearchPath, % "Please create the ini-file you want to use.", *ini
if (Chosen!="") {
if !RegexMatch(Chosen,"\.ini$") {
Chosen.=".ini"
}
guicontrol % "GC:",vUsedConfigLocation, % Chosen
if (!FileExist(Chosen)) {
writeFile(Chosen,"",script.config.Configurator_settings.INI_Encoding,,true)
} else {
dynGUI.loadConfigFromFile(Chosen)
, dynGUI.validateLoadedConfig()
, dynGUI.populateLoadedConfig()
, handleConfig(dynGUI,false)
IniRead ExperimentName_Key, % Chosen, Experiment, Name, % "Name not specified"
SplitPath % Chosen,,,, FileName
itemLocation:=LV_EX_FindStringEx( hwndLV_ConfigHistory, Chosen)
if !itemLocation && !IsObject(itemLocation){
gui listview,% hwndLV_ConfigHistory
LV_Add("",ExperimentName_Key,FileName,Chosen)
}
}
} else {
ttip("Please select a configuration file. Aborting file-creation.")
return
}
GFA_configurationFile:=Chosen
, dynGUI.GFA_Evaluation_Configfile_Location:=Chosen
guiResize(guiObject)
if (Chosen!="") {
if (script.config.Configurator_settings.UseRelativeConfigPaths) {
if (InStr(FileExist(Chosen),"D")) { ;; directory
Chosen.="\GFA_conf.ini"
}
WINDOWS:=strreplace(Chosen,"/","\")
MAC:=strreplace(Chosen,"/","\")
SplitPath WINDOWS, WINDOWS, GFA_Evaluation_RScript_Location
SplitPath MAC, MAC
guiObject.dynGUI.GFA_Evaluation_RScript_Location:=GFA_Evaluation_RScript_Location "\RScript.R"
guicontrol % "GC:",vStarterRScriptLocation, % guiObject.dynGUI.GFA_Evaluation_RScript_Location
if !FileExist(guiObject.dynGUI.GFA_Evaluation_RScript_Location) {
writeFile(guiObject.dynGUI.GFA_Evaluation_RScript_Location,"","UTF-8-RAW",,true)
}