OSDN Git Service

DTXMania089リリースに際してのtag付け。
[dtxmania/dtxmania.git] / 110401(DTXMania089) / DTXCreatorプロジェクト / コード / 02.WAV_BMP_AVI / CBMPリスト管理.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Text;\r
4 using System.Windows.Forms;\r
5 using System.IO;\r
6 using DTXCreator.譜面;\r
7 using DTXCreator.UndoRedo;\r
8 \r
9 namespace DTXCreator.WAV_BMP_AVI\r
10 {\r
11         internal class CBMPリスト管理\r
12         {\r
13                 public int n現在選択中のItem番号0to1294 = -1;\r
14 \r
15                 public CBMPリスト管理( Cメインフォーム sメインフォーム, ListView pListViewBMPリスト )\r
16                 {\r
17                         this._Form = sメインフォーム;\r
18                         this.listViewBMPリスト = pListViewBMPリスト;\r
19                 }\r
20                 public void tBMPリストにフォーカスを当てる()\r
21                 {\r
22                         this.listViewBMPリスト.Focus();\r
23                 }\r
24                 public CBMP tBMPをキャッシュから検索して返す( int nBMP番号1to1295 )\r
25                 {\r
26                         return this.BMPキャッシュ.tBMPをキャッシュから検索して返す( nBMP番号1to1295 );\r
27                 }\r
28                 public CBMP tBMPをキャッシュから検索して返す・なければ新規生成する( int nBMP番号1to1295 )\r
29                 {\r
30                         return this.BMPキャッシュ.tBMPをキャッシュから検索して返す・なければ新規生成する( nBMP番号1to1295 );\r
31                 }\r
32                 public ListViewItem tBMP番号に対応するListViewItemを返す( int nBMP番号1to1295 )\r
33                 {\r
34                         if( ( nBMP番号1to1295 < 1 ) || ( nBMP番号1to1295 > 0x50f ) )\r
35                         {\r
36                                 throw new Exception( "BMP番号が範囲外です。--->[" + nBMP番号1to1295 + "]" );\r
37                         }\r
38                         return this.listViewBMPリスト.Items[ nBMP番号1to1295 - 1 ];\r
39                 }\r
40                 public void tBMP編集のRedo( CBMP bc変更前, CBMP bc変更後 )\r
41                 {\r
42                         int num = bc変更後.nBMP番号1to1295;\r
43                         CBMP cbmp = this.BMPキャッシュ.tBMPをキャッシュから検索して返す( num );\r
44                         cbmp.tコピーfrom( bc変更後 );\r
45                         cbmp.tコピーto( this.listViewBMPリスト.Items[ num - 1 ] );\r
46                         this._Form.tWAV・BMP・AVIリストのカーソルを全部同じ行に合わせる( cbmp.nBMP番号1to1295 - 1 );\r
47                         this._Form.tタブを選択する( Cメインフォーム.Eタブ種別.BMP );\r
48                         this.listViewBMPリスト.Refresh();\r
49                 }\r
50                 public void tBMP編集のUndo( CBMP bc変更前, CBMP bc変更後 )\r
51                 {\r
52                         int num = bc変更前.nBMP番号1to1295;\r
53                         CBMP cbmp = this.BMPキャッシュ.tBMPをキャッシュから検索して返す( num );\r
54                         cbmp.tコピーfrom( bc変更前 );\r
55                         cbmp.tコピーto( this.listViewBMPリスト.Items[ num - 1 ] );\r
56                         this._Form.tWAV・BMP・AVIリストのカーソルを全部同じ行に合わせる( cbmp.nBMP番号1to1295 - 1 );\r
57                         this._Form.tタブを選択する( Cメインフォーム.Eタブ種別.BMP );\r
58                         this.listViewBMPリスト.Refresh();\r
59                 }\r
60                 public ListViewItem tCBMPとListViewItemを生成して返す( int n行番号1to1295 )\r
61                 {\r
62                         return this.tBMPをキャッシュから検索して返す・なければ新規生成する( n行番号1to1295 ).t現在の内容から新しいListViewItemを作成して返す();\r
63                 }\r
64                 public void tItemを交換する( int nItem番号1, int nItem番号2 )\r
65                 {\r
66                         if( !CUndoRedo管理.bUndoRedoした直後 )\r
67                         {\r
68                                 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
69                                 this._Form.tUndoRedo用GUIの有効・無効を設定する();\r
70                         }\r
71                         CUndoRedo管理.bUndoRedoした直後 = false;\r
72                         this.tItemを交換する・ListViewItem( nItem番号1, nItem番号2 );\r
73                         this.tItemを交換する・BMPキャッシュ( nItem番号1, nItem番号2 );\r
74                         this.tItemを交換する・チップパレット( nItem番号1, nItem番号2 );\r
75                         this.tItemを交換する・譜面上のチップ( nItem番号1, nItem番号2 );\r
76                         this.tItemを交換する・レーン割付チップ( nItem番号1, nItem番号2 );\r
77                         this.tItemを交換する・カーソル移動( nItem番号1, nItem番号2 );\r
78                         this._Form.listViewBMPリスト.Refresh();\r
79                         this._Form.pictureBox譜面パネル.Refresh();\r
80                         this._Form.b未保存 = true;\r
81                 }\r
82                 public void tItemを選択する( int nItem番号0to1294 )\r
83                 {\r
84                         this.n現在選択中のItem番号0to1294 = nItem番号0to1294;\r
85                         this.listViewBMPリスト.Items[ nItem番号0to1294 ].Selected = true;\r
86                         this.listViewBMPリスト.Items[ nItem番号0to1294 ].Focused = true;\r
87                 }\r
88                 public void tファイル名の相対パス化( string str基本フォルダ名 )\r
89                 {\r
90                         for( int i = 1; i <= 0x50f; i++ )\r
91                         {\r
92                                 CBMP cbmp = this.BMPキャッシュ.tBMPをキャッシュから検索して返す( i );\r
93                                 if( ( cbmp != null ) && ( cbmp.strファイル名.Length > 0 ) )\r
94                                 {\r
95                                         try\r
96                                         {\r
97                                                 Uri uri = new Uri( str基本フォルダ名 );\r
98                                                 cbmp.strファイル名 = Uri.UnescapeDataString( uri.MakeRelativeUri( new Uri( cbmp.strファイル名 ) ).ToString() ).Replace( '/', '\\' );\r
99                                         }\r
100                                         catch( UriFormatException )\r
101                                         {\r
102                                         }\r
103                                 }\r
104                         }\r
105                 }\r
106                 public void t画像プロパティを開いて編集する( int nBMP番号1to1295, string str相対パスの基本フォルダ )\r
107                 {\r
108                         this._Form.dlgチップパレット.t一時的に隠蔽する();\r
109                         CBMP cbmp = this.tBMPをキャッシュから検索して返す・なければ新規生成する( nBMP番号1to1295 );\r
110                         ListViewItem item = cbmp.t現在の内容から新しいListViewItemを作成して返す();\r
111                         string directoryName = "";\r
112                         if( item.SubItems[ 3 ].Text.Length > 0 )\r
113                         {\r
114                                 directoryName = Path.GetDirectoryName( this._Form.strファイルの存在するディレクトリを絶対パスで返す( item.SubItems[ 3 ].Text ) );\r
115                         }\r
116                         C画像プロパティダイアログ c画像プロパティダイアログ = new C画像プロパティダイアログ( str相対パスの基本フォルダ, directoryName );\r
117                         c画像プロパティダイアログ.bmp = cbmp;\r
118                         c画像プロパティダイアログ.textBoxBMP番号.Text = item.SubItems[ 2 ].Text;\r
119                         c画像プロパティダイアログ.textBoxラベル.Text = item.SubItems[ 1 ].Text;\r
120                         c画像プロパティダイアログ.textBoxファイル.Text = item.SubItems[ 3 ].Text;\r
121                         c画像プロパティダイアログ.checkBoxBMPTEX.CheckState = c画像プロパティダイアログ.bmp.bテクスチャ ? CheckState.Checked : CheckState.Unchecked;\r
122                         c画像プロパティダイアログ.textBoxBMP番号.ForeColor = item.ForeColor;\r
123                         c画像プロパティダイアログ.textBoxBMP番号.BackColor = item.BackColor;\r
124                         if( c画像プロパティダイアログ.ShowDialog() == DialogResult.OK )\r
125                         {\r
126                                 CBMP bmp = c画像プロパティダイアログ.bmp;\r
127                                 CBMP cbmp3 = new CBMP();\r
128                                 cbmp3.nBMP番号1to1295 = c画像プロパティダイアログ.bmp.nBMP番号1to1295;\r
129                                 cbmp3.strラベル名 = c画像プロパティダイアログ.textBoxラベル.Text;\r
130                                 cbmp3.strファイル名 = c画像プロパティダイアログ.textBoxファイル.Text;\r
131                                 cbmp3.bテクスチャ = c画像プロパティダイアログ.checkBoxBMPTEX.Checked;\r
132                                 cbmp3.col文字色 = c画像プロパティダイアログ.textBoxBMP番号.ForeColor;\r
133                                 cbmp3.col背景色 = c画像プロパティダイアログ.textBoxBMP番号.BackColor;\r
134                                 if( !cbmp3.b内容が同じwith( bmp ) )\r
135                                 {\r
136                                         bmp = new CBMP();\r
137                                         bmp.tコピーfrom( c画像プロパティダイアログ.bmp );\r
138                                         this._Form.mgrUndoRedo管理者.tノードを追加する( new CUndoRedoセル<CBMP>( null, new DGUndoを実行する<CBMP>( this.tBMP編集のUndo ), new DGRedoを実行する<CBMP>( this.tBMP編集のRedo ), bmp, cbmp3 ) );\r
139                                         this._Form.tUndoRedo用GUIの有効・無効を設定する();\r
140                                         c画像プロパティダイアログ.bmp.tコピーfrom( cbmp3 );\r
141                                         if( this.tBMP番号に対応するListViewItemを返す( nBMP番号1to1295 ) != null )\r
142                                         {\r
143                                                 ListViewItem item2 = c画像プロパティダイアログ.bmp.t現在の内容から新しいListViewItemを作成して返す();\r
144                                                 item = this.tBMP番号に対応するListViewItemを返す( nBMP番号1to1295 );\r
145                                                 item.SubItems[ 0 ].Text = item2.SubItems[ 0 ].Text;\r
146                                                 item.SubItems[ 1 ].Text = item2.SubItems[ 1 ].Text;\r
147                                                 item.SubItems[ 2 ].Text = item2.SubItems[ 2 ].Text;\r
148                                                 item.SubItems[ 3 ].Text = item2.SubItems[ 3 ].Text;\r
149                                                 item.ForeColor = item2.ForeColor;\r
150                                                 item.BackColor = item2.BackColor;\r
151                                         }\r
152                                         this.listViewBMPリスト.Refresh();\r
153                                         this._Form.b未保存 = true;\r
154                                 }\r
155                         }\r
156                         this._Form.dlgチップパレット.t一時的な隠蔽を解除する();\r
157                 }\r
158                 public void t行交換のRedo( int n変更前のItem番号0to1294, int n変更後のItem番号0to1294 )\r
159                 {\r
160                         CUndoRedo管理.bUndoRedoした直後 = true;\r
161                         this.tItemを交換する( n変更前のItem番号0to1294, n変更後のItem番号0to1294 );\r
162                 }\r
163                 public void t行交換のUndo( int n変更前のItem番号0to1294, int n変更後のItem番号0to1294 )\r
164                 {\r
165                         CUndoRedo管理.bUndoRedoした直後 = true;\r
166                         this.tItemを交換する( n変更前のItem番号0to1294, n変更後のItem番号0to1294 );\r
167                 }\r
168                 public void t新規生成のRedo( CBMP bc生成前はNull, CBMP bc生成されたBMPの複製 )\r
169                 {\r
170                         int num = bc生成されたBMPの複製.nBMP番号1to1295;\r
171                         CBMP cbmp = this.BMPキャッシュ.tBMPをキャッシュから検索して返す・なければ新規生成する( num );\r
172                         cbmp.tコピーfrom( bc生成されたBMPの複製 );\r
173                         cbmp.tコピーto( this.listViewBMPリスト.Items[ num - 1 ] );\r
174                         this._Form.tタブを選択する( Cメインフォーム.Eタブ種別.BMP );\r
175                         this.listViewBMPリスト.Refresh();\r
176                 }\r
177                 public void t新規生成のUndo( CBMP bc生成前はNull, CBMP bc生成されたBMPの複製 )\r
178                 {\r
179                         int num = bc生成されたBMPの複製.nBMP番号1to1295;\r
180                         new CBMP().tコピーto( this.listViewBMPリスト.Items[ num - 1 ] );\r
181                         this.BMPキャッシュ.tBMPをキャッシュから削除する( num );\r
182                         this._Form.tタブを選択する( Cメインフォーム.Eタブ種別.BMP );\r
183                         this.listViewBMPリスト.Refresh();\r
184                 }\r
185 \r
186                 #region [ private ]\r
187                 //-----------------\r
188                 private Cメインフォーム _Form;\r
189                 private CBMPキャッシュ BMPキャッシュ = new CBMPキャッシュ();\r
190                 private ListView listViewBMPリスト;\r
191 \r
192                 private void tItemを交換する・BMPキャッシュ( int nItem番号1, int nItem番号2 )\r
193                 {\r
194                         int num = nItem番号1 + 1;\r
195                         int num2 = nItem番号2 + 1;\r
196                         CBMP bc = this.BMPキャッシュ.tBMPをキャッシュから検索して返す( num );\r
197                         CBMP cbmp2 = this.BMPキャッシュ.tBMPをキャッシュから検索して返す( num2 );\r
198                         CBMP cbmp3 = new CBMP();\r
199                         cbmp3.tコピーfrom( bc );\r
200                         bc.tコピーfrom( cbmp2 );\r
201                         bc.nBMP番号1to1295 = num;\r
202                         cbmp2.tコピーfrom( cbmp3 );\r
203                         cbmp2.nBMP番号1to1295 = num2;\r
204                 }\r
205                 private void tItemを交換する・ListViewItem( int nItem番号1, int nItem番号2 )\r
206                 {\r
207                         int num = nItem番号1 + 1;\r
208                         int num2 = nItem番号2 + 1;\r
209                         CBMP cbmp = new CBMP();\r
210                         cbmp.tコピーfrom( this.listViewBMPリスト.Items[ nItem番号1 ] );\r
211                         cbmp.nBMP番号1to1295 = num2;\r
212                         CBMP cbmp2 = new CBMP();\r
213                         cbmp2.tコピーfrom( this.listViewBMPリスト.Items[ nItem番号2 ] );\r
214                         cbmp2.nBMP番号1to1295 = num;\r
215                         cbmp2.tコピーto( this.listViewBMPリスト.Items[ nItem番号1 ] );\r
216                         cbmp.tコピーto( this.listViewBMPリスト.Items[ nItem番号2 ] );\r
217                 }\r
218                 private void tItemを交換する・カーソル移動( int nItem番号1, int nItem番号2 )\r
219                 {\r
220                         this.tItemを選択する( nItem番号2 );\r
221                 }\r
222                 private void tItemを交換する・チップパレット( int nItem番号1, int nItem番号2 )\r
223                 {\r
224                         this._Form.dlgチップパレット.tパレットセルの番号を置換する( 1, nItem番号1 + 1, nItem番号2 + 1 );\r
225                 }\r
226                 private void tItemを交換する・レーン割付チップ( int nItem番号1, int nItem番号2 )\r
227                 {\r
228                         for( int i = 0; i < this._Form.mgr譜面管理者.listレーン.Count; i++ )\r
229                         {\r
230                                 Cレーン cレーン = this._Form.mgr譜面管理者.listレーン[ i ];\r
231                                 if( cレーン.eレーン種別 == Cレーン.E種別.BMP )\r
232                                 {\r
233                                         if( cレーン.nレーン割付チップ・表0or1to1295 == ( nItem番号1 + 1 ) )\r
234                                         {\r
235                                                 cレーン.nレーン割付チップ・表0or1to1295 = nItem番号2 + 1;\r
236                                         }\r
237                                         else if( cレーン.nレーン割付チップ・表0or1to1295 == ( nItem番号2 + 1 ) )\r
238                                         {\r
239                                                 cレーン.nレーン割付チップ・表0or1to1295 = nItem番号1 + 1;\r
240                                         }\r
241                                         if( cレーン.nレーン割付チップ・裏0or1to1295 == ( nItem番号1 + 1 ) )\r
242                                         {\r
243                                                 cレーン.nレーン割付チップ・裏0or1to1295 = nItem番号2 + 1;\r
244                                         }\r
245                                         else if( cレーン.nレーン割付チップ・裏0or1to1295 == ( nItem番号2 + 1 ) )\r
246                                         {\r
247                                                 cレーン.nレーン割付チップ・裏0or1to1295 = nItem番号1 + 1;\r
248                                         }\r
249                                 }\r
250                         }\r
251                 }\r
252                 private void tItemを交換する・譜面上のチップ( int nItem番号1, int nItem番号2 )\r
253                 {\r
254                         foreach( KeyValuePair<int, C小節> pair in this._Form.mgr譜面管理者.dic小節 )\r
255                         {\r
256                                 C小節 c小節 = pair.Value;\r
257                                 for( int i = 0; i < c小節.listチップ.Count; i++ )\r
258                                 {\r
259                                         Cチップ cチップ = c小節.listチップ[ i ];\r
260                                         if( this._Form.mgr譜面管理者.listレーン[ cチップ.nレーン番号0to ].eレーン種別 == Cレーン.E種別.BMP )\r
261                                         {\r
262                                                 if( cチップ.n値・整数1to1295 == ( nItem番号1 + 1 ) )\r
263                                                 {\r
264                                                         cチップ.n値・整数1to1295 = nItem番号2 + 1;\r
265                                                 }\r
266                                                 else if( cチップ.n値・整数1to1295 == ( nItem番号2 + 1 ) )\r
267                                                 {\r
268                                                         cチップ.n値・整数1to1295 = nItem番号1 + 1;\r
269                                                 }\r
270                                         }\r
271                                 }\r
272                         }\r
273                 }\r
274                 //-----------------\r
275                 #endregion\r
276         }\r
277 }\r