2 using System.Collections.Generic;
\r
4 using System.Windows.Forms;
\r
6 using System.Threading;
\r
7 using DTXCreator.UndoRedo;
\r
11 namespace DTXCreator.WAV_BMP_AVI
\r
13 internal class CWAVリスト管理
\r
15 public int n現在選択中のItem番号0to1294 = -1;
\r
17 internal delegate void DGサウンドを再生する( int nWAV番号1to1295 );
\r
19 public CWAVリスト管理( Cメインフォーム pメインフォーム, ListView pListViewWAVリスト )
\r
21 this._Form = pメインフォーム;
\r
22 this.listViewWAVリスト = pListViewWAVリスト;
\r
23 this.sound管理 = new CSound管理( this._Form.Handle );
\r
24 this.soundPreview = null;
\r
26 #region [ #26122 2011.8.31 yyagi; ストリーム再生のために、t再生中の処理をする()を定期的に呼び出す処理を追加 ]
\r
27 timerDelegate = new TimerCallback( this.sound管理.t再生中の処理をする );
\r
28 timer = new System.Threading.Timer( timerDelegate, null, 0, 300 );
\r
31 public ListViewItem tCWAVとListViewItemを生成して返す( int n行番号1to1295 )
\r
33 return this.tWAVをキャッシュから検索して返す・なければ新規生成する( n行番号1to1295 ).t現在の内容から新しいListViewItemを作成して返す();
\r
35 public void tDirectSoundの解放()
\r
37 if( this.soundPreview != null )
\r
39 this.soundPreview.Dispose();
\r
41 if ( timer != null )
\r
43 timer.Change( Timeout.Infinite, Timeout.Infinite );
\r
47 if ( timerDelegate != null )
\r
49 timerDelegate = null;
\r
51 if( this.sound管理 != null )
\r
53 this.sound管理.Dispose();
\r
56 public void tItemを交換する( int nItem番号1, int nItem番号2 )
\r
58 if( !CUndoRedo管理.bUndoRedoした直後 )
\r
60 this._Form.mgrUndoRedo管理者.tノードを追加する( new CUndoRedoセル<int>( null, new DGUndoを実行する<int>( this.t行交換のUndo ), new DGRedoを実行する<int>( this.t行交換のRedo ), nItem番号1, nItem番号2 ) );
\r
61 this._Form.tUndoRedo用GUIの有効・無効を設定する();
\r
63 CUndoRedo管理.bUndoRedoした直後 = false;
\r
64 this.tItemを交換する・ListViewItem( nItem番号1, nItem番号2 );
\r
65 this.tItemを交換する・WAVキャッシュ( nItem番号1, nItem番号2 );
\r
66 this.tItemを交換する・チップパレット( nItem番号1, nItem番号2 );
\r
67 this.tItemを交換する・譜面上のチップ( nItem番号1, nItem番号2 );
\r
68 this.tItemを交換する・レーン割付チップ( nItem番号1, nItem番号2 );
\r
69 this.tItemを交換する・カーソル移動( nItem番号1, nItem番号2 );
\r
70 this._Form.listViewWAVリスト.Refresh();
\r
71 this._Form.pictureBox譜面パネル.Refresh();
\r
72 this._Form.b未保存 = true;
\r
74 public void tItemを選択する( int nItem番号0to1294 )
\r
76 this.n現在選択中のItem番号0to1294 = nItem番号0to1294;
\r
77 this.listViewWAVリスト.Items[ nItem番号0to1294 ].Selected = true;
\r
78 this.listViewWAVリスト.Items[ nItem番号0to1294 ].Focused = true;
\r
80 public void tWAVリストにフォーカスを当てる()
\r
82 this.listViewWAVリスト.Focus();
\r
84 public CWAV tWAVをキャッシュから検索して返す( int nWAV番号1to1295 )
\r
86 return this.WAVキャッシュ.tWAVをキャッシュから検索して返す( nWAV番号1to1295 );
\r
88 public CWAV tWAVをキャッシュから検索して返す・なければ新規生成する( int nWAV番号1to1295 )
\r
90 return this.WAVキャッシュ.tWAVをキャッシュから検索して返す・なければ新規生成する( nWAV番号1to1295 );
\r
92 public ListViewItem tWAV番号に対応するListViewItemを返す( int nWAV番号1to1295 )
\r
94 if( ( nWAV番号1to1295 < 1 ) || ( nWAV番号1to1295 > 36 * 36 - 1 ) )
\r
96 throw new Exception( "WAV番号が範囲外です。--->[" + nWAV番号1to1295 + "]" );
\r
98 return this.listViewWAVリスト.Items[ nWAV番号1to1295 - 1 ];
\r
100 public void tWAV編集のRedo( CWAV wc変更前, CWAV wc変更後 )
\r
102 int num = wc変更後.nWAV番号1to1295;
\r
103 CWAV cwav = this.WAVキャッシュ.tWAVをキャッシュから検索して返す( num );
\r
104 cwav.tコピーfrom( wc変更後 );
\r
105 cwav.tコピーto( this.listViewWAVリスト.Items[ num - 1 ] );
\r
106 this._Form.tWAV・BMP・AVIリストのカーソルを全部同じ行に合わせる( cwav.nWAV番号1to1295 - 1 );
\r
107 this._Form.tタブを選択する( Cメインフォーム.Eタブ種別.WAV );
\r
108 this.listViewWAVリスト.Refresh();
\r
110 public void tWAV編集のUndo( CWAV wc変更前, CWAV wc変更後 )
\r
112 int num = wc変更前.nWAV番号1to1295;
\r
113 CWAV cwav = this.WAVキャッシュ.tWAVをキャッシュから検索して返す( num );
\r
114 cwav.tコピーfrom( wc変更前 );
\r
115 cwav.tコピーto( this.listViewWAVリスト.Items[ num - 1 ] );
\r
116 this._Form.tWAV・BMP・AVIリストのカーソルを全部同じ行に合わせる( cwav.nWAV番号1to1295 - 1 );
\r
117 this._Form.tタブを選択する( Cメインフォーム.Eタブ種別.WAV );
\r
118 this.listViewWAVリスト.Refresh();
\r
120 public void tサウンドプロパティを開いて編集する( int nWAV番号1to1295, string str相対パスの基本フォルダ )
\r
122 this._Form.dlgチップパレット.t一時的に隠蔽する();
\r
123 CWAV cwav = this.tWAVをキャッシュから検索して返す・なければ新規生成する( nWAV番号1to1295 );
\r
124 ListViewItem item = cwav.t現在の内容から新しいListViewItemを作成して返す();
\r
125 string directoryName = "";
\r
126 if( item.SubItems[ 2 ].Text.Length > 0 )
\r
128 directoryName = Path.GetDirectoryName( this._Form.strファイルの存在するディレクトリを絶対パスで返す( item.SubItems[ 2 ].Text ) );
\r
130 Cサウンドプロパティダイアログ cサウンドプロパティダイアログ = new Cサウンドプロパティダイアログ( str相対パスの基本フォルダ, directoryName, new DGサウンドを再生する( this.tプレビュー音を再生する ) );
\r
131 cサウンドプロパティダイアログ.wav = cwav;
\r
132 cサウンドプロパティダイアログ.textBoxラベル.Text = item.SubItems[ 0 ].Text;
\r
133 cサウンドプロパティダイアログ.textBoxWAV番号.Text = item.SubItems[ 1 ].Text;
\r
134 cサウンドプロパティダイアログ.textBoxファイル.Text = item.SubItems[ 2 ].Text;
\r
135 cサウンドプロパティダイアログ.textBox音量.Text = item.SubItems[ 3 ].Text;
\r
136 cサウンドプロパティダイアログ.textBox位置.Text = item.SubItems[ 4 ].Text;
\r
137 cサウンドプロパティダイアログ.hScrollBar音量.Value = cサウンドプロパティダイアログ.wav.n音量0to100;
\r
138 cサウンドプロパティダイアログ.hScrollBar位置.Value = cサウンドプロパティダイアログ.wav.n位置_100to100 + 100;
\r
139 cサウンドプロパティダイアログ.checkBoxBGM.CheckState = cサウンドプロパティダイアログ.wav.bBGMとして使用 ? CheckState.Checked : CheckState.Unchecked;
\r
140 cサウンドプロパティダイアログ.textBoxWAV番号.ForeColor = item.ForeColor;
\r
141 cサウンドプロパティダイアログ.textBoxWAV番号.BackColor = item.BackColor;
\r
142 if( cサウンドプロパティダイアログ.ShowDialog() == DialogResult.OK )
\r
144 CWAV wav = cサウンドプロパティダイアログ.wav;
\r
145 CWAV cwav3 = new CWAV();
\r
146 cwav3.nWAV番号1to1295 = cサウンドプロパティダイアログ.wav.nWAV番号1to1295;
\r
147 cwav3.strラベル名 = cサウンドプロパティダイアログ.textBoxラベル.Text;
\r
148 cwav3.strファイル名 = cサウンドプロパティダイアログ.textBoxファイル.Text;
\r
149 cwav3.n音量0to100 = cサウンドプロパティダイアログ.hScrollBar音量.Value;
\r
150 cwav3.n位置_100to100 = cサウンドプロパティダイアログ.hScrollBar位置.Value - 100;
\r
151 cwav3.bBGMとして使用 = cサウンドプロパティダイアログ.checkBoxBGM.Checked;
\r
152 cwav3.col文字色 = cサウンドプロパティダイアログ.textBoxWAV番号.ForeColor;
\r
153 cwav3.col背景色 = cサウンドプロパティダイアログ.textBoxWAV番号.BackColor;
\r
154 if( !cwav3.b内容が同じwith( wav ) )
\r
157 wav.tコピーfrom( cサウンドプロパティダイアログ.wav );
\r
158 this._Form.mgrUndoRedo管理者.tノードを追加する( new CUndoRedoセル<CWAV>( null, new DGUndoを実行する<CWAV>( this.tWAV編集のUndo ), new DGRedoを実行する<CWAV>( this.tWAV編集のRedo ), wav, cwav3 ) );
\r
159 this._Form.tUndoRedo用GUIの有効・無効を設定する();
\r
160 cサウンドプロパティダイアログ.wav.tコピーfrom( cwav3 );
\r
161 if( this.tWAV番号に対応するListViewItemを返す( nWAV番号1to1295 ) != null )
\r
163 ListViewItem item2 = cサウンドプロパティダイアログ.wav.t現在の内容から新しいListViewItemを作成して返す();
\r
164 item = this.tWAV番号に対応するListViewItemを返す( nWAV番号1to1295 );
\r
165 item.SubItems[ 0 ].Text = item2.SubItems[ 0 ].Text;
\r
166 item.SubItems[ 1 ].Text = item2.SubItems[ 1 ].Text;
\r
167 item.SubItems[ 2 ].Text = item2.SubItems[ 2 ].Text;
\r
168 item.SubItems[ 3 ].Text = item2.SubItems[ 3 ].Text;
\r
169 item.SubItems[ 4 ].Text = item2.SubItems[ 4 ].Text;
\r
170 item.SubItems[ 5 ].Text = item2.SubItems[ 5 ].Text;
\r
171 item.ForeColor = item2.ForeColor;
\r
172 item.BackColor = item2.BackColor;
\r
174 this.listViewWAVリスト.Refresh();
\r
175 this._Form.b未保存 = true;
\r
178 this._Form.dlgチップパレット.t一時的な隠蔽を解除する();
\r
180 public void tファイル名の相対パス化( string str基本フォルダ名 )
\r
182 for( int i = 1; i <= 36 * 36 - 1; i++ )
\r
184 CWAV cwav = this.WAVキャッシュ.tWAVをキャッシュから検索して返す( i );
\r
185 if( ( cwav != null ) && ( cwav.strファイル名.Length > 0 ) )
\r
189 Uri uri = new Uri( str基本フォルダ名 );
\r
190 cwav.strファイル名 = Uri.UnescapeDataString( uri.MakeRelativeUri( new Uri( cwav.strファイル名 ) ).ToString() ).Replace( '/', '\\' );
\r
192 catch( UriFormatException )
\r
198 public void tプレビュー音を再生する( CWAV wc )
\r
200 if( ( wc != null ) && ( wc.strファイル名.Length != 0 ) )
\r
202 string str = this._Form.strファイルの存在するディレクトリを絶対パスで返す( wc.strファイル名 );
\r
205 this.tプレビュー音を停止する();
\r
206 this.soundPreview = this.sound管理.tサウンドを生成する( str );
\r
207 this.soundPreview.n音量 = wc.n音量0to100;
\r
208 this.soundPreview.n位置 = wc.n位置_100to100;
\r
209 this.soundPreview.t再生を開始する();
\r
216 public void tプレビュー音を再生する( int nWAV番号1to1295 )
\r
218 CWAV wc = this.WAVキャッシュ.tWAVをキャッシュから検索して返す( nWAV番号1to1295 );
\r
219 this.tプレビュー音を再生する( wc );
\r
221 public void tプレビュー音を停止する()
\r
223 if( this.soundPreview != null )
\r
225 this.soundPreview.t再生を停止する();
\r
228 public void t行交換のRedo( int n変更前のItem番号0to1294, int n変更後のItem番号0to1294 )
\r
230 CUndoRedo管理.bUndoRedoした直後 = true;
\r
231 this.tItemを交換する( n変更前のItem番号0to1294, n変更後のItem番号0to1294 );
\r
233 public void t行交換のUndo( int n変更前のItem番号0to1294, int n変更後のItem番号0to1294 )
\r
235 CUndoRedo管理.bUndoRedoした直後 = true;
\r
236 this.tItemを交換する( n変更前のItem番号0to1294, n変更後のItem番号0to1294 );
\r
238 public void t新規生成のRedo( CWAV wc生成前はNull, CWAV wc生成されたWAVの複製 )
\r
240 int num = wc生成されたWAVの複製.nWAV番号1to1295;
\r
241 CWAV cwav = this.WAVキャッシュ.tWAVをキャッシュから検索して返す・なければ新規生成する( num );
\r
242 cwav.tコピーfrom( wc生成されたWAVの複製 );
\r
243 cwav.tコピーto( this.listViewWAVリスト.Items[ num - 1 ] );
\r
244 this._Form.tタブを選択する( Cメインフォーム.Eタブ種別.WAV );
\r
245 this.listViewWAVリスト.Refresh();
\r
247 public void t新規生成のUndo( CWAV wc生成前はNull, CWAV wc生成されたWAVの複製 )
\r
249 int num = wc生成されたWAVの複製.nWAV番号1to1295;
\r
250 new CWAV().tコピーto( this.listViewWAVリスト.Items[ num - 1 ] );
\r
251 this.WAVキャッシュ.tWAVをキャッシュから削除する( num );
\r
252 this._Form.tタブを選択する( Cメインフォーム.Eタブ種別.WAV );
\r
253 this.listViewWAVリスト.Refresh();
\r
256 #region [ private ]
\r
257 //-----------------
\r
258 private Cメインフォーム _Form;
\r
259 private ListView listViewWAVリスト;
\r
260 private CSound soundPreview;
\r
261 private CSound管理 sound管理;
\r
262 private CWAVキャッシュ WAVキャッシュ = new CWAVキャッシュ();
\r
263 private TimerCallback timerDelegate;
\r
264 private System.Threading.Timer timer;
\r
266 private void tItemを交換する・ListViewItem( int nItem番号1, int nItem番号2 )
\r
268 int num = nItem番号1 + 1;
\r
269 int num2 = nItem番号2 + 1;
\r
270 CWAV cwav = new CWAV();
\r
271 cwav.tコピーfrom( this.listViewWAVリスト.Items[ nItem番号1 ] );
\r
272 cwav.nWAV番号1to1295 = num2;
\r
273 CWAV cwav2 = new CWAV();
\r
274 cwav2.tコピーfrom( this.listViewWAVリスト.Items[ nItem番号2 ] );
\r
275 cwav2.nWAV番号1to1295 = num;
\r
276 cwav2.tコピーto( this.listViewWAVリスト.Items[ nItem番号1 ] );
\r
277 cwav.tコピーto( this.listViewWAVリスト.Items[ nItem番号2 ] );
\r
279 private void tItemを交換する・WAVキャッシュ( int nItem番号1, int nItem番号2 )
\r
281 int num = nItem番号1 + 1;
\r
282 int num2 = nItem番号2 + 1;
\r
283 CWAV wc = this.WAVキャッシュ.tWAVをキャッシュから検索して返す( num );
\r
284 CWAV cwav2 = this.WAVキャッシュ.tWAVをキャッシュから検索して返す( num2 );
\r
285 CWAV cwav3 = new CWAV();
\r
286 cwav3.tコピーfrom( wc );
\r
287 wc.tコピーfrom( cwav2 );
\r
288 wc.nWAV番号1to1295 = num;
\r
289 cwav2.tコピーfrom( cwav3 );
\r
290 cwav2.nWAV番号1to1295 = num2;
\r
292 private void tItemを交換する・カーソル移動( int nItem番号1, int nItem番号2 )
\r
294 this.tItemを選択する( nItem番号2 );
\r
296 private void tItemを交換する・チップパレット( int nItem番号1, int nItem番号2 )
\r
298 this._Form.dlgチップパレット.tパレットセルの番号を置換する( 0, nItem番号1 + 1, nItem番号2 + 1 );
\r
300 private void tItemを交換する・レーン割付チップ( int nItem番号1, int nItem番号2 )
\r
302 for( int i = 0; i < this._Form.mgr譜面管理者.listレーン.Count; i++ )
\r
304 Cレーン cレーン = this._Form.mgr譜面管理者.listレーン[ i ];
\r
305 if( ( ( cレーン.eレーン種別 == Cレーン.E種別.WAV ) || ( cレーン.eレーン種別 == Cレーン.E種別.GtV ) ) || ( cレーン.eレーン種別 == Cレーン.E種別.BsV ) )
\r
307 if( cレーン.nレーン割付チップ・表0or1to1295 == ( nItem番号1 + 1 ) )
\r
309 cレーン.nレーン割付チップ・表0or1to1295 = nItem番号2 + 1;
\r
311 else if( cレーン.nレーン割付チップ・表0or1to1295 == ( nItem番号2 + 1 ) )
\r
313 cレーン.nレーン割付チップ・表0or1to1295 = nItem番号1 + 1;
\r
315 if( cレーン.nレーン割付チップ・裏0or1to1295 == ( nItem番号1 + 1 ) )
\r
317 cレーン.nレーン割付チップ・裏0or1to1295 = nItem番号2 + 1;
\r
319 else if( cレーン.nレーン割付チップ・裏0or1to1295 == ( nItem番号2 + 1 ) )
\r
321 cレーン.nレーン割付チップ・裏0or1to1295 = nItem番号1 + 1;
\r
326 private void tItemを交換する・譜面上のチップ( int nItem番号1, int nItem番号2 )
\r
328 foreach( KeyValuePair<int, C小節> pair in this._Form.mgr譜面管理者.dic小節 )
\r
330 C小節 c小節 = pair.Value;
\r
331 for( int i = 0; i < c小節.listチップ.Count; i++ )
\r
333 Cチップ cチップ = c小節.listチップ[ i ];
\r
334 switch( this._Form.mgr譜面管理者.listレーン[ cチップ.nレーン番号0to ].eレーン種別 )
\r
339 if( cチップ.n値・整数1to1295 == ( nItem番号1 + 1 ) )
\r
341 cチップ.n値・整数1to1295 = nItem番号2 + 1;
\r
343 else if( cチップ.n値・整数1to1295 == ( nItem番号2 + 1 ) )
\r
345 cチップ.n値・整数1to1295 = nItem番号1 + 1;
\r
352 //-----------------
\r