Subversion Repository Public Repository

Nextrek

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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
´╗┐Imports System.IO
Imports GameEditor.Estensioni

Public Class GameEditorPanel

    'Private TopHorizontalBorderWidth As Int16
    'Private TopHorizontalBorderHeight As Int16
    'Private BottomHorizontalBorderWidth As Int16
    'Private BottomHorizontalBorderHeight As Int16
    'Private MidHorizontalBorderWidth As Int16
    'Private MidHorizontalBorderHeight As Int16
    'Private LeftVerticalBorderWidth As Int16
    'Private LeftVerticalBorderHeight As Int16
    'Private RightVerticalBorderWidth As Int16
    'Private RightVerticalBorderHeight As Int16
    'Private InventoryIconWidth As Int16
    'Private InventoryIconHeight As Int16
    'Private QuestIconWidth As Int16
    'Private QuestIconHeight As Int16
    'Private EventsIconWidth As Int16
    'Private EventsIconHeight As Int16
    'Private SplashForegroundWidth As Int16
    'Private SplashForegroundHeight As Int16
    'Private LoadingForegroundWidth As Int16
    'Private LoadingForegroundHeight As Int16
    Private firstTime As Boolean = True
    Private ObjectImageWidth As Int16
    Private ObjectImageHeight As Int16
    Private EventImageWidth As Int16
    Private EventImageHeight As Int16
    Private QuestImageWidth As Int16
    Private QuestImageHeight As Int16
    Private storyNowLoaded As String = ""
    Private buttonsShown As Dictionary(Of Integer, Boolean) = New Dictionary(Of Integer, Boolean)

    Private Sub GameEditorPanel_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
        Me.buttonsShown.Add(1, True)
        For i As Integer = 2 To 6
            Me.buttonsShown.Add(i, False)
        Next
        WarningPanel.BringToFront()
        SaveLoadPopupPanel.BringToFront()
        PageIdPopupPanel.BringToFront()
        PageMoreOptionPanel.BringToFront()

    End Sub

#Region "UTILITIES"

    Private Function getImagesPath() As String
        Return Application.StartupPath + "\images\"
    End Function

    Private Function getSavedPath() As String
        Return Application.StartupPath + "\saves\"
    End Function

    Private Function getMinstrekPath() As String
        Return Application.StartupPath + "\MinsTrek\"
    End Function

    Private Function getJsonPath() As String
        Return Application.StartupPath + "\json\"

    End Function

    Private Function checkId(ByVal id As String, ByVal grid As DataGridView)
        Dim valid As Boolean = False

        For Each row As DataGridViewRow In grid.Rows
            If (row.Cells.Item(0).Value = id) Then
                valid = True
            End If

        Next

        Return valid

    End Function

    Private Function checkConditionIDS(ByVal textBox As TextBox, ByVal grid As DataGridView) As Boolean
        Dim valid = True
        Dim toBeChecked As String = textBox.Text
        Dim strs As String()

        textBox.ForeColor = Color.Black

        If (Not toBeChecked = "") Then
            strs = toBeChecked.Split(",")
            For Each item As String In strs
                If (Not checkId(item, grid)) Then
                    valid = False
                End If
            Next


        End If

        Return valid

    End Function

    Private Sub setColor(ByVal textBox As TextBox)
        Dim dr As DialogResult = ColorDialog1.ShowDialog()
        If (dr = DialogResult.OK) Then
            Dim color As System.Drawing.Color = ColorDialog1.Color
            Dim hexColor As String = ColorTranslator.ToHtml(color)
            textBox.Text = hexColor
            textBox.BackColor = color
        End If
    End Sub

    Private Sub setImage(ByVal textBox As TextBox, ByVal pictureBox As PictureBox, ByVal folder As String)
        Dim dr As DialogResult
        Dim path As String
        Dim img As Bitmap

        OpenFileDialog1.Filter = "ALL|*.jpeg;*.png;*.jpg;*.gif|JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"
        dr = OpenFileDialog1.ShowDialog()

        If (dr = DialogResult.OK) Then
            path = OpenFileDialog1.FileName
            textBox.Text = OpenFileDialog1.SafeFileName
            My.Computer.FileSystem.CopyFile(path, getImagesPath() + folder + OpenFileDialog1.SafeFileName, True)
            If Not IsNothing(pictureBox) Then
                img = New Bitmap(OpenFileDialog1.FileName)

                pictureBox.BackgroundImage = img

            End If



        End If

    End Sub

    Private Sub checkIfInt16(ByVal textBox As TextBox)
        textBox.ForeColor = Color.Black
        Try
            Dim value As Int16 = Int16.Parse(textBox.Text)
        Catch ex As Exception
            textBox.ForeColor = Color.Red
            textBox.Text = "not valid"
        End Try
    End Sub

    Private Function checkTextInTB(ByVal textBox As TextBox) As Boolean
        Dim text As String = textBox.Text
        Return (Not text = "") And (Not text = "not valid") And (Not text = " page not created")
    End Function

    Private Function checkPrePostCondTextInTB(ByVal textBox As TextBox) As Boolean
        Dim text As String = textBox.Text
        Return (Not text = " quest not created") And (Not text = " page not created") And (Not text = " object not created") And (Not text = "format: object1,object2,object3,....")
    End Function

    Private Sub WarningCloseLabe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WarningCloseLabe.Click
        WarningPanel.Hide()
        WarningCancelButton.Visible = False
        WarningContinueButton.Visible = False
    End Sub

    Private Sub showWarning(ByVal message As String)
        WarningTextLabel.Text = message
        WarningPanel.Location = New System.Drawing.Point(200, 200)
        WarningSaveStoryNameText.Visible = False
        WarningPanel.Show()
    End Sub

    Private Sub WarningCancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WarningCancelButton.Click
        WarningPanel.Hide()
        WarningCancelButton.Visible = False
        WarningContinueButton.Visible = False
    End Sub

    Private Sub showSavePopup()
        SaveLoadPopupPanel.Location = New System.Drawing.Point(200, 200)
        SaveLoadPopupPanel.Show()
        SaveStoryNameText.Show()
        SaveOKButton.Show()
        LoadStoryComboBox.Hide()
        SaveStoryNameText.Text = Me.storyNowLoaded
    End Sub

    Private Sub showLoadPopup()
        Dim firstIndex As Int16
        Dim lastIndex As Int16
        SaveLoadPopupPanel.Location = New System.Drawing.Point(200, 200)
        SaveLoadPopupPanel.Show()
        SaveStoryNameText.Hide()
        SaveOKButton.Hide()
        LoadStoryComboBox.Show()
        LoadStoryComboBox.Items.Clear()
        Dim stories = Directory.GetDirectories(getSavedPath())
        For Each story As String In stories

            firstIndex = story.LastIndexOf("\")
            lastIndex = story.Length - 1
            ' EventDescriptionText.Text += story + CStr(story.LastIndexOf("\")) + "     " + CStr(story.Length - 1) + vbNewLine
            story = story.Substring(firstIndex + 1)

            LoadStoryComboBox.Items.Add(story)
        Next

    End Sub

    Private Sub SaveOKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveOKButton.Click

        If (Not SaveStoryNameText.Text.Equals("")) Then
            saveStory(SaveStoryNameText.Text)
        End If
        SaveLoadPopupPanel.Hide()

    End Sub

    Private Sub LoadStoryComboBox_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadStoryComboBox.SelectedValueChanged
        Me.storyNowLoaded = LoadStoryComboBox.SelectedItem.ToString
        loadStory(Me.storyNowLoaded)

        SaveLoadPopupPanel.Hide()
    End Sub

    Private Sub cleanFile(ByVal filePathName As String)
        Dim fr = New StreamReader(filePathName)

        Dim content As String = fr.ReadToEnd
        fr.Close()
        content = content.Replace("""undefined""", "undefined")
        content = content.Replace("True", "true")
        content = content.Replace("False", "false")
        content = content.Replace("," + vbNewLine + "}", "" + vbNewLine + "}")
        content = content.Replace("," + vbNewLine + vbTab + "}", "" + vbNewLine + vbTab + "}")
        content = content.Replace("," + vbNewLine + vbTab + vbTab + "}", "" + vbNewLine + vbTab + vbTab + "}")
        'PageDescriptionText.Text = content
        Dim fw = New StreamWriter(filePathName)
        fw.Write(content)
        fw.Close()



    End Sub

    Private Function escape(ByVal text As String) As String
        Return text.Replace("""", "\""")

    End Function

    Private Sub cleanControl(ByVal control As Control)

        For Each ctr As Control In control.Controls
            If ctr.GetType.Name = "TextBox" Then
                ctr.Text = ""
            ElseIf ctr.GetType.Name = "CheckedListBox" Then
                CType(ctr, CheckedListBox).ClearSelected()
            ElseIf ctr.GetType.Name = "ComboBox" Then
                CType(ctr, ComboBox).SelectedIndex = CType(ctr, ComboBox).SelectionStart

            ElseIf ctr.GetType.Name = "GroupBox" Then
                For Each ctr1 As Control In ctr.Controls
                    If ctr1.GetType.Name = "TextBox" Then
                        ctr1.Text = ""
                    ElseIf ctr1.GetType.Name = "CheckedListBox" Then
                        CType(ctr1, CheckedListBox).ClearSelected()
                    ElseIf ctr1.GetType.Name = "ComboBox" Then
                        CType(ctr1, ComboBox).SelectedIndex = CType(ctr1, ComboBox).SelectionStart
                    End If

                Next
            End If
        Next

    End Sub

#End Region

#Region "MENU"

    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        showSavePopup()
    End Sub

    Private Sub LoadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadToolStripMenuItem.Click
        showLoadPopup()
    End Sub

    Private Sub SaveLoadCloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveLoadCloseButton.Click
        SaveLoadPopupPanel.Hide()
    End Sub

    Private Sub saveStory(ByVal storyName As String)

        If (Not Directory.Exists(getSavedPath() + storyName)) Then
            Directory.CreateDirectory(getSavedPath() + storyName)
        End If

        Dim writeFile As System.IO.TextWriter = New StreamWriter(getSavedPath() + storyName + "\" + "save.txt")



        Dim tabs = GameEditorTabs.TabPages

        For Each tab As System.Windows.Forms.TabPage In tabs
            For Each ctr As Control In tab.Controls
                If (ctr.GetType.Name = "GroupBox") Then
                    For Each ctr1 As Control In ctr.Controls
                        If (ctr1.GetType().Name = "TextBox") Then
                            writeFile.WriteLine(ctr1.Name + "[" + ctr1.Text.Replace("" + vbNewLine, "<br/>") + "[" + CStr(ctr1.BackColor.ToArgb))
                        End If
                    Next

                End If
                If (ctr.GetType().Name = "TextBox") Then

                    writeFile.WriteLine(ctr.Name + "[" + ctr.Text.Replace("" + vbNewLine, "<br/>") + "[" + CStr(ctr.BackColor.ToArgb))


                    ' If (IsNothing(My.Settings.Properties.Item(ctr.Name))) Then
                    'Dim settingsProperty = New System.Configuration.SettingsProperty(ctr.Name)
                    'My.Settings.Properties.Add(settingsProperty)
                    'End If
                    'My.Settings.Properties.Item(ctr.Name).DefaultValue = ctr.Text
                    'QuestDescriptionText.Text += ctr.Name + " : " + My.Settings.Properties.Item(ctr.Name).DefaultValue + vbCrLf
                    ' My.Settings.Item(ctr.Name) = ctr.Text
                End If




            Next
        Next
        writeFile.Close()
        saveGrid(ObjectsGrid, storyName)
        saveGrid(EventsGrid, storyName)
        saveGrid(QuestsGrid, storyName)
        saveGrid(PagesGrid, storyName)
        saveGrid(PageButtonGrid, storyName)



    End Sub

    Private Sub saveGrid(ByVal grid As DataGridView, ByVal storyName As String)
        Dim fw = New StreamWriter(getSavedPath() + storyName + "\" + "save" + grid.Name + ".txt")
        Dim cells As DataGridViewCellCollection
        Dim line As String = ""
        For Each rw As DataGridViewRow In grid.Rows
            line = ""
            cells = rw.Cells
            For Each cell As DataGridViewCell In cells
                If cell.Value Is Nothing Then
                    line += "undefined["
                ElseIf (cell.Value.ToString.Equals("")) Then
                    line += "undefined["
                Else
                    line += cell.Value.ToString.Replace("" + vbNewLine, "<br/>") + "["
                End If
            Next
            fw.WriteLine(line)

        Next
        fw.Close()
    End Sub

    Private Sub loadGrid(ByVal grid As DataGridView, ByVal storyName As String)
        Dim map As String()
        Dim fr = New StreamReader(getSavedPath() + storyName + "\" + "save" + grid.Name + ".txt")
        Dim line As String

        grid.Rows.Clear()

        While (Not fr.EndOfStream)
            line = fr.ReadLine()
            line = line.Replace("<br/>", "" + vbNewLine)
            map = line.Split("[")

            grid.Rows.Add(map)
        End While
        fr.Close()


    End Sub

    Private Sub loadStory(ByVal storyName As String)
        Dim map As String()
        Dim line As String
        Dim tabs = GameEditorTabs.TabPages

        If (File.Exists(getSavedPath() + storyName + "\" + "\save.txt")) Then
            Dim readerFile As System.IO.StreamReader = New System.IO.StreamReader(getSavedPath() + storyName + "\" + "\save.txt")

            While (Not readerFile.EndOfStream)
                line = readerFile.ReadLine
                line = line.Replace("<br/>", "" + vbNewLine)
                map = line.Split("[")



                For Each tab As System.Windows.Forms.TabPage In tabs
                    For Each ctr As Control In tab.Controls
                        If (ctr.GetType.Name = "GroupBox") Then
                            For Each ctr1 As Control In ctr.Controls
                                If (ctr1.GetType().Name = "TextBox" And ctr1.Name = map(0)) Then
                                    ctr1.Text = map(1)

                                    ctr1.BackColor = Color.FromArgb(CInt(map(2)))

                                    Exit For
                                    Exit For
                                    Exit For
                                End If
                            Next

                        End If
                        If (ctr.GetType().Name = "TextBox" And ctr.Name = map(0)) Then
                            ctr.Text = map(1)
                            If (Not map(2) = "Window") Then

                                ctr.BackColor = Color.FromArgb(CInt(map(2)))

                            End If

                            Exit For
                            Exit For
                        End If
                    Next
                Next

            End While

            readerFile.Close()
        End If

        loadGrid(EventsGrid, storyName)
        loadGrid(ObjectsGrid, storyName)
        loadGrid(QuestsGrid, storyName)
        loadGrid(PagesGrid, storyName)
        loadGrid(PageButtonGrid, storyName)
        updateOEQCheckedListBoxes()
        updatePageCheckBoxes()
    End Sub

    Private Sub ObjectsfromTxtToJson(ByVal storyName As String)
        Dim advObjectCol As My.Types.advObjectCollection = New My.Types.advObjectCollection

        Using fr = New StreamReader(getSavedPath() + storyName + "\" + "saveObjectsGrid.txt")
            Using fw = New StreamWriter(getJsonPath() + storyName + "\" + "objects.js")
                fw.WriteLine("var advObjects = {")
                While (Not fr.EndOfStream)
                    Dim line As String = fr.ReadLine
                    Dim map As String() = line.Split("[")
                    fw.WriteLine(vbTab + """" + map(0) + """ : {")
                    fw.WriteLine(vbTab + vbTab + " ""name"" :" + " """ + escape(map(1)) + """ ,")
                    fw.WriteLine(vbTab + vbTab + " ""description"" :" + " """ + escape(map(2)) + """ ,")
                    fw.WriteLine(vbTab + vbTab + " ""img"" :" + " """ + map(3) + """ ,")
                    fw.WriteLine(vbTab + vbTab + " ""had"" :" + " " + map(4) + " ")
                    fw.WriteLine(vbTab + "},")
                    Dim advObj As New My.Types.advObject
                    advObj.name = map(1)
                    advObj.description = map(2)
                    advObj.img = map(3)
                    advObj.had = Convert.ToBoolean(map(4))
                    advObjectCol.results.Add(advObj)
                End While
                fw.WriteLine("};")
                fw.Close()
            End Using
            fr.Close()
        End Using

        Dim jsonStr As String = advObjectCol.ToJSON()
        System.IO.File.WriteAllText(getJsonPath() + storyName + "\" + "advObjects.js", jsonStr)
    End Sub

    Private Sub EventsfromTxtToJson(ByVal storyName As String)
        Dim advEventCol As My.Types.advEventCollection = New My.Types.advEventCollection

        Using fr = New StreamReader(getSavedPath() + storyName + "\" + "saveEventsGrid.txt")
            Using fw = New StreamWriter(getJsonPath() + storyName + "\" + "events.js")
                fw.WriteLine("var advEvents = {")

                While (Not fr.EndOfStream)
                    Dim line As String = fr.ReadLine
                    Dim map As String() = line.Split("[")

                    Dim advEvent As My.Types.advEvent = New My.Types.advEvent
                    With advEvent
                        .name = map(1)
                        .description = map(2)
                        .img = map(3)
                        .happened = Convert.ToBoolean(map(4))
                    End With
                    advEventCol.results.Add(advEvent)

                    fw.WriteLine(vbTab + """" + map(0) + """ : {")
                    fw.WriteLine(vbTab + vbTab + " ""name"" :" + " """ + escape(map(1)) + """ ,")
                    fw.WriteLine(vbTab + vbTab + " ""description"" :" + " """ + escape(map(2)) + """ ,")
                    fw.WriteLine(vbTab + vbTab + " ""img"" :" + " """ + map(3) + """ ,")
                    fw.WriteLine(vbTab + vbTab + " ""happened"" :" + " " + map(4) + " ")
                    fw.WriteLine(vbTab + "},")
                End While
                fw.WriteLine("};")
                fw.Close()
            End Using
            fr.Close()
        End Using

        Dim jsonStr As String = advEventCol.ToJSON()
        System.IO.File.WriteAllText(getJsonPath() + storyName + "\" + "advEvents.js", jsonStr)
    End Sub

    Private Sub QuestsfromTxtToJson(ByVal storyName As String)
        Dim advQuestCol As New My.Types.advQuestCollection

        Using fr = New StreamReader(getSavedPath() + storyName + "\" + "saveQuestsGrid.txt")
            Using fw = New StreamWriter(getJsonPath() + storyName + "\" + "quests.js")
                fw.WriteLine("var advQuests = {")
                While (Not fr.EndOfStream)
                    Dim line As String = fr.ReadLine
                    Dim map As String() = line.Split("[")
                    fw.WriteLine(vbTab + """" + map(0) + """ : {")
                    fw.WriteLine(vbTab + vbTab + " ""name"" :" + " """ + escape(map(1)) + """ ,")
                    fw.WriteLine(vbTab + vbTab + " ""description"" :" + " """ + escape(map(2)) + """ ,")
                    fw.WriteLine(vbTab + vbTab + " ""img"" :" + " """ + map(3) + """ ,")
                    fw.WriteLine(vbTab + vbTab + " ""status"" :" + " '" + map(4) + "' ")
                    fw.WriteLine(vbTab + "},")
                    Dim advQuest As New My.Types.advQuest
                    advQuest.name = map(1)
                    advQuest.description = map(2)
                    advQuest.img = map(3)
                    advQuest.status = map(4)
                    advQuestCol.results.Add(advQuest)
                End While
                fw.WriteLine("};")
                fw.Close()
            End Using
            fr.Close()
        End Using

        Dim jsonStr As String = advQuestCol.ToJSON()
        System.IO.File.WriteAllText(getJsonPath() + storyName + "\" + "advQuests.js", jsonStr)
    End Sub

    Private Sub PagesfromTxtToJson(ByVal storyName As String)

        Dim advPageCol As My.Types.advPageCollection = New My.Types.advPageCollection
        Dim buttonArrayList As ArrayList
        Dim buttonMap As Dictionary(Of String, ArrayList) = New Dictionary(Of String, ArrayList)

        Using fw = New StreamWriter(getJsonPath() + storyName + "\" + "pages.js")

            Using buttonFr = New StreamReader(getSavedPath() + storyName + "\" + "savePageButtonGrid.txt")
                While (Not buttonFr.EndOfStream)
                    Dim line As String = buttonFr.ReadLine
                    Dim map As String() = line.Split("[")
                    Try
                        buttonMap.Item(map(0)).Add(map)
                    Catch ex As Exception
                        buttonMap.Add(map(0), New ArrayList())
                        buttonMap.Item(map(0)).Add(map)
                    End Try
                End While
                buttonFr.Close()
            End Using

            fw.WriteLine("var advPages = {")

            Using pageFr = New StreamReader(getSavedPath() + storyName + "\" + "savePagesGrid.txt")
                Dim pageCount As Integer = 0
                While (Not pageFr.EndOfStream)
                    Dim line As String = pageFr.ReadLine
                    Dim map As String() = line.Split("[")

                    Dim advPage As New My.Types.advPage
                    With advPage
                        ._id = pageCount.ToString
                        .text = map(3)
                        .bgColor = map(2)
                        .inventoryImg = map(4)
                        .eventsImg = map(5)
                        .questsImg = map(6)
                        .titleColor = map(7)
                        .topBgColor = map(8)
                        .hBorderTopImg = map(9)
                        .hBorderMidImg = map(10)
                        .bottomBgColor = map(11)
                        .hBorderBottomImg = map(12)
                        .wBorderLeftImg = map(13)
                        .wBorderRightImg = map(14)
                        .topImage = map(15)
                        .bottomImage = map(16)
                    End With

                    fw.WriteLine(vbTab + " """ + map(0) + """ :  {")
                    fw.WriteLine(vbTab + vbTab + " ""text"" :  """ + escape(map(3)) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""background-color"" :  """ + map(2) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""inventory-img"" :  """ + map(4) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""events-img"" :  """ + map(5) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""quests-img"" :  """ + map(6) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""title-color"" :  """ + map(7) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""top-background-color"" :  """ + map(8) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""hBorderTop-img"" :  """ + map(9) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""hBorderMid-img"" :  """ + map(10) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""bottom-background-color"" :  """ + map(11) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""hBorderBottom-img"" :  """ + map(12) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""wBorderLeft-img"" :  """ + map(13) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""wBorderRight-img"" :  """ + map(14) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""topImage"" :  """ + map(15) + """   ,")
                    fw.WriteLine(vbTab + vbTab + " ""bottomImage"" :  """ + map(16) + """   ,")
                    Dim buttonNum As Byte
                    Try
                        buttonNum = buttonMap.Item(map(0)).Count
                    Catch e As KeyNotFoundException
                        buttonNum = 0
                    End Try

                    fw.WriteLine(vbTab + vbTab + " ""buttons"" :  " + CStr(buttonNum) + "   ,")
                    advPage.buttons = buttonNum

                    If (map(17).Equals("undefined") Or map(17).Equals("")) Then
                        fw.WriteLine(vbTab + vbTab + " ""buttonsWidth"" :  " + Me.DefaultButtonWidthText.Text + "   ,")
                        advPage.buttonsWidth = Me.DefaultButtonWidthText.Text
                    Else
                        fw.WriteLine(vbTab + vbTab + " ""buttonsWidth"" :  " + map(17) + "   ,")
                        advPage.buttonsWidth = map(17)
                    End If

                    If (map(18).Equals("undefined") Or map(18).Equals("")) Then
                        fw.WriteLine(vbTab + vbTab + " ""buttonsHeight"" :  " + Me.DefaultButtonHeightText.Text + "   ,")
                        advPage.buttonsHeight = Me.DefaultButtonHeightText.Text
                    Else
                        fw.WriteLine(vbTab + vbTab + " ""buttonsHeight"" :  " + map(18) + "   ,")
                        advPage.buttonsHeight = map(18)
                    End If

                    Try
                        buttonArrayList = buttonMap.Item(map(0))
                        Dim counter As Int16 = 0
                        While counter <= (buttonArrayList.Count - 1)
                            Dim map2 As String() = buttonArrayList.Item(counter)
                            fw.WriteLine(vbTab + vbTab + " ""button" + CStr(counter) + """ :  {")
                            Dim advButton As New My.Types.advSceneButton
                            advButton.button = counter.ToString

                            If ((map2(17).Equals("undefined") Or map2(17).Equals(""))) Then
                                fw.WriteLine(vbTab + vbTab + vbTab + " ""buttonImage"" :  """ + Me.DefaultButtonImageText.Text + """  ,")
                                advButton.buttonImage = Me.DefaultButtonImageText.Text
                            Else
                                fw.WriteLine(vbTab + vbTab + vbTab + " ""buttonImage"" :  """ + map2(17) + """  ,")
                                advButton.buttonImage = map2(17)
                            End If

                            fw.WriteLine(vbTab + vbTab + vbTab + " ""targetId"" :  """ + map2(1) + """ ,")
                            fw.WriteLine(vbTab + vbTab + vbTab + " ""buttonText"" :  """ + escape(map2(2)) + """ ,")
                            fw.Write(vbTab + vbTab + vbTab + " ""buttonPreCond"" :  """)

                            advButton.targetId = map2(1)
                            advButton.buttonText = map2(2)
                            advButton.buttonPreCond = ""

                            Dim temp As String = ""
                            'pre object owned
                            Dim prePostLine As String = map2(3)
                            Dim map3 As String()
                            If prePostLine.Equals("undefined") Then
                                map3 = {}
                            Else : map3 = prePostLine.Split(",")
                            End If
                            For Each item As String In map3
                                temp += "oggetto(" + item.Trim() + ",true)&"
                            Next
                            'pre object not owned
                            prePostLine = map2(4)
                            If prePostLine.Equals("undefined") Then
                                map3 = {}
                            Else
                                map3 = prePostLine.Split(",")
                            End If
                            For Each item As String In map3
                                temp += "oggetto(" + item.Trim() + ",false)&"
                            Next
                            'pre event occured
                            prePostLine = map2(5)
                            If prePostLine.Equals("undefined") Then
                                map3 = {}
                            Else
                                map3 = prePostLine.Split(",")
                            End If
                            For Each item As String In map3
                                temp += "evento(" + item.Trim() + ",true)&"
                            Next
                            'pre event not occured
                            prePostLine = map2(6)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3
                                temp += "evento(" + item.Trim() + ",false)&"
                            Next
                            'pre quest none
                            prePostLine = map2(7)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3
                                temp += "quest(" + item.Trim() + ",'none')&"
                            Next
                            'pre quest had
                            prePostLine = map2(8)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3
                                temp += "quest(" + item.Trim() + ",'had')&"
                            Next
                            'pre quest done
                            prePostLine = map2(9)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3
                                temp += "quest(" + item.Trim() + ",'done')&"
                            Next
                            If (temp.Length > 0) Then
                                temp = temp.Substring(0, temp.Length - 1)
                            End If
                            fw.WriteLine(temp + """,")


                            fw.Write(vbTab + vbTab + vbTab + " ""buttonPostCond"" :  """)
                            advButton.buttonPostCond = ""

                            temp = ""
                            'post object owned
                            prePostLine = map2(10)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3
                                temp += "oggetto(" + item.Trim() + ",true)&"
                            Next
                            'post object not owned
                            prePostLine = map2(11)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3
                                temp += "oggetto(" + item.Trim() + ",false)&"
                            Next
                            'post event occured
                            prePostLine = map2(12)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3
                                temp += "evento(" + item.Trim() + ",true)&"
                            Next
                            'post event not occured
                            prePostLine = map2(13)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3
                                temp += "evento(" + item.Trim() + ",false)&"
                            Next
                            'post quest none
                            prePostLine = map2(14)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3
                                temp += "quest(" + item.Trim() + ",'none')&"
                            Next
                            'post quest had
                            prePostLine = map2(15)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3

                                temp += "quest(" + item.Trim() + ",'had')&"
                            Next
                            'post quest done
                            prePostLine = map2(16)
                            If prePostLine.Equals("undefined") Then map3 = {} Else map3 = prePostLine.Split(",")
                            For Each item As String In map3

                                temp += "quest(" + item.Trim() + ",'done')&"
                            Next

                            If (temp.Length > 0) Then
                                temp = temp.Substring(0, temp.Length - 1)
                            End If
                            fw.WriteLine(temp + """")
                            fw.WriteLine(vbTab + vbTab + "},")

                            advPage.scenebuttons.Add(advButton)
                            counter += 1
                        End While
                    Catch e As KeyNotFoundException
                    End Try
                    fw.WriteLine(vbTab + "},")

                    advPageCol.results.Add(advPage)
                    pageCount += 1
                End While

                pageFr.Close()
            End Using

            fw.WriteLine("};")
            fw.Close()
        End Using

        Dim jsonStr As String = advPageCol.ToJSON()
        System.IO.File.WriteAllText(getJsonPath() + storyName + "\" + "advPages.js", jsonStr)
    End Sub

    Private Sub MainDatafromTxtToJson(ByVal storyName As String)

        Dim advMainDataCol As New My.Types.advMainDataCollection
        Dim advMainData As New My.Types.advMainData
        Dim img As Bitmap
        Using fw = New StreamWriter(getJsonPath() + storyName + "\" + "mainData.js")
            advMainData.title = GameTitleText.Text
            advMainData.titleColor = TitleColorText.Text
            'advMainData.events = New My.Types.advEventCollection
            'advMainData.objects = New My.Types.advObjectCollection
            'advMainData.quests = New My.Types.advQuestCollection
            'advMainData.pages = New My.Types.advPageCollection

            fw.WriteLine("var mainData = {")
            fw.WriteLine(vbTab + """title""  : """ + escape(GameTitleText.Text) + """  ,")
            fw.WriteLine(vbTab + """title-color""  : """ + TitleColorText.Text + """  ,")
            fw.WriteLine(vbTab + " ""events""  : advEvents  ,")
            fw.WriteLine(vbTab + " ""objects""  : advObjects  ,")
            fw.WriteLine(vbTab + " ""quests""  : advQuests  ,")
            fw.WriteLine(vbTab + " ""pages""  : advPages  ,")

            Dim advSplash As New My.Types.advSplash
            advSplash.splashTime = SplashTimeText.Text
            advSplash.splashBgColor = SplashBGText.Text
            advSplash.splashForeground = SplashForegroundIMGText.Text

            fw.WriteLine(vbTab + " ""splash""  :  {")
            fw.WriteLine(vbTab + vbTab + " ""splash-time""  :  " + SplashTimeText.Text + " ,")
            fw.WriteLine(vbTab + vbTab + " ""splash-background-color""  :  """ + SplashBGText.Text + """ ,")
            fw.WriteLine(vbTab + vbTab + " ""splash-foreground""  :  """ + SplashForegroundIMGText.Text + """ ,")
            Try
                img = New Bitmap(getImagesPath() + SplashForegroundIMGText.Text)
                fw.WriteLine(vbTab + vbTab + " ""splash-foreground-width""  :  " + CStr(img.Width) + " ,")
                fw.WriteLine(vbTab + vbTab + " ""splash-foreground-height""  :  " + CStr(img.Height) + " ,")
                advSplash.splashForegroundWidth = img.Width
                advSplash.splashForegroundHeight = img.Height
            Catch
                fw.WriteLine(vbTab + vbTab + " ""splash-foreground-width""  : 0 ,")
                fw.WriteLine(vbTab + vbTab + " ""splash-foreground-height""  :  0 ,")
                advSplash.splashForegroundWidth = 0
                advSplash.splashForegroundHeight = 0
            End Try
            fw.WriteLine(vbTab + vbTab + " ""splash-text""  :  """ + escape(SplashTextText.Text) + """ ,")
            fw.WriteLine(vbTab + vbTab + " ""splash-text-color""  :  """ + SplashTextColorText.Text + """ ")
            fw.WriteLine(vbTab + "},")

            advSplash.splashText = SplashTextText.Text
            advSplash.splashTextColor = SplashTextColorText.Text
            advMainData.splash = advSplash


            Dim advLoading As New My.Types.advLoading
            advLoading.loadTime = LoadingTimeText.Text
            advLoading.loadDelay = LoadingDelayText.Text
            advLoading.loadBgColor = LoadingBGText.Text
            advLoading.loadForeground = LoadingForegroundIMGText.Text

            fw.WriteLine(vbTab + " ""loading""  :  {")
            fw.WriteLine(vbTab + vbTab + " ""load-time""  :  " + LoadingTimeText.Text + " ,")
            fw.WriteLine(vbTab + vbTab + " ""load-delay""  :  " + LoadingDelayText.Text + " ,")
            fw.WriteLine(vbTab + vbTab + " ""load-background-color""  :  """ + LoadingBGText.Text + """ ,")
            fw.WriteLine(vbTab + vbTab + " ""load-foreground""  :  """ + LoadingForegroundIMGText.Text + """ ,")
            Try
                img = New Bitmap(getImagesPath() + LoadingForegroundIMGText.Text)
                fw.WriteLine(vbTab + vbTab + " ""load-foreground-width""  :  " + CStr(img.Width) + " ,")
                fw.WriteLine(vbTab + vbTab + " ""load-foreground-height""  :  " + CStr(img.Height) + " ,")
                advLoading.loadForegroundWidth = img.Width
                advLoading.loadForegroundHeight = img.Height
            Catch
                fw.WriteLine(vbTab + vbTab + " ""load-foreground-width""  : 0 ,")
                fw.WriteLine(vbTab + vbTab + " ""load-foreground-height""  :  0 ,")
                advLoading.loadForegroundWidth = 0
                advLoading.loadForegroundHeight = 0
            End Try
            fw.WriteLine(vbTab + vbTab + " ""load-text""  :  """ + escape(LoadingTextText.Text) + """ ,")
            fw.WriteLine(vbTab + vbTab + " ""load-text-color""  :  """ + LoadingTextColorText.Text + """ ")
            fw.WriteLine(vbTab + "},")

            advLoading.loadText = LoadingTextText.Text
            advLoading.loadTextColor = LoadingTextColorText.Text
            advMainData.loading = advLoading


            Dim advAlert As New My.Types.advAlert
            advAlert.widthPerc = AlertWidthText.Text
            advAlert.heightPerc = AlertHeightText.Text
            advAlert.alertBgColor = AlertBGColorText.Text
            advAlert.alertBackgroundImg = AlertBGIMGText.Text
            advAlert.hBorderTopImg = AlertTopBGIMGText.Text
            advAlert.hBorderBottomImg = AlertBottomBGIMGText.Text
            advAlert.wBorderLeftImg = AlertLeftBGIMGText.Text
            advAlert.wBorderRightImg = AlertRightBGIMGText.Text
            advAlert.alertOKButtonImg = AlertOKButtonText.Text

            fw.WriteLine(vbTab + """alert""    :{")
            fw.WriteLine(vbTab + vbTab + " ""widthPerc""    : " + AlertWidthText.Text + " ,")
            fw.WriteLine(vbTab + vbTab + " ""heightPerc""    : " + AlertHeightText.Text + " ,")
            fw.WriteLine(vbTab + vbTab + " ""alert-background-color""    : """ + AlertBGColorText.Text + """ ,")
            fw.WriteLine(vbTab + vbTab + " ""alert-background-img""    : """ + AlertBGIMGText.Text + """ ,")
            fw.WriteLine(vbTab + vbTab + " ""hBorderTop-img""    : """ + AlertTopBGIMGText.Text + """ ,")
            fw.WriteLine(vbTab + vbTab + " ""hBorderBottom-img""    : """ + AlertBottomBGIMGText.Text + """ ,")
            fw.WriteLine(vbTab + vbTab + " ""wBorderLeft-img""    : """ + AlertLeftBGIMGText.Text + """ ,")
            fw.WriteLine(vbTab + vbTab + " ""wBorderRight-img""    : """ + AlertRightBGIMGText.Text + """ ,")

            Try
                img = New Bitmap(getImagesPath() + AlertTopBGIMGText.Text)
                fw.WriteLine(vbTab + vbTab + " ""hBorder-height"" :  " + CStr(img.Height) + "   ,")
                advAlert.hBorderHeight = img.Height
                img = New Bitmap(getImagesPath() + AlertLeftBGIMGText.Text)
                fw.WriteLine(vbTab + vbTab + " ""wBorder-width"" :  " + CStr(img.Width) + "   ,")
                advAlert.wBorderWidth = img.Width
            Catch ex As Exception
                fw.WriteLine(vbTab + vbTab + " ""hBorder-height"" : 10   ,")
                fw.WriteLine(vbTab + vbTab + " ""wBorder-width"" :  10  ,")
                advAlert.hBorderHeight = 10
                advAlert.wBorderWidth = 10
            End Try
            fw.WriteLine(vbTab + vbTab + " ""alert-OKButton-img""    : """ + AlertOKButtonText.Text + """ ,")
            Try
                img = New Bitmap(getImagesPath() + AlertOKButtonText.Text)
                fw.WriteLine(vbTab + vbTab + " ""alert-OKButton-width"" :  " + CStr(img.Width) + "   ,")
                fw.WriteLine(vbTab + vbTab + " ""alert-OKButton-height"" :  " + CStr(img.Height) + "   ,")
                advAlert.alertOKButtonWidth = img.Width
                advAlert.alertOKButtonHeight = img.Height
            Catch ex As Exception
                fw.WriteLine(vbTab + vbTab + " ""alert-OKButton-width"" : 30   ,")
                fw.WriteLine(vbTab + vbTab + " ""alert-OKButton-height"" :  30  ")
                advAlert.alertOKButtonWidth = 30
                advAlert.alertOKButtonHeight = 30
            End Try
            fw.WriteLine(vbTab + "},")

            advMainData.alert = advAlert

            Dim advDefaults As New My.Types.advDefaults
            advDefaults.bgColor = BGText.Text
            advDefaults.topBgColor = TopAreaBGText.Text
            advDefaults.bottomBgColor = BottomAreaBGText.Text
            advDefaults.topContainerHeight = TopAreaHeightText.Text
            advDefaults.hBorderTopImg = TopHorizontalBorderIMGText.Text

            fw.WriteLine(vbTab + " ""defaults""  :  {")

            fw.WriteLine(vbTab + vbTab + " ""background-color"" :  """ + BGText.Text + """   ,")
            fw.WriteLine(vbTab + vbTab + " ""top-background-color"" :  """ + TopAreaBGText.Text + """   ,")
            fw.WriteLine(vbTab + vbTab + " ""bottom-background-color"" :  """ + BottomAreaBGText.Text + """   ,")
            fw.WriteLine(vbTab + vbTab + " ""topContainer-height"" :  " + TopAreaHeightText.Text + "   ,")
            fw.WriteLine(vbTab + vbTab + " ""hBorderTop-img"" :  """ + TopHorizontalBorderIMGText.Text + """   ,")
            Try
                img = New Bitmap(getImagesPath() + TopHorizontalBorderIMGText.Text)
                fw.WriteLine(vbTab + vbTab + " ""hBorder-height"" :  " + CStr(img.Height) + "   ,")
                advDefaults.hBorderHeight = img.Height
            Catch
                fw.WriteLine(vbTab + vbTab + " ""hBorder-height"" :  0  ,")
                advDefaults.hBorderHeight = 0
            End Try
            fw.WriteLine(vbTab + vbTab + " ""hBorderMid-img"" :  """ + MidHorizontalBorderIMGText.Text + """   ,")
            fw.WriteLine(vbTab + vbTab + " ""hBorderBottom-img"" :  """ + BottomHorizontalBorderIMGText.Text + """   ,")
            fw.WriteLine(vbTab + vbTab + " ""wBorderLeft-img"" :  """ + LeftVerticalBorderIMGText.Text + """   ,")

            advDefaults.hBorderMidImg = MidHorizontalBorderIMGText.Text
            advDefaults.hBorderBottomImg = BottomHorizontalBorderIMGText.Text
            advDefaults.wBorderLeftImg = LeftVerticalBorderIMGText.Text

            Try
                img = New Bitmap(getImagesPath() + LeftVerticalBorderIMGText.Text)
                fw.WriteLine(vbTab + vbTab + " ""wBorder-width"" :  " + CStr(img.Width) + "   ,")
                advDefaults.wBorderWidth = img.Width
            Catch ex As Exception
                fw.WriteLine(vbTab + vbTab + " ""wBorder-width"" :  0  ,")
                advDefaults.wBorderWidth = 0
            End Try

            fw.WriteLine(vbTab + vbTab + " ""wBorderRight-img"" :  """ + RightVerticalBorderText.Text + """   ,")
            fw.WriteLine(vbTab + vbTab + " ""inventory-img"" :  """ + InventoryIconText.Text + """   ,")

            advDefaults.wBorderRightImg = RightVerticalBorderText.Text
            advDefaults.inventoryImg = InventoryIconText.Text

            Try
                img = New Bitmap(getImagesPath() + InventoryIconText.Text)
                fw.WriteLine(vbTab + vbTab + " ""inventory-img-width"" :  " + CStr(img.Width) + "   ,")
                fw.WriteLine(vbTab + vbTab + " ""inventory-img-height"" :  " + CStr(img.Height) + "   ,")
                advDefaults.inventoryImgWidth = img.Width
                advDefaults.inventoryImgHeight = img.Height
            Catch ex As Exception
                fw.WriteLine(vbTab + vbTab + " ""inventory-img-width"" : 0   ,")
                fw.WriteLine(vbTab + vbTab + " ""inventory-img-height"" :  0  ,")
                advDefaults.inventoryImgWidth = 0
                advDefaults.inventoryImgHeight = 0
            End Try
            fw.WriteLine(vbTab + vbTab + " ""object-width"" :  " + ObjectImagesWidthText.Text + "   ,")
            fw.WriteLine(vbTab + vbTab + " ""object-height"" :  " + ObjectImagesHeightText.Text + "   ,")

            fw.WriteLine(vbTab + vbTab + " ""quests-img"" :  """ + QuestIconIMGText.Text + """   ,")
            Try
                img = New Bitmap(getImagesPath() + QuestIconIMGText.Text)
                fw.WriteLine(vbTab + vbTab + " ""quests-img-width"" :  " + CStr(img.Width) + "   ,")
                fw.WriteLine(vbTab + vbTab + " ""quests-img-height"" :  " + CStr(img.Height) + "   ,")
            Catch ex As Exception
                fw.WriteLine(vbTab + vbTab + " ""quests-img-width"" :  0  ,")
                fw.WriteLine(vbTab + vbTab + " ""quests-img-height"" : 0  ,")
            End Try

            fw.WriteLine(vbTab + vbTab + " ""quests-width"" :  " + QuestImagesWidthText.Text + "   ,")
            fw.WriteLine(vbTab + vbTab + " ""quests-height"" :  " + QuestImagesHeightText.Text + "   ,")

            fw.WriteLine(vbTab + vbTab + " ""events-img"" :  """ + EventsIconIMGText.Text + """   ,")
            Try
                img = New Bitmap(getImagesPath() + EventsIconIMGText.Text)
                fw.WriteLine(vbTab + vbTab + " ""events-img-width"" :  " + CStr(img.Width) + "   ,")
                fw.WriteLine(vbTab + vbTab + " ""events-img-height"" :  " + CStr(img.Height) + "   ,")
            Catch ex As Exception
                fw.WriteLine(vbTab + vbTab + " ""events-img-width"" :  0  ,")
                fw.WriteLine(vbTab + vbTab + " ""events-img-height"" :  0  ,")
            End Try

            fw.WriteLine(vbTab + vbTab + " ""events-width"" :  " + EventsImagesWidthText.Text + "   ,")
            fw.WriteLine(vbTab + vbTab + " ""events-height"" :  " + EventsImagesHeightText.Text + "   ")

            fw.WriteLine(vbTab + "}")

            advMainData.defaults = advDefaults

            fw.WriteLine("};")

            fw.Close()
        End Using
        advMainDataCol.results.Add(advMainData)

        Dim jsonStr As String = advMainDataCol.ToJSON()
        System.IO.File.WriteAllText(getJsonPath() + storyName + "\" + "advMainData.js", jsonStr)
    End Sub

    Private Sub FinishEditingToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FinishEditingToolStripMenuItem.Click
        Dim initFound As Boolean = False
        Dim endFound As Boolean = False
        For Each row As DataGridViewRow In PagesGrid.Rows
            If (CStr(row.Cells.Item(0).Value) = "init") Then
                initFound = True
            End If
            If (CStr(row.Cells.Item(0).Value) = "end") Then
                endFound = True
            End If

        Next

        If (initFound And endFound) Then
            showWarning("All the changes will be saved.continue?")
            WarningSaveStoryNameText.Text = Me.storyNowLoaded
            WarningSaveStoryNameText.Visible = True
            WarningCancelButton.Visible = True
            WarningContinueButton.Visible = True
        Else
            showWarning("Page with id ""init"" and/or ""end"" still not created.")
            WarningCancelButton.Visible = False
            WarningContinueButton.Visible = False
            WarningCancelButton.Visible = False
        End If
    End Sub

    Private Sub WarningContinueButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WarningContinueButton.Click
        Dim storyName As String = WarningSaveStoryNameText.Text

        If (Not storyName.Equals("")) Then

            If (Not Directory.Exists(getJsonPath() + storyName)) Then
                Directory.CreateDirectory(getJsonPath() + storyName)
            End If

            saveStory(WarningSaveStoryNameText.Text)

            ObjectsfromTxtToJson(storyName)
            EventsfromTxtToJson(storyName)
            QuestsfromTxtToJson(storyName)
            PagesfromTxtToJson(storyName)
            MainDatafromTxtToJson(storyName)

            cleanFile(getJsonPath() + storyName + "\" + "pages.js")
            cleanFile(getJsonPath() + storyName + "\" + "objects.js")
            cleanFile(getJsonPath() + storyName + "\" + "events.js")
            cleanFile(getJsonPath() + storyName + "\" + "quests.js")
            cleanFile(getJsonPath() + storyName + "\" + "mainData.js")


            Try
                IO.File.Copy(getJsonPath() + storyName + "\" + "objects.js", getMinstrekPath() + "storyData/objects.js", True)
                IO.File.Copy(getJsonPath() + storyName + "\" + "events.js", getMinstrekPath() + "storyData/events.js", True)
                IO.File.Copy(getJsonPath() + storyName + "\" + "quests.js", getMinstrekPath() + "storyData/quests.js", True)
                IO.File.Copy(getJsonPath() + storyName + "\" + "pages.js", getMinstrekPath() + "storyData/pages.js", True)
                IO.File.Copy(getJsonPath() + storyName + "\" + "mainData.js", getMinstrekPath() + "storyData/mainData.js", True)
            Catch

            End Try

            WarningCancelButton.Visible = False
            WarningContinueButton.Visible = False
            WarningPanel.Visible = False
        End If
    End Sub

#End Region

#Region "GENERAL SETTINGS"

    Private Sub GameTitleText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GameTitleText.Leave
        GameTitleText.ForeColor = Color.Black
        If (GameTitleText.Text = "") Then
            GameTitleText.Text = "not valid"
            GameTitleText.ForeColor = Color.Red

        End If

    End Sub

    Private Sub BGText_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles BGText.Click
        Me.setColor(BGText)

    End Sub

    Private Sub TopAreaBGText_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TopAreaBGText.Click

        Me.setColor(TopAreaBGText)
    End Sub

    Private Sub BottomAreaBGText_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles BottomAreaBGText.Click

        Me.setColor(BottomAreaBGText)

    End Sub

    Private Sub TopAreaHeightText_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TopAreaHeightText.Leave

        TopAreaHeightText.ForeColor = Color.Black
        Try
            Dim height As Byte = Byte.Parse(TopAreaHeightText.Text)

            If (height <= 0 Or height >= 75) Then
                TopAreaHeightText.Text = "must be >0 and <75"
                TopAreaHeightText.ForeColor = Color.Red
            Else
                BottomAreaHeightText.Text = CStr(100 - height)

            End If
        Catch ex As Exception
            TopAreaHeightText.Text = "not valid"
            TopAreaHeightText.ForeColor = Color.Red
        End Try


    End Sub

    Private Sub BottomAreaHeightText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BottomAreaHeightText.Leave
        BottomAreaHeightText.ForeColor = Color.Black
        Try
            Dim height As Byte = Byte.Parse(BottomAreaHeightText.Text)

            If (height <= 0 Or height >= 75) Then
                BottomAreaHeightText.Text = "must be >0 and <75"
                BottomAreaHeightText.ForeColor = Color.Red
            Else
                TopAreaHeightText.Text = CStr(100 - height)

            End If
        Catch ex As Exception
            BottomAreaHeightText.Text = "not valid"
            BottomAreaHeightText.ForeColor = Color.Red
        End Try
    End Sub

    Private Sub TitleColorText_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TitleColorText.Click
        Me.setColor(TitleColorText)
    End Sub

    Private Sub TopHorizontalBorderText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TopHorizontalBorderIMGText.Click

        Me.setImage(TopHorizontalBorderIMGText, TopHorizontalBorderPic, "")

    End Sub

    Private Sub BottomHorizontalBorderText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BottomHorizontalBorderIMGText.Click
        Me.setImage(BottomHorizontalBorderIMGText, BottomHorizontalBorderPic, "")
    End Sub

    Private Sub MidHorizontalBorderText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MidHorizontalBorderIMGText.Click
        Me.setImage(MidHorizontalBorderIMGText, MidHorizontalBorderPic, "")
    End Sub

    Private Sub LeftVerticalBorderText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LeftVerticalBorderIMGText.Click

        Me.setImage(LeftVerticalBorderIMGText, LeftVerticalBorderPic, "")
    End Sub

    Private Sub RightVerticalBorderText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RightVerticalBorderText.Click

        Me.setImage(RightVerticalBorderText, RightVerticalBorderPic, "")
    End Sub

    Private Sub InventoryIconText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InventoryIconText.Click

        Me.setImage(InventoryIconText, InventoryIconPic, "")
    End Sub

    Private Sub QuestIconText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuestIconIMGText.Click

        Me.setImage(QuestIconIMGText, QuestIconPic, "")
    End Sub

    Private Sub EventsIconText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EventsIconIMGText.Click

        Me.setImage(EventsIconIMGText, EventsIconPic, "")
    End Sub

    Private Sub DefaultButtonImageText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DefaultButtonImageText.Click
        Me.setImage(DefaultButtonImageText, Nothing, "")
    End Sub

    Private Sub ObjectImagesWidthText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ObjectImagesWidthText.Leave
        Me.checkIfInt16(ObjectImagesWidthText)
    End Sub

    Private Sub ObjectImagesHeightText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ObjectImagesHeightText.Leave
        Me.checkIfInt16(ObjectImagesHeightText)
    End Sub

    Private Sub QuestImagesWidthText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuestImagesWidthText.Leave
        Me.checkIfInt16(QuestImagesWidthText)
    End Sub

    Private Sub QuestImagesHeightText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuestImagesHeightText.Leave
        Me.checkIfInt16(QuestImagesHeightText)
    End Sub

    Private Sub EventsImagesWidthText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EventsImagesWidthText.Leave
        Me.checkIfInt16(EventsImagesWidthText)
    End Sub

    Private Sub EventsImagesHeightText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EventsImagesHeightText.Leave
        Me.checkIfInt16(EventsImagesHeightText)
    End Sub

#End Region

#Region "SPLASH"

    Private Sub SplashTimeText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplashTimeText.Leave
        SplashTimeText.ForeColor = Color.Black
        Try
            Dim time As Int16 = Int16.Parse(SplashTimeText.Text)

            If (time < 1000 Or time > 99999) Then
                SplashTimeText.Text = "must be >=1000 and <9999"
                SplashTimeText.ForeColor = Color.Red
            End If
        Catch ex As Exception
            SplashTimeText.Text = "not valid"
            SplashTimeText.ForeColor = Color.Red
        End Try
    End Sub

    Private Sub SplashBGText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplashBGText.Click
        Me.setColor(SplashBGText)
    End Sub

    Private Sub SplashForegroundText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplashForegroundIMGText.Click

        Me.setImage(SplashForegroundIMGText, SplashForegroundPic, "")
    End Sub

    Private Sub SplashTextColorText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplashTextColorText.Click
        Me.setColor(SplashTextColorText)
    End Sub

#End Region

#Region "LOADING"

    Private Sub LoadingTimeText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadingTimeText.Leave
        LoadingTimeText.ForeColor = Color.Black
        Try
            Dim time As Int16 = Int16.Parse(LoadingTimeText.Text)

            If (time < 500 Or time > 5000) Then
                LoadingTimeText.Text = "must be >=500 and <5000"
                LoadingTimeText.ForeColor = Color.Red
            End If
        Catch ex As Exception
            LoadingTimeText.Text = "not valid"
            LoadingTimeText.ForeColor = Color.Red
        End Try
    End Sub

    Private Sub LoadingDelayText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadingDelayText.Leave
        LoadingDelayText.ForeColor = Color.Black
        Try
            Dim time As Int16 = Int16.Parse(LoadingDelayText.Text)

            If (time < 200 Or time > 1000) Then
                LoadingDelayText.Text = "must be >=200 and <1000"
                LoadingDelayText.ForeColor = Color.Red
            End If
        Catch ex As Exception
            LoadingDelayText.Text = "not valid"
            LoadingDelayText.ForeColor = Color.Red
        End Try
    End Sub

    Private Sub LoadingBGText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadingBGText.Click
        Me.setColor(LoadingBGText)
    End Sub

    Private Sub LoadingForegroundText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadingForegroundIMGText.Click

        Me.setImage(LoadingForegroundIMGText, LoadingForegroundPic, "")
    End Sub

    Private Sub LoadingTextColorText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadingTextColorText.Click
        Me.setColor(LoadingTextColorText)
    End Sub

#End Region

#Region "OBJECTS"

    Private Sub ObjectImageText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ObjectIMGText.Click

        Dim dr As DialogResult
        Dim path As String
        Dim img As Bitmap

        OpenFileDialog1.Filter = "ALL|*.jpeg;*.png;*.jpg;*.gif|JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"
        dr = OpenFileDialog1.ShowDialog()

        If (dr = DialogResult.OK) Then
            path = OpenFileDialog1.FileName
            ObjectIMGText.Text = OpenFileDialog1.SafeFileName
            My.Computer.FileSystem.CopyFile(path, getImagesPath() + OpenFileDialog1.SafeFileName, True)
            img = New Bitmap(OpenFileDialog1.FileName)
            Me.ObjectImageHeight = img.Height
            Me.ObjectImageWidth = img.Width
            ObjectImagePic.Image = img
        End If
    End Sub

    Private Sub CreateObjectButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateObjectButton.Click
        Dim id As String = ObjectIdText.Text.ToLower
        Dim name As String = ObjectNameText.Text.ToLower
        Dim img As String = ObjectIMGText.Text
        Dim desc As String = ObjectDescriptionText.Text
        Dim owned As String = CStr(ObjectOwnedTrue.Checked)
        owned = owned.ToLower()
        Dim rows = ObjectsGrid.Rows.Count



        If (Me.checkObjectFields(id, name, img)) Then

            ObjectsGrid.Rows.Add(New String() {id, name, desc, img, owned, Me.ObjectImageWidth, Me.ObjectImageHeight})
            ObjectIdText.ForeColor = Color.Black
            ObjectNameText.ForeColor = Color.Black
            ObjectIMGText.ForeColor = Color.Black
            ObjectIdText.Text = ""
            ObjectNameText.Text = ""
            ObjectIMGText.Text = ""
            ObjectDescriptionText.Text = ""
            updateObjectCheckedListBoxes()



        End If








    End Sub

    Private Function checkObjectFields(ByVal id As String, ByVal name As String, ByVal img As String) As Boolean
        Dim rows = ObjectsGrid.Rows.Count - 1

        Dim allowed As Boolean = True

        If (rows = -1) Then


            If (id = "not valid" Or id = "") Then
                ObjectIdText.ForeColor = Color.Red
                ObjectIdText.Text = "not valid"
                allowed = False
            End If
            If (name = "not valid" Or name = "") Then
                ObjectNameText.ForeColor = Color.Red
                ObjectNameText.Text = "not valid"
                allowed = False
            End If
            If (img = "" Or img = "click to select an image") Then
                ObjectIMGText.ForeColor = Color.Red
                ObjectIMGText.Text = "click to select an image"
                allowed = False
            End If

        Else

            While (rows >= 0)

                If (ObjectsGrid.Rows.Item(rows).Cells(0).Value = id Or id = "not valid" Or id = "") Then
                    ObjectIdText.ForeColor = Color.Red
                    ObjectIdText.Text = "not valid"
                    allowed = False
                End If

                If (ObjectsGrid.Rows.Item(rows).Cells(1).Value = name Or name = "not valid" Or name = "") Then
                    ObjectNameText.ForeColor = Color.Red
                    ObjectNameText.Text = "not valid"
                    allowed = False
                End If

                If (img = "" Or img = "click to select an image") Then
                    ObjectIMGText.ForeColor = Color.Red
                    ObjectIMGText.Text = "click to select an image"
                    allowed = False
                End If

                rows -= 1

            End While

        End If

        Return allowed

    End Function

    Private Sub DeleteRowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteRowToolStripMenuItem.Click
        If (Not ObjectsGrid.SelectedRows.Count = 0) Then
            Dim row = ObjectsGrid.SelectedRows.Item(0)
            If (Not IsNothing(row)) Then
                ObjectsGrid.Rows.Remove(ObjectsGrid.SelectedRows.Item(0))
                updateObjectCheckedListBoxes()
            End If
        End If
    End Sub

#End Region

#Region "EVENTS"

    Private Sub EventImageText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EventIMGText.Click
        Dim dr As DialogResult
        Dim path As String
        Dim img As Bitmap

        OpenFileDialog1.Filter = "ALL|*.jpeg;*.png;*.jpg;*.gif|JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"
        dr = OpenFileDialog1.ShowDialog()

        If (dr = DialogResult.OK) Then
            path = OpenFileDialog1.FileName
            EventIMGText.Text = OpenFileDialog1.SafeFileName
            My.Computer.FileSystem.CopyFile(path, getImagesPath() + OpenFileDialog1.SafeFileName, True)
            img = New Bitmap(OpenFileDialog1.FileName)
            Me.EventImageHeight = img.Height
            Me.EventImageWidth = img.Width
            EventImagePic.Image = img
        End If
    End Sub

    Private Sub CreateEventButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateEventButton.Click
        Dim id As String = EventIdText.Text.ToLower
        Dim name As String = EventNameText.Text.ToLower
        Dim img As String = EventIMGText.Text
        Dim desc As String = EventDescriptionText.Text
        Dim occured As String = CStr(EventOccuredTrue.Checked)
        occured = occured.ToLower()
        Dim rows = EventsGrid.Rows.Count



        If (Me.checkEventFields(id, name, img)) Then

            EventsGrid.Rows.Add(New String() {id, name, desc, img, occured, Me.EventImageWidth, Me.EventImageHeight})
            EventIdText.ForeColor = Color.Black
            EventNameText.ForeColor = Color.Black
            EventIMGText.ForeColor = Color.Black
            EventIdText.Text = ""
            EventNameText.Text = ""
            EventIMGText.Text = ""
            EventDescriptionText.Text = ""
            updateEventCheckedListBoxes()



        End If






    End Sub

    Private Function checkEventFields(ByVal id As String, ByVal name As String, ByVal img As String) As Boolean
        Dim rows = EventsGrid.Rows.Count - 1

        Dim allowed As Boolean = True

        If (rows = -1) Then


            If (id = "not valid" Or id = "") Then
                EventIdText.ForeColor = Color.Red
                EventIdText.Text = "not valid"
                allowed = False
            End If
            If (name = "not valid" Or name = "") Then
                EventNameText.ForeColor = Color.Red
                EventNameText.Text = "not valid"
                allowed = False
            End If
            If (img = "" Or img = "click to select an image") Then
                EventIMGText.ForeColor = Color.Red
                EventIMGText.Text = "click to select an image"
                allowed = False
            End If

        Else

            While (rows >= 0)

                If (EventsGrid.Rows.Item(rows).Cells(0).Value = id Or id = "not valid" Or id = "") Then
                    EventIdText.ForeColor = Color.Red
                    EventIdText.Text = "not valid"
                    allowed = False
                End If

                If (EventsGrid.Rows.Item(rows).Cells(1).Value = name Or name = "not valid" Or name = "") Then
                    EventNameText.ForeColor = Color.Red
                    EventNameText.Text = "not valid"
                    allowed = False
                End If

                If (img = "" Or img = "click to select an image") Then
                    EventIMGText.ForeColor = Color.Red
                    EventIMGText.Text = "click to select an image"
                    allowed = False
                End If

                rows -= 1

            End While

        End If

        Return allowed

    End Function

    Private Sub DeleteHighlightedRowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteHighlightedRowToolStripMenuItem.Click
        If (Not EventsGrid.SelectedRows.Count = 0) Then
            Dim row = EventsGrid.SelectedRows.Item(0)
            If (Not IsNothing(row)) Then
                EventsGrid.Rows.Remove(EventsGrid.SelectedRows.Item(0))
                updateEventCheckedListBoxes()
            End If
        End If
    End Sub

#End Region

#Region "QUESTS"

    Private Sub QuestImageText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuestIMGText.Click
        Dim dr As DialogResult
        Dim path As String
        Dim img As Bitmap

        OpenFileDialog1.Filter = "ALL|*.jpeg;*.png;*.jpg;*.gif|JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"
        dr = OpenFileDialog1.ShowDialog()

        If (dr = DialogResult.OK) Then
            path = OpenFileDialog1.FileName
            QuestIMGText.Text = OpenFileDialog1.SafeFileName
            My.Computer.FileSystem.CopyFile(path, getImagesPath() + OpenFileDialog1.SafeFileName, True)
            img = New Bitmap(OpenFileDialog1.FileName)
            Me.QuestImageHeight = img.Height
            Me.QuestImageWidth = img.Width
            QuestImagePic.Image = img
        End If
    End Sub

    Private Sub CreateQuestButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateQuestButton.Click
        Dim id As String = QuestIdText.Text.ToLower
        Dim name As String = QuestNameText.Text.ToLower
        Dim img As String = QuestIMGText.Text
        Dim desc As String = QuestDescriptionText.Text
        Dim state As String
        Dim rows = QuestsGrid.Rows.Count

        If (QuestStateNone.Checked) Then
            state = "none"
        ElseIf (QuestStateStarted.Checked) Then
            state = "had"
        Else
            state = "done"
        End If



        If (Me.checkQuestFields(id, name, img)) Then

            QuestsGrid.Rows.Add(New String() {id, name, desc, img, state, Me.QuestImageWidth, Me.QuestImageHeight})
            QuestIdText.ForeColor = Color.Black
            QuestNameText.ForeColor = Color.Black
            QuestIMGText.ForeColor = Color.Black
            QuestIdText.Text = ""
            QuestNameText.Text = ""
            QuestIMGText.Text = ""
            QuestDescriptionText.Text = ""
            updateQuestsCheckedListBoxes()




        End If






    End Sub

    Private Function checkQuestFields(ByVal id As String, ByVal name As String, ByVal img As String) As Boolean
        Dim rows = QuestsGrid.Rows.Count - 1

        Dim allowed As Boolean = True

        If (rows = -1) Then


            If (id = "not valid" Or id = "") Then
                QuestIdText.ForeColor = Color.Red
                QuestIdText.Text = "not valid"
                allowed = False
            End If
            If (name = "not valid" Or name = "") Then
                QuestNameText.ForeColor = Color.Red
                QuestNameText.Text = "not valid"
                allowed = False
            End If
            If (img = "" Or img = "click to select an image") Then
                QuestIMGText.ForeColor = Color.Red
                QuestIMGText.Text = "click to select an image"
                allowed = False
            End If

        Else

            While (rows >= 0)

                If (QuestsGrid.Rows.Item(rows).Cells(0).Value = id Or id = "not valid" Or id = "") Then
                    QuestIdText.ForeColor = Color.Red
                    QuestIdText.Text = "not valid"
                    allowed = False
                End If

                If (QuestsGrid.Rows.Item(rows).Cells(1).Value = name Or name = "not valid" Or name = "") Then
                    QuestNameText.ForeColor = Color.Red
                    QuestNameText.Text = "not valid"
                    allowed = False
                End If

                If (img = "" Or img = "click to select an image") Then
                    QuestIMGText.ForeColor = Color.Red
                    QuestIMGText.Text = "click to select an image"
                    allowed = False
                End If

                rows -= 1

            End While

        End If

        Return allowed

    End Function

    Private Sub DeleteHighlightedRowToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteHighlightedRowToolStripMenuItem1.Click
        If (Not QuestsGrid.SelectedRows.Count = 0) Then
            Dim row = QuestsGrid.SelectedRows.Item(0)
            If (Not IsNothing(row)) Then
                QuestsGrid.Rows.Remove(QuestsGrid.SelectedRows.Item(0))
                updateQuestsCheckedListBoxes()
            End If
        End If
    End Sub

#End Region

#Region "PAGES"

    Private Sub PageBGText_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PageBGText.Click
        Me.setColor(PageBGText)



    End Sub

    Private Sub PageTopAreaBGText_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PageTopAreaBGText.Click
        Me.setColor(PageTopAreaBGText)


    End Sub

    Private Sub PageBottomAreaBGText_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PageBottomAreaBGText.Click
        Me.setColor(PageBottomAreaBGText)

    End Sub

    Private Sub PageTitleColorText_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PageTitleColorText.Click
        Me.setColor(PageTitleColorText)

    End Sub

    Private Sub PageTopHorizontalBorderText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.setImage(PageTopHorizontalBorderIMGText, PageTopHorizontalBorderPic, "")
    End Sub

    Private Sub PageBottomHorizontalBorderText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Me.setImage(PageBottomHorizontalBorderIMGText, PageBottomHorizontalBorderPic, "")
    End Sub

    Private Sub PageBottomAreaImgText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.setImage(PageBottomAreaImgText, Nothing, "")
    End Sub

    Private Sub PageMidHorizontalBorderText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Me.setImage(PageMidHorizontalBorderIMGText, PageMidHorizontalBorderPic, "")
    End Sub

    Private Sub PageLeftVerticalBorderText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Me.setImage(PageLeftVerticalBorderIMGText, PageLeftVerticalBorderPic, "")
    End Sub

    Private Sub PageRightVerticalBorderText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Me.setImage(PageRightVerticalBorderIMGText, PageRightVerticalBorderPic, "")
    End Sub

    Private Sub PageInventoryIconText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Me.setImage(PageInventoryIconIMGText, PageInventoryIconPic, "")
    End Sub

    Private Sub PageQuestIconText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Me.setImage(PageQuestIconIMGText, PageQuestIconPic, "")
    End Sub

    Private Sub PageEventsIconText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Me.setImage(PageEventsIconIMGText, PageEventsIconPic, "")
    End Sub

    Private Sub PageTitleText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs)
        PageTitleText.ForeColor = Color.Black
        If (PageTitleText.Text = "") Then
            PageTitleText.Text = "not valid"
            PageTitleText.ForeColor = Color.Red

        End If
    End Sub

    Private Sub PageDescriptionText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs)
        PageDescriptionText.ForeColor = Color.Black
        If (PageDescriptionText.Text = "") Then
            PageDescriptionText.Text = "not valid"
            PageDescriptionText.ForeColor = Color.Red

        End If
    End Sub

    Private Sub PageIDText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim valid As Boolean = True
        Dim text As String = PageIDText.Text
        PageIDText.ForeColor = Color.Black

        For Each row As DataGridViewRow In PagesGrid.Rows
            If (row.Cells.Item(0).Value = text) Then
                valid = False
            End If
        Next

        If (Not valid Or text = "") Then
            PageIDText.ForeColor = Color.Red
            PageIDText.Text = "not valid"
        End If
    End Sub

    Private Sub ShowButtonPanelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowButtonPanelButton.Click
        GameEditorTabs.SelectTab(ButtonsTabPage)
    End Sub

    Private Sub CreatePageButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreatePageButton.Click


    End Sub

    Private Sub DeleteHighlightedRowToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteHighlightedRowToolStripMenuItem2.Click
        If (Not PagesGrid.SelectedRows.Count = 0) Then
            Dim row = PagesGrid.SelectedRows.Item(0)
            If (Not IsNothing(row)) Then
                PagesGrid.Rows.Remove(row)
            End If
        End If
    End Sub

#End Region

#Region "BUTTONS"

    Private Sub PreconditionObjectsOText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreconditionObjectsOText.MouseDown
        If (Me.firstTime) Then
            PreconditionObjectsOText.Text = ""
            PreconditionObjectsOText.ForeColor = Color.Black
            PreconditionObjectsOText.Font = New System.Drawing.Font("Microsoft Sans Serif", 10, FontStyle.Regular)
            Me.firstTime = False
        End If
    End Sub

    Private Sub PreconditionObjectsOText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreconditionObjectsOText.Leave


        If (Not checkConditionIDS(PreconditionObjectsOText, ObjectsGrid)) Then
            PreconditionObjectsOText.Text = " object not created"
            PreconditionObjectsOText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PreconditionObjectsNOText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreconditionObjectsNOText.Leave
        If (Not checkConditionIDS(PreconditionObjectsNOText, ObjectsGrid)) Then
            PreconditionObjectsNOText.Text = " object not created"
            PreconditionObjectsNOText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PreconditionEventsOText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreconditionEventsOText.Leave
        If (Not checkConditionIDS(PreconditionEventsOText, EventsGrid)) Then
            PreconditionEventsOText.Text = " event not created"
            PreconditionEventsOText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PreconditionEventsNOText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreconditionEventsNOText.Leave
        If (Not checkConditionIDS(PreconditionEventsNOText, EventsGrid)) Then
            PreconditionEventsNOText.Text = " event not created"
            PreconditionEventsNOText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PreconditionQuestsNText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreconditionQuestsNText.Leave
        If (Not checkConditionIDS(PreconditionQuestsNText, QuestsGrid)) Then
            PreconditionQuestsNText.Text = " quest not created"
            PreconditionQuestsNText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PreconditionQuestsSText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreconditionQuestsSText.Leave
        If (Not checkConditionIDS(PreconditionQuestsSText, QuestsGrid)) Then
            PreconditionQuestsSText.Text = " quest not created"
            PreconditionQuestsSText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PreconditionQuestsDText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreconditionQuestsDText.Leave
        If (Not checkConditionIDS(PreconditionQuestsDText, QuestsGrid)) Then
            PreconditionQuestsDText.Text = " quest not created"
            PreconditionQuestsDText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PostconditionObjectsOText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PostconditionObjectsOText.Leave
        If (Not checkConditionIDS(PostconditionObjectsOText, ObjectsGrid)) Then
            PostconditionObjectsOText.Text = " object not created"
            PostconditionObjectsOText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PostconditionObjectsNOText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PostconditionObjectsNOText.Leave
        If (Not checkConditionIDS(PostconditionObjectsNOText, ObjectsGrid)) Then
            PostconditionObjectsNOText.Text = " object not created"
            PostconditionObjectsNOText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PostconditionEventsOText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PostconditionEventsOText.Leave
        If (Not checkConditionIDS(PostconditionEventsOText, EventsGrid)) Then
            PostconditionEventsOText.Text = " event not created"
            PostconditionEventsOText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PostconditionEventsNOText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PostconditionEventsNOText.Leave
        If (Not checkConditionIDS(PostconditionEventsNOText, EventsGrid)) Then
            PostconditionEventsNOText.Text = " event not created"
            PostconditionEventsNOText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PostconditionQuestsNText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PostconditionQuestsNText.Leave
        If (Not checkConditionIDS(PostconditionQuestsNText, QuestsGrid)) Then
            PostconditionQuestsNText.Text = " quest not created"
            PostconditionQuestsNText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PostconditionQuestsSText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PostconditionQuestsSText.Leave
        If (Not checkConditionIDS(PostconditionQuestsSText, QuestsGrid)) Then
            PostconditionQuestsSText.Text = " quest not created"
            PostconditionQuestsSText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PostconditionQuestsDText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PostconditionQuestsDText.Leave
        If (Not checkConditionIDS(PostconditionQuestsDText, QuestsGrid)) Then
            PostconditionQuestsDText.Text = " quest not created"
            PostconditionQuestsDText.ForeColor = Color.Red
        End If
    End Sub

    Private Sub PageButtonIDText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageButtonIDText.Leave

    End Sub

#End Region

    'Private Sub PageButtonTextText_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs)
    'Dim text As String = PageButtonTextText.Text
    'PageButtonTextText.ForeColor = Color.Black
    'If (text = "") Then
    'PageButtonTextText.ForeColor = Color.Red
    'PageButtonTextText.Text = "not valid"
    'End If
    'End Sub

    Private Sub PageButtonIMGText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageButtonIMGText.Click
        Me.setImage(PageButtonIMGText, PageButtonIMGPic, "")
    End Sub

    Private Sub CreateButtonButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateButtonButton.Click


    End Sub

    Private Sub DeleteHighlightedRowToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteHighlightedRowToolStripMenuItem3.Click
        If (Not PageButtonGrid.SelectedRows.Count = 0) Then
            Dim row = PageButtonGrid.SelectedRows.Item(0)
            If (Not IsNothing(row)) Then
                PageButtonGrid.Rows.Remove(row)
            End If
        End If
    End Sub

    Private Sub filterButtonButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles filterButtonButton.Click
        Dim pageId As String = PageButtonIDText.Text

        If (pageId = "") Then
            For Each row As DataGridViewRow In PageButtonGrid.Rows
                row.Visible = True

            Next
        Else
            For Each row As DataGridViewRow In PageButtonGrid.Rows
                If (Not row.Cells.Item(0).Value = pageId) Then
                    row.Visible = False
                End If
            Next
        End If

    End Sub

#Region "ALERT"

    Private Sub AlertBGColorText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlertBGColorText.Click
        Me.setColor(AlertBGColorText)
    End Sub

    Private Sub AlertTopBGIMGText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlertTopBGIMGText.Click
        Me.setImage(AlertTopBGIMGText, AlertTopBGIMGPic, "")
    End Sub

    Private Sub AlertLeftBGIMGText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlertLeftBGIMGText.Click
        Me.setImage(AlertLeftBGIMGText, AlertLeftBGIMGPic, "")
    End Sub

    Private Sub AlertRightBGIMGText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlertRightBGIMGText.Click
        Me.setImage(AlertRightBGIMGText, AlertRightBGIMGPic, "")
    End Sub

    Private Sub AlertBGIMGText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlertBGIMGText.Click
        Me.setImage(AlertBGIMGText, AlertBGIMGPic, "")
    End Sub

    Private Sub AlertBottomBGIMGText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlertBottomBGIMGText.Click
        Me.setImage(AlertBottomBGIMGText, AlertBottomBGIMGPic, "")
    End Sub

#End Region

#Region "PAGE & BUTTON"

#Region "BUTTON(1)"

    Private Sub B1PreconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionObjectsOText.MouseEnter
        B1PreconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B1PreconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B1PreconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionObjectsOText.MouseLeave
        B1PreconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PreconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionObjectsNOText.MouseEnter
        B1PreconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        B1PreconditionObjectsNOText.BringToFront()
    End Sub

    Private Sub B1PreconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionObjectsNOText.MouseLeave
        B1PreconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PostconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionObjectsOText.MouseEnter
        B1PostconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B1PostconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B1PostconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionObjectsOText.MouseLeave
        B1PostconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PostconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionObjectsNOText.MouseEnter
        B1PostconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonObjectsGB.BringToFront()

        B1PostconditionObjectsNOText.BringToFront()

    End Sub

    Private Sub B1PostconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionObjectsNOText.MouseLeave
        B1PostconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PreconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionEventsOText.MouseEnter
        B1PreconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B1PreconditionEventsOText.BringToFront()

    End Sub

    Private Sub B1PreconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionEventsOText.MouseLeave
        B1PreconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PreconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionEventsNOText.MouseEnter
        B1PreconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        B1PreconditionEventsNOText.BringToFront()

    End Sub

    Private Sub B1PreconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionEventsNOText.MouseLeave
        B1PreconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PostconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionEventsOText.MouseEnter
        B1PostconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B1PostconditionEventsOText.BringToFront()

    End Sub

    Private Sub B1PostconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionEventsOText.MouseLeave
        B1PostconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PostconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionEventsNOText.MouseEnter
        B1PostconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonEventsGB.BringToFront()
        B1PostconditionEventsNOText.BringToFront()


    End Sub

    Private Sub B1PostconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionEventsNOText.MouseLeave
        B1PostconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PreconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionQuestsNText.MouseEnter
        B1PreconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B1PreconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B1PreconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionQuestsNText.MouseLeave
        B1PreconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PreconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionQuestsSText.MouseEnter
        B1PreconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B1PreconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B1PreconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionQuestsSText.MouseLeave
        B1PreconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PreconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionQuestsDText.MouseEnter
        B1PreconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B1PreconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B1PreconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PreconditionQuestsDText.MouseLeave
        B1PreconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PostconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionQuestsNText.MouseEnter
        B1PostconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B1PostconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B1PostconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionQuestsNText.MouseLeave
        B1PostconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PostconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionQuestsSText.MouseEnter
        B1PostconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B1PostconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B1PostconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionQuestsSText.MouseLeave
        B1PostconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B1PostconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionQuestsDText.MouseEnter
        B1PostconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B1PostconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B1PostconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1PostconditionQuestsDText.MouseLeave
        B1PostconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

#End Region

#Region "BUTTON(2)"

    Private Sub B2PreconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionObjectsOText.MouseEnter
        B2PreconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B2PreconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B2PreconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionObjectsOText.MouseLeave
        B2PreconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PreconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionObjectsNOText.MouseEnter
        B2PreconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        B2PreconditionObjectsNOText.BringToFront()
    End Sub

    Private Sub B2PreconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionObjectsNOText.MouseLeave
        B2PreconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PostconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionObjectsOText.MouseEnter
        B2PostconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B2PostconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B2PostconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionObjectsOText.MouseLeave
        B2PostconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PostconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionObjectsNOText.MouseEnter
        B2PostconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonObjectsGB.BringToFront()

        B2PostconditionObjectsNOText.BringToFront()

    End Sub

    Private Sub B2PostconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionObjectsNOText.MouseLeave
        B2PostconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PreconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionEventsOText.MouseEnter
        B2PreconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B2PreconditionEventsOText.BringToFront()

    End Sub

    Private Sub B2PreconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionEventsOText.MouseLeave
        B2PreconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PreconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionEventsNOText.MouseEnter
        B2PreconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        B2PreconditionEventsNOText.BringToFront()

    End Sub

    Private Sub B2PreconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionEventsNOText.MouseLeave
        B2PreconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PostconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionEventsOText.MouseEnter
        B2PostconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B2PostconditionEventsOText.BringToFront()

    End Sub

    Private Sub B2PostconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionEventsOText.MouseLeave
        B2PostconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PostconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionEventsNOText.MouseEnter
        B2PostconditionEventsNOText.Size = New System.Drawing.Size(150, 21)
        ButtonEventsGB.BringToFront()
        B2PostconditionEventsNOText.BringToFront()


    End Sub

    Private Sub B2PostconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionEventsNOText.MouseLeave
        B2PostconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PreconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionQuestsNText.MouseEnter
        B2PreconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B2PreconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B2PreconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionQuestsNText.MouseLeave
        B2PreconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PreconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionQuestsSText.MouseEnter
        B2PreconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B2PreconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B2PreconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionQuestsSText.MouseLeave
        B2PreconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PreconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionQuestsDText.MouseEnter
        B2PreconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B2PreconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B2PreconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PreconditionQuestsDText.MouseLeave
        B2PreconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PostconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionQuestsNText.MouseEnter
        B2PostconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B2PostconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B2PostconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionQuestsNText.MouseLeave
        B2PostconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PostconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionQuestsSText.MouseEnter
        B2PostconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B2PostconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B2PostconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionQuestsSText.MouseLeave
        B2PostconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B2PostconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionQuestsDText.MouseEnter
        B2PostconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B2PostconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B2PostconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2PostconditionQuestsDText.MouseLeave
        B2PostconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

#End Region

#Region "BUTTON(3)"

    Private Sub B3PreconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionObjectsOText.MouseEnter
        B3PreconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B3PreconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B3PreconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionObjectsOText.MouseLeave
        B3PreconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PreconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionObjectsNOText.MouseEnter
        B3PreconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        B3PreconditionObjectsNOText.BringToFront()
    End Sub

    Private Sub B3PreconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionObjectsNOText.MouseLeave
        B3PreconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PostconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionObjectsOText.MouseEnter
        B3PostconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B3PostconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B3PostconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionObjectsOText.MouseLeave
        B3PostconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PostconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionObjectsNOText.MouseEnter
        B3PostconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonObjectsGB.BringToFront()

        B3PostconditionObjectsNOText.BringToFront()

    End Sub

    Private Sub B3PostconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionObjectsNOText.MouseLeave
        B3PostconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PreconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionEventsOText.MouseEnter
        B3PreconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B3PreconditionEventsOText.BringToFront()

    End Sub

    Private Sub B3PreconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionEventsOText.MouseLeave
        B3PreconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PreconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionEventsNOText.MouseEnter
        B3PreconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        B3PreconditionEventsNOText.BringToFront()

    End Sub

    Private Sub B3PreconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionEventsNOText.MouseLeave
        B3PreconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PostconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionEventsOText.MouseEnter
        B3PostconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B3PostconditionEventsOText.BringToFront()

    End Sub

    Private Sub B3PostconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionEventsOText.MouseLeave
        B3PostconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PostconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionEventsNOText.MouseEnter
        B3PostconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonEventsGB.BringToFront()
        B3PostconditionEventsNOText.BringToFront()


    End Sub

    Private Sub B3PostconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionEventsNOText.MouseLeave
        B3PostconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PreconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionQuestsNText.MouseEnter
        B3PreconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B3PreconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B3PreconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionQuestsNText.MouseLeave
        B3PreconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PreconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionQuestsSText.MouseEnter
        B3PreconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B3PreconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B3PreconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionQuestsSText.MouseLeave
        B3PreconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PreconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionQuestsDText.MouseEnter
        B3PreconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B3PreconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B3PreconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PreconditionQuestsDText.MouseLeave
        B3PreconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PostconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionQuestsNText.MouseEnter
        B3PostconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B3PostconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B3PostconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionQuestsNText.MouseLeave
        B3PostconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PostconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionQuestsSText.MouseEnter
        B3PostconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B3PostconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B3PostconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionQuestsSText.MouseLeave
        B3PostconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B3PostconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionQuestsDText.MouseEnter
        B3PostconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B3PostconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B3PostconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3PostconditionQuestsDText.MouseLeave
        B3PostconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

#End Region

#Region "BUTTONS(4)"

    Private Sub B4PreconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionObjectsOText.MouseEnter
        B4PreconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B4PreconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B4PreconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionObjectsOText.MouseLeave
        B4PreconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PreconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionObjectsNOText.MouseEnter
        B4PreconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        B4PreconditionObjectsNOText.BringToFront()
    End Sub

    Private Sub B4PreconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionObjectsNOText.MouseLeave
        B4PreconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PostconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionObjectsOText.MouseEnter
        B4PostconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B4PostconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B4PostconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionObjectsOText.MouseLeave
        B4PostconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PostconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionObjectsNOText.MouseEnter
        B4PostconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonObjectsGB.BringToFront()

        B4PostconditionObjectsNOText.BringToFront()

    End Sub

    Private Sub B4PostconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionObjectsNOText.MouseLeave
        B4PostconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PreconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionEventsOText.MouseEnter
        B4PreconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B4PreconditionEventsOText.BringToFront()

    End Sub

    Private Sub B4PreconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionEventsOText.MouseLeave
        B4PreconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PreconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionEventsNOText.MouseEnter
        B4PreconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        B4PreconditionEventsNOText.BringToFront()

    End Sub

    Private Sub B4PreconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionEventsNOText.MouseLeave
        B4PreconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PostconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionEventsOText.MouseEnter
        B4PostconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B4PostconditionEventsOText.BringToFront()

    End Sub

    Private Sub B4PostconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionEventsOText.MouseLeave
        B4PostconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PostconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionEventsNOText.MouseEnter
        B4PostconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonEventsGB.BringToFront()
        B4PostconditionEventsNOText.BringToFront()


    End Sub

    Private Sub B4PostconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionEventsNOText.MouseLeave
        B4PostconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PreconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionQuestsNText.MouseEnter
        B4PreconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B4PreconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B4PreconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionQuestsNText.MouseLeave
        B4PreconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PreconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionQuestsSText.MouseEnter
        B4PreconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B4PreconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B4PreconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionQuestsSText.MouseLeave
        B4PreconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PreconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionQuestsDText.MouseEnter
        B4PreconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B4PreconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B4PreconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PreconditionQuestsDText.MouseLeave
        B4PreconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PostconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionQuestsNText.MouseEnter
        B4PostconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B4PostconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B4PostconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionQuestsNText.MouseLeave
        B4PostconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PostconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionQuestsSText.MouseEnter
        B4PostconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B4PostconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B4PostconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionQuestsSText.MouseLeave
        B4PostconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B4PostconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionQuestsDText.MouseEnter
        B4PostconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B4PostconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B4PostconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4PostconditionQuestsDText.MouseLeave
        B4PostconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

#End Region

#Region "BUTTONS(5)"

    Private Sub B5PreconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionObjectsOText.MouseEnter
        B5PreconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B5PreconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B5PreconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionObjectsOText.MouseLeave
        B5PreconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PreconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionObjectsNOText.MouseEnter
        B5PreconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        B5PreconditionObjectsNOText.BringToFront()
    End Sub

    Private Sub B5PreconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionObjectsNOText.MouseLeave
        B5PreconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PostconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionObjectsOText.MouseEnter
        B5PostconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B5PostconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B5PostconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionObjectsOText.MouseLeave
        B5PostconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PostconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionObjectsNOText.MouseEnter
        B5PostconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonObjectsGB.BringToFront()

        B5PostconditionObjectsNOText.BringToFront()

    End Sub

    Private Sub B5PostconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionObjectsNOText.MouseLeave
        B5PostconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PreconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionEventsOText.MouseEnter
        B5PreconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B5PreconditionEventsOText.BringToFront()

    End Sub

    Private Sub B5PreconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionEventsOText.MouseLeave
        B5PreconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PreconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionEventsNOText.MouseEnter
        B5PreconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        B5PreconditionEventsNOText.BringToFront()

    End Sub

    Private Sub B5PreconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionEventsNOText.MouseLeave
        B5PreconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PostconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionEventsOText.MouseEnter
        B5PostconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B5PostconditionEventsOText.BringToFront()

    End Sub

    Private Sub B5PostconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionEventsOText.MouseLeave
        B5PostconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PostconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionEventsNOText.MouseEnter
        B5PostconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonEventsGB.BringToFront()
        B5PostconditionEventsNOText.BringToFront()


    End Sub

    Private Sub B5PostconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionEventsNOText.MouseLeave
        B5PostconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PreconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionQuestsNText.MouseEnter
        B5PreconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B5PreconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B5PreconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionQuestsNText.MouseLeave
        B5PreconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PreconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionQuestsSText.MouseEnter
        B5PreconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B5PreconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B5PreconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionQuestsSText.MouseLeave
        B5PreconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PreconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionQuestsDText.MouseEnter
        B5PreconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B5PreconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B5PreconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PreconditionQuestsDText.MouseLeave
        B5PreconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PostconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionQuestsNText.MouseEnter
        B5PostconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B5PostconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B5PostconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionQuestsNText.MouseLeave
        B5PostconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PostconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionQuestsSText.MouseEnter
        B5PostconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B5PostconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B5PostconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionQuestsSText.MouseLeave
        B5PostconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B5PostconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionQuestsDText.MouseEnter
        B5PostconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B5PostconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B5PostconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5PostconditionQuestsDText.MouseLeave
        B5PostconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

#End Region

#Region "BUTTONS(6)"

    Private Sub B6PreconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionObjectsOText.MouseEnter
        B6PreconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B6PreconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B6PreconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionObjectsOText.MouseLeave
        B6PreconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PreconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionObjectsNOText.MouseEnter
        B6PreconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        B6PreconditionObjectsNOText.BringToFront()
    End Sub

    Private Sub B6PreconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionObjectsNOText.MouseLeave
        B6PreconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PostconditionObjectsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionObjectsOText.MouseEnter
        B6PostconditionObjectsOText.Size = New System.Drawing.Size(150, 38)
        B6PostconditionObjectsOText.BringToFront()
    End Sub

    Private Sub B6PostconditionObjectsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionObjectsOText.MouseLeave
        B6PostconditionObjectsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PostconditionObjectsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionObjectsNOText.MouseEnter
        B6PostconditionObjectsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonObjectsGB.BringToFront()

        B6PostconditionObjectsNOText.BringToFront()

    End Sub

    Private Sub B6PostconditionObjectsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionObjectsNOText.MouseLeave
        B6PostconditionObjectsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PreconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionEventsOText.MouseEnter
        B6PreconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B6PreconditionEventsOText.BringToFront()

    End Sub

    Private Sub B6PreconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionEventsOText.MouseLeave
        B6PreconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PreconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionEventsNOText.MouseEnter
        B6PreconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        B6PreconditionEventsNOText.BringToFront()

    End Sub

    Private Sub B6PreconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionEventsNOText.MouseLeave
        B6PreconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PostconditionEventsOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionEventsOText.MouseEnter
        B6PostconditionEventsOText.Size = New System.Drawing.Size(150, 38)
        B6PostconditionEventsOText.BringToFront()

    End Sub

    Private Sub B6PostconditionEventsOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionEventsOText.MouseLeave
        B6PostconditionEventsOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PostconditionEventsNOText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionEventsNOText.MouseEnter
        B6PostconditionEventsNOText.Size = New System.Drawing.Size(150, 38)
        ButtonEventsGB.BringToFront()
        B6PostconditionEventsNOText.BringToFront()


    End Sub

    Private Sub B6PostconditionEventsNOText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionEventsNOText.MouseLeave
        B6PostconditionEventsNOText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PreconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionQuestsNText.MouseEnter
        B6PreconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B6PreconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B6PreconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionQuestsNText.MouseLeave
        B6PreconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PreconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionQuestsSText.MouseEnter
        B6PreconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B6PreconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B6PreconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionQuestsSText.MouseLeave
        B6PreconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PreconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionQuestsDText.MouseEnter
        B6PreconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B6PreconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B6PreconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PreconditionQuestsDText.MouseLeave
        B6PreconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PostconditionQuestsNText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionQuestsNText.MouseEnter
        B6PostconditionQuestsNText.Size = New System.Drawing.Size(150, 38)
        B6PostconditionQuestsNText.BringToFront()
    End Sub

    Private Sub B6PostconditionQuestsNText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionQuestsNText.MouseLeave
        B6PostconditionQuestsNText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PostconditionQuestsSText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionQuestsSText.MouseEnter
        B6PostconditionQuestsSText.Size = New System.Drawing.Size(150, 38)
        B6PostconditionQuestsSText.BringToFront()
    End Sub

    Private Sub B6PostconditionQuestsSText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionQuestsSText.MouseLeave
        B6PostconditionQuestsSText.Size = New System.Drawing.Size(72, 21)
    End Sub

    Private Sub B6PostconditionQuestsDText_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionQuestsDText.MouseEnter
        B6PostconditionQuestsDText.Size = New System.Drawing.Size(150, 38)
        B6PostconditionQuestsDText.BringToFront()
    End Sub

    Private Sub B6PostconditionQuestsDText_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6PostconditionQuestsDText.MouseLeave
        B6PostconditionQuestsDText.Size = New System.Drawing.Size(72, 21)
    End Sub

#End Region

    Private Sub PageTopAreaImg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageTopAreaImg.Click
        setImage(PageTopAreaImgText, PageTopAreaImg, "")
    End Sub

    'aggiorna una CheckedListBox secondo la datagridview passata come parametro
    Private Sub updateCheckedListBox(ByVal checkedListBox As CheckedListBox, ByVal data As DataGridView)
        Dim value As String
        checkedListBox.Items.Clear()
        For Each dgv As DataGridViewRow In data.Rows
            value = dgv.Cells.Item(0).Value.ToString() + "(" + dgv.Cells.Item(1).Value.ToString() + ")"
            checkedListBox.Items.Add(value)
        Next

    End Sub

    'aggiorna le checkedlistbox di objects,events e quests
    Private Sub updateObjectCheckedListBoxes()
        For Each control As Control In ButtonObjectsGB.Controls
            If (control.GetType.Name = "CheckedListBox") Then
                updateCheckedListBox(control, ObjectsGrid)
            End If
        Next
    End Sub

    Private Sub updateEventCheckedListBoxes()
        For Each control As Control In ButtonEventsGB.Controls
            If (control.GetType.Name = "CheckedListBox") Then
                updateCheckedListBox(control, EventsGrid)
            End If
        Next
    End Sub

    Private Sub updateQuestsCheckedListBoxes()

        For Each control As Control In ButtonQuestsGB.Controls
            If (control.GetType.Name = "CheckedListBox") Then
                updateCheckedListBox(control, QuestsGrid)
            End If
        Next
    End Sub

    Private Sub updateOEQCheckedListBoxes()

        updateObjectCheckedListBoxes()
        updateEventCheckedListBoxes()
        updateQuestsCheckedListBoxes()



    End Sub

    'aggiorna una ComboBox secondo la datagridview passata come parametro
    Private Sub updateComboBox(ByVal comboBox As ComboBox, ByVal data As DataGridView)
        Dim value As String
        comboBox.Items.Clear()
        For Each dgv As DataGridViewRow In data.Rows
            value = dgv.Cells.Item(0).Value.ToString()
            comboBox.Items.Add(value)
        Next

    End Sub

    Private Sub updatePageCheckBoxes()
        updateComboBox(ViewPageCB, PagesGrid)
        updateComboBox(B1PageButtonDestinationIDText, PagesGrid)
        updateComboBox(B2PageButtonDestinationIDText, PagesGrid)
        updateComboBox(B3PageButtonDestinationIDText, PagesGrid)
        updateComboBox(B4PageButtonDestinationIDText, PagesGrid)
        updateComboBox(B5PageButtonDestinationIDText, PagesGrid)
        updateComboBox(B6PageButtonDestinationIDText, PagesGrid)
    End Sub

    'nasconde i controlli relativi al bottone con numero passato come parametro
    Private Sub hideButton(ByVal buttonNumber As Byte)

        For Each ctr As Control In PageButtonTabPage.Controls
            If Not ctr.Name.IndexOf("B" + CStr(buttonNumber)) = -1 Then
                ctr.Visible = False
            End If
            If ctr.GetType.Name = "GroupBox" Then
                For Each ctr1 As Control In ctr.Controls
                    If Not ctr1.Name.IndexOf("B" + CStr(buttonNumber)) = -1 Then
                        ctr1.Visible = False
                    End If
                Next
            End If
        Next

    End Sub

    'rende visibile i controlli relativi al bottone con numero passato come parametro
    Private Sub showButton(ByVal buttonNumber As Byte)


        For Each ctr As Control In PageButtonTabPage.Controls
            If Not ctr.Name.IndexOf("B" + CStr(buttonNumber)) = -1 Then
                ctr.Visible = True
            End If
            If ctr.GetType.Name = "GroupBox" Then
                For Each ctr1 As Control In ctr.Controls
                    If Not ctr1.Name.IndexOf("B" + CStr(buttonNumber)) = -1 Then
                        ctr1.Visible = True
                    End If
                Next
            End If
        Next



    End Sub

    Private Sub AddButtonButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButtonButton.Click
        Dim button As Byte = 0

        For Each i As Byte In Me.buttonsShown.Keys
            If Not Me.buttonsShown.Item(i) Then

                button = i
                Exit For
            End If
        Next

        If button = 0 Then
            showWarning("max 6 button per page")
        Else
            showButton(button)
            Me.buttonsShown.Item(button) = True
        End If

    End Sub

    Private Sub B2DeleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2DeleteButton.Click
        hideButton(2)
        Me.buttonsShown.Item(2) = False
    End Sub

    Private Sub B3DeleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3DeleteButton.Click
        hideButton(3)
        Me.buttonsShown.Item(3) = False
    End Sub

    Private Sub B4DeleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B4DeleteButton.Click
        hideButton(4)
        Me.buttonsShown.Item(4) = False
    End Sub

    Private Sub B5DeleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5DeleteButton.Click
        hideButton(5)
        Me.buttonsShown.Item(5) = False
    End Sub

    Private Sub B6DeleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B6DeleteButton.Click
        hideButton(6)
        Me.buttonsShown.Item(6) = False
    End Sub

    Private Sub PageIdDoneButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageIdDoneButton.Click
        Dim row As String() = New String(19) {}


        If PageIDText.Text = "" Then
            PageIDText.Text = "not valid id"
        ElseIf checkId(PageIDText.Text, PagesGrid) Then
            PageIDText.Text = "id already used"
        Else
            For i As Int16 = 1 To 18
                row(i) = "undefined"
            Next
            row(0) = PageIDText.Text
            PagesGrid.Rows.Add(row)
            updatePageCheckBoxes()
            ViewPageCB.SelectedItem = PageIDText.Text
            PageTitleText.Text = PageIDText.Text
            PageIDText.Text = ""
            PageIdPopupPanel.Hide()

        End If
    End Sub

    Private Sub NewPageButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewPageButton.Click
        PageIdPopupPanel.Show()
    End Sub

    Private Sub PageIdCancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageIdCancelButton.Click
        PageIdPopupPanel.Hide()
        PageIDText.Text = ""
    End Sub

    Private Sub RemovePageButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemovePageButton.Click
        Dim toRemove As String = ""
        Try
            toRemove = ViewPageCB.SelectedItem.ToString()
        Catch
        End Try
        Dim index As Int16 = -1

        For Each row As DataGridViewRow In PagesGrid.Rows
            If row.Cells.Item(0).Value = toRemove Then
                index = row.Index
            End If
        Next

        If (Not index = -1) Then
            PagesGrid.Rows.RemoveAt(index)
            updatePageCheckBoxes()
            Try
                ViewPageCB.SelectedIndex = ViewPageCB.SelectionStart
            Catch
                ViewPageCB.Text = ""
            End Try
        End If



    End Sub

    'Salva la pagina corrente e i relativi bottoni
    Private Sub SavePageButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SavePageButton.Click
        Dim currentPage As String = ViewPageCB.SelectedItem.ToString
        Dim index As Integer = -1

        If (checkTextInTB(PageDescriptionText) And Not (currentPage = "")) Then


            For Each row As DataGridViewRow In PagesGrid.Rows
                If (row.Cells.Item(0).Value = currentPage) Then
                    index = row.Index
                    Exit For
                End If
            Next


            PagesGrid.Rows.Item(index).Cells.Item("PageDescriptionTextCell").Value = PageDescriptionText.Text
            PagesGrid.Rows.Item(index).Cells.Item("PageTopAreaImgTextCell").Value = PageTopAreaImgText.Text




            For Each ctr As Control In PageMoreOptionPanel.Controls
                If (ctr.GetType.Name = "GroupBox") Then
                    For Each ctr1 As Control In ctr.Controls
                        If (ctr1.GetType().Name = "TextBox") Then
                            If (ctr1.Text = "") Then
                                PagesGrid.Rows.Item(index).Cells.Item(ctr1.Name + "Cell").Value = "undefined"
                            Else
                                PagesGrid.Rows.Item(index).Cells.Item(ctr1.Name + "Cell").Value = ctr1.Text
                            End If

                        End If
                    Next

                End If
                If (ctr.GetType().Name = "TextBox") Then
                    If (ctr.Text = "") Then
                        PagesGrid.Rows.Item(index).Cells.Item(ctr.Name + "Cell").Value = "undefined"
                    Else
                        PagesGrid.Rows.Item(index).Cells.Item(ctr.Name + "Cell").Value = ctr.Text
                    End If


                End If
            Next
            addButtons()

        Else
            showWarning("Page description must not be empty")
        End If
    End Sub

    'salva un bottone
    Private Sub addButton(ByVal buttonNumber As Integer)
        Dim id As String = ""
        Dim dId As String = ""
        Dim goOn As Boolean = True
        Try
            id = ViewPageCB.SelectedItem.ToString
        Catch
            showWarning("Select a page")
            goOn = False
        End Try

        Try
            dId = CType(PageButtonTabPage.Controls.Item("B" + CStr(buttonNumber) + "PageButtonDestinationIDText"), ComboBox).SelectedItem.ToString
        Catch
            showWarning("Select a destination page for button " + CStr(buttonNumber))
            goOn = False
        End Try

        If goOn Then

            Dim index = PageButtonGrid.Rows.Add()
            Dim value As String = ""



            For Each ctr As Control In PageButtonTabPage.Controls

                If ctr.GetType.Name = "GroupBox" Then
                    For Each ctr1 As Control In ctr.Controls
                        If (Not ctr1.Name.IndexOf("B" + CStr(buttonNumber)) = -1) And (ctr1.GetType.Name = "CheckedListBox") Then
                            value = ""
                            For Each checked As CheckedListBox.CheckedItemCollection In CType(ctr1, CheckedListBox).CheckedItems
                                value += checked.ToString + ","
                            Next
                            If Not value = "" Then
                                value = value.Remove(value.Length - 1)

                            Else
                                value = "undefined"
                            End If
                            PageButtonGrid.Rows.Item(index).Cells.Item(ctr1.Name.Substring(2) + "Cell").Value = value

                        End If
                    Next
                End If
            Next

            PageButtonGrid.Rows.Item(index).Cells.Item(0).Value = id
            PageButtonGrid.Rows.Item(index).Cells.Item(1).Value = dId
            PageButtonGrid.Rows.Item(index).Cells.Item(2).Value = PageButtonTabPage.Controls.Item("B" + CStr(buttonNumber) + "PageButtonTextText").Text
        End If




    End Sub

    'salva tutti i bottoni della pagina corrente
    Private Sub addButtons()
        Dim id As String = ""
        Dim goOn As Boolean = True
        Dim indexs As ArrayList = New ArrayList


        Try
            id = ViewPageCB.SelectedItem.ToString

        Catch ex As Exception
            showWarning("select a page")
            goOn = False
        End Try

        If goOn Then


            For Each row As DataGridViewRow In PageButtonGrid.Rows
                If (row.Cells(0).Value = id) Then
                    indexs.Add(row.Index)
                End If
            Next

            For Each index As Integer In indexs
                PageButtonGrid.Rows.RemoveAt(index)
            Next

            For Each key As Integer In buttonsShown.Keys
                If buttonsShown(key) Then

                    addButton(key)

                End If
            Next


        End If

    End Sub

    'mostra i dati di una pagina
    Private Sub fillPage(ByVal pageId As String)
        Dim cells As DataGridViewCellCollection = Nothing

        For Each row As DataGridViewRow In PagesGrid.Rows
            If row.Cells.Item(0).Value = pageId Then
                cells = row.Cells
            End If
        Next
        If (Not IsNothing(cells)) Then
            PageDescriptionText.Text = cells.Item("PageDescriptionTextCell").Value
            PageTopAreaImgText.Text = cells.Item("PageTopAreaImgTextCell").Value
            If PageTopAreaImgText.Text = "undefined" Then
                PageTopAreaImg.Image = Nothing
            Else
                PageTopAreaImg.Image = New Bitmap(getImagesPath() + cells.Item("PageTopAreaImgTextCell").Value.ToString)
            End If

            For Each ctr As Control In PageMoreOptionPanel.Controls
                If ctr.GetType.Name = "TextBox" Then
                    ctr.Text = cells.Item(ctr.Name + "Cell").Value
                ElseIf ctr.GetType.Name = "GroupBox" Then
                    For Each ctr1 As Control In ctr.Controls
                        If ctr1.GetType.Name = "TextBox" Then
                            ctr1.Text = cells.Item(ctr1.Name + "Cell").Value
                        End If
                    Next
                End If

            Next
        End If

    End Sub

    'mostra i dati di un bottone
    Private Sub fillButton(ByVal buttonNumber As Integer, ByVal dataCells As DataGridViewCellCollection)
        Dim map As String()
        Dim index As Integer = -1

        For Each ctr As Control In PageButtonTabPage.Controls
            If Not ctr.Name.IndexOf("B" + CStr(buttonNumber)) = -1 Then
                If ctr.GetType.Name = "TextBox" Then
                    ctr.Text = dataCells.Item(ctr.Name.Substring(2) + "Cell").Value
                ElseIf ctr.GetType.Name = "ComboBox" Then
                    CType(ctr, ComboBox).SelectedItem = dataCells.Item(ctr.Name.Substring(2) + "Cell").Value.ToString
                End If
            End If
            If ctr.GetType.Name = "GroupBox" Then
                For Each ctr1 As Control In ctr.Controls
                    If Not ctr1.Name.IndexOf("B" + CStr(buttonNumber)) = -1 Then
                        If ctr1.GetType.Name = "CheckedListBox" Then
                            map = dataCells.Item(ctr1.Name.Substring(2) + "Cell").Value.ToString.Split(",")
                            For Each val As String In map

                                index = CType(ctr1, CheckedListBox).Items.IndexOf(val)
                                If (Not index = -1) Then
                                    CType(ctr1, CheckedListBox).SetItemChecked(index, True)
                                End If
                            Next
                        End If
                    End If
                Next
            End If
        Next
    End Sub

    'mostra i bottoni di una pagina
    Private Sub fillButtons(ByVal pageId As String)
        Dim cellsArray As ArrayList = New ArrayList()
        Dim buttonNumber As Byte = 2

        For Each row As DataGridViewRow In PageButtonGrid.Rows
            If row.Cells.Item(0).Value.ToString = pageId Then
                cellsArray.Add(row.Cells)
            End If
        Next

        For i As Byte = 2 To 6
            hideButton(i)
        Next

        For Each cells As DataGridViewCellCollection In cellsArray


        Next



    End Sub

    Private Sub ViewPageCB_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewPageCB.SelectedIndexChanged
        Dim pageId As String = ViewPageCB.SelectedItem.ToString
        cleanControl(PageButtonTabPage)
        cleanControl(PageMoreOptionPanel)
        fillPage(pageId)
        fillButtons(pageId)
    End Sub

#End Region

#Region "MORE OPTIONS PANEL"

    Private Sub PageMoreOptionCloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageMoreOptionCloseButton.Click
        PageMoreOptionPanel.Hide()
    End Sub

    Private Sub PageMoreOptionDoneButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageMoreOptionDoneButton.Click
        PageMoreOptionPanel.Hide()
    End Sub

    Private Sub MoreOptionsButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoreOptionsButton.Click
        PageMoreOptionPanel.Show()
    End Sub

#End Region

End Class




Commits for Nextrek/minstrek/GameEditorBKP - Copia/GameEditor/Form1.vb

Diff revisions: vs.
Revision Author Commited Message
59 Diff Diff DTocci picture DTocci Fri 20 Dec, 2013 09:37:55 +0000
56 Diff Diff DTocci picture DTocci Thu 12 Dec, 2013 13:42:02 +0000
55 Diff Diff DTocci picture DTocci Thu 12 Dec, 2013 11:38:11 +0000
51 JMBauan picture JMBauan Sat 07 Dec, 2013 13:40:04 +0000