/
MainWindow.xaml.cs
992 lines (928 loc) · 38.7 KB
/
MainWindow.xaml.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace FstFileEditor
{
/// <summary>
/// MainWindow.xaml の相互作用ロジック
/// </summary>
public partial class MainWindow : Window
{
int _lastSelection = 0;//カーソルの位置変数
string _filePath = null;//ファイルパス
int _searchIndex;
//各タブがもつControlをまとめるControl配列の初期化
Control[] EVENTINPUT;
Control[] MODELTAB, MOTIONTAB, MOVETAB, SOUNDTAB, STAGETAB, LIGHTTAB, CAMERATAB, SPEECHTAB, VARIABLETAB, PLUGINTAB, OTHERTAB, FREETAB;
//コマンドバインディングのための初期化
public readonly static RoutedCommand FocusTop = new RoutedCommand("FocusTop", typeof(MainWindow));//一番上にフォーカスする
public readonly static RoutedCommand NewCommand = new RoutedCommand("NewCommand", typeof(MainWindow));//Ctrl+Nの新規コマンド
public readonly static RoutedCommand FileOpenCommand = new RoutedCommand("FileOpenCommand", typeof(MainWindow));//Ctrl+Oのファイル開くコマンド
public readonly static RoutedCommand Save = new RoutedCommand("Save", typeof(MainWindow));//Ctrl+sの上書き保存用コマンド
public readonly static RoutedCommand NamedScriptionCommand = new RoutedCommand("NamedScriptionCommand", typeof(MainWindow));//Ctrl+Wの名前を付けて保存コマンド
public readonly static RoutedCommand ShowSearchRegion = new RoutedCommand("ShowSearchRegion", typeof(MainWindow));//検索ウィンドウを似非表示する
public readonly static RoutedCommand OpenMMDAexe = new RoutedCommand("OpenMMDAexe", typeof(MainWindow));
public MainWindow()
{
InitializeComponent();
initTabs();
initCommandBindings();
initSearchEngine();
}
private void initSearchEngine()
{
_searchIndex = fst_textBox.SelectionStart;
allEnable_Disable4Search(false);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
//-----------------------------------------------------------------------------------
//大域変数にControl配列をとったので、それを初期化する。
private void initTabs()
{
EVENTINPUT = new Control[] { textBoxE1, textBoxE2, comboBoxE1, textBoxE3 };
MODELTAB = new Control[] { comboBox1, comboBox16, textBox2, textBox3, textBox4, checkBox1, textBox5, textBox6 };
MOTIONTAB = new Control[] { comboBox2, textBox7, textBox8, textBox9, comboBox3, comboBox15, checkBox2, checkBox3 };
MOVETAB = new Control[] { comboBox4, textBox10, textBox11, comboBox5, textBox12 };
SOUNDTAB = new Control[] { comboBox6, textBox13, textBox14 };
STAGETAB = new Control[] { comboBox7, textBox15, textBox16 };
LIGHTTAB = new Control[] { comboBox8, textBox17, textBox18 };
CAMERATAB = new Control[] { comboBox9, textBox19, textBox20, textBox21, textBox22 };
SPEECHTAB = new Control[] { comboBox10, textBox23, textBox24, textBox25, textBox26 };
VARIABLETAB = new Control[] { comboBox11, textBox27, textBox28, textBox29, textBox30, comboBox12, textBox31, textBox32 };
PLUGINTAB = new Control[] { comboBox13, textBox33 };
OTHERTAB = new Control[] { comboBox14, textBox34, textBox35, textBox36, checkBox4, checkBox5, checkBox6 };
FREETAB = new Control[] { textBox37, textBox38, textBox39 };
}
//-----------------------------------------------------------------------------------
//コマンドバインディングの内容初期化
private void initCommandBindings()
{
this.CommandBindings.Add(new CommandBinding(FocusTop, FocusTopbutton_Click, (s, e) => e.CanExecute = true));
this.CommandBindings.Add(new CommandBinding(NewCommand, MenuItem_Click_New, (s, e) => e.CanExecute = true));
this.CommandBindings.Add(new CommandBinding(FileOpenCommand, FileOpen_Click, (s, e) => e.CanExecute = true));
this.CommandBindings.Add(new CommandBinding(Save, SuperScription_Click, (s, e) => e.CanExecute = true));
this.CommandBindings.Add(new CommandBinding(NamedScriptionCommand, NamedScription_Click, (s, e) => e.CanExecute = true));
this.CommandBindings.Add(new CommandBinding(ShowSearchRegion, searchbutton_Click, (s, e) => e.CanExecute = true));
this.CommandBindings.Add(new CommandBinding(OpenMMDAexe, executeMMDAgentButton_Click, (s, e) => e.CanExecute = true));
}
//FocusTopbutton_Click(s, e);
//-----------------------------------------------------------------------------------
//常に最前に表示のためのメソッド
private void Menu_topmost_Click(object sender, RoutedEventArgs e)
{
this.Topmost = Menu_topmost.IsChecked;
}
//-----------------------------------------------------------------------------------
//テキストを右で折り返す のためのメソッド
private void Menu_returnRight_Click(object sender, RoutedEventArgs e)
{
if (Menu_returnRight.IsChecked)
fst_textBox.TextWrapping = TextWrapping.Wrap;
else
{
fst_textBox.TextWrapping = TextWrapping.NoWrap;
}
}
//-----------------------------------------------------------------------------------
//EVENTTABのコンボボックスをEnterキーで開く
private void comboBoxE1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBoxE1.IsDropDownOpen = true;
}
//-----------------------------------------------------------------------------------
//FsttextBoxの書き込み用関数フォーカスとカーソルの移動をする。
private void focus_and_write(string s)
{
_lastSelection = fst_textBox.SelectionStart;
fst_textBox.Text = fst_textBox.Text.Substring(0, fst_textBox.SelectionStart) + s + fst_textBox.Text.Substring(fst_textBox.SelectionStart);//カーソルの位置に書きこむ
fst_textBox.SelectionStart = _lastSelection + s.Length;//カーソルの位置を調整する
fst_textBox.Focus();//書き込んだ後テキストボックスをアクティブにする
// fst_textBox.ScrollToLine();//カーソルを書き込んだ位置にもっていく
}
//-----------------------------------------------------------------------------------
//TabControl上のコントロールからテキストを生成する。
private string makeString(IEnumerable<Control> ctls)
{
string strtemp = "";
if (ctls.Equals(FREETAB) && (bool)isCommentCheckBox.IsChecked)
strtemp += "#";
strtemp += makeEventString();
bool isFirstString = true;
foreach (Control t1 in ctls)
{
if (t1.IsEnabled)
{
var t = t1 as TextBox;
if (t == null)
{
var c = t1 as ComboBox;
if (c == null)
{
var ch = t1 as CheckBox;
strtemp += ((bool)ch.IsChecked) ? "|ON" : "|OFF";
}
else
{
if (c.Text != string.Empty)
{
strtemp += (isFirstString) ? c.Text : "|" + c.Text;
isFirstString = false;
}
}
}
else
{
if (t.Text != string.Empty)
{
strtemp += (isFirstString) ? t.Text : "|" + t.Text;
isFirstString = false;
}
}
}
}
return strtemp + "\n";
}
//-----------------------------------------------------------------------------------
//書き込み後のコントロールの初期化(チェックボックスは初期化していないが…)
private void initTabContents(IEnumerable<Control> ctls)
{
Control[] seq = EVENTINPUT.Concat(ctls).ToArray();
foreach (Control ctl in seq)
{
var t = ctl as TextBox;
if (t == null)
{
var c = ctl as ComboBox;
if (c == null)
{
var ch = ctl as CheckBox;
ch.IsChecked = false;
}
else
{
c.Text = string.Empty;
}
}
else
{
t.Text = string.Empty;
}
ctl.IsEnabled = true;
}
}
//-----------------------------------------------------------------------------------
//EVENTTABと引数で与えたControl配列を組み合わせる。(Write処理の時に一気に入力内容を書き込むために用いる)
public void arrayPlusEvent(Control[] ctls)
{
Control[] seq = EVENTINPUT.Concat(ctls).ToArray();
}
//-----------------------------------------------------------------------------------
//EVENTTABの入力した内容を文字列にして返す。
//(EVENTINPUT以外に使わないので、For文で走査するよりはそのまま記述したほうが早い)
public string makeEventString()
{
string eventString = string.Empty;
eventString += textBoxE1.Text == string.Empty ? "" : textBoxE1.Text + " ";
eventString += textBoxE2.Text == string.Empty ? "" : textBoxE2.Text + " ";
eventString += comboBoxE1.Text == string.Empty ? "" : comboBoxE1.Text;
eventString += textBoxE3.Text == string.Empty ? "" : "|" + textBoxE3.Text;
//if (textBoxE3.Text == string.Empty) eventString.Replace("|", "");
eventString += (eventString == string.Empty) ? "" : " ";
return eventString;
}
#region MODELTAB
private void comboBox1_KeyDown(object sender, KeyEventArgs e)//MODEL_Cmd
{
if (e.Key == Key.Enter)
comboBox1.IsDropDownOpen = true;
}
private void checkBox1_KeyDown(object sender, KeyEventArgs e)//MODEL_cartoon
{
if (e.Key == Key.Enter)
{
checkBox1.IsChecked = !checkBox1.IsChecked;
}
}
private void button1_Click(object sender, RoutedEventArgs e) //MODEL_OK
{
focus_and_write(makeString(MODELTAB));
initTabContents(MODELTAB);
}
private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (comboBox1.SelectedItem == null) return;
foreach (Control t in MODELTAB)
{
t.IsEnabled = true;
}
string s = comboBox1.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", string.Empty);
int rist_index = MODELTAB.Length;
switch (s)
{
case "MODEL_ADD":
break;
case "MODEL_CHANGE":
rist_index = 2;
break;
default:
rist_index = 1;
break;
}
for (int i = 0; i < MODELTAB.Length; i++)
{
if (i > rist_index)
MODELTAB[i].IsEnabled = false;
}
}
#endregion
#region MOTIONTAB
private void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (comboBox2.SelectedItem == null) return;
foreach (Control t in MOTIONTAB)
{
t.IsEnabled = true;
}
string s = comboBox2.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", string.Empty);
int ristIndex = MOTIONTAB.Length;
switch (s)
{
case "MOTION_ADD":
break;
case "MOTION_CHANGE":
ristIndex = 3;
break;
default:
ristIndex = 2;
break;
}
for (int i = 0; i < MOTIONTAB.Length; i++)
{
if (i > ristIndex)
MOTIONTAB[i].IsEnabled = false;
}
}
private void comboBox2_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBox2.IsDropDownOpen = true;
}
private void comboBox3_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBox3.IsDropDownOpen = true;
}
private void comboBox15_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBox15.IsDropDownOpen = true;
}
private void checkBox2_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
checkBox2.IsChecked = !checkBox2.IsChecked;
}
private void checkBox3_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
checkBox3.IsChecked = !checkBox3.IsChecked;
}
private void button2_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(MOTIONTAB));
initTabContents(MOTIONTAB);
}
#endregion
#region MOVETAB
private void comboBox4_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (comboBox4.SelectedItem == null) return;
foreach (Control t in MOVETAB)
{
t.IsEnabled = true;
}
string s = comboBox4.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", string.Empty);
int ristIndex = MOVETAB.Length;
switch (s)
{
case "MOVE_START":
case "TURN_START":
case "ROTATE_START":
break;
default:
ristIndex = 1;
break;
}
for (int i = 0; i < MOVETAB.Length; i++)
{
if (i > ristIndex)
MOVETAB[i].IsEnabled = false;
}
}
private void comboBox4_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBox4.IsDropDownOpen = true;
}
private void comboBox5_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBox5.IsDropDownOpen = true;
}
private void button3_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(MOVETAB));
initTabContents(MOVETAB);
}
#endregion
#region SOUNDTAB
private void button6_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(SOUNDTAB));
initTabContents(SOUNDTAB);
}
private void comboBox6_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (comboBox6.SelectedItem == null) return;
foreach (Control t in SOUNDTAB)
{
t.IsEnabled = true;
}
string s = comboBox6.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", string.Empty);
int ristIndex = SOUNDTAB.Length;
switch (s)
{
case "SOUND_START":
break;
default:
ristIndex = 1;
break;
}
for (int i = 0; i < SOUNDTAB.Length; i++)
{
if (i > ristIndex)
SOUNDTAB[i].IsEnabled = false;
}
}
private void comboBox6_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBox6.IsDropDownOpen = true;
}
#endregion
#region STAGETAB
private void comboBox7_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void comboBox7_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBox7.IsDropDownOpen = true;
}
private void button7_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(STAGETAB));
initTabContents(STAGETAB);
}
#endregion
#region LIGHTTAB
private void button8_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(LIGHTTAB));
initTabContents(LIGHTTAB);
}
private void comboBox8Changed(object sender, SelectionChangedEventArgs e)
{
if (comboBox8.SelectedItem == null) return;
foreach (Control t in LIGHTTAB)
{
t.IsEnabled = true;
}
string s = comboBox8.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", string.Empty);
int ristIndex = LIGHTTAB.Length;
switch (s)
{
case "LIGHTCOLOR":
LIGHTTAB[2].IsEnabled = false;
break;
case "LIGHTDIRECTION":
LIGHTTAB[1].IsEnabled = false;
break;
}
}
private void comboBox8_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
comboBox8.IsDropDownOpen = true;
}
}
#endregion
#region CAMERATAB
private void comboBox9_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (comboBox9.SelectedItem == null) return;
foreach (Control t in CAMERATAB)
{
t.IsEnabled = true;
}
string s = comboBox9.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", string.Empty);
int rist_index = CAMERATAB.Length;
switch (s)
{
case "CAMERA":
break;
}
for (int i = 0; i < CAMERATAB.Length; i++)
{
if (i > rist_index)
CAMERATAB[i].IsEnabled = false;
}
}
private void comboBox9_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBox9.IsDropDownOpen = true;
}
private void button9_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(CAMERATAB));
initTabContents(CAMERATAB);
}
#endregion
#region SPEECHTAB
private void comboBox10_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (comboBox10.SelectedItem == null) return;
foreach (Control t in SPEECHTAB)
{
t.IsEnabled = true;
}
string s = comboBox10.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", string.Empty);
int ristIndex = SPEECHTAB.Length;
switch (s)
{
case "SYNTH_START":
ristIndex = 3;
break;
case "LIPSYNC_START":
for (int o = 1; o <= 3; o++) SPEECHTAB[o].IsEnabled = false;
break;
default:
ristIndex = 1;
break;
}
for (int i = 0; i < SPEECHTAB.Length; i++)
{
if (i > ristIndex)
SPEECHTAB[i].IsEnabled = false;
}
}
private void comboBox10_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
comboBox10.IsDropDownOpen = true;
}
}
private void button4_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(SPEECHTAB));
initTabContents(SPEECHTAB);
}
#endregion
#region VARIABLE
private void button5_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(VARIABLETAB));
initTabContents(VARIABLETAB);
}
private void comboBox11_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (comboBox11.SelectedItem == null) return;
foreach (Control t in VARIABLETAB)
{
t.IsEnabled = true;
}
string s = comboBox11.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", string.Empty);
int ristIndex = VARIABLETAB.Length;
switch (s)
{
case "VALUE_SET":
ristIndex = 4;
break;
case "VALUE_GET":
ristIndex = 1;
break;
case "VALUE_EVAL":
for (int o = 2; o <= 4; o++) VARIABLETAB[o].IsEnabled = false; VARIABLETAB[6].IsEnabled = false;
break;
case "TIMER_START":
case "TIMER_STOP":
for (int o = 1; o <= 5; o++) VARIABLETAB[o].IsEnabled = false;
break;
default:
ristIndex = 1;
break;
}
for (int i = 0; i < VARIABLETAB.Length; i++)
{
if (i > ristIndex)
VARIABLETAB[i].IsEnabled = false;
}
}
private void comboBox11_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
comboBox11.IsDropDownOpen = true;
}
}
private void comboBox12_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
comboBox12.IsDropDownOpen = true;
}
}
#endregion
#region PLUGINTAB
private void button10_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(PLUGINTAB));
initTabContents(PLUGINTAB);
}
private void comboBox13_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBox13.IsDropDownOpen = true;
}
#endregion
#region OTHERTAB
private void button11_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(OTHERTAB));
initTabContents(OTHERTAB);
}
private void checkBox4_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
checkBox4.IsChecked = !checkBox1.IsChecked;
}
}
private void checkBox5_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
checkBox5.IsChecked = !checkBox1.IsChecked;
}
}
private void checkBox6_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
checkBox6.IsChecked = !checkBox1.IsChecked;
}
}
private void comboBox14_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
comboBox14.IsDropDownOpen = true;
}
private void comboBox14_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (comboBox14.SelectedItem == null) return;
foreach (Control t in OTHERTAB)
{
t.IsEnabled = true;
}
string s = comboBox14.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", string.Empty);
int ristIndex = OTHERTAB.Length;
switch (s)
{
case "EXECUTE":
ristIndex = 1;
break;
default:
OTHERTAB[1].IsEnabled = false;
break;
}
for (int i = 0; i < OTHERTAB.Length; i++)
{
if (i > ristIndex)
OTHERTAB[i].IsEnabled = false;
}
}
#endregion
#region FREETAB
private void button12_Click(object sender, RoutedEventArgs e)
{
focus_and_write(makeString(FREETAB));
initTabContents(FREETAB);
}
#endregion
//-----------------------------------------------------------------------------------
//ドラッグが入ってきた時
private void fst_textBox_DragEnter(object sender, DragEventArgs e)
{
e.Effects = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.All : DragDropEffects.Move;
}
//-----------------------------------------------------------------------------------
//読み込む前の前処理
private void fst_textBox_PreviewDragOver(object sender, DragEventArgs e)
{
e.Handled = e.Data.GetData(DataFormats.FileDrop) != null;
}
//-----------------------------------------------------------------------------------
//Dropしたらfstファイルを読み込む。
private void fst_textBox_Drop(object sender, DragEventArgs e)//D&Dしたファイルが指定された拡張子かどうかの判定
{
readFstFile(e);
}
//-----------------------------------------------------------------------------------
//Fstファイルを読み込むメソッド(別にFstファイルだけではないが)
private void readFstFile(DragEventArgs e)
{
string[] DDfilePaths = (string[])e.Data.GetData(DataFormats.FileDrop, false);
string DDfilePath = DDfilePaths[0];
if (CheckExtension(DDfilePath))
{
_filePath = DDfilePath;
this.Title = System.IO.Path.GetFileName(DDfilePath) + " - FstFileEditor Ver2.00";
var sr = new StreamReader(new FileStream(DDfilePath, FileMode.Open), Encoding.GetEncoding("SJIS"));
fst_textBox.Text = sr.ReadToEnd();
titleDefaultUpdate();
sr.Close();
}
}
//-----------------------------------------------------------------------------------
//Fstファイルを読み込むメソッド(別にFstファイルだけではないが)これはファイルを開くから選んだ場合のオーバーロード
private void readFstFile(string Path)
{
string DDfilePath = Path;
if (CheckExtension(DDfilePath))
{
_filePath = DDfilePath;
this.Title = System.IO.Path.GetFileName(DDfilePath) + " - FstFileEditor Ver2.00";
var sr = new StreamReader(new FileStream(DDfilePath, FileMode.Open), Encoding.GetEncoding("SJIS"));
fst_textBox.Text = sr.ReadToEnd();
titleDefaultUpdate();
sr.Close();
}
}
//-----------------------------------------------------------------------------------
//D&Dの際にexArrayに登録された拡張子以外は弾くメソッド
private bool CheckExtension(string DDfilePath)
{
string ex = System.IO.Path.GetExtension(DDfilePath);
string[] exArray = { ".fst", ".txt", ".mdf", ".ojt", "dic", ".xml" };
return exArray.Any(extension => extension == ex);
}
//-----------------------------------------------------------------------------------
//ヘルプリファレンスウィンドウの表示
private void Menu_help_Click(object sender, RoutedEventArgs e)
{
}
//-----------------------------------------------------------------------------------
//フォントダイアログの表示
private void Menu_font_Click(object sender, RoutedEventArgs e)
{
var dlg = new emanual.Wpf.Controls.FontDialogEx
{
Left = this.Left + 50,
Top = this.Top + 50,
DlgFontFamily = new FontFamily("メイリオ"),
DlgFontSize = 15,
DlgLanguage = "ja-jp",
DlgSampleText = "テスト Test"
};
//dlg.DlgFontWeight = FontWeights.Bold;
if (dlg.ShowDialog() == true)
{
fst_textBox.FontFamily = dlg.DlgFontFamily;
fst_textBox.FontSize = dlg.DlgFontSize;
fst_textBox.FontWeight = dlg.DlgFontWeight;
fst_textBox.FontStyle = dlg.DlgFontStyle;
}
}
//-----------------------------------------------------------------------------------
//文字色設定ダイアログの表示
private void Menu_forecolorChoose_Click(object sender, RoutedEventArgs e)
{
var cd = new System.Windows.Forms.ColorDialog();
if (cd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
System.Drawing.Color color = cd.Color;
System.Windows.Media.Color clr = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B);
fst_textBox.Foreground = new SolidColorBrush(clr);
}
}
//-----------------------------------------------------------------------------------
//背景色設定ダイアログの表示
private void Menu_backcolorChoose_Click(object sender, RoutedEventArgs e)
{
var cd = new System.Windows.Forms.ColorDialog();
if (cd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
System.Drawing.Color color = cd.Color;
var clr = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B);
fst_textBox.Background = new SolidColorBrush(clr);
}
}
//-----------------------------------------------------------------------------------
//終了ボタン
private void TheEnd_Click(object sender, RoutedEventArgs e)
{
if (deleteAnnounce())
this.Close();
}
//-----------------------------------------------------------------------------------
//Topへフォーカスするためのショートカットのためのダミーボタン
private void FocusTopbutton_Click(object sender, RoutedEventArgs e)
{
textBoxE1.Focus();
}
//-----------------------------------------------------------------------------------
//STAGEタブのbmp,bmpへの対応
private void textBox16_Drop(object sender, DragEventArgs e)
{
string[] DDfilePath = (string[])e.Data.GetData(DataFormats.FileDrop, false);
if (textBox16.Text.Contains("\\") && !textBox16.Text.Contains(","))
{
textBox16.Text += "," + DDfilePath[0];
}
else
textBox16.Text = DDfilePath[0];
}
private void textBox16_PreviewDragOver(object sender, DragEventArgs e)
{
e.Handled = e.Data.GetData(DataFormats.FileDrop) != null;
}
//-----------------------------------------------------------------------------------
//ヘルプ->FstFileEditorヘルプの表示
private void FFEHELP_Click(object sender, RoutedEventArgs e)
{
var hw = new HelpWindow(this);
hw.Show();
}
//-----------------------------------------------------------------------------------
//ヘルプ->作者について
private void Myself_Click(object sender, RoutedEventArgs e)
{
var im = new IntroduceMyself(this);
im.Show();
}
//-----------------------------------------------------------------------------------
//MMDAコマンドリファレンスの表示
private void MMDACR_Click(object sender, RoutedEventArgs e)
{
var mcrw = new MMDAgentCommandReferenceWindow(this);
mcrw.Show();
}
private void Menu_Search_Click(object sender, RoutedEventArgs e)
{
searchbutton_Click(sender, e);
}
private void fst_textBox_LostFocus(object sender, RoutedEventArgs e)
{
e.Handled = true;
}
//-------------------------------------------------------------------------------------------
private void searchbutton_Click(object sender, RoutedEventArgs e)
{
allEnable_Disable4Search(true);
HideSearchRect.Width = 0;
searchStringTextBox.Focus();
}
//--------------------------------------------------------------------------------------------
//検索ボタン
private void StringSearchButton_Click(object sender, RoutedEventArgs e)
{
fst_textBox.Focus();
searchText(searchStringTextBox.Text);
StringSearchButton.Focus();
}
//--------------------------------------------------------------------------------------------
//文字列検索用メソッド
private void searchText(string str)
{
int findTextIndex;
if ((bool)isIgnoreCheckBox.IsChecked)
{
if ((bool)isDown.IsChecked)
findTextIndex = fst_textBox.Text.IndexOf(str, _searchIndex);
else
findTextIndex = fst_textBox.Text.LastIndexOf(str, _searchIndex);
}
else
{
if ((bool)isDown.IsChecked)
findTextIndex = fst_textBox.Text.IndexOf(str, _searchIndex,
StringComparison.CurrentCultureIgnoreCase);
else
findTextIndex = fst_textBox.Text.LastIndexOf(str, _searchIndex,
StringComparison.CurrentCultureIgnoreCase);
}
if (findTextIndex == -1)
{
MessageBox.Show("指定した文字列が見つかりませんでした。", "FFE - Search", MessageBoxButton.OK);
return;
}
fst_textBox.Select(findTextIndex, str.Length);
fst_textBox.ScrollToLine(fst_textBox.GetLineIndexFromCharacterIndex(findTextIndex));
if ((bool)isUp.IsChecked)
_searchIndex = findTextIndex - 1;
else
_searchIndex = findTextIndex + str.Length;
}
//-----------------------------------------------------------------
//検索文字列が空文字の時は検索しない。
private void searchStringTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
StringSearchButton.IsEnabled = searchStringTextBox.Text != "";
}
//-----------------------------------------------------------------
//検索枠のコントロールを全enableOR全disableする。
private void allEnable_Disable4Search(bool isAllEnable)
{
var sc = new Control[] { searchStringTextBox, isUp, isDown, isIgnoreCheckBox, /*StringSearchButton,*/ SearchCancelButton };
foreach (Control t in sc)
t.IsEnabled = isAllEnable;
}
private void SearchCancelButton_Click(object sender, RoutedEventArgs e)
{
// fst_textBox.Focus();
allEnable_Disable4Search(false);
HideSearchRect.Width = 378;
}
//-------------------------------------------------------------------------------
//終了イベントハンドラ(終了して良いか判断する)
private void window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (!deleteAnnounce())
{
e.Cancel = true;
}
if (!e.Cancel)
{
//セッティングセーブメソッドがあればここに書く。
}
}
//-------------------------------------------------------------------------------
//MMDAgentのパスを相対パスのために登録する
private void Menu_folderRegist_Click(object sender, RoutedEventArgs e)
{
var sw = new SearchWindow(this);
sw.Show();
}
//-------------------------------------------------------------------------------
//正規表現で座標が正しいか確認する。
private void Coodinate_CheckEvent(object sender, TextChangedEventArgs e)
{
var t = sender as TextBox;
Brush br;
if (System.Text.RegularExpressions.Regex.IsMatch(t.Text, @"[-]?\d,[-]?\d,[-]?\d") &&
!System.Text.RegularExpressions.Regex.IsMatch(t.Text, "[a-z]{1,}|[A-Z]{1,}") &&
CountChar(t.Text, ',') == 2
)
{
br = Brushes.Black;
}
else
br = Brushes.Red;
t.Foreground = br;
}
//-------------------------------------------------------------------------------
//文字列中の特定の文字の出現回数を調べる。
private int CountChar(string text, char ch)
{
return text.Length - text.Replace(ch.ToString(), "").Length;
}
//-------------------------------------------------------------------------------
//MMDAgentを起動するためのクリックイベント
private void executeMMDAgentButton_Click(object sender, RoutedEventArgs e)
{
SuperScription_Click(sender, e);
var fp = new SearchWindow(this);
var oma = new OpenMMDAexe(fp.MmdAgentFolderPath);
oma.OpenMmda();
}
private void searchStringTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
StringSearchButton_Click(sender, e);
}
}
}
}