OSDN Git Service

ed4234befbe97ee0742e539b6a922e5f66506a86
[dtxmania/dtxmania.git] / DTXCreator / コード / 05.譜面 / C検索ダイアログ.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Windows.Forms;
5 using System.ComponentModel;
6 using DTXCreator.Properties;
7 using FDK;
8
9 namespace DTXCreator.譜面
10 {
11         public partial class C検索ダイアログ : Form
12         {
13                 public static bool b前回値_チップ範囲指定 = true;
14                 public static bool[] b前回値_レーンリストチェック = null;
15                 public static bool b前回値_レーン指定 = false;
16                 public static bool b前回値_小節範囲指定 = false;
17                 public static bool b前回値_表チップ = true;
18                 public static bool b前回値_裏チップ = true;
19                 public static string[] str前回値_レーンリスト = null;
20
21                 public bool bチップ範囲指定CheckBoxがチェックされている
22                 {
23                         get
24                         {
25                                 return this.checkBoxチップ範囲指定.Checked;
26                         }
27                 }
28                 public bool bレーンリストの内訳が生成済みである
29                 {
30                         get
31                         {
32                                 if( str前回値_レーンリスト == null )
33                                 {
34                                         return false;
35                                 }
36                                 return true;
37                         }
38                 }
39                 public bool bレーン指定CheckBoxがチェックされている
40                 {
41                         get
42                         {
43                                 return this.checkBoxレーン指定.Checked;
44                         }
45                 }
46                 public bool b小節範囲指定CheckBoxがチェックされている
47                 {
48                         get
49                         {
50                                 return this.checkBox小節範囲指定.Checked;
51                         }
52                 }
53                 public bool b表チップCheckBoxがチェックされている
54                 {
55                         get
56                         {
57                                 return this.checkBox表チップ.Checked;
58                         }
59                 }
60                 public bool b裏チップCheckBoxがチェックされている
61                 {
62                         get
63                         {
64                                 return this.checkBox裏チップ.Checked;
65                         }
66                 }
67                 public int nチップ範囲開始番号
68                 {
69                         get
70                         {
71                                 if( this.textBoxチップ範囲開始.Text.Length > 0 )
72                                 {
73                                         string num = this.textBoxチップ範囲開始.Text;
74                                         if( num.Length == 1 )
75                                         {
76                                                 num = "0" + num;
77                                         }
78                                         return C変換.n36進数2桁の文字列を数値に変換して返す( num );
79                                 }
80                                 if( this.textBoxチップ範囲終了.Text.Length <= 0 )
81                                 {
82                                         return -1;
83                                 }
84                                 string text = this.textBoxチップ範囲終了.Text;
85                                 if( text.Length == 1 )
86                                 {
87                                         text = "0" + text;
88                                 }
89                                 return C変換.n36進数2桁の文字列を数値に変換して返す( text );
90                         }
91                 }
92                 public int nチップ範囲終了番号
93                 {
94                         get
95                         {
96                                 if( this.textBoxチップ範囲終了.Text.Length > 0 )
97                                 {
98                                         string num = this.textBoxチップ範囲終了.Text;
99                                         if( num.Length == 1 )
100                                         {
101                                                 num = "0" + num;
102                                         }
103                                         return C変換.n36進数2桁の文字列を数値に変換して返す( num );
104                                 }
105                                 if( this.textBoxチップ範囲開始.Text.Length <= 0 )
106                                 {
107                                         return -1;
108                                 }
109                                 string text = this.textBoxチップ範囲開始.Text;
110                                 if( text.Length == 1 )
111                                 {
112                                         text = "0" + text;
113                                 }
114                                 return C変換.n36進数2桁の文字列を数値に変換して返す( text );
115                         }
116                 }
117                 public int n小節範囲開始番号
118                 {
119                         get
120                         {
121                                 int num2;
122                                 if( this.textBox小節範囲開始.Text.Length > 0 )
123                                 {
124                                         int num;
125                                         if( !int.TryParse( this.textBox小節範囲開始.Text, out num ) )
126                                         {
127                                                 num = -1;
128                                         }
129                                         return num;
130                                 }
131                                 if( this.textBox小節範囲終了.Text.Length <= 0 )
132                                 {
133                                         return -1;
134                                 }
135                                 if( !int.TryParse( this.textBox小節範囲終了.Text, out num2 ) )
136                                 {
137                                         num2 = -1;
138                                 }
139                                 return num2;
140                         }
141                 }
142                 public int n小節範囲終了番号
143                 {
144                         get
145                         {
146                                 int num2;
147                                 if( this.textBox小節範囲終了.Text.Length > 0 )
148                                 {
149                                         int num;
150                                         if( !int.TryParse( this.textBox小節範囲終了.Text, out num ) )
151                                         {
152                                                 num = -1;
153                                         }
154                                         return num;
155                                 }
156                                 if( this.textBox小節範囲開始.Text.Length <= 0 )
157                                 {
158                                         return -1;
159                                 }
160                                 if( !int.TryParse( this.textBox小節範囲開始.Text, out num2 ) )
161                                 {
162                                         num2 = -1;
163                                 }
164                                 return num2;
165                         }
166                 }
167
168                 public C検索ダイアログ()
169                 {
170                         this.InitializeComponent();
171                         this.checkBoxレーン指定.CheckState = b前回値_レーン指定 ? CheckState.Checked : CheckState.Unchecked;
172                         this.checkBoxチップ範囲指定.CheckState = b前回値_チップ範囲指定 ? CheckState.Checked : CheckState.Unchecked;
173                         this.checkBox小節範囲指定.CheckState = b前回値_小節範囲指定 ? CheckState.Checked : CheckState.Unchecked;
174                         this.checkBox表チップ.CheckState = b前回値_表チップ ? CheckState.Checked : CheckState.Unchecked;
175                         this.checkBox裏チップ.CheckState = b前回値_裏チップ ? CheckState.Checked : CheckState.Unchecked;
176                         if( ( str前回値_レーンリスト != null ) && ( str前回値_レーンリスト.Length > 0 ) )
177                         {
178                                 for( int i = 0; i < str前回値_レーンリスト.Length; i++ )
179                                 {
180                                         this.checkedListBoxレーン選択リスト.Items.Add( str前回値_レーンリスト[ i ], b前回値_レーンリストチェック[ i ] );
181                                 }
182                         }
183                         this.tチェックに連動して有効無効が決まるパーツについてEnabledを設定する();
184                 }
185                 public bool bレーンが検索対象である( int nレーン番号 )
186                 {
187                         if( ( nレーン番号 < 0 ) || ( nレーン番号 >= this.checkedListBoxレーン選択リスト.Items.Count ) )
188                         {
189                                 return false;
190                         }
191                         if( this.checkedListBoxレーン選択リスト.GetItemCheckState( nレーン番号 ) != CheckState.Checked )
192                         {
193                                 return false;
194                         }
195                         return true;
196                 }
197                 public void tレーンリストの内訳を生成する( string[] strリスト要素 )
198                 {
199                         b前回値_レーンリストチェック = new bool[ strリスト要素.Length ];
200                         for( int i = 0; i < strリスト要素.Length; i++ )
201                         {
202                                 this.checkedListBoxレーン選択リスト.Items.Add( strリスト要素[ i ] );
203                                 b前回値_レーンリストチェック[ i ] = false;
204                         }
205                         str前回値_レーンリスト = strリスト要素;
206                 }
207
208                 private void tチェックに連動して有効無効が決まるパーツについてEnabledを設定する()
209                 {
210                         bool flag = this.checkBoxレーン指定.Checked;
211                         this.buttonALL.Enabled = flag;
212                         this.buttonNONE.Enabled = flag;
213                         this.checkedListBoxレーン選択リスト.Enabled = flag;
214                         flag = this.checkBoxチップ範囲指定.Checked;
215                         this.textBoxチップ範囲開始.Enabled = flag;
216                         this.textBoxチップ範囲終了.Enabled = flag;
217                         flag = this.checkBox小節範囲指定.Checked;
218                         this.textBox小節範囲開始.Enabled = flag;
219                         this.textBox小節範囲終了.Enabled = flag;
220                 }
221
222                 private void C検索ダイアログ_FormClosing( object sender, FormClosingEventArgs e )
223                 {
224                         if( base.DialogResult == DialogResult.OK )
225                         {
226                                 string text = this.textBoxチップ範囲開始.Text;
227                                 if( text.Length == 1 )
228                                 {
229                                         text = "0" + text;
230                                 }
231                                 if( ( text.Length > 0 ) && ( ( text.Length > 2 ) || ( C変換.n36進数2桁の文字列を数値に変換して返す( text ) == -1 ) ) )
232                                 {
233                                         MessageBox.Show( Resources.strチップ番号に誤りがありますMSG + Environment.NewLine + "'" + text + "'", Resources.strエラーダイアログのタイトル, MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1 );
234                                         this.textBoxチップ範囲開始.Focus();
235                                         this.textBoxチップ範囲開始.SelectAll();
236                                         e.Cancel = true;
237                                 }
238                                 else
239                                 {
240                                         text = this.textBoxチップ範囲終了.Text;
241                                         if( text.Length == 1 )
242                                         {
243                                                 text = "0" + text;
244                                         }
245                                         if( ( text.Length > 0 ) && ( ( text.Length > 2 ) || ( C変換.n36進数2桁の文字列を数値に変換して返す( text ) == -1 ) ) )
246                                         {
247                                                 MessageBox.Show( Resources.strチップ番号に誤りがありますMSG + Environment.NewLine + "'" + text + "'", Resources.strエラーダイアログのタイトル, MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1 );
248                                                 this.textBoxチップ範囲終了.Focus();
249                                                 this.textBoxチップ範囲終了.SelectAll();
250                                                 e.Cancel = true;
251                                         }
252                                         else
253                                         {
254                                                 int num;
255                                                 text = this.textBox小節範囲開始.Text;
256                                                 if( ( text.Length > 0 ) && ( !int.TryParse( text, out num ) || ( num < 0 ) ) )
257                                                 {
258                                                         MessageBox.Show( Resources.str小節番号に誤りがありますMSG + Environment.NewLine + "'" + text + "'", Resources.strエラーダイアログのタイトル, MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1 );
259                                                         this.textBox小節範囲開始.Focus();
260                                                         this.textBox小節範囲開始.SelectAll();
261                                                         e.Cancel = true;
262                                                 }
263                                                 else
264                                                 {
265                                                         text = this.textBox小節範囲終了.Text;
266                                                         if( ( text.Length > 0 ) && ( !int.TryParse( text, out num ) || ( num < 0 ) ) )
267                                                         {
268                                                                 MessageBox.Show( Resources.str小節番号に誤りがありますMSG + Environment.NewLine + "'" + text + "'", Resources.strエラーダイアログのタイトル, MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1 );
269                                                                 this.textBox小節範囲終了.Focus();
270                                                                 this.textBox小節範囲終了.SelectAll();
271                                                                 e.Cancel = true;
272                                                         }
273                                                         else
274                                                         {
275                                                                 b前回値_レーン指定 = this.checkBoxレーン指定.Checked;
276                                                                 b前回値_チップ範囲指定 = this.checkBoxチップ範囲指定.Checked;
277                                                                 b前回値_小節範囲指定 = this.checkBox小節範囲指定.Checked;
278                                                                 b前回値_表チップ = this.checkBox表チップ.Checked;
279                                                                 b前回値_裏チップ = this.checkBox裏チップ.Checked;
280                                                                 for( int i = 0; i < this.checkedListBoxレーン選択リスト.Items.Count; i++ )
281                                                                 {
282                                                                         b前回値_レーンリストチェック[ i ] = this.checkedListBoxレーン選択リスト.GetItemCheckState( i ) == CheckState.Checked;
283                                                                 }
284                                                         }
285                                                 }
286                                         }
287                                 }
288                         }
289                 }
290                 private void C検索ダイアログ_KeyDown( object sender, KeyEventArgs e )
291                 {
292                         if( e.KeyCode == Keys.Return )
293                         {
294                                 this.buttonOK.PerformClick();
295                         }
296                         else if( e.KeyCode == Keys.Escape )
297                         {
298                                 this.buttonキャンセル.PerformClick();
299                         }
300                 }
301                 private void textBoxチップ範囲開始_KeyDown( object sender, KeyEventArgs e )
302                 {
303                         if( e.KeyCode == Keys.Return )
304                         {
305                                 this.buttonOK.PerformClick();
306                         }
307                         else if( e.KeyCode == Keys.Escape )
308                         {
309                                 this.buttonキャンセル.PerformClick();
310                         }
311                 }
312                 private void textBoxチップ範囲終了_KeyDown( object sender, KeyEventArgs e )
313                 {
314                         if( e.KeyCode == Keys.Return )
315                         {
316                                 this.buttonOK.PerformClick();
317                         }
318                         else if( e.KeyCode == Keys.Escape )
319                         {
320                                 this.buttonキャンセル.PerformClick();
321                         }
322                 }
323                 private void textBox小節範囲開始_KeyDown( object sender, KeyEventArgs e )
324                 {
325                         if( e.KeyCode == Keys.Return )
326                         {
327                                 this.buttonOK.PerformClick();
328                         }
329                         else if( e.KeyCode == Keys.Escape )
330                         {
331                                 this.buttonキャンセル.PerformClick();
332                         }
333                 }
334                 private void textBox小節範囲終了_KeyDown( object sender, KeyEventArgs e )
335                 {
336                         if( e.KeyCode == Keys.Return )
337                         {
338                                 this.buttonOK.PerformClick();
339                         }
340                         else if( e.KeyCode == Keys.Escape )
341                         {
342                                 this.buttonキャンセル.PerformClick();
343                         }
344                 }
345                 private void checkBox小節範囲指定_CheckStateChanged( object sender, EventArgs e )
346                 {
347                         this.tチェックに連動して有効無効が決まるパーツについてEnabledを設定する();
348                 }
349                 private void checkBox小節範囲指定_KeyDown( object sender, KeyEventArgs e )
350                 {
351                         if( e.KeyCode == Keys.Return )
352                         {
353                                 this.buttonOK.PerformClick();
354                         }
355                         else if( e.KeyCode == Keys.Escape )
356                         {
357                                 this.buttonキャンセル.PerformClick();
358                         }
359                 }
360                 private void checkBoxチップ範囲指定_CheckStateChanged( object sender, EventArgs e )
361                 {
362                         this.tチェックに連動して有効無効が決まるパーツについてEnabledを設定する();
363                 }
364                 private void checkBoxチップ範囲指定_KeyDown( object sender, KeyEventArgs e )
365                 {
366                         if( e.KeyCode == Keys.Return )
367                         {
368                                 this.buttonOK.PerformClick();
369                         }
370                         else if( e.KeyCode == Keys.Escape )
371                         {
372                                 this.buttonキャンセル.PerformClick();
373                         }
374                 }
375                 private void checkBoxレーン指定_CheckStateChanged( object sender, EventArgs e )
376                 {
377                         this.tチェックに連動して有効無効が決まるパーツについてEnabledを設定する();
378                 }
379                 private void checkBoxレーン指定_KeyDown( object sender, KeyEventArgs e )
380                 {
381                         if( e.KeyCode == Keys.Return )
382                         {
383                                 this.buttonOK.PerformClick();
384                         }
385                         else if( e.KeyCode == Keys.Escape )
386                         {
387                                 this.buttonキャンセル.PerformClick();
388                         }
389                 }
390                 private void checkedListBoxレーン選択リスト_KeyDown( object sender, KeyEventArgs e )
391                 {
392                         if( e.KeyCode == Keys.Return )
393                         {
394                                 this.buttonOK.PerformClick();
395                         }
396                         else if( e.KeyCode == Keys.Escape )
397                         {
398                                 this.buttonキャンセル.PerformClick();
399                         }
400                 }
401                 private void checkBox表チップ_KeyDown( object sender, KeyEventArgs e )
402                 {
403                         if( e.KeyCode == Keys.Return )
404                         {
405                                 this.buttonOK.PerformClick();
406                         }
407                         else if( e.KeyCode == Keys.Escape )
408                         {
409                                 this.buttonキャンセル.PerformClick();
410                         }
411                 }
412                 private void checkBox裏チップ_KeyDown( object sender, KeyEventArgs e )
413                 {
414                         if( e.KeyCode == Keys.Return )
415                         {
416                                 this.buttonOK.PerformClick();
417                         }
418                         else if( e.KeyCode == Keys.Escape )
419                         {
420                                 this.buttonキャンセル.PerformClick();
421                         }
422                 }
423                 private void buttonNONE_Click( object sender, EventArgs e )
424                 {
425                         for( int i = 0; i < this.checkedListBoxレーン選択リスト.Items.Count; i++ )
426                         {
427                                 this.checkedListBoxレーン選択リスト.SetItemCheckState( i, CheckState.Unchecked );
428                         }
429                 }
430                 private void buttonNONE_KeyDown( object sender, KeyEventArgs e )
431                 {
432                         if( e.KeyCode == Keys.Escape )
433                         {
434                                 this.buttonキャンセル.PerformClick();
435                         }
436                 }
437                 private void buttonALL_Click( object sender, EventArgs e )
438                 {
439                         for( int i = 0; i < this.checkedListBoxレーン選択リスト.Items.Count; i++ )
440                         {
441                                 this.checkedListBoxレーン選択リスト.SetItemChecked( i, true );
442                         }
443                 }
444                 private void buttonALL_KeyDown( object sender, KeyEventArgs e )
445                 {
446                         if( e.KeyCode == Keys.Escape )
447                         {
448                                 this.buttonキャンセル.PerformClick();
449                         }
450                 }
451         }
452 }