-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathForm1.cs
1546 lines (1332 loc) · 71.6 KB
/
Form1.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;
using System.IO;
using IniParser;
using IniParser.Model;
using System.Diagnostics;
using System.Runtime.Serialization.Formatters.Binary;
using System.Configuration;
using System.Collections.Specialized;
using BrightIdeasSoftware;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Guid InstanceID;
public TFCard[] ImportDB;
public int ImportedCardsCount;
public int CurrentlySelectedCard;
int DisplayedCardsCount = 0;
bool bCurrentlySearching = false;
string ClipboardURL;
string CurrentFilename;
string CurrentCacheDir;
string CurrentCacheIni;
char CurrentLang = 'E';
bool bJapaneseLangDetected = false;
Font DefaultWestStyle = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point);
Font DescWestStyle = new Font("Segoe UI Historic", 8.25F, FontStyle.Regular, GraphicsUnit.Point);
Font JapaneseStyle = new Font("MS UI Gothic", 10F, FontStyle.Regular, GraphicsUnit.Point);
FindBox findBoxDialog;
FilterBox filterBoxDialog;
SaveQuestionBox saveQuestionDialog;
CardSearch cardSearch;
CardSearchParams replaceParams;
bool bUnsavedChangesMade = false;
// stolen from: https://stackoverflow.com/a/3301750
// written by Dan Tao
T[] InitializeArray<T>(int length) where T : new()
{
T[] array = new T[length];
for (int i = 0; i < length; ++i)
{
array[i] = new T();
}
return array;
}
int GetLangIndex()
{
switch (CurrentLang)
{
case 'J':
return 0;
case 'G':
return 2;
case 'F':
return 3;
case 'I':
return 4;
case 'S':
return 5;
case 'E':
default:
return 1;
}
}
char SetLangIndex(int index)
{
switch (index)
{
case 0:
return 'J';
case 2:
return 'G';
case 3:
return 'F';
case 4:
return 'I';
case 5:
return 'S';
case 1:
default:
return 'E';
}
}
int SearchCardIndexByID(int CardID)
{
for (int i = 0; i < ImportedCardsCount; i++)
{
if (ImportDB[i].CardID == CardID)
return i;
}
return 0;
}
void ResetAppState()
{
linkLabel1.Enabled = false;
linkLabel2.Enabled = false;
textBox1.Enabled = false;
propertyGrid1.Enabled = false;
label1.Visible = false;
label2.Visible = false;
label3.Visible = false;
label4.Visible = false;
label5.Visible = false;
label6.Visible = false;
toolStripStatusLabel1.Text = "";
toolStripStatusLabel2.Text = "";
toolStripProgressBar1.Value = 0;
propertyGrid1.SelectedObject = null;
textBox1.Text = null;
bJapaneseLangDetected = false;
hiraganaCheckBox.Enabled = false;
hiraganaCheckBox.Checked = false;
saveToolStripMenuItem.Enabled = false;
saveAsToolStripMenuItem.Enabled = false;
comboBox1.Enabled = false;
comboBox1.SelectedIndex = -1;
bUnsavedChangesMade = false;
}
public void UpdateTexts()
{
linkLabel1.Enabled = true;
linkLabel2.Enabled = true;
textBox1.Enabled = true;
propertyGrid1.Enabled = true;
label1.Visible = true;
label2.Visible = true;
label3.Visible = true;
label4.Visible = true;
label5.Visible = true;
label6.Visible = true;
bJapaneseLangDetected = false;
// detect Japanese...
if (textBox1.Text.Contains("$R"))
{
bJapaneseLangDetected = true;
hiraganaCheckBox.Enabled = true;
/*if (!hiraganaCheckBox.Checked)
{
// string[] HiraganaText = textBox1.Text.Split("$R");
}*/
}
// Text box - style and text
textBox1.Text = ImportDB[CurrentlySelectedCard].Description.Replace("\n", "\r\n");
if (ImportDB[CurrentlySelectedCard].Kind == CardKinds.Normal && (CurrentLang != 'J'))
textBox1.Font = new Font(DescWestStyle, FontStyle.Italic);
else if (CurrentLang == 'J')
textBox1.Font = JapaneseStyle;
else
textBox1.Font = new Font(DefaultWestStyle, FontStyle.Regular);
// description box display stuff...
// name
if (CurrentLang == 'J')
label1.Font = JapaneseStyle;
else
label1.Font = DefaultWestStyle;
label1.Text = ImportDB[CurrentlySelectedCard].Name;
// ATK and DEF
if ((ImportDB[CurrentlySelectedCard].Kind == CardKinds.Spell) || (ImportDB[CurrentlySelectedCard].Kind == CardKinds.Trap))
label2.Text = "";
else
{
label2.Text = "ATK/ ";
if (ImportDB[CurrentlySelectedCard].ATK == 5110)
label2.Text += "?";
else
label2.Text += ImportDB[CurrentlySelectedCard].ATK;
label2.Text += " DEF/ ";
if (ImportDB[CurrentlySelectedCard].DEF == 5110)
label2.Text += "?";
else
label2.Text += ImportDB[CurrentlySelectedCard].DEF;
}
// Attribute
if (ImportDB[CurrentlySelectedCard].Attr == CardAttributes.None)
label3.Text = "?";
else
label3.Text = TypeDescriptor.GetConverter(typeof(CardAttributes)).ConvertToString(ImportDB[CurrentlySelectedCard].Attr);
// Level / S/T text
if ((ImportDB[CurrentlySelectedCard].Kind == CardKinds.Spell) || (ImportDB[CurrentlySelectedCard].Kind == CardKinds.Trap))
{
label4.Font = new Font(label4.Font, FontStyle.Bold);
label4.Text = "[";
if (ImportDB[CurrentlySelectedCard].Kind == CardKinds.Spell)
label4.Text += "SPELL CARD";
else
label4.Text += "TRAP CARD";
if (ImportDB[CurrentlySelectedCard].Icon != CardIcons.None)
label4.Text += " (" + TypeDescriptor.GetConverter(typeof(CardIcons)).ConvertToString(ImportDB[CurrentlySelectedCard].Icon) + ")";
label4.Text += "]";
}
else
{
label4.Font = new Font(label4.Font, FontStyle.Regular);
label4.Text = "Level: ";
if (ImportDB[CurrentlySelectedCard].Level == 0)
label4.Text += "?";
else
label4.Text += ImportDB[CurrentlySelectedCard].Level;
}
// Monster type
if (!((ImportDB[CurrentlySelectedCard].Kind == CardKinds.Spell) || (ImportDB[CurrentlySelectedCard].Kind == CardKinds.Trap)))
{
label5.Text = "[";
if (ImportDB[CurrentlySelectedCard].Type == CardTypes.None)
label5.Text += "?";
else
label5.Text += TypeDescriptor.GetConverter(typeof(CardTypes)).ConvertToString(ImportDB[CurrentlySelectedCard].Type);
label5.Text += "/" + TypeDescriptor.GetConverter(typeof(CardKinds)).ConvertToString(ImportDB[CurrentlySelectedCard].Kind);
label5.Text += "]";
}
else
label5.Text = "";
// Password
if (ImportDB[CurrentlySelectedCard].Kind == CardKinds.Token)
label6.Text = "This card cannot be in a Deck.";
else
label6.Text = string.Format("{0:00000000}", ImportDB[CurrentlySelectedCard].Password);
// update ListView as well...
//listView1.SelectedItems[0].SubItems[(int)CardProps.Name].Text = ImportDB[CurrentlySelectedCard].Name;
//listView1.SelectedItems[0].SubItems[(int)CardProps.Kind].Text = TypeDescriptor.GetConverter(typeof(CardKinds)).ConvertToString(ImportDB[CurrentlySelectedCard].Kind);
//listView1.SelectedItems[0].SubItems[(int)CardProps.Level].Text = ImportDB[CurrentlySelectedCard].Level.ToString();
//listView1.SelectedItems[0].SubItems[(int)CardProps.ATK].Text = ImportDB[CurrentlySelectedCard].ATK.ToString();
//listView1.SelectedItems[0].SubItems[(int)CardProps.DEF].Text = ImportDB[CurrentlySelectedCard].DEF.ToString();
//listView1.SelectedItems[0].SubItems[(int)CardProps.Type].Text = TypeDescriptor.GetConverter(typeof(CardTypes)).ConvertToString(ImportDB[CurrentlySelectedCard].Type);
//listView1.SelectedItems[0].SubItems[(int)CardProps.Attr].Text = TypeDescriptor.GetConverter(typeof(CardAttributes)).ConvertToString(ImportDB[CurrentlySelectedCard].Attr);
//listView1.SelectedItems[0].SubItems[(int)CardProps.Icon].Text = TypeDescriptor.GetConverter(typeof(CardIcons)).ConvertToString(ImportDB[CurrentlySelectedCard].Icon);
//listView1.SelectedItems[0].SubItems[(int)CardProps.Rarity].Text = TypeDescriptor.GetConverter(typeof(CardRarity)).ConvertToString(ImportDB[CurrentlySelectedCard].Rarity);
//listView1.SelectedItems[0].SubItems[(int)CardProps.Password].Text = ImportDB[CurrentlySelectedCard].Password.ToString();
//listView1.SelectedItems[0].SubItems[(int)CardProps.CardExists].Text = ImportDB[CurrentlySelectedCard].CardExistFlag.ToString();
//listView1.SelectedItems[0].SubItems[(int)CardProps.Description].Text = ImportDB[CurrentlySelectedCard].Description;
}
void UpdateListView(bool[] UpdateFlags, bool bUpdateAll)
{
int ci;
if (UpdateFlags == null)
UpdateFlags = new bool[listView1.Items.Count];
for (int i = 0; i < listView1.Items.Count; i++)
{
if (UpdateFlags[i] || bUpdateAll)
{
ci = SearchCardIndexByID(Int32.Parse(listView1.Items[i].SubItems[0].Text));
listView1.Items[i].SubItems[(int)CardProps.Name].Text = ImportDB[ci].Name;
listView1.Items[i].SubItems[(int)CardProps.Kind].Text = TypeDescriptor.GetConverter(typeof(CardKinds)).ConvertToString(ImportDB[ci].Kind);
listView1.Items[i].SubItems[(int)CardProps.Level].Text = ImportDB[ci].Level.ToString();
listView1.Items[i].SubItems[(int)CardProps.ATK].Text = ImportDB[ci].ATK.ToString();
listView1.Items[i].SubItems[(int)CardProps.DEF].Text = ImportDB[ci].DEF.ToString();
listView1.Items[i].SubItems[(int)CardProps.Type].Text = TypeDescriptor.GetConverter(typeof(CardTypes)).ConvertToString(ImportDB[ci].Type);
listView1.Items[i].SubItems[(int)CardProps.Attr].Text = TypeDescriptor.GetConverter(typeof(CardAttributes)).ConvertToString(ImportDB[ci].Attr);
listView1.Items[i].SubItems[(int)CardProps.Icon].Text = TypeDescriptor.GetConverter(typeof(CardIcons)).ConvertToString(ImportDB[ci].Icon);
listView1.Items[i].SubItems[(int)CardProps.Rarity].Text = TypeDescriptor.GetConverter(typeof(CardRarity)).ConvertToString(ImportDB[ci].Rarity);
listView1.Items[i].SubItems[(int)CardProps.Password].Text = ImportDB[ci].Password.ToString();
listView1.Items[i].SubItems[(int)CardProps.CardExists].Text = ImportDB[ci].CardExistFlag.ToString();
listView1.Items[i].SubItems[(int)CardProps.Description].Text = ImportDB[ci].Description;
}
}
}
void AddListViewItem(int listview_index, int carddb_index)
{
listView1.Items.Add(ImportDB[carddb_index].CardID.ToString());
listView1.Items[listview_index].SubItems.Add(ImportDB[carddb_index].Name);
listView1.Items[listview_index].SubItems.Add(TypeDescriptor.GetConverter(typeof(CardKinds)).ConvertToString(ImportDB[carddb_index].Kind));
listView1.Items[listview_index].SubItems.Add(ImportDB[carddb_index].Level.ToString());
listView1.Items[listview_index].SubItems.Add(ImportDB[carddb_index].ATK.ToString());
listView1.Items[listview_index].SubItems.Add(ImportDB[carddb_index].DEF.ToString());
listView1.Items[listview_index].SubItems.Add(TypeDescriptor.GetConverter(typeof(CardTypes)).ConvertToString(ImportDB[carddb_index].Type));
listView1.Items[listview_index].SubItems.Add(TypeDescriptor.GetConverter(typeof(CardAttributes)).ConvertToString(ImportDB[carddb_index].Attr));
listView1.Items[listview_index].SubItems.Add(TypeDescriptor.GetConverter(typeof(CardIcons)).ConvertToString(ImportDB[carddb_index].Icon));
listView1.Items[listview_index].SubItems.Add(TypeDescriptor.GetConverter(typeof(CardRarity)).ConvertToString(ImportDB[carddb_index].Rarity));
listView1.Items[listview_index].SubItems.Add(ImportDB[carddb_index].Password.ToString());
listView1.Items[listview_index].SubItems.Add(ImportDB[carddb_index].CardExistFlag.ToString());
listView1.Items[listview_index].SubItems.Add(ImportDB[carddb_index].Description);
}
void GenerateListView()
{
listView1.SetObjects(ImportDB);
DisplayedCardsCount = listView1.Items.Count;
}
bool FilterCheckName(CardFilterParams filterParams, TFCard card)
{
if (filterParams.MatchCase)
{
if (filterParams.MatchExact)
{
if (card.Name.Equals(filterParams.Name))
return true;
}
else if (card.Name.Contains(filterParams.Name))
return true;
}
if (filterParams.MatchExact)
{
if (card.Name.ToUpper().Equals(filterParams.Name.ToUpper()))
return true;
}
else if (card.Name.ToUpper().Contains(filterParams.Name.ToUpper()))
return true;
return false;
}
bool FilterCheckKinds(CardFilterParams filterParams, TFCard card)
{
if ((card.Kind == CardKinds.Normal) && filterParams.Kind[(int)CardKinds.Normal])
return true;
if (((card.Kind == CardKinds.Effect) || (card.Kind == CardKinds.Toon) || (card.Kind == CardKinds.Spirit) || (card.Kind == CardKinds.Union)) && filterParams.Kind[(int)CardKinds.Effect])
return true;
if (((card.Kind == CardKinds.Fusion) || (card.Kind == CardKinds.FusionEffect)) && filterParams.Kind[(int)CardKinds.Fusion])
return true;
if (((card.Kind == CardKinds.Ritual) || (card.Kind == CardKinds.RitualEffect)) && filterParams.Kind[(int)CardKinds.Ritual])
return true;
if ((card.Kind == CardKinds.Token) && filterParams.Kind[(int)CardKinds.Token])
return true;
if ((card.Kind == CardKinds.Toon) && filterParams.Kind[(int)CardKinds.Toon])
return true;
if ((card.Kind == CardKinds.Spirit) && filterParams.Kind[(int)CardKinds.Spirit])
return true;
if ((card.Kind == CardKinds.Union) && filterParams.Kind[(int)CardKinds.Union])
return true;
if ((card.Kind == CardKinds.Spell) && filterParams.Kind[(int)CardKinds.Spell])
return true;
if ((card.Kind == CardKinds.Trap) && filterParams.Kind[(int)CardKinds.Trap])
return true;
return false;
}
bool FilterCheckTypes(CardFilterParams filterParams, TFCard card)
{
if ((card.Type == CardTypes.Dragon) && filterParams.Type[(int)CardTypes.Dragon])
return true;
if ((card.Type == CardTypes.Zombie) && filterParams.Type[(int)CardTypes.Zombie])
return true;
if ((card.Type == CardTypes.Fiend) && filterParams.Type[(int)CardTypes.Fiend])
return true;
if ((card.Type == CardTypes.Pyro) && filterParams.Type[(int)CardTypes.Pyro])
return true;
if ((card.Type == CardTypes.SeaSerpent) && filterParams.Type[(int)CardTypes.SeaSerpent])
return true;
if ((card.Type == CardTypes.Rock) && filterParams.Type[(int)CardTypes.Rock])
return true;
if ((card.Type == CardTypes.Machine) && filterParams.Type[(int)CardTypes.Machine])
return true;
if ((card.Type == CardTypes.Fish) && filterParams.Type[(int)CardTypes.Fish])
return true;
if ((card.Type == CardTypes.Dinosaur) && filterParams.Type[(int)CardTypes.Dinosaur])
return true;
if ((card.Type == CardTypes.Insect) && filterParams.Type[(int)CardTypes.Insect])
return true;
if ((card.Type == CardTypes.Beast) && filterParams.Type[(int)CardTypes.Beast])
return true;
if ((card.Type == CardTypes.BeastWarrior) && filterParams.Type[(int)CardTypes.BeastWarrior])
return true;
if ((card.Type == CardTypes.Plant) && filterParams.Type[(int)CardTypes.Plant])
return true;
if ((card.Type == CardTypes.Aqua) && filterParams.Type[(int)CardTypes.Aqua])
return true;
if ((card.Type == CardTypes.Warrior) && filterParams.Type[(int)CardTypes.Warrior])
return true;
if ((card.Type == CardTypes.WingedBeast) && filterParams.Type[(int)CardTypes.WingedBeast])
return true;
if ((card.Type == CardTypes.Fairy) && filterParams.Type[(int)CardTypes.Fairy])
return true;
if ((card.Type == CardTypes.Spellcaster) && filterParams.Type[(int)CardTypes.Spellcaster])
return true;
if ((card.Type == CardTypes.Thunder) && filterParams.Type[(int)CardTypes.Thunder])
return true;
if ((card.Type == CardTypes.Reptile) && filterParams.Type[(int)CardTypes.Reptile])
return true;
if ((card.Type == CardTypes.DivineBeast) && filterParams.Type[(int)CardTypes.DivineBeast])
return true;
if ((card.Type == CardTypes.Spell) && filterParams.Type[(int)CardTypes.Spell])
return true;
if ((card.Type == CardTypes.Trap) && filterParams.Type[(int)CardTypes.Trap])
return true;
if ((card.Type == CardTypes.None) && filterParams.Type[(int)CardTypes.None])
return true;
return false;
}
bool FilterCheckAttr(CardFilterParams filterParams, TFCard card)
{
if ((card.Attr == CardAttributes.LIGHT) && filterParams.Attr[(int)CardAttributes.LIGHT])
return true;
if ((card.Attr == CardAttributes.DARK) && filterParams.Attr[(int)CardAttributes.DARK])
return true;
if ((card.Attr == CardAttributes.WATER) && filterParams.Attr[(int)CardAttributes.WATER])
return true;
if ((card.Attr == CardAttributes.FIRE) && filterParams.Attr[(int)CardAttributes.FIRE])
return true;
if ((card.Attr == CardAttributes.EARTH) && filterParams.Attr[(int)CardAttributes.EARTH])
return true;
if ((card.Attr == CardAttributes.WIND) && filterParams.Attr[(int)CardAttributes.WIND])
return true;
if ((card.Attr == CardAttributes.DIVINE) && filterParams.Attr[(int)CardAttributes.DIVINE])
return true;
if ((card.Attr == CardAttributes.SPELL) && filterParams.Attr[(int)CardAttributes.SPELL])
return true;
if ((card.Attr == CardAttributes.TRAP) && filterParams.Attr[(int)CardAttributes.TRAP])
return true;
if ((card.Attr == CardAttributes.None) && filterParams.Attr[(int)CardAttributes.None])
return true;
return false;
}
bool FilterCheckIcon(CardFilterParams filterParams, TFCard card)
{
if ((card.Icon == CardIcons.Counter) && filterParams.Icon[(int)CardIcons.Counter])
return true;
if ((card.Icon == CardIcons.Field) && filterParams.Icon[(int)CardIcons.Field])
return true;
if ((card.Icon == CardIcons.Equip) && filterParams.Icon[(int)CardIcons.Equip])
return true;
if ((card.Icon == CardIcons.Continuous) && filterParams.Icon[(int)CardIcons.Continuous])
return true;
if ((card.Icon == CardIcons.QuickPlay) && filterParams.Icon[(int)CardIcons.QuickPlay])
return true;
if ((card.Icon == CardIcons.RitualSpell) && filterParams.Icon[(int)CardIcons.RitualSpell])
return true;
if ((card.Icon == CardIcons.None) && filterParams.Icon[(int)CardIcons.None])
return true;
return false;
}
bool FilterCheckRarity(CardFilterParams filterParams, TFCard card)
{
if ((card.Rarity == CardRarity.Common) && filterParams.Rarity[(int)CardRarity.Common])
return true;
if ((card.Rarity == CardRarity.Rare) && filterParams.Rarity[(int)CardRarity.Rare])
return true;
if ((card.Rarity == CardRarity.SuperRare) && filterParams.Rarity[(int)CardRarity.SuperRare])
return true;
if ((card.Rarity == CardRarity.UltraRare) && filterParams.Rarity[(int)CardRarity.UltraRare])
return true;
if ((card.Rarity == CardRarity.UltimateRare) && filterParams.Rarity[(int)CardRarity.UltimateRare])
return true;
return false;
}
void FilterListView(CardFilterParams filterParams)
{
ModelFilter defaultFilter = new ModelFilter(delegate (object x) { return true; });
ModelFilter filterCardIDmin = defaultFilter;
ModelFilter filterCardIDmax = defaultFilter;
ModelFilter filterName = defaultFilter;
ModelFilter filterKind = defaultFilter;
ModelFilter filterLevelmin = defaultFilter;
ModelFilter filterLevelmax = defaultFilter;
ModelFilter filterATKmin = defaultFilter;
ModelFilter filterATKmax = defaultFilter;
ModelFilter filterDEFmin = defaultFilter;
ModelFilter filterDEFmax = defaultFilter;
ModelFilter filterAttr = defaultFilter;
ModelFilter filterIcon = defaultFilter;
ModelFilter filterRarity = defaultFilter;
ModelFilter filterPassMin = defaultFilter;
ModelFilter filterPassMax = defaultFilter;
ModelFilter filterCardExist = filterName = new ModelFilter(delegate (object x) { return ((TFCard)x).CardExistFlag == filterParams.CardExists; }); ;
ModelFilter filterType = defaultFilter;
if (!string.IsNullOrEmpty(filterParams.Name))
filterName = new ModelFilter(delegate (object x) { return FilterCheckName(filterParams, (TFCard)x); });
if (filterParams.bAreAnyFiltersEnabled_Kind())
filterKind = new ModelFilter(delegate (object x) { return FilterCheckKinds(filterParams, (TFCard)x); });
if (filterParams.bAreAnyFiltersEnabled_Type())
filterType = new ModelFilter(delegate (object x) { return FilterCheckTypes(filterParams, (TFCard)x); });
if (filterParams.bAreAnyFiltersEnabled_Attr())
filterAttr = new ModelFilter(delegate (object x) { return FilterCheckAttr(filterParams, (TFCard)x); });
if (filterParams.bAreAnyFiltersEnabled_Icon())
filterIcon = new ModelFilter(delegate (object x) { return FilterCheckIcon(filterParams, (TFCard)x); });
if (filterParams.bAreAnyFiltersEnabled_Rarity())
filterRarity = new ModelFilter(delegate (object x) { return FilterCheckRarity(filterParams, (TFCard)x); });
if (filterParams.MaxATK >= 0)
filterATKmax = new ModelFilter(delegate (object x) { return ((TFCard)x).ATK <= filterParams.MaxATK; });
if (filterParams.MinATK >= 0)
filterATKmin = new ModelFilter(delegate (object x) { return ((TFCard)x).ATK >= filterParams.MinATK; });
if (filterParams.MaxDEF >= 0)
filterDEFmax = new ModelFilter(delegate (object x) { return ((TFCard)x).DEF <= filterParams.MaxDEF; });
if (filterParams.MinDEF >= 0)
filterDEFmin = new ModelFilter(delegate (object x) { return ((TFCard)x).DEF >= filterParams.MinDEF; });
if (filterParams.MaxLevel >= 0)
filterLevelmax = new ModelFilter(delegate (object x) { return ((TFCard)x).Level <= filterParams.MaxLevel; });
if (filterParams.MinLevel >= 0)
filterLevelmin = new ModelFilter(delegate (object x) { return ((TFCard)x).Level >= filterParams.MinLevel; });
if (filterParams.MaxPassword >= 0)
filterPassMax = new ModelFilter(delegate (object x) { return ((TFCard)x).Password <= filterParams.MaxPassword; });
if (filterParams.MinPassword >= 0)
filterPassMin = new ModelFilter(delegate (object x) { return ((TFCard)x).Password >= filterParams.MinPassword; });
if (filterParams.MaxCardID >= 0)
filterCardIDmax = new ModelFilter(delegate (object x) { return ((TFCard)x).CardID <= filterParams.MaxCardID; });
if (filterParams.MinCardID >= 0)
filterCardIDmin = new ModelFilter(delegate (object x) { return ((TFCard)x).CardID >= filterParams.MinCardID; });
var filterTotal = new CompositeAllFilter(new List<IModelFilter> { filterCardIDmin, filterCardIDmax, filterName, filterKind, filterLevelmin, filterLevelmax, filterATKmin, filterATKmax, filterDEFmin, filterDEFmax, filterAttr, filterIcon, filterRarity, filterPassMin, filterPassMax, filterCardExist, filterType });
listView1.ModelFilter = filterTotal;
DisplayedCardsCount = listView1.Items.Count;
}
public bool InitiateCardSearch(CardSearchParams searchParams)
{
string dispstr;
bCurrentlySearching = true;
if (cardSearch.Search(searchParams, listView1, false, false))
{
dispstr = searchParams.ResultString;
listView1.Items[searchParams.SearchResultIndex].Selected = true;
listView1.Items[searchParams.SearchResultIndex].Focused = true;
listView1.EnsureVisible(searchParams.SearchResultIndex);
if (searchParams.SearchContext == CardProps.Description)
{
textBox1.Focus();
textBox1.Select(searchParams.SearchResultSubStrIndex, searchParams.SearchString.Length);
}
else
listView1.Focus();
if (searchParams.bMatchWhole)
dispstr = listView1.Items[searchParams.SearchResultIndex].SubItems[(int)Enum.ToObject(typeof(CardProps), searchParams.SearchContext)].Text;
toolStripStatusLabel1.Text = "Found: " + "[" + searchParams.SearchContext.ToString() + "] " + dispstr + " at item [" + (searchParams.SearchResultIndex + 1) + "]";
bCurrentlySearching = false;
return true;
}
else
toolStripStatusLabel1.Text = "String: \"" + searchParams.SearchString + "\" not found.";
bCurrentlySearching = false;
return false;
}
public void InitiateReplacing(CardSearchParams searchParams)
{
if (searchParams.SearchResultIndex < 0) // if a card is unselected / index has changed, search without replacing....
InitiateCardSearch(searchParams);
else // else if we have a search result, replace and continue searching again...
{
int ci = SearchCardIndexByID(Int32.Parse(listView1.SelectedItems[0].SubItems[0].Text));
cardSearch.Replace(searchParams, ImportDB[ci]);
UpdateTexts();
InitiateCardSearch(searchParams);
bUnsavedChangesMade = true;
}
}
public void InitiateReplaceAll(CardSearchParams searchParams)
{
int ci;
int rc = 0;
bool[] lvUpdateFlags = new bool[listView1.Items.Count];
for (int i = 0; i < listView1.Items.Count; i++)
{
cardSearch.bFirstSearch = true;
cardSearch.CurrentlySelectedItem = i;
cardSearch.CurrentlySelectedSubItem = -1;
searchParams.SearchResultSubStrIndex = -1;
searchParams.SearchResultSubStrIndex_Name = -1;
searchParams.SearchResultSubStrIndex_Desc = -1;
if (cardSearch.Search(searchParams, listView1, true, true))
{
if (i < searchParams.SearchResultIndex)
i = searchParams.SearchResultIndex; // boost the counter forward and only forward...
ci = SearchCardIndexByID(Int32.Parse(listView1.Items[searchParams.SearchResultIndex].SubItems[0].Text));
cardSearch.Replace(searchParams, ImportDB[ci]);
lvUpdateFlags[i] = true;
rc++;
}
}
UpdateTexts();
UpdateListView(lvUpdateFlags, false);
toolStripStatusLabel1.Text = "Replaced " + rc + " instances";
if (rc > 0)
bUnsavedChangesMade = true;
}
int ExtractEHP(string InFilename, string OutFolder)
{
var ehpprocess = new Process { StartInfo = new ProcessStartInfo { UseShellExecute = false, CreateNoWindow = true, FileName = "ehppack.exe", Arguments = "\"" + InFilename + "\" \"" + OutFolder + "\""} };
ehpprocess.Start();
ehpprocess.WaitForExit();
return ehpprocess.ExitCode;
}
int PackEHP(string InFolder, string OutFilename)
{
var ehpprocess = new Process { StartInfo = new ProcessStartInfo { UseShellExecute = false, CreateNoWindow = true, FileName = "ehppack.exe", Arguments = "-p \"" + InFolder + "\" \"" + OutFilename + "\"" } };
ehpprocess.Start();
ehpprocess.WaitForExit();
return ehpprocess.ExitCode;
}
int ConvertDBToIni(string InFolder, string OutFilename, string LanguageDesignator)
{
var tfcecli_process = new Process { StartInfo = new ProcessStartInfo { UseShellExecute = false, CreateNoWindow = true, FileName = "TFCardEdit.exe", Arguments = "\"" + InFolder + "\" \"" + OutFilename + "\" " + LanguageDesignator } };
tfcecli_process.Start();
tfcecli_process.WaitForExit();
return tfcecli_process.ExitCode;
}
int ConvertIniToDB(string InFilename, string OutFolder, string LanguageDesignator)
{
var tfcecli_process = new Process { StartInfo = new ProcessStartInfo { UseShellExecute = false, CreateNoWindow = true, FileName = "TFCardEdit.exe", Arguments = "-w \"" + InFilename + "\" \"" + OutFolder + "\" " + LanguageDesignator } };
tfcecli_process.Start();
tfcecli_process.WaitForExit();
return tfcecli_process.ExitCode;
}
char DetectLangFromFilename(string Filename)
{
if (Filename.LastIndexOf('_') != -1)
{
char LangChar = Filename[Filename.LastIndexOf('_') + 1];
LangChar = LangChar.ToString().ToUpper()[0];
return LangChar;
}
return 'E';
}
void CopyFilesForEHP(string Path)
{
if (File.Exists(Path + "\\CARD_SamePict_" + CurrentLang.ToString() + ".bin") && !File.Exists(CurrentCacheDir + "\\CARD_SamePict_" + CurrentLang.ToString() + ".bin"))
File.Copy(Path + "\\CARD_SamePict_" + CurrentLang.ToString() + ".bin", CurrentCacheDir + "\\CARD_SamePict_" + CurrentLang.ToString() + ".bin");
if (File.Exists(Path + "\\CARD_Sort_" + CurrentLang.ToString() + ".bin") && !File.Exists(CurrentCacheDir + "\\CARD_Sort_" + CurrentLang.ToString() + ".bin"))
File.Copy(Path + "\\CARD_Sort_" + CurrentLang.ToString() + ".bin", CurrentCacheDir + "\\CARD_Sort_" + CurrentLang.ToString() + ".bin");
if (File.Exists(Path + "\\CARD_Top_" + CurrentLang.ToString() + ".bin") && !File.Exists(CurrentCacheDir + "\\CARD_Top_" + CurrentLang.ToString() + ".bin"))
File.Copy(Path + "\\CARD_Top_" + CurrentLang.ToString() + ".bin", CurrentCacheDir + "\\CARD_Top_" + CurrentLang.ToString() + ".bin");
if (File.Exists(Path + "\\DLG_Indx_" + CurrentLang.ToString() + ".bin") && !File.Exists(CurrentCacheDir + "\\DLG_Indx_" + CurrentLang.ToString() + ".bin"))
File.Copy(Path + "\\DLG_Indx_" + CurrentLang.ToString() + ".bin", CurrentCacheDir + "\\DLG_Indx_" + CurrentLang.ToString() + ".bin");
if (File.Exists(Path + "\\DLG_Text_" + CurrentLang.ToString() + ".bin") && !File.Exists(CurrentCacheDir + "\\DLG_Text_" + CurrentLang.ToString() + ".bin"))
File.Copy(Path + "\\DLG_Text_" + CurrentLang.ToString() + ".bin", CurrentCacheDir + "\\DLG_Text_" + CurrentLang.ToString() + ".bin");
if (File.Exists(Path + "\\CARD_Genre.bin") && !File.Exists(Path + CurrentCacheDir + "\\CARD_Genre.bin"))
File.Copy(Path + "\\CARD_Genre.bin", CurrentCacheDir + "\\CARD_Genre.bin");
}
void ImportCardDB(string Filename)
{
int CardImporterCounter = 0;
FileIniDataParser ImportIni = new FileIniDataParser();
IniData ParsedIni = ImportIni.ReadFile(Filename);
ImportedCardsCount = ParsedIni.Sections.Count;
//ImportDB = new TFCard[ImportedCardsCount];
ImportDB = InitializeArray<TFCard>(ImportedCardsCount);
if (listView1.Items.Count > 0)
{
ResetAppState();
}
toolStripProgressBar1.Enabled = true;
toolStripProgressBar1.Visible = true;
toolStripProgressBar1.Maximum = ImportedCardsCount;
toolStripProgressBar1.Value = 0;
foreach (IniParser.Model.SectionData s in ParsedIni.Sections)
{
ImportDB[CardImporterCounter].CardID = Int32.Parse(s.SectionName);
ImportDB[CardImporterCounter].Name = s.Keys.GetKeyData("Name").Value;
ImportDB[CardImporterCounter].Description = s.Keys.GetKeyData("Description").Value;
ImportDB[CardImporterCounter].ATK = Int32.Parse(s.Keys.GetKeyData("ATK").Value);
ImportDB[CardImporterCounter].DEF = Int32.Parse(s.Keys.GetKeyData("DEF").Value);
ImportDB[CardImporterCounter].Password = Int32.Parse(s.Keys.GetKeyData("Password").Value);
ImportDB[CardImporterCounter].CardExistFlag = Convert.ToBoolean(Int32.Parse(s.Keys.GetKeyData("CardExistFlag").Value));
ImportDB[CardImporterCounter].Kind = (CardKinds)Int32.Parse(s.Keys.GetKeyData("Kind").Value);
ImportDB[CardImporterCounter].Attr = (CardAttributes)Int32.Parse(s.Keys.GetKeyData("Attr").Value);
ImportDB[CardImporterCounter].Level = Int32.Parse(s.Keys.GetKeyData("Level").Value);
ImportDB[CardImporterCounter].Icon = (CardIcons)Int32.Parse(s.Keys.GetKeyData("Icon").Value);
ImportDB[CardImporterCounter].Type = (CardTypes)Int32.Parse(s.Keys.GetKeyData("Type").Value);
ImportDB[CardImporterCounter].Rarity = (CardRarity)Int32.Parse(s.Keys.GetKeyData("Rarity").Value);
// also replace the newline character in card descriptions as we're loading them...
ImportDB[CardImporterCounter].Description = ImportDB[CardImporterCounter].Description.Replace('^', '\n').Replace('˘', '\r');
toolStripProgressBar1.Value++;
CardImporterCounter++;
}
toolStripProgressBar1.Visible = false;
toolStripProgressBar1.Enabled = false;
}
void ExportCardDB(string Filename, int ProgressBarAdditional)
{
FileIniDataParser ExportIniParser = new FileIniDataParser();
IniData ExportIni = new IniData();
toolStripProgressBar1.Maximum = ImportedCardsCount + 1 + ProgressBarAdditional;
toolStripProgressBar1.Value = 0;
ExportIni.Configuration.NewLineStr = "\n";
for (int i = 0; i < ImportedCardsCount; i++)
{
ExportIni.Sections.AddSection(ImportDB[i].CardID.ToString());
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("Name", ImportDB[i].Name);
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("Description", ImportDB[i].Description.Replace('\n', '^').Replace('\r', '˘'));
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("ATK", ImportDB[i].ATK.ToString());
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("DEF", ImportDB[i].DEF.ToString());
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("Password", ImportDB[i].Password.ToString());
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("CardExistFlag", Convert.ToInt32(ImportDB[i].CardExistFlag).ToString());
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("Kind", Convert.ToInt32(ImportDB[i].Kind).ToString());
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("Attr", Convert.ToInt32(ImportDB[i].Attr).ToString());
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("Level", ImportDB[i].Level.ToString());
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("Icon", Convert.ToInt32(ImportDB[i].Icon).ToString());
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("Type", Convert.ToInt32(ImportDB[i].Type).ToString());
ExportIni.Sections.GetSectionData(ImportDB[i].CardID.ToString()).Keys.AddKey("Rarity", Convert.ToInt32(ImportDB[i].Rarity).ToString());
toolStripProgressBar1.Value++;
}
if (File.Exists(Filename))
File.Delete(Filename);
ExportIniParser.WriteFile(Filename, ExportIni, Encoding.Unicode);
toolStripProgressBar1.Value++;
}
void DoTheSaving(string Filename)
{
bool bFileCheckLoop = true;
if (string.Compare(Path.GetExtension(Filename), ".ehp") == 0)
{
ExportCardDB(CurrentCacheIni, 20);
if (!Directory.Exists(CurrentCacheDir))
Directory.CreateDirectory(CurrentCacheDir);
ConvertIniToDB(CurrentCacheIni, CurrentCacheDir, CurrentLang.ToString());
toolStripProgressBar1.Value += 10;
// check if all necessary files are in the work folder, if not, ask the user to find them
while (bFileCheckLoop)
{
bFileCheckLoop = false;
if (!File.Exists(CurrentCacheDir + "\\CARD_SamePict_" + CurrentLang.ToString() + ".bin"))
{
bFileCheckLoop = true;
toolStripStatusLabel1.Text = "Missing: CARD_SamePict_" + CurrentLang.ToString() + ".bin! Please point to the directory containing the files.";
openFileDialog2.FileName = "CARD_SamePict_" + CurrentLang.ToString() + ".bin";
var openFileResult = openFileDialog2.ShowDialog();
if (openFileResult != DialogResult.OK)
return;
CopyFilesForEHP(Path.GetDirectoryName(openFileDialog2.FileName));
}
if (!File.Exists(CurrentCacheDir + "\\CARD_Sort_" + CurrentLang.ToString() + ".bin"))
{
bFileCheckLoop = true;
toolStripStatusLabel1.Text = "Missing: CARD_Sort_" + CurrentLang.ToString() + ".bin! Please point to the directory containing the files.";
openFileDialog2.FileName = "CARD_Sort_" + CurrentLang.ToString() + ".bin";
var openFileResult = openFileDialog2.ShowDialog();
if (openFileResult != DialogResult.OK)
return;
CopyFilesForEHP(Path.GetDirectoryName(openFileDialog2.FileName));
}
if (!File.Exists(CurrentCacheDir + "\\CARD_Top_" + CurrentLang.ToString() + ".bin"))
{
bFileCheckLoop = true;
toolStripStatusLabel1.Text = "Missing: CARD_Top_" + CurrentLang.ToString() + ".bin! Please point to the directory containing the files.";
openFileDialog2.FileName = "CARD_Top_" + CurrentLang.ToString() + ".bin";
var openFileResult = openFileDialog2.ShowDialog();
if (openFileResult != DialogResult.OK)
return;
CopyFilesForEHP(Path.GetDirectoryName(openFileDialog2.FileName));
}
if (!File.Exists(CurrentCacheDir + "\\DLG_Indx_" + CurrentLang.ToString() + ".bin"))
{
bFileCheckLoop = true;
toolStripStatusLabel1.Text = "Missing: DLG_Indx_" + CurrentLang.ToString() + ".bin! Please point to the directory containing the files.";
openFileDialog2.FileName = "DLG_Indx_" + CurrentLang.ToString() + ".bin";
var openFileResult = openFileDialog2.ShowDialog();
if (openFileResult != DialogResult.OK)
return;
CopyFilesForEHP(Path.GetDirectoryName(openFileDialog2.FileName));
}
if (!File.Exists(CurrentCacheDir + "\\DLG_Text_" + CurrentLang.ToString() + ".bin"))
{
bFileCheckLoop = true;
toolStripStatusLabel1.Text = "Missing: DLG_Text_" + CurrentLang.ToString() + ".bin! Please point to the directory containing the files.";
openFileDialog2.FileName = "DLG_Text_" + CurrentLang.ToString() + ".bin";
var openFileResult = openFileDialog2.ShowDialog();
if (openFileResult != DialogResult.OK)
return;
CopyFilesForEHP(Path.GetDirectoryName(openFileDialog2.FileName));
}
if (!File.Exists(CurrentCacheDir + "\\CARD_Genre.bin"))
{
bFileCheckLoop = true;
toolStripStatusLabel1.Text = "Missing: CARD_Genre.bin! Please point to the directory containing the files.";
openFileDialog2.FileName = "CARD_Genre.bin";
var openFileResult = openFileDialog2.ShowDialog();
if (openFileResult != DialogResult.OK)
return;
CopyFilesForEHP(Path.GetDirectoryName(openFileDialog2.FileName));
}
}
PackEHP(CurrentCacheDir, Filename);
toolStripProgressBar1.Value += 10;
}
else if (string.Compare(Path.GetExtension(Filename), ".bin") == 0)
{
ExportCardDB(CurrentCacheIni, 10);
ConvertIniToDB(CurrentCacheIni, Path.GetDirectoryName(Filename), CurrentLang.ToString());
toolStripProgressBar1.Value += 10;
}
else
ExportCardDB(Filename, 0);
}
public Form1()
{
InitializeComponent();
findBoxDialog = new FindBox();
filterBoxDialog = new FilterBox();
saveQuestionDialog = new SaveQuestionBox();
replaceParams = new CardSearchParams();
replaceParams.bSearchName = true;
cardSearch = new CardSearch();
InstanceID = Guid.NewGuid();
CurrentCacheDir = "cache\\" + InstanceID + "\\workehp";
CurrentCacheIni = CurrentCacheDir + ".ini";
JapaneseStyle = new Font("Meiryo", 8.25F, FontStyle.Regular, GraphicsUnit.Point);
if (JapaneseStyle.Name != "Meiryo")
JapaneseStyle = new Font("MS UI Gothic", 10F, FontStyle.Regular, GraphicsUnit.Point);
}
bool HandleUnsavedQuestion()
{
if (bUnsavedChangesMade)
{
saveQuestionDialog.Filename = Path.GetFileName(CurrentFilename).ToString();
DialogResult result = saveQuestionDialog.ShowDialog();
if (result == DialogResult.Cancel)
return false;
if (result == DialogResult.OK)
{
if (ImportedCardsCount > 0 && !string.IsNullOrEmpty(CurrentFilename))
{
toolStripStatusLabel1.Text = "Saving to: " + CurrentFilename;
toolStripProgressBar1.Enabled = true;
toolStripProgressBar1.Visible = true;
DoTheSaving(CurrentFilename);
toolStripProgressBar1.Visible = false;
toolStripProgressBar1.Enabled = false;
toolStripStatusLabel1.Text = "Saved to: " + CurrentFilename;
bUnsavedChangesMade = false;
}
}
}
return true;
}
private void Form1_Load(object sender, EventArgs e)
{
toolStrip1.Visible = Properties.Settings.Default.ShowToolbar;
toolbarToolStripMenuItem.Checked = Properties.Settings.Default.ShowToolbar;
statusStrip1.Visible = Properties.Settings.Default.ShowStatusBar;
statusBarToolStripMenuItem.Checked = Properties.Settings.Default.ShowStatusBar;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!HandleUnsavedQuestion())
return;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
OpenFile(openFileDialog1.FileName);
}
private void OpenFile(string FileName)
{
CurrentFilename = FileName;
toolStripStatusLabel1.Text = "Opening: " + FileName;
CurrentLang = DetectLangFromFilename(FileName);
if (string.Compare(Path.GetExtension(FileName), ".ehp") == 0)
{
if (File.Exists(CurrentCacheIni))
File.Delete(CurrentCacheIni);
if (Directory.Exists(CurrentCacheDir))
{
Directory.Delete(CurrentCacheDir, true);
Directory.CreateDirectory(CurrentCacheDir);
}
else
Directory.CreateDirectory(CurrentCacheDir);
// invoke the toolchain...
int ehpresult = ExtractEHP(FileName, CurrentCacheDir);
if (ehpresult != 0)
{
toolStripStatusLabel1.Text = "ERROR: EHP extraction failed! Status code: " + ehpresult;