OSDN Git Service

#28263 DTX2WAVの基本機能を実装。コマンドラインオプションで、WAV録音が可能。
[dtxmania/dtxmania.git] / DTXMania / コード / 全体 / CDTXMania.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Globalization;
4 using System.Text;
5 using System.Windows.Forms;
6 using System.Drawing;
7 using System.Diagnostics;
8 using System.IO;
9 using System.Threading;
10 using System.Management;
11 using SharpDX;
12 using SharpDX.Direct3D9;
13 using FDK;
14 using SampleFramework;
15 using System.Runtime.Serialization;
16 using System.Xml;
17
18 using Point = System.Drawing.Point;
19 using Color = System.Drawing.Color;
20
21 namespace DTXMania
22 {
23         internal class CDTXMania : Game
24         {
25                 // プロパティ
26                 #region [ properties ]
27                 public static readonly string VERSION = "112(180201)";
28                 public static readonly string SLIMDXDLL = "c_net20x86_Jun2010";
29                 public static readonly string D3DXDLL = "d3dx9_43.dll";     // June 2010
30                                                                                                                                                                                                                                                                 //public static readonly string D3DXDLL = "d3dx9_42.dll";       // February 2010
31                                                                                                                                                                                                                                                                 //public static readonly string D3DXDLL = "d3dx9_41.dll";       // March 2009
32                 private static CDTXMania instance = new CDTXMania();
33
34                 public static CDTXMania Instance
35                 {
36                         get
37                         {
38                                 return instance;
39                         }
40                 }
41                 public C文字コンソール act文字コンソール { get; private set; }
42                 public bool bコンパクトモード { get; private set; }
43                 public CConfigXml ConfigIni;
44                 public CResources Resources;
45
46                 public CDTX DTX
47                 {
48                         get
49                         {
50                                 return dtx;
51                         }
52                         set
53                         {
54                                 if ((dtx != null) && (Instance != null))
55                                 {
56                                         dtx.On非活性化();
57                                         Instance.listトップレベルActivities.Remove(dtx);
58                                 }
59                                 dtx = value;
60                                 if ((dtx != null) && (Instance != null))
61                                 {
62                                         Instance.listトップレベルActivities.Add(dtx);
63                                 }
64                         }
65                 }
66                 public CFPS FPS { get; private set; }
67                 public CInput管理 Input管理 { get; private set; }
68                 #region [ 入力範囲ms ]
69                 public int nPerfect範囲ms
70                 {
71                         get
72                         {
73                                 if (stage選曲.r確定された曲 != null)
74                                 {
75                                         C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
76                                         if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nPerfect範囲ms >= 0))
77                                         {
78                                                 return c曲リストノード.nPerfect範囲ms;
79                                         }
80                                 }
81                                 return ConfigIni.nHitRange.Perfect;
82                         }
83                 }
84                 public int nGreat範囲ms
85                 {
86                         get
87                         {
88                                 if (stage選曲.r確定された曲 != null)
89                                 {
90                                         C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
91                                         if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nGreat範囲ms >= 0))
92                                         {
93                                                 return c曲リストノード.nGreat範囲ms;
94                                         }
95                                 }
96                                 return ConfigIni.nHitRange.Great;
97                         }
98                 }
99                 public int nGood範囲ms
100                 {
101                         get
102                         {
103                                 if (stage選曲.r確定された曲 != null)
104                                 {
105                                         C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
106                                         if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nGood範囲ms >= 0))
107                                         {
108                                                 return c曲リストノード.nGood範囲ms;
109                                         }
110                                 }
111                                 return ConfigIni.nHitRange.Good;
112                         }
113                 }
114                 public int nPoor範囲ms
115                 {
116                         get
117                         {
118                                 if (stage選曲.r確定された曲 != null)
119                                 {
120                                         C曲リストノード c曲リストノード = stage選曲.r確定された曲.r親ノード;
121                                         if (((c曲リストノード != null) && (c曲リストノード.eノード種別 == C曲リストノード.Eノード種別.BOX)) && (c曲リストノード.nPoor範囲ms >= 0))
122                                         {
123                                                 return c曲リストノード.nPoor範囲ms;
124                                         }
125                                 }
126                                 return ConfigIni.nHitRange.Poor;
127                         }
128                 }
129                 #endregion
130                 public CPad Pad { get; private set; }
131                 public Random Random { get; private set; }
132                 public CSkin Skin { get; private set; }
133                 public CSongs管理 Songs管理 { get; set; }// 2012.1.26 yyagi private解除 CStage起動でのdesirialize読み込みのため
134                 public CEnumSongs EnumSongs { get; private set; }
135                 public CActEnumSongs actEnumSongs { get; private set; }
136                 public CActFlushGPU actFlushGPU { get; private set; }
137
138                 public CSound管理 Sound管理 { get; private set; }
139                 public CStage起動 stage起動 { get; private set; }
140                 public CStageタイトル stageタイトル { get; private set; }
141                 public CStageコンフィグ stageコンフィグ { get; private set; }
142                 public CStage選曲 stage選曲 { get; private set; }
143                 public CStage曲読み込み stage曲読み込み { get; private set; }
144                 public CStage演奏画面共通 stage演奏画面 { get; private set; }
145                 public CStage結果 stage結果 { get; private set; }
146                 public CStageChangeSkin stageChangeSkin { get; private set; }
147                 public CStage終了 stage終了 { get; private set; }
148                 public CStage r現在のステージ = null;
149                 public CStage r直前のステージ = null;
150                 public string strEXEのあるフォルダ { get; private set; }
151                 public string strコンパクトモードファイル { get; private set; }
152                 public CTimer Timer { get; private set; }
153                 public Format TextureFormat = Format.A8R8G8B8;
154                 internal IPluginActivity act現在入力を占有中のプラグイン = null;
155                 public bool bApplicationActive { get; private set; }
156                 public bool b次のタイミングで垂直帰線同期切り替えを行う { get; set; }
157                 public bool b次のタイミングで全画面_ウィンドウ切り替えを行う { get; set; }
158                 public Coordinates.CCoordinates Coordinates;
159                 public Device Device
160                 {
161                         get
162                         {
163                                 return base.GraphicsDeviceManager.Direct3D9.Device;
164                         }
165                 }
166                 public CPluginHost PluginHost { get; private set; }
167                 public List<STPlugin> listプラグイン = new List<STPlugin>();
168
169                 private Size currentClientSize { get; set; }    // #23510 2010.10.27 add yyagi to keep current window size
170                                                                                                                                                                                                                 //              public static CTimer ct;
171                 public IntPtr WindowHandle                  // 2012.10.24 yyagi; to add ASIO support
172                 {
173                         get
174                         {
175                                 return base.Window.Handle;
176                         }
177                 }
178         public CDTXVmode DTXVmode;                       // #28821 2014.1.23 yyagi
179         public CDTX2WAVmode DTX2WAVmode;
180         public CCommandParse CommandParse;
181         #endregion
182
183         // コンストラクタ
184
185         private CDTXMania()
186                 {
187                 }
188
189                 public void InitializeInstance()
190                 {
191                         #region [ strEXEのあるフォルダを決定する ]
192                         // BEGIN #23629 2010.11.13 from: デバッグ時は Application.ExecutablePath が ($SolutionDir)/bin/x86/Debug/ などになり System/ の読み込みに失敗するので、カレントディレクトリを採用する。(プロジェクトのプロパティ→デバッグ→作業ディレクトリが有効になる)
193 #if DEBUG
194                         strEXEのあるフォルダ = Environment.CurrentDirectory + @"\";
195                         //strEXEのあるフォルダ = Path.GetDirectoryName( Environment.GetCommandLineArgs()[ 0 ] ) + @"\";
196 #else
197                         strEXEのあるフォルダ = Path.GetDirectoryName(Application.ExecutablePath) + @"\"; // #23629 2010.11.9 yyagi: set correct pathname where DTXManiaGR.exe is.
198 #endif
199                         // END #23629 2010.11.13 from
200                         #endregion
201
202                         #region [ 言語リソースの初期化 ]
203                         Trace.TraceInformation("言語リソースの初期化を行います。");
204                         Trace.Indent();
205                         try
206                         {
207                                 Resources = new CResources();
208                                 Resources.LoadResources("");
209                                 Trace.TraceInformation("言語リソースの初期化を完了しました。");
210                         }
211                         finally
212                         {
213                                 Trace.Unindent();
214                         }
215                         #endregion
216
217                         #region [ Config.ini の読込み ]
218                         ConfigIni = new CConfigXml();
219                         CDTXMania.Instance.LoadConfig();
220                         // #28200 2011.5.1 yyagi
221                         this.Window.EnableSystemMenu = CDTXMania.Instance.ConfigIni.bIsEnabledSystemMenu;
222                         // 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
223                         #endregion
224
225
226                         #region[座標値読み込み]
227                         Coordinates = new Coordinates.CCoordinates();
228                         UpdateCoordinates();
229                         //Coordinates = (DTXMania.Coordinates.CCoordinates) CDTXMania.DeserializeXML( strEXEのあるフォルダ + "Coordinates.xml", typeof( DTXMania.Coordinates.CCoordinates ) );
230                         //if ( Coordinates == null )
231                         //{
232                         //      if ( File.Exists( strEXEのあるフォルダ + "Coordinates.xml" ) )
233                         //      {
234                         //              Trace.TraceInformation( "Coordinates.xmlファイルは存在します。" );
235                         //      }
236                         //      Trace.TraceInformation( "Coordiantes.xmlファイルの読み込みができませんでした。無視して進めます。" );
237                         //      Coordinates = new Coordinates.CCoordinates();
238                         //}
239                         #endregion
240
241                         #region [ ログ出力開始 ]
242                         Trace.AutoFlush = true;
243                         if (ConfigIni.bLog)
244                         {
245                                 try
246                                 {
247                                         Trace.Listeners.Add(new CTraceLogListener(new StreamWriter(System.IO.Path.Combine(strEXEのあるフォルダ, "DTXManiaLog.txt"), false, Encoding.GetEncoding("utf-16"))));
248                                 }
249                                 catch (System.UnauthorizedAccessException)          // #24481 2011.2.20 yyagi
250                                 {
251                                         Resources.Language = instance.ConfigIni.strLanguage;
252                                         string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
253                                         MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
254                                         Environment.Exit(1);
255                                 }
256                         }
257                         Trace.WriteLine("");
258                         Trace.WriteLine("DTXMania powered by YAMAHA Silent Session Drums");
259                         Trace.WriteLine(string.Format("Release: {0}", VERSION));
260                         Trace.WriteLine("");
261                         Trace.TraceInformation("----------------------");
262                         Trace.TraceInformation("■ アプリケーションの初期化");
263
264                         PutSystemLog();
265
266
267                         #endregion
268
269                         #region [ 言語の設定 ]
270                         Trace.TraceInformation("言語情報の読み込みを開始します。");
271                         //Debug.WriteLine( "language=" + Resources.Language );
272                         //Debug.WriteLine( "settings=" + instance.ConfigIni.strLanguage );
273                         Resources.Language = instance.ConfigIni.strLanguage;
274                         Trace.TraceInformation("言語を{0}に設定しました。", Resources.Language);
275
276                         #endregion
277
278                         #region [ DTXVmodeクラス, DTX2WAVmodeクラス, CommandParseクラス の初期化 ]
279                         //Trace.TraceInformation( "DTXVモードの初期化を行います。" );
280                         //Trace.Indent();
281                         try
282                         {
283                                 DTXVmode = new CDTXVmode();
284                                 DTXVmode.Enabled = false;
285                 //Trace.TraceInformation( "DTXVモードの初期化を完了しました。" );
286
287                 DTX2WAVmode = new CDTX2WAVmode();
288                 //Trace.TraceInformation( "DTX2WAVモードの初期化を完了しました。" );
289
290                 CommandParse = new CCommandParse();
291                 //Trace.TraceInformation( "CommandParseの初期化を完了しました。" );
292             }
293             finally
294                         {
295                                 //Trace.Unindent();
296                         }
297                         #endregion
298                         #region [ コンパクトモードスイッチの有無、もしくは、DTXViewerとしての起動 ]
299                         bコンパクトモード = false;
300                         strコンパクトモードファイル = "";
301                         string[] commandLineArgs = Environment.GetCommandLineArgs();
302                         if ((commandLineArgs != null) && (commandLineArgs.Length > 1))
303                         {
304                                 bコンパクトモード = true;
305                                 string arg = "";
306
307                                 for (int i = 1; i < commandLineArgs.Length; i++)
308                                 {
309                                         if (i != 1)
310                                         {
311                                                 arg += " " + "\"" + commandLineArgs[i] + "\"";
312                                         }
313                                         else
314                                         {
315                                                 arg += commandLineArgs[i];
316                                         }
317                                 }
318                                 CommandParse.ParseArguments(arg, ref DTXVmode, ref DTX2WAVmode);
319                                 if (DTXVmode.Enabled)
320                                 {
321                                         DTXVmode.Refreshed = false;                             // 初回起動時は再読み込みに走らせない
322                                         strコンパクトモードファイル = DTXVmode.filename;
323                                         switch (DTXVmode.soundDeviceType)                       // サウンド再生方式の設定
324                                         {
325                                                 case ESoundDeviceType.DirectSound:
326                                                         ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.DSound;
327                                                         break;
328                                                 case ESoundDeviceType.ExclusiveWASAPI:
329                                                         ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Exclusive;
330                                                         break;
331                                                 case ESoundDeviceType.SharedWASAPI:
332                                                         ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Shared;
333                                                         break;
334                                                 case ESoundDeviceType.ASIO:
335                                                         ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.ASIO;
336                                                         ConfigIni.strASIODevice.Index = DTXVmode.nASIOdevice;
337                                                         break;
338                                         }
339
340                                         CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
341                                         CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
342                                         if (DTXVmode.GRmode)
343                                         {
344                                                 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
345                                         }
346                                         else
347                                         {
348                                                 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
349                                         }
350
351                                         CDTXMania.Instance.ConfigIni.bFullScreen.Value = false;
352                                         CDTXMania.Instance.ConfigIni.rcWindow_backup = CDTXMania.Instance.ConfigIni.rcWindow;       // #36612 2016.9.12 yyagi
353                                         CDTXMania.Instance.ConfigIni.rcWindow.W = CDTXMania.Instance.ConfigIni.rcViewerWindow.W;
354                                         CDTXMania.Instance.ConfigIni.rcWindow.H = CDTXMania.Instance.ConfigIni.rcViewerWindow.H;
355                                         CDTXMania.Instance.ConfigIni.rcWindow.X = CDTXMania.Instance.ConfigIni.rcViewerWindow.X;
356                                         CDTXMania.Instance.ConfigIni.rcWindow.Y = CDTXMania.Instance.ConfigIni.rcViewerWindow.Y;
357                                 }
358                                 else if (DTX2WAVmode.Enabled)
359                                 {
360                                         strコンパクトモードファイル = DTX2WAVmode.dtxfilename;
361                                         FDK.CSound管理.strRecordInputDTXfilename = DTX2WAVmode.dtxfilename;
362                                         FDK.CSound管理.strRecordOutFilename = DTX2WAVmode.outfilename;
363                                         FDK.CSound管理.strRecordFileType = DTX2WAVmode.Format.ToString();
364                                         #region [ 録音用の本体設定 ]
365                                         ConfigIni.nSoundDeviceType.Value = ESoundDeviceTypeForConfig.WASAPI_Shared;
366                                         CDTXMania.Instance.ConfigIni.bVSyncWait.Value = false;
367                                         CDTXMania.Instance.ConfigIni.bTimeStretch.Value = false;
368                                         CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
369
370                                         CDTXMania.Instance.ConfigIni.bFullScreen.Value = false;
371                                         CDTXMania.Instance.ConfigIni.rcWindow_backup = CDTXMania.Instance.ConfigIni.rcWindow;
372                                         CDTXMania.Instance.ConfigIni.rcWindow.W = CDTXMania.Instance.ConfigIni.rcViewerWindow.W;
373                                         CDTXMania.Instance.ConfigIni.rcWindow.H = CDTXMania.Instance.ConfigIni.rcViewerWindow.H;
374                                         CDTXMania.Instance.ConfigIni.rcWindow.X = CDTXMania.Instance.ConfigIni.rcViewerWindow.X;
375                                         CDTXMania.Instance.ConfigIni.rcWindow.Y = CDTXMania.Instance.ConfigIni.rcViewerWindow.Y;
376
377                                         //全オート
378                                         CDTXMania.instance.ConfigIni.bAutoPlay.LC.Value = true;
379                                         CDTXMania.instance.ConfigIni.bAutoPlay.HH.Value = true;
380                                         CDTXMania.instance.ConfigIni.bAutoPlay.HHO.Value = true;
381                                         CDTXMania.instance.ConfigIni.bAutoPlay.SD.Value = true;
382                                         CDTXMania.instance.ConfigIni.bAutoPlay.BD.Value = true;
383                                         CDTXMania.instance.ConfigIni.bAutoPlay.HT.Value = true;
384                                         CDTXMania.instance.ConfigIni.bAutoPlay.LT.Value = true;
385                                         CDTXMania.instance.ConfigIni.bAutoPlay.FT.Value = true;
386                                         CDTXMania.instance.ConfigIni.bAutoPlay.CY.Value = true;
387                                         CDTXMania.instance.ConfigIni.bAutoPlay.RD.Value = true;
388
389                                         CDTXMania.instance.ConfigIni.bAutoPlay.GtR.Value = true;
390                                         CDTXMania.instance.ConfigIni.bAutoPlay.GtG.Value = true;
391                                         CDTXMania.instance.ConfigIni.bAutoPlay.GtB.Value = true;
392                                         CDTXMania.instance.ConfigIni.bAutoPlay.GtPick.Value = true;
393                                         //CDTXMania.instance.ConfigIni.bAutoPlay.GtWail.Value = true;  // 無くてもよい 処理不可削減のため、敢えてWailはAutoにしない
394                                         CDTXMania.instance.ConfigIni.bAutoPlay.BsR.Value = true;
395                                         CDTXMania.instance.ConfigIni.bAutoPlay.BsG.Value = true;
396                                         CDTXMania.instance.ConfigIni.bAutoPlay.BsB.Value = true;
397                                         CDTXMania.instance.ConfigIni.bAutoPlay.BsPick.Value = true;
398                                         //CDTXMania.instance.ConfigIni.bAutoPlay.BsWail.Value = true;
399
400                                         //FillInオフ, 歓声オフ
401                                         CDTXMania.instance.ConfigIni.bFillin.Value = false;
402                                         CDTXMania.instance.ConfigIni.bAudience.Value = false;
403                                         //ストイックモード
404                                         CDTXMania.instance.ConfigIni.bStoicMode.Value = false;
405                                         //チップ非表示
406                                         CDTXMania.instance.ConfigIni.eSudHidInv.Drums.Value = ESudHidInv.FullInv;
407                                         CDTXMania.instance.ConfigIni.eSudHidInv.Guitar.Value = ESudHidInv.FullInv;
408                                         CDTXMania.instance.ConfigIni.eSudHidInv.Bass.Value = ESudHidInv.FullInv;
409
410                                         // Dark=Full
411                                         CDTXMania.instance.ConfigIni.eDark.Value = EDark.Full;
412
413                                         //多重再生数=4
414                                         CDTXMania.instance.ConfigIni.nPolyphonicSounds.Value = 4;
415
416                                         //再生速度x1
417                                         CDTXMania.instance.ConfigIni.nPlaySpeed.Value = 20;
418
419                                         //メトロノーム音量0
420                                         CDTXMania.instance.ConfigIni.eClickType.Value = EClickType.Off;
421                                         CDTXMania.instance.ConfigIni.nClickHighVolume.Value = 0;
422                                         CDTXMania.instance.ConfigIni.nClickLowVolume.Value = 0;
423
424                                         //自動再生音量=100
425                                         CDTXMania.instance.ConfigIni.nAutoVolume.Value = 100;
426                                         CDTXMania.instance.ConfigIni.nChipVolume.Value = 100;
427
428                                         //マスターボリューム100
429                                         CDTXMania.instance.ConfigIni.nMasterVolume.Value = 100;
430
431                                         //StageFailedオフ
432                                         CDTXMania.instance.ConfigIni.bStageFailed.Value = false;
433
434                                         //グラフ無効
435                                         CDTXMania.instance.ConfigIni.bGraph.Drums.Value = false;
436                                         CDTXMania.instance.ConfigIni.bGraph.Guitar.Value = false;
437                                         CDTXMania.instance.ConfigIni.bGraph.Bass.Value = false;
438
439                                         //コンボ非表示,判定非表示
440                                         CDTXMania.instance.ConfigIni.bDisplayCombo.Drums.Value = false;
441                                         CDTXMania.instance.ConfigIni.bDisplayCombo.Guitar.Value = false;
442                                         CDTXMania.instance.ConfigIni.bDisplayCombo.Bass.Value = false;
443                                         CDTXMania.instance.ConfigIni.bDisplayJudge.Drums.Value = false;
444                                         CDTXMania.instance.ConfigIni.bDisplayJudge.Guitar.Value = false;
445                                         CDTXMania.instance.ConfigIni.bDisplayJudge.Bass.Value = false;
446
447
448                                         //デバッグ表示オフ
449                                         //CDTXMania.instance.ConfigIni.b演奏情報を表示する = false;
450                                         CDTXMania.instance.ConfigIni.bDebugInfo.Value = false;
451
452                                         //BGAオフ, AVIオフ
453                                         CDTXMania.instance.ConfigIni.bBGA.Value = false;
454                                         CDTXMania.instance.ConfigIni.bAVI.Value = false;
455
456                                         //BGMオン、チップ音オン
457                                         CDTXMania.instance.ConfigIni.bBGMPlay.Value = true;
458                                         CDTXMania.instance.ConfigIni.bDrumsHitSound.Value = true;
459                                         #endregion
460                                 }
461                                 else                                                        // 通常のコンパクトモード
462                                 {
463                                         strコンパクトモードファイル = commandLineArgs[1];
464                                 }
465
466                                 if (!File.Exists(strコンパクトモードファイル))      // #32985 2014.1.23 yyagi 
467                                 {
468                                         Trace.TraceError("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。[{0}]", strコンパクトモードファイル);
469 #if DEBUG
470                                         Environment.Exit(-1);
471 #else
472                                         if (strコンパクトモードファイル == "")      // DTXMania未起動状態で、DTXCで再生停止ボタンを押した場合は、何もせず終了
473                                         {
474                                                 Environment.Exit(-1);
475                                         }
476                                         else
477                                         {
478                                                 throw new FileNotFoundException("コンパクトモードで指定されたファイルが見つかりません。DTXManiaを終了します。", strコンパクトモードファイル);
479                                         }
480 #endif
481                                 }
482                                 if (DTXVmode.Enabled)
483                                 {
484                                         Trace.TraceInformation("DTXVモードで起動します。[{0}]", strコンパクトモードファイル);
485                                 }
486                                 else
487                                 {
488                                         Trace.TraceInformation("コンパクトモードで起動します。[{0}]", strコンパクトモードファイル);
489                                 }
490                         }
491                         else
492                         {
493                                 Trace.TraceInformation("通常モードで起動します。");
494                         }
495                         #endregion
496
497                         #region [ 現在の電源プランをバックアップし、CONFIGのHighPower=ONの場合は HighPerformanceに変更 ]
498                         CPowerPlan.BackupCurrentPowerPlan();
499                         if (CDTXMania.Instance.ConfigIni.bForceHighPowerPlan)
500                         {
501                                 CPowerPlan.ChangeHighPerformance();
502                         }
503                         #endregion
504
505                         #region [ Input管理 の初期化 ]
506                         Trace.TraceInformation("DirectInput, MIDI入力の初期化を行います。");
507                         Trace.Indent();
508                         try
509                         {
510                                 bool bUseMIDIIn = !DTXVmode.Enabled;
511                                 Input管理 = new CInput管理(base.Window.Handle, bUseMIDIIn);
512                                 foreach (IInputDevice device in Input管理.list入力デバイス)
513                                 {
514                                         if ((device.e入力デバイス種別 == E入力デバイス種別.Joystick) && !ConfigIni.dicJoystick.Value.ContainsValue(device.GUID))
515                                         {
516                                                 int key = 0;
517                                                 while (ConfigIni.dicJoystick.Value.ContainsKey(key))
518                                                 {
519                                                         key++;
520                                                 }
521                                                 ConfigIni.dicJoystick.Value.Add(key, device.GUID);
522                                         }
523                                 }
524                                 foreach (IInputDevice device2 in Input管理.list入力デバイス)
525                                 {
526                                         if (device2.e入力デバイス種別 == E入力デバイス種別.Joystick)
527                                         {
528                                                 foreach (KeyValuePair<int, string> pair in ConfigIni.dicJoystick.Value)
529                                                 {
530                                                         if (device2.GUID.Equals(pair.Value))
531                                                         {
532                                                                 ((CInputJoystick)device2).SetID(pair.Key);
533                                                                 break;
534                                                         }
535                                                 }
536                                                 continue;
537                                         }
538                                 }
539                                 Trace.TraceInformation("DirectInput の初期化を完了しました。");
540                         }
541                         catch (Exception exception2)
542                         {
543                                 Trace.TraceError(exception2.Message);
544                                 Trace.TraceError("DirectInput, MIDI入力の初期化に失敗しました。");
545
546                                 string mes = CDTXMania.Instance.Resources.Explanation("strErrorLogWrite");
547                                 MessageBox.Show(mes, "DTXMania boot error", MessageBoxButtons.OK, MessageBoxIcon.Error);
548                                 Environment.Exit(1);
549                         }
550                         finally
551                         {
552                                 Trace.Unindent();
553                         }
554                         #endregion
555
556                         #region [ ウィンドウ初期化 ]
557                         // #30675 2013.02.04 ikanick add
558                         base.Window.StartPosition = FormStartPosition.Manual;
559                         base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
560                         // 事前にDTXVmodeの実体を作っておくこと
561                         base.Window.Text = this.strWindowTitle;
562                         //base.Window.StartPosition = FormStartPosition.Manual;
563                         //base.Window.Location = new Point(ConfigIni.rcWindow.X, ConfigIni.rcWindow.Y);
564
565                         // #34510 yyagi 2010.10.31 to change window size got from Config.ini
566                         base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
567 #if !WindowedFullscreen
568                         if (!ConfigIni.bウィンドウモード)                                               // #23510 2010.11.02 yyagi: add; to recover window size in case bootup with fullscreen mode
569                         {                                                                                                               // #30666 2013.02.02 yyagi: currentClientSize should be always made
570 #endif
571                         currentClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
572 #if !WindowedFullscreen
573                         }
574 #endif
575                         // #23510 2010.11.04 yyagi: to support maximizing window
576                         base.Window.MaximizeBox = true;
577                         // #23510 2010.10.27 yyagi: changed from FixedDialog to Sizable, to support window resize
578                         base.Window.FormBorderStyle = FormBorderStyle.Sizable;
579                         // #30666 2013.02.02 yyagi: moved the code to t全画面・ウインドウモード切り替え()
580                         base.Window.ShowIcon = true;
581                         base.Window.Icon = Properties.Resources.dtx;
582                         base.Window.KeyDown += new KeyEventHandler(this.Window_KeyDown);
583                         base.Window.MouseUp += new MouseEventHandler(this.Window_MouseUp);
584                         // #23510 2010.11.13 yyagi: to go fullscreen mode
585                         base.Window.MouseDoubleClick += new MouseEventHandler(this.Window_MouseDoubleClick);
586                         // #23510 2010.11.20 yyagi: to set resized window size in Config.ini
587                         base.Window.ResizeEnd += new EventHandler(this.Window_ResizeEnd);
588                         base.Window.ApplicationActivated += new EventHandler(this.Window_ApplicationActivated);
589                         base.Window.ApplicationDeactivated += new EventHandler(this.Window_ApplicationDeactivated);
590                         base.Window.MouseMove += new MouseEventHandler(this.Window_MouseMove);
591                         #endregion
592
593                         #region [ Direct3D9Exを使うかどうか判定 ]
594                         #endregion
595
596                         #region [ Direct3D9 デバイスの生成 ]
597                         DeviceSettings settings = new DeviceSettings();
598 #if WindowedFullscreen
599                         // #30666 2013.2.2 yyagi: Fullscreenmode is "Maximized window" mode
600                         settings.Windowed = true;
601 #else
602                         settings.Windowed = ConfigIni.bウィンドウモード;
603 #endif
604                         settings.BackBufferWidth = SampleFramework.GameWindowSize.Width;
605                         settings.BackBufferHeight = SampleFramework.GameWindowSize.Height;
606                         settings.EnableVSync = ConfigIni.bVSyncWait;
607                         //settings.MultisampleType = MultisampleType.FourSamples;
608                         //settings.MultisampleQuality = 3;
609                         //settings.MultisampleType = MultisampleType.NonMaskable;
610                         //settings.Multithreaded = true;
611
612
613                         try
614                         {
615                                 base.GraphicsDeviceManager.ChangeDevice(settings);
616                         }
617                         catch (DeviceCreationException e)
618                         {
619                                 Trace.TraceError(e.ToString());
620                                 MessageBox.Show(e.Message + e.ToString(), "DTXMania failed to boot: DirectX9 Initialize Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
621                                 Environment.Exit(-1);
622                         }
623                         Trace.TraceInformation("DeviceCaps       = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps.ToString());
624                         Trace.TraceInformation("DeviceCaps2      = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.DeviceCaps2.ToString());
625                         Trace.TraceInformation("MaxTextureWidth  = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureWidth);
626                         Trace.TraceInformation("MaxTextureHeight = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.MaxTextureHeight);
627                         Trace.TraceInformation("TextureCaps      = " + base.GraphicsDeviceManager.Direct3D9.Device.Capabilities.TextureCaps.ToString());
628                         Trace.TraceInformation("DeviceInformation= " + base.GraphicsDeviceManager.DeviceInformation.ToString());
629                         Trace.TraceInformation("DeviceStatics    = " + base.GraphicsDeviceManager.DeviceStatistics.ToString());
630
631                         base.IsFixedTimeStep = false;
632                         //                      base.TargetElapsedTime = TimeSpan.FromTicks( 10000000 / 75 );
633                         // #23510 2010.10.31 yyagi: to recover window size. width and height are able to get from Config.ini.
634                         base.Window.ClientSize = new Size(ConfigIni.rcWindow.W, ConfigIni.rcWindow.H);
635                         // #23568 2010.11.3 yyagi: to support valiable sleep value when !IsActive
636                         base.InactiveSleepTime = TimeSpan.FromMilliseconds((float)(ConfigIni.nSleepUnfocusMs));
637                         // #23568 2010.11.4 ikanick changed ( 1 -> ConfigIni )
638 #if WindowedFullscreen
639                         // #30666 2013.2.2 yyagi: finalize settings for "Maximized window mode"
640                         this.t全画面_ウィンドウモード切り替え();
641 #endif
642                         actFlushGPU = new CActFlushGPU();
643                         #endregion
644
645                         DTX = null;
646
647                         #region [ Skin の初期化 ]
648                         Trace.TraceInformation("スキンの初期化を行います。");
649                         Trace.Indent();
650                         try
651                         {
652                                 Skin = new CSkin(
653                                         CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath,
654                                         CDTXMania.Instance.ConfigIni.bUseBoxDefSkin);
655                                 // 旧指定のSkinフォルダが消滅していた場合に備える
656                                 CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value = CDTXMania.Instance.Skin.GetCurrentSkinSubfolderFullName(true);
657                                 Trace.TraceInformation("スキンの初期化を完了しました。");
658                         }
659                         catch
660                         {
661                                 Trace.TraceInformation("スキンの初期化に失敗しました。");
662                                 throw;
663                         }
664                         finally
665                         {
666                                 Trace.Unindent();
667                         }
668
669                         #region [ Skin配下にある言語リソースの確認と初期化 ]
670                         Trace.TraceInformation("スキンフォルダに言語リソースがないか確認します。");
671                         Trace.Indent();
672                         try
673                         {
674                                 Resources.csvCurrentPath = CDTXMania.Instance.ConfigIni.strSystemSkinSubfolderPath.Value;
675                                 Trace.TraceInformation("Skin Path:" + Resources.csvCurrentPath);
676
677                                 bool ret = Resources.LoadResources(instance.ConfigIni.strLanguage);
678                                 if (ret)
679                                 {
680                                         Trace.TraceInformation("スキンフォルダ内に言語リソースが見つかりました。この言語リソースを使用します。");
681                                 }
682                                 else
683                                 {
684                                         Trace.TraceInformation("スキンフォルダ内の言語リソースを使用できません。既定の言語リソースを使用します。");
685
686                                 }
687                         }
688                         finally
689                         {
690                                 Trace.Unindent();
691                         }
692                         #endregion
693
694                         #endregion
695
696                         #region [ Timer の初期化 ]
697                         Trace.TraceInformation("タイマの初期化を行います。");
698                         Trace.Indent();
699                         try
700                         {
701                                 Timer = new CTimer(CTimer.E種別.MultiMedia);
702                                 Trace.TraceInformation("タイマの初期化を完了しました。");
703                         }
704                         finally
705                         {
706                                 Trace.Unindent();
707                         }
708                         #endregion
709
710                         #region [ マウス消去用のクラスを初期化 ]
711                         cMouseHideControl = new CMouseHideControl();
712                         #endregion
713
714                         #region [ FPS カウンタの初期化 ]
715                         Trace.TraceInformation("FPSカウンタの初期化を行います。");
716                         Trace.Indent();
717                         try
718                         {
719                                 FPS = new CFPS();
720                                 Trace.TraceInformation("FPSカウンタを生成しました。");
721                         }
722                         finally
723                         {
724                                 Trace.Unindent();
725                         }
726                         #endregion
727
728                         #region [ act文字コンソールの初期化 ]
729                         Trace.TraceInformation("文字コンソールの初期化を行います。");
730                         Trace.Indent();
731                         try
732                         {
733                                 act文字コンソール = new C文字コンソール();
734                                 Trace.TraceInformation("文字コンソールを生成しました。");
735                                 act文字コンソール.On活性化();
736                                 Trace.TraceInformation("文字コンソールを活性化しました。");
737                                 Trace.TraceInformation("文字コンソールの初期化を完了しました。");
738                         }
739                         catch (Exception exception)
740                         {
741                                 Trace.TraceError(exception.Message);
742                                 Trace.TraceError("文字コンソールの初期化に失敗しました。");
743                         }
744                         finally
745                         {
746                                 Trace.Unindent();
747                         }
748                         #endregion
749
750                         #region [ Pad の初期化 ]
751                         Trace.TraceInformation("パッドの初期化を行います。");
752                         Trace.Indent();
753                         try
754                         {
755                                 Pad = new CPad();
756                                 Trace.TraceInformation("パッドの初期化を完了しました。");
757                         }
758                         catch (Exception exception3)
759                         {
760                                 Trace.TraceError(exception3.Message);
761                                 Trace.TraceError("パッドの初期化に失敗しました。");
762                         }
763                         finally
764                         {
765                                 Trace.Unindent();
766                         }
767                         #endregion
768
769                         #region [ Sound管理 の初期化 ]
770                         Trace.TraceInformation("サウンドデバイスの初期化を行います。");
771                         Trace.Indent();
772                         try
773                         {
774                                 ESoundDeviceType soundDeviceType;
775                                 switch (CDTXMania.Instance.ConfigIni.nSoundDeviceType.Value)
776                                 {
777                                         case ESoundDeviceTypeForConfig.DSound:
778                                                 soundDeviceType = ESoundDeviceType.DirectSound;
779                                                 break;
780                                         case ESoundDeviceTypeForConfig.ASIO:
781                                                 soundDeviceType = ESoundDeviceType.ASIO;
782                                                 break;
783                                         case ESoundDeviceTypeForConfig.WASAPI_Exclusive:
784                                                 soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
785                                                 break;
786                                         case ESoundDeviceTypeForConfig.WASAPI_Shared:
787                                                 soundDeviceType = ESoundDeviceType.SharedWASAPI;
788                                                 break;
789                                         default:
790                                                 soundDeviceType = ESoundDeviceType.Unknown;
791                                                 break;
792                                 }
793                                 Sound管理 = new CSound管理(base.Window.Handle,
794                                                                                         soundDeviceType,
795                                                                                         CDTXMania.Instance.ConfigIni.nWASAPIBufferSizeMs,
796                                                                                         CDTXMania.instance.ConfigIni.bEventDrivenWASAPI,
797                                                                                         0,
798                                                                                         CDTXMania.Instance.ConfigIni.strASIODevice.Index,
799                                                                                         CDTXMania.Instance.ConfigIni.bUseOSTimer
800                                 );
801                                 //Sound管理 = FDK.CSound管理.Instance;
802                                 //Sound管理.t初期化( soundDeviceType, 0, 0, CDTXMania.Instance.ConfigIni.nASIODevice, base.Window.Handle );
803
804                                 ShowWindowTitleWithSoundType();
805                                 FDK.CSound管理.bIsTimeStretch = CDTXMania.Instance.ConfigIni.bTimeStretch;
806                                 Sound管理.nMasterVolume = CDTXMania.Instance.ConfigIni.nMasterVolume;
807                                 //FDK.CSound管理.bIsMP3DecodeByWindowsCodec = CDTXMania.Instance.ConfigIni.bNoMP3Streaming;
808                                 Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
809                         }
810                         catch (Exception e)
811                         {
812                                 Trace.TraceError(e.Message);
813                                 throw;
814                         }
815                         finally
816                         {
817                                 Trace.Unindent();
818                         }
819                         #endregion
820
821                         #region [ Songs管理 の初期化 ]
822                         //---------------------
823                         Trace.TraceInformation("曲リストの初期化を行います。");
824                         Trace.Indent();
825                         try
826                         {
827                                 Songs管理 = new CSongs管理();
828                                 //                              Songs管理_裏読 = new CSongs管理();
829                                 EnumSongs = new CEnumSongs();
830                                 actEnumSongs = new CActEnumSongs();
831                                 Trace.TraceInformation("曲リストの初期化を完了しました。");
832                         }
833                         catch (Exception e)
834                         {
835                                 Trace.TraceError(e.Message);
836                                 Trace.TraceError("曲リストの初期化に失敗しました。");
837                         }
838                         finally
839                         {
840                                 Trace.Unindent();
841                         }
842                         //---------------------
843                         #endregion
844
845                         #region [ CAvi の初期化 ]
846                         CAvi.t初期化();
847                         #endregion
848
849                         #region [ Random の初期化 ]
850                         Random = new Random((int)Timer.nシステム時刻);
851                         #endregion
852
853                         #region [ ステージの初期化 ]
854                         r現在のステージ = null;
855                         r直前のステージ = null;
856                         stage起動 = new CStage起動();
857                         stageタイトル = new CStageタイトル();
858                         stageコンフィグ = new CStageコンフィグ();
859                         stage選曲 = new CStage選曲();
860                         stage曲読み込み = new CStage曲読み込み();
861                         stage演奏画面 = new CStage演奏画面共通();
862                         stage結果 = new CStage結果();
863                         stageChangeSkin = new CStageChangeSkin();
864                         stage終了 = new CStage終了();
865
866                         this.listトップレベルActivities = new List<CActivity>();
867                         this.listトップレベルActivities.Add(actEnumSongs);
868                         this.listトップレベルActivities.Add(act文字コンソール);
869                         this.listトップレベルActivities.Add(stage起動);
870                         this.listトップレベルActivities.Add(stageタイトル);
871                         this.listトップレベルActivities.Add(stageコンフィグ);
872                         this.listトップレベルActivities.Add(stage選曲);
873                         this.listトップレベルActivities.Add(stage曲読み込み);
874                         this.listトップレベルActivities.Add(stage演奏画面);
875                         this.listトップレベルActivities.Add(stage結果);
876                         this.listトップレベルActivities.Add(stageChangeSkin);
877                         this.listトップレベルActivities.Add(stage終了);
878                         this.listトップレベルActivities.Add(actFlushGPU);
879                         #endregion
880
881                         #region [ プラグインの検索と生成 ]
882                         PluginHost = new CPluginHost();
883
884                         Trace.TraceInformation("プラグインの検索と生成を行います。");
885                         Trace.Indent();
886                         try
887                         {
888                                 this.tプラグイン検索と生成();
889                                 Trace.TraceInformation("プラグインの検索と生成を完了しました。");
890                         }
891                         finally
892                         {
893                                 Trace.Unindent();
894                         }
895                         #endregion
896
897                         #region [ プラグインの初期化 ]
898                         if (this.listプラグイン != null && this.listプラグイン.Count > 0)
899                         {
900                                 Trace.TraceInformation("プラグインの初期化を行います。");
901                                 Trace.Indent();
902                                 try
903                                 {
904                                         foreach (STPlugin st in this.listプラグイン)
905                                         {
906                                                 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
907                                                 st.plugin.On初期化(this.PluginHost);
908                                                 st.plugin.OnManagedリソースの作成();
909                                                 st.plugin.OnUnmanagedリソースの作成();
910                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
911                                         }
912                                         Trace.TraceInformation("すべてのプラグインの初期化を完了しました。");
913                                 }
914                                 catch
915                                 {
916                                         Trace.TraceError("プラグインのどれかの初期化に失敗しました。");
917                                         throw;
918                                 }
919                                 finally
920                                 {
921                                         Trace.Unindent();
922                                 }
923                         }
924                         #endregion
925
926
927                         Trace.TraceInformation("アプリケーションの初期化を完了しました。");
928
929                         #region [ 最初のステージの起動 ]
930                         Trace.TraceInformation("----------------------");
931                         Trace.TraceInformation("■ 起動");
932
933                         if (CDTXMania.Instance.bコンパクトモード)
934                         {
935                                 r現在のステージ = stage曲読み込み;
936                         }
937                         else
938                         {
939                                 r現在のステージ = stage起動;
940                         }
941                         r現在のステージ.On活性化();
942                         #endregion
943                 }
944
945
946                 public void t全画面_ウィンドウモード切り替え()
947                 {
948 #if WindowedFullscreen
949                         if (ConfigIni != null)
950 #else
951                         DeviceSettings settings = base.GraphicsDeviceManager.CurrentSettings.Clone();
952                         if ( ( ConfigIni != null ) && ( ConfigIni.bウィンドウモード != settings.Windowed ) )
953 #endif
954                         {
955 #if !WindowedFullscreen
956                                 settings.Windowed = ConfigIni.bウィンドウモード;
957 #endif
958                                 if (ConfigIni.bウィンドウモード == false)   // #23510 2010.10.27 yyagi: backup current window size before going fullscreen mode
959                                 {
960                                         currentClientSize = this.Window.ClientSize;
961                                         ConfigIni.rcWindow.W = this.Window.ClientSize.Width;
962                                         ConfigIni.rcWindow.H = this.Window.ClientSize.Height;
963                                         //                                      FDK.CTaskBar.ShowTaskBar( false );
964                                 }
965 #if !WindowedFullscreen
966                                 base.GraphicsDeviceManager.ChangeDevice( settings );
967 #endif
968                                 if (ConfigIni.bウィンドウモード == true)    // #23510 2010.10.27 yyagi: to resume window size from backuped value
969                                 {
970 #if WindowedFullscreen
971                                         // #30666 2013.2.2 yyagi Don't use Fullscreen mode becasue NVIDIA GeForce is
972                                         // tend to delay drawing on Fullscreen mode. So DTXMania uses Maximized window
973                                         // in spite of using fullscreen mode.
974                                         Instance.Window.WindowState = FormWindowState.Normal;
975                                         Instance.Window.FormBorderStyle = FormBorderStyle.Sizable;
976                                         Instance.Window.WindowState = FormWindowState.Normal;
977 #endif
978                                         base.Window.ClientSize =
979                                                         new Size(currentClientSize.Width, currentClientSize.Height);
980                                         //                                      FDK.CTaskBar.ShowTaskBar( true );
981                                 }
982 #if WindowedFullscreen
983                                 else
984                                 {
985                                         Instance.Window.WindowState = FormWindowState.Normal;
986                                         Instance.Window.FormBorderStyle = FormBorderStyle.None;
987                                         Instance.Window.WindowState = FormWindowState.Maximized;
988                                 }
989                                 if (cMouseHideControl != null)
990                                 {
991                                         if (ConfigIni.bウィンドウモード)
992                                         {
993                                                 cMouseHideControl.Show();
994                                         }
995                                         else
996                                         {
997                                                 cMouseHideControl.Hide();
998                                         }
999                                 }
1000 #endif
1001                         }
1002                 }
1003
1004                 #region [ #24609 リザルト画像をpngで保存する ]              // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
1005                 /// <summary>
1006                 /// リザルト画像のキャプチャと保存。
1007                 /// </summary>
1008                 /// <param name="strFilename">保存するファイル名(フルパス)</param>
1009                 public bool SaveResultScreen(string strFullPath)
1010                 {
1011                         string strSavePath = Path.GetDirectoryName(strFullPath);
1012                         if (!Directory.Exists(strSavePath))
1013                         {
1014                                 try
1015                                 {
1016                                         Directory.CreateDirectory(strSavePath);
1017                                 }
1018                                 catch
1019                                 {
1020                                         return false;
1021                                 }
1022                         }
1023
1024                         // http://www.gamedev.net/topic/594369-dx9slimdxati-incorrect-saving-surface-to-file/
1025                         using (Surface pSurface = CDTXMania.Instance.Device.GetRenderTarget(0))
1026                         {
1027                                 Surface.ToFile(pSurface, strFullPath, ImageFileFormat.Png);
1028                         }
1029                         return true;
1030                 }
1031                 #endregion
1032
1033                 // Game 実装
1034
1035                 protected override void Initialize()
1036                 {
1037                         //                      new GCBeep();
1038                         //sw.Start();
1039                         //swlist1 = new List<int>( 8192 );
1040                         //swlist2 = new List<int>( 8192 );
1041                         //swlist3 = new List<int>( 8192 );
1042                         //swlist4 = new List<int>( 8192 );
1043                         //swlist5 = new List<int>( 8192 );
1044                         if (this.listトップレベルActivities != null)
1045                         {
1046                                 foreach (CActivity activity in this.listトップレベルActivities)
1047                                         activity.OnManagedリソースの作成();
1048                         }
1049
1050                         foreach (STPlugin st in this.listプラグイン)
1051                         {
1052                                 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1053                                 st.plugin.OnManagedリソースの作成();
1054                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1055                         }
1056 #if GPUFlushAfterPresent
1057                         FrameEnd += dtxmania_FrameEnd;
1058 #endif
1059                 }
1060 #if GPUFlushAfterPresent
1061                 void dtxmania_FrameEnd( object sender, EventArgs e )    // GraphicsDeviceManager.game_FrameEnd()後に実行される
1062                 {                                                                                                               // → Present()直後にGPUをFlushする
1063                                                                                                                                 // → 画面のカクツキが頻発したため、ここでのFlushは行わない
1064                         actFlushGPU.On進行描画();           // Flush GPU
1065                 }
1066 #endif
1067                 protected override void LoadContent()
1068                 {
1069                         if (cMouseHideControl != null)
1070                         {
1071                                 if (ConfigIni.bウィンドウモード)
1072                                 {
1073                                         cMouseHideControl.Show();
1074                                 }
1075                                 else
1076                                 {
1077                                         cMouseHideControl.Hide();
1078                                 }
1079                         }
1080                         this.Device.SetTransform(TransformState.View, Matrix.LookAtLH(new Vector3(0f, 0f, (float)(-SampleFramework.GameWindowSize.Height / 2 * Math.Sqrt(3.0))), new Vector3(0f, 0f, 0f), new Vector3(0f, 1f, 0f)));
1081                         this.Device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH(C変換.DegreeToRadian((float)60f), ((float)this.Device.Viewport.Width) / ((float)this.Device.Viewport.Height), -100f, 100f));
1082                         this.Device.SetRenderState(RenderState.Lighting, false);
1083                         this.Device.SetRenderState(RenderState.ZEnable, false);                                         // trueにすると、一部システムで画面表示できなくなる
1084                         this.Device.SetRenderState(RenderState.AntialiasedLineEnable, false);       // trueにすると、一部システムで画面表示できなくなる 
1085                         this.Device.SetRenderState(RenderState.AlphaTestEnable, true);
1086                         this.Device.SetRenderState(RenderState.AlphaRef, 10);
1087
1088                         this.Device.SetRenderState(RenderState.MultisampleAntialias, true);
1089                         this.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
1090                         this.Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
1091
1092                         this.Device.SetRenderState<Compare>(RenderState.AlphaFunc, Compare.Greater);
1093                         this.Device.SetRenderState(RenderState.AlphaBlendEnable, true);
1094                         this.Device.SetRenderState<Blend>(RenderState.SourceBlend, Blend.SourceAlpha);
1095                         this.Device.SetRenderState<Blend>(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
1096                         this.Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
1097                         this.Device.SetTextureStageState(0, TextureStage.AlphaArg1, 2);
1098                         this.Device.SetTextureStageState(0, TextureStage.AlphaArg2, 1);
1099
1100                         if (this.listトップレベルActivities != null)
1101                         {
1102                                 foreach (CActivity activity in this.listトップレベルActivities)
1103                                         activity.OnUnmanagedリソースの作成();
1104                         }
1105
1106                         foreach (STPlugin st in this.listプラグイン)
1107                         {
1108                                 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1109                                 st.plugin.OnUnmanagedリソースの作成();
1110                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1111                         }
1112                 }
1113                 protected override void UnloadContent()
1114                 {
1115                         if (this.listトップレベルActivities != null)
1116                         {
1117                                 foreach (CActivity activity in this.listトップレベルActivities)
1118                                         activity.OnUnmanagedリソースの解放();
1119                         }
1120
1121                         foreach (STPlugin st in this.listプラグイン)
1122                         {
1123                                 Directory.SetCurrentDirectory(st.strプラグインフォルダ);
1124                                 st.plugin.OnUnmanagedリソースの解放();
1125                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1126                         }
1127                 }
1128                 protected override void OnExiting(EventArgs e)
1129                 {
1130                         CPowerManagement.tEnableMonitorSuspend();       // スリープ抑止状態を解除
1131                         this.t終了処理();
1132                         base.OnExiting(e);
1133                 }
1134                 protected override void Update(GameTime gameTime)
1135                 {
1136                 }
1137                 protected override void Draw(GameTime gameTime)
1138                 {
1139                         if (Sound管理 == null)
1140                         {
1141                                 return;
1142                         }
1143                         Sound管理.t再生中の処理をする();
1144
1145                         if (Timer != null)
1146                                 Timer.t更新();
1147                         if (CSound管理.rc演奏用タイマ != null)
1148                                 CSound管理.rc演奏用タイマ.t更新();
1149
1150                         if (Input管理 != null)
1151                                 Input管理.tポーリング(this.bApplicationActive, CDTXMania.Instance.ConfigIni.bBufferedInput);
1152
1153                         if (FPS != null)
1154                                 FPS.tカウンタ更新();
1155
1156                         //if( Pad != null )                                     ポーリング時にクリアしたらダメ!曲の開始時に1回だけクリアする。(2010.9.11)
1157                         //      Pad.st検知したデバイス.Clear();
1158
1159                         if (this.Device == null)
1160                                 return;
1161
1162                         if (this.bApplicationActive)    // DTXMania本体起動中の本体/モニタの省電力モード移行を抑止
1163                                 CPowerManagement.tDisableMonitorSuspend();
1164
1165                         // #xxxxx 2013.4.8 yyagi; sleepの挿入位置を、EndScnene~Present間から、BeginScene前に移動。描画遅延を小さくするため。
1166                         #region [ スリープ ]
1167                         if (ConfigIni.nSleepPerFrameMs >= 0)            // #xxxxx 2011.11.27 yyagi
1168                         {
1169                                 Thread.Sleep(ConfigIni.nSleepPerFrameMs);
1170                         }
1171                         #endregion
1172
1173                         #region [ DTXCreatorからの指示 ]
1174                         if (this.Window.IsReceivedMessage)  // ウインドウメッセージで、
1175                         {
1176                                 string strMes = this.Window.strMessage;
1177                                 this.Window.IsReceivedMessage = false;
1178
1179                                 if (strMes != null)
1180                                 {
1181                                         CommandParse.ParseArguments(strMes, ref DTXVmode, ref DTX2WAVmode);
1182
1183                                         if (DTXVmode.Enabled)
1184                                         {
1185                                                 bコンパクトモード = true;
1186                                                 strコンパクトモードファイル = DTXVmode.filename;
1187                                                 if (DTXVmode.Command == CDTXVmode.ECommand.Preview)
1188                                                 {
1189                                                         // preview soundの再生
1190                                                         string strPreviewFilename = DTXVmode.previewFilename;
1191                                                         //Trace.TraceInformation( "Preview Filename=" + DTXVmode.previewFilename );
1192                                                         try
1193                                                         {
1194                                                                 if (this.previewSound != null)
1195                                                                 {
1196                                                                         this.previewSound.tサウンドを停止する();
1197                                                                         this.previewSound.Dispose();
1198                                                                         this.previewSound = null;
1199                                                                 }
1200                                                                 this.previewSound = CDTXMania.Instance.Sound管理.tサウンドを生成する(strPreviewFilename);
1201                                                                 this.previewSound.n音量 = DTXVmode.previewVolume;
1202                                                                 this.previewSound.n位置 = DTXVmode.previewPan;
1203                                                                 this.previewSound.t再生を開始する();
1204                                                                 Trace.TraceInformation("DTXCからの指示で、サウンドを生成しました。({0})", strPreviewFilename);
1205                                                         }
1206                                                         catch
1207                                                         {
1208                                                                 Trace.TraceError("DTXCからの指示での、サウンドの生成に失敗しました。({0})", strPreviewFilename);
1209                                                                 if (this.previewSound != null)
1210                                                                 {
1211                                                                         this.previewSound.Dispose();
1212                                                                 }
1213                                                                 this.previewSound = null;
1214                                                         }
1215                                                 }
1216                                         }
1217                                 }
1218                         }
1219                         #endregion
1220
1221                         this.Device.BeginScene();
1222                         this.Device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, SharpDX.Color.Black, 1f, 0);
1223
1224                         if (r現在のステージ != null)
1225                         {
1226                                 this.n進行描画の戻り値 = (r現在のステージ != null) ? r現在のステージ.On進行描画() : 0;
1227
1228                                 #region [ プラグインの進行描画 ]
1229                                 //---------------------
1230                                 foreach (STPlugin sp in this.listプラグイン)
1231                                 {
1232                                         Directory.SetCurrentDirectory(sp.strプラグインフォルダ);
1233
1234                                         if (CDTXMania.Instance.act現在入力を占有中のプラグイン == null || CDTXMania.Instance.act現在入力を占有中のプラグイン == sp.plugin)
1235                                                 sp.plugin.On進行描画(CDTXMania.Instance.Pad, CDTXMania.Instance.Input管理.Keyboard);
1236                                         else
1237                                                 sp.plugin.On進行描画(null, null);
1238
1239                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1240                                 }
1241                                 //---------------------
1242                                 #endregion
1243
1244
1245                                 CScoreIni scoreIni = null;
1246
1247                                 if (Control.IsKeyLocked(Keys.CapsLock))             // #30925 2013.3.11 yyagi; capslock=ON時は、EnumSongsしないようにして、起動負荷とASIOの音切れの関係を確認する
1248                                 {
1249                                         // → songs.db等の書き込み時だと音切れするっぽい
1250                                         actEnumSongs.On非活性化();
1251                                         EnumSongs.SongListEnumCompletelyDone();
1252                                         CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1253                                 }
1254                                 #region [ 曲検索スレッドの起動/終了 ここに"Enumerating Songs..."表示を集約 ]
1255                                 if (!CDTXMania.Instance.bコンパクトモード)
1256                                 {
1257                                         actEnumSongs.On進行描画();                          // "Enumerating Songs..."アイコンの描画
1258                                 }
1259                                 switch (r現在のステージ.eステージID)
1260                                 {
1261                                         case CStage.Eステージ.タイトル:
1262                                         case CStage.Eステージ.コンフィグ:
1263                                         case CStage.Eステージ.選曲:
1264                                         case CStage.Eステージ.曲読み込み:
1265                                                 if (EnumSongs != null)
1266                                                 {
1267                             #region [ (特定条件時) 曲検索スレッドの起動・開始 ]
1268                                                         if (r現在のステージ.eステージID == CStage.Eステージ.タイトル &&
1269                                                                          r直前のステージ.eステージID == CStage.Eステージ.起動 &&
1270                                                                          this.n進行描画の戻り値 == (int)CStageタイトル.E戻り値.継続 &&
1271                                                                          !EnumSongs.IsSongListEnumStarted)
1272                                                         {
1273                                                                 actEnumSongs.On活性化();
1274                                                                 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = true;
1275                                                                 EnumSongs.Init(CDTXMania.Instance.Songs管理.listSongsDB, CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数); // songs.db情報と、取得した曲数を、新インスタンスにも与える
1276                                                                 EnumSongs.StartEnumFromDisk();      // 曲検索スレッドの起動・開始
1277                                                                 if (CDTXMania.Instance.Songs管理.nSongsDBから取得できたスコア数 == 0)    // もし初回起動なら、検索スレッドのプライオリティをLowestでなくNormalにする
1278                                                                 {
1279                                                                         EnumSongs.ChangeEnumeratePriority(ThreadPriority.Normal);
1280                                                                 }
1281                                                         }
1282                                                         #endregion
1283
1284                                                         #region [ 曲検索の中断と再開 ]
1285                                                         if (r現在のステージ.eステージID == CStage.Eステージ.選曲 && !EnumSongs.IsSongListEnumCompletelyDone)
1286                                                         {
1287                                                                 switch (this.n進行描画の戻り値)
1288                                                                 {
1289                                                                         case 0:     // 何もない
1290                                                                                                                         //if ( CDTXMania.Instance.stage選曲.bIsEnumeratingSongs )
1291                                                                                 if (!CDTXMania.Instance.stage選曲.bIsPlayingPremovie)
1292                                                                                 {
1293                                                                                         EnumSongs.Resume();                     // #27060 2012.2.6 yyagi 中止していたバックグランド曲検索を再開
1294                                                                                         EnumSongs.IsSlowdown = false;
1295                                                                                 }
1296                                                                                 else
1297                                                                                 {
1298                                                                                         // EnumSongs.Suspend();                                 // #27060 2012.3.2 yyagi #PREMOVIE再生中は曲検索を低速化
1299                                                                                         EnumSongs.IsSlowdown = true;
1300                                                                                 }
1301                                                                                 actEnumSongs.On活性化();
1302                                                                                 break;
1303
1304                                                                         case 2:     // 曲決定
1305                                                                                 EnumSongs.Suspend();                        // #27060 バックグラウンドの曲検索を一時停止
1306                                                                                 actEnumSongs.On非活性化();
1307                                                                                 break;
1308                                                                 }
1309                                                         }
1310                                                         #endregion
1311
1312                                                         #region [ 曲探索中断待ち待機 ]
1313                                                         if (r現在のステージ.eステージID == CStage.Eステージ.曲読み込み && !EnumSongs.IsSongListEnumCompletelyDone &&
1314                                                                         EnumSongs.thDTXFileEnumerate != null)                           // #28700 2012.6.12 yyagi; at Compact mode, enumerating thread does not exist.
1315                                                         {
1316                                                                 EnumSongs.WaitUntilSuspended();                                 // 念のため、曲検索が一時中断されるまで待機
1317                                                         }
1318                                                         #endregion
1319
1320                                                         #region [ 曲検索が完了したら、実際の曲リストに反映する ]
1321                                                         // CStage選曲.On活性化() に回した方がいいかな?
1322                                                         if (EnumSongs.IsSongListEnumerated)
1323                                                         {
1324                                                                 actEnumSongs.On非活性化();
1325                                                                 CDTXMania.Instance.stage選曲.bIsEnumeratingSongs = false;
1326
1327                                                                 bool bRemakeSongTitleBar = (r現在のステージ.eステージID == CStage.Eステージ.選曲) ? true : false;
1328                                                                 CDTXMania.Instance.stage選曲.Refresh(EnumSongs.Songs管理, bRemakeSongTitleBar);
1329                                                                 EnumSongs.SongListEnumCompletelyDone();
1330                                                         }
1331                                                         #endregion
1332                                                 }
1333                                                 break;
1334                                 }
1335                                 #endregion
1336
1337                                 switch (r現在のステージ.eステージID)
1338                                 {
1339                                         case CStage.Eステージ.何もしない:
1340                                                 break;
1341
1342                                         case CStage.Eステージ.起動:
1343                                                 #region [ *** ]
1344                                                 //-----------------------------
1345                                                 if (this.n進行描画の戻り値 != 0)
1346                                                 {
1347                                                         if (!bコンパクトモード)
1348                                                         {
1349                                                                 r現在のステージ.On非活性化();
1350                                                                 Trace.TraceInformation("----------------------");
1351                                                                 Trace.TraceInformation("■ タイトル");
1352                                                                 stageタイトル.On活性化();
1353                                                                 r直前のステージ = r現在のステージ;
1354                                                                 r現在のステージ = stageタイトル;
1355                                                         }
1356                                                         else
1357                                                         {
1358                                                                 r現在のステージ.On非活性化();
1359                                                                 Trace.TraceInformation("----------------------");
1360                                                                 Trace.TraceInformation("■ 曲読み込み");
1361                                                                 stage曲読み込み.On活性化();
1362                                                                 r直前のステージ = r現在のステージ;
1363                                                                 r現在のステージ = stage曲読み込み;
1364
1365                                                         }
1366                                                         foreach (STPlugin pg in this.listプラグイン)
1367                                                         {
1368                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1369                                                                 pg.plugin.Onステージ変更();
1370                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1371                                                         }
1372
1373                                                         this.tガベージコレクションを実行する();
1374                                                 }
1375                                                 //-----------------------------
1376                                                 #endregion
1377                                                 break;
1378
1379                                         case CStage.Eステージ.タイトル:
1380                         #region [ *** ]
1381                         //-----------------------------
1382                         switch (this.n進行描画の戻り値)
1383                                                 {
1384                                                         case (int)CStageタイトル.E戻り値.GAMESTART:
1385                                                                 #region [ 選曲処理へ ]
1386                                                                 //-----------------------------
1387                                                                 r現在のステージ.On非活性化();
1388                                                                 Trace.TraceInformation("----------------------");
1389                                                                 Trace.TraceInformation("■ 選曲");
1390                                                                 stage選曲.On活性化();
1391                                                                 r直前のステージ = r現在のステージ;
1392                                                                 r現在のステージ = stage選曲;
1393                                                                 //-----------------------------
1394                                                                 #endregion
1395                                                                 break;
1396
1397                                                         #region [ OPTION: 廃止済 ]
1398                                                         //                                                      case 2:                                                                 // #24525 OPTIONとCONFIGの統合に伴い、OPTIONは廃止
1399                                                         //                                                              #region [ *** ]
1400                                                         //                                                              //-----------------------------
1401                                                         //                                                              r現在のステージ.On非活性化();
1402                                                         //                                                              Trace.TraceInformation( "----------------------" );
1403                                                         //                                                              Trace.TraceInformation( "■ オプション" );
1404                                                         //                                                              stageオプション.On活性化();
1405                                                         //                                                              r直前のステージ = r現在のステージ;
1406                                                         //                                                              r現在のステージ = stageオプション;
1407                                                         //                                                              //-----------------------------
1408                                                         //                                                              #endregion
1409                                                         //                                                              break;
1410                                                         #endregion
1411
1412                                                         case (int)CStageタイトル.E戻り値.CONFIG:
1413                                                                 #region [ *** ]
1414                                                                 //-----------------------------
1415                                                                 r現在のステージ.On非活性化();
1416                                                                 Trace.TraceInformation("----------------------");
1417                                                                 Trace.TraceInformation("■ コンフィグ");
1418                                                                 stageコンフィグ.On活性化();
1419                                                                 r直前のステージ = r現在のステージ;
1420                                                                 r現在のステージ = stageコンフィグ;
1421                                                                 //-----------------------------
1422                                                                 #endregion
1423                                                                 break;
1424
1425                                                         case (int)CStageタイトル.E戻り値.EXIT:
1426                                                                 #region [ *** ]
1427                                                                 //-----------------------------
1428                                                                 r現在のステージ.On非活性化();
1429                                                                 Trace.TraceInformation("----------------------");
1430                                                                 Trace.TraceInformation("■ 終了");
1431                                                                 stage終了.On活性化();
1432                                                                 r直前のステージ = r現在のステージ;
1433                                                                 r現在のステージ = stage終了;
1434                                                                 //-----------------------------
1435                                                                 #endregion
1436                                                                 break;
1437                                                 }
1438
1439                                                 foreach (STPlugin pg in this.listプラグイン)
1440                                                 {
1441                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1442                                                         pg.plugin.Onステージ変更();
1443                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1444                                                 }
1445
1446                                                 //this.tガベージコレクションを実行する();                // #31980 2013.9.3 yyagi タイトル画面でだけ、毎フレームGCを実行して重くなっていた問題の修正
1447                                                 //-----------------------------
1448                                                 #endregion
1449                                                 break;
1450
1451                                         case CStage.Eステージ.コンフィグ:
1452                                                 #region [ *** ]
1453                                                 //-----------------------------
1454                                                 if (this.n進行描画の戻り値 != 0)
1455                                                 {
1456                                                         switch (r直前のステージ.eステージID)
1457                                                         {
1458                                                                 case CStage.Eステージ.タイトル:
1459                                                                         #region [ *** ]
1460                                                                         //-----------------------------
1461                                                                         r現在のステージ.On非活性化();
1462                                                                         Trace.TraceInformation("----------------------");
1463                                                                         Trace.TraceInformation("■ タイトル");
1464                                                                         stageタイトル.On活性化();
1465                                                                         r直前のステージ = r現在のステージ;
1466                                                                         r現在のステージ = stageタイトル;
1467
1468                                                                         foreach (STPlugin pg in this.listプラグイン)
1469                                                                         {
1470                                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1471                                                                                 pg.plugin.Onステージ変更();
1472                                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1473                                                                         }
1474
1475                                                                         this.tガベージコレクションを実行する();
1476                                                                         break;
1477                                                                 //-----------------------------
1478                                                                 #endregion
1479
1480                                                                 case CStage.Eステージ.選曲:
1481                                                                         #region [ *** ]
1482                                                                         //-----------------------------
1483                                                                         r現在のステージ.On非活性化();
1484                                                                         Trace.TraceInformation("----------------------");
1485                                                                         Trace.TraceInformation("■ 選曲");
1486                                                                         stage選曲.On活性化();
1487                                                                         r直前のステージ = r現在のステージ;
1488                                                                         r現在のステージ = stage選曲;
1489
1490                                                                         foreach (STPlugin pg in this.listプラグイン)
1491                                                                         {
1492                                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1493                                                                                 pg.plugin.Onステージ変更();
1494                                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1495                                                                         }
1496
1497                                                                         this.tガベージコレクションを実行する();
1498                                                                         break;
1499                                                                         //-----------------------------
1500                                                                         #endregion
1501                                                         }
1502                                                 }
1503                                                 //-----------------------------
1504                                                 #endregion
1505                                                 break;
1506
1507                                         case CStage.Eステージ.選曲:
1508                                                 #region [ *** ]
1509                                                 //-----------------------------
1510                                                 switch (this.n進行描画の戻り値)
1511                                                 {
1512                                                         case (int)CStage選曲.E戻り値.タイトルに戻る:
1513                                                                 #region [ *** ]
1514                                                                 //-----------------------------
1515                                                                 r現在のステージ.On非活性化();
1516                                                                 Trace.TraceInformation("----------------------");
1517                                                                 Trace.TraceInformation("■ タイトル");
1518                                                                 stageタイトル.On活性化();
1519                                                                 r直前のステージ = r現在のステージ;
1520                                                                 r現在のステージ = stageタイトル;
1521
1522                                                                 foreach (STPlugin pg in this.listプラグイン)
1523                                                                 {
1524                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1525                                                                         pg.plugin.Onステージ変更();
1526                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1527                                                                 }
1528
1529                                                                 this.tガベージコレクションを実行する();
1530                                                                 break;
1531                                                         //-----------------------------
1532                                                         #endregion
1533
1534                                                         case (int)CStage選曲.E戻り値.選曲した:
1535                                                                 #region [ *** ]
1536                                                                 //-----------------------------
1537                                                                 r現在のステージ.On非活性化();
1538                                                                 Trace.TraceInformation("----------------------");
1539                                                                 Trace.TraceInformation("■ 曲読み込み");
1540                                                                 stage曲読み込み.On活性化();
1541                                                                 r直前のステージ = r現在のステージ;
1542                                                                 r現在のステージ = stage曲読み込み;
1543
1544                                                                 foreach (STPlugin pg in this.listプラグイン)
1545                                                                 {
1546                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1547                                                                         pg.plugin.Onステージ変更();
1548                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1549                                                                 }
1550
1551                                                                 this.tガベージコレクションを実行する();
1552                                                                 break;
1553                                                         //-----------------------------
1554                                                         #endregion
1555
1556                                                         case (int)CStage選曲.E戻り値.コンフィグ呼び出し:
1557                                                                 #region [ *** ]
1558                                                                 //-----------------------------
1559                                                                 r現在のステージ.On非活性化();
1560                                                                 Trace.TraceInformation("----------------------");
1561                                                                 Trace.TraceInformation("■ コンフィグ");
1562                                                                 stageコンフィグ.On活性化();
1563                                                                 r直前のステージ = r現在のステージ;
1564                                                                 r現在のステージ = stageコンフィグ;
1565
1566                                                                 foreach (STPlugin pg in this.listプラグイン)
1567                                                                 {
1568                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1569                                                                         pg.plugin.Onステージ変更();
1570                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1571                                                                 }
1572
1573                                                                 this.tガベージコレクションを実行する();
1574                                                                 break;
1575                                                         //-----------------------------
1576                                                         #endregion
1577
1578                                                         case (int)CStage選曲.E戻り値.スキン変更:
1579
1580                                                                 #region [ *** ]
1581                                                                 //-----------------------------
1582                                                                 r現在のステージ.On非活性化();
1583                                                                 Trace.TraceInformation("----------------------");
1584                                                                 Trace.TraceInformation("■ スキン切り替え");
1585                                                                 stageChangeSkin.On活性化();
1586                                                                 r直前のステージ = r現在のステージ;
1587                                                                 r現在のステージ = stageChangeSkin;
1588                                                                 break;
1589                                                                 //-----------------------------
1590                                                                 #endregion
1591                                                 }
1592                                                 //-----------------------------
1593                                                 #endregion
1594                                                 break;
1595
1596                                         case CStage.Eステージ.曲読み込み:
1597                                                 #region [ *** ]
1598                                                 //-----------------------------
1599                                                 DTXVmode.Refreshed = false;     // 曲のリロード中に発生した再リロードは、無視する。
1600                                                 if (this.n進行描画の戻り値 != 0)
1601                                                 {
1602                                                         CDTXMania.Instance.Pad.st検知したデバイス.Clear();  // 入力デバイスフラグクリア(2010.9.11)
1603                                                         r現在のステージ.On非活性化();
1604                                                         #region [ ESC押下時は、曲の読み込みを中止して選曲画面に戻る ]
1605                                                         if (this.n進行描画の戻り値 == (int)E曲読込画面の戻り値.読込中止)
1606                                                         {
1607                                                                 //DTX.t全チップの再生停止();
1608                                                                 DTX.On非活性化();
1609                                                                 Trace.TraceInformation("曲の読み込みを中止しました。");
1610                                                                 this.tガベージコレクションを実行する();
1611                                                                 Trace.TraceInformation("----------------------");
1612                                                                 Trace.TraceInformation("■ 選曲");
1613                                                                 stage選曲.On活性化();
1614                                                                 r直前のステージ = r現在のステージ;
1615                                                                 r現在のステージ = stage選曲;
1616                                                                 foreach (STPlugin pg in this.listプラグイン)
1617                                                                 {
1618                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1619                                                                         pg.plugin.Onステージ変更();
1620                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1621                                                                 }
1622                                                                 break;
1623                                                         }
1624                                                         #endregion
1625
1626                                                         Trace.TraceInformation("----------------------");
1627                                                         Trace.TraceInformation("■ 演奏(ドラム画面)");
1628                                                         r直前のステージ = r現在のステージ;
1629                                                         r現在のステージ = stage演奏画面;
1630
1631                                                         foreach (STPlugin pg in this.listプラグイン)
1632                                                         {
1633                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1634                                                                 pg.plugin.Onステージ変更();
1635                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1636                                                         }
1637
1638                                                         this.tガベージコレクションを実行する();
1639                                                 }
1640                                                 //-----------------------------
1641                                                 #endregion
1642                                                 break;
1643
1644                                         case CStage.Eステージ.演奏:
1645                                                 #region [ *** ]
1646                                                 //-----------------------------
1647                                                 //long n1 = FDK.CSound管理.rc演奏用タイマ.nシステム時刻ms;
1648                                                 //long n2 = FDK.CSound管理.SoundDevice.n経過時間ms;
1649                                                 //long n3 = FDK.CSound管理.SoundDevice.tmシステムタイマ.nシステム時刻ms;
1650                                                 //long n4 = FDK.CSound管理.rc演奏用タイマ.n現在時刻;
1651                                                 //long n5 = FDK.CSound管理.SoundDevice.n経過時間を更新したシステム時刻ms;
1652
1653                                                 //swlist1.Add( Convert.ToInt32(n1) );
1654                                                 //swlist2.Add( Convert.ToInt32(n2) );
1655                                                 //swlist3.Add( Convert.ToInt32( n3 ) );
1656                                                 //swlist4.Add( Convert.ToInt32( n4 ) );
1657                                                 //swlist5.Add( Convert.ToInt32( n5 ) );
1658
1659                                                 #region [ DTXVモード中にDTXCreatorから指示を受けた場合の処理 ]
1660                                                 if (DTXVmode.Enabled && DTXVmode.Refreshed)
1661                                                 {
1662                                                         DTXVmode.Refreshed = false;
1663
1664                                                         if (DTXVmode.Command == CDTXVmode.ECommand.Stop)
1665                                                         {
1666                                                                 CDTXMania.Instance.stage演奏画面.t停止();
1667
1668                                                                 if (previewSound != null)
1669                                                                 {
1670                                                                         this.previewSound.tサウンドを停止する();
1671                                                                         this.previewSound.Dispose();
1672                                                                         this.previewSound = null;
1673                                                                 }
1674                                                                 //{
1675                                                                 //    int lastd = 0;
1676                                                                 //    int f = 0;
1677                                                                 //    for ( int i = 0; i < swlist1.Count; i++ )
1678                                                                 //    {
1679                                                                 //        int d1 = swlist1[ i ];
1680                                                                 //        int d2 = swlist2[ i ];
1681                                                                 //        int d3 = swlist3[ i ];
1682                                                                 //        int d4 = swlist4[ i ];
1683                                                                 //        int d5 = swlist5[ i ];
1684
1685                                                                 //        int dif = d1 - lastd;
1686                                                                 //        string s = "";
1687                                                                 //        if ( 16 <= dif && dif <= 17 )
1688                                                                 //        {
1689                                                                 //        }
1690                                                                 //        else
1691                                                                 //        {
1692                                                                 //            s = "★";
1693                                                                 //        }
1694                                                                 //        Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3} - {7:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4, d5 );
1695                                                                 //        lastd = d1;
1696                                                                 //        f++;
1697                                                                 //    }
1698                                                                 //    swlist1.Clear();
1699                                                                 //    swlist2.Clear();
1700                                                                 //    swlist3.Clear();
1701                                                                 //    swlist4.Clear();
1702                                                                 //    swlist5.Clear();
1703
1704                                                                 //}
1705                                                         }
1706                                                         else if (DTXVmode.Command == CDTXVmode.ECommand.Play)
1707                                                         {
1708                                                                 if (DTXVmode.NeedReload)
1709                                                                 {
1710                                                                         CDTXMania.Instance.stage演奏画面.t再読込();
1711                                                                         if (DTXVmode.GRmode)
1712                                                                         {
1713                                                                                 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.GBOnly;
1714                                                                         }
1715                                                                         else
1716                                                                         {
1717                                                                                 CDTXMania.Instance.ConfigIni.eActiveInst.Value = EActiveInstrument.Both;
1718                                                                         }
1719                                                                         CDTXMania.Instance.ConfigIni.bTimeStretch.Value = DTXVmode.TimeStretch;
1720                                                                         CSound管理.bIsTimeStretch = DTXVmode.TimeStretch;
1721                                                                         if (CDTXMania.Instance.ConfigIni.bVSyncWait != DTXVmode.VSyncWait)
1722                                                                         {
1723                                                                                 CDTXMania.Instance.ConfigIni.bVSyncWait.Value = DTXVmode.VSyncWait;
1724                                                                                 CDTXMania.Instance.b次のタイミングで垂直帰線同期切り替えを行う = true;
1725                                                                         }
1726                                                                 }
1727                                                                 else
1728                                                                 {
1729                                                                         CDTXMania.Instance.stage演奏画面.t演奏位置の変更(CDTXMania.Instance.DTXVmode.nStartBar);
1730                                                                 }
1731                                                         }
1732                                                 }
1733                                                 #endregion
1734
1735                                                 switch (this.n進行描画の戻り値)
1736                                                 {
1737                                                         case (int)E演奏画面の戻り値.再読込_再演奏:
1738                                                                 #region [ DTXファイルを再読み込みして、再演奏 ]
1739                                                                 DTX.t全チップの再生停止();
1740                                                                 DTX.On非活性化();
1741                                                                 r現在のステージ.On非活性化();
1742                                                                 stage曲読み込み.On活性化();
1743                                                                 r直前のステージ = r現在のステージ;
1744                                                                 r現在のステージ = stage曲読み込み;
1745                                                                 this.tガベージコレクションを実行する();
1746                                                                 break;
1747                                                         #endregion
1748
1749                                                         //case (int) E演奏画面の戻り値.再演奏:
1750                                                         #region [ 再読み込み無しで、再演奏 ]
1751                                                         #endregion
1752                                                         //      break;
1753
1754                                                         case (int)E演奏画面の戻り値.継続:
1755                                                                 break;
1756
1757                                                         case (int)E演奏画面の戻り値.演奏中断:
1758                                                                 #region [ 演奏キャンセル ]
1759                                                                 //-----------------------------
1760                                                                 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Play canceled");
1761                                                                 if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass)      // #35417 2015.8.18 yyagi Gt/Bsを入れ替えていたなら、演奏設定を元に戻す
1762                                                                 {
1763                                                                         //CDTXMania.Instance.DTX.SwapGuitarBassInfos();                                         // 譜面情報も元に戻す (現在は再演奏機能なしのため、元に戻す必要はない)
1764                                                                 }
1765
1766                                                                 //int lastd = 0;
1767                                                                 //int f = 0;
1768                                                                 //for (int i = 0; i < swlist1.Count; i++)
1769                                                                 //{
1770                                                                 //    int d1 = swlist1[ i ];
1771                                                                 //    int d2 = swlist2[ i ];
1772                                                                 //    int d3 = swlist3[ i ];
1773                                                                 //    int d4 = swlist4[ i ];
1774
1775                                                                 //    int dif = d1 - lastd;
1776                                                                 //    string s = "";
1777                                                                 //    if ( 16 <= dif && dif <= 17 )
1778                                                                 //    {
1779                                                                 //    }
1780                                                                 //    else
1781                                                                 //    {
1782                                                                 //        s = "★";
1783                                                                 //    }
1784                                                                 //    Trace.TraceInformation( "frame {0:D4}: {1:D3} ( {2:D3}, {3:D3}, {4:D3} ) {5}, n現在時刻={6}", f, dif, d1, d2, d3, s, d4 );
1785                                                                 //    lastd = d1;
1786                                                                 //    f++;
1787                                                                 //}
1788                                                                 //swlist1.Clear();
1789                                                                 //swlist2.Clear();
1790                                                                 //swlist3.Clear();
1791                                                                 //swlist4.Clear();
1792
1793                                                                 #region [ プラグイン On演奏キャンセル() の呼び出し ]
1794                                                                 //---------------------
1795                                                                 foreach (STPlugin pg in this.listプラグイン)
1796                                                                 {
1797                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1798                                                                         pg.plugin.On演奏キャンセル(scoreIni);
1799                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1800                                                                 }
1801                                                                 //---------------------
1802                                                                 #endregion
1803
1804                                                                 DTX.t全チップの再生停止();
1805                                                                 DTX.On非活性化();
1806                                                                 r現在のステージ.On非活性化();
1807                                                                 if (bコンパクトモード)
1808                                                                 {
1809                                                                         base.Window.Close();
1810                                                                 }
1811                                                                 else
1812                                                                 {
1813                                                                         Trace.TraceInformation("----------------------");
1814                                                                         Trace.TraceInformation("■ 選曲");
1815                                                                         stage選曲.On活性化();
1816                                                                         r直前のステージ = r現在のステージ;
1817                                                                         r現在のステージ = stage選曲;
1818
1819                                                                         #region [ プラグイン Onステージ変更() の呼び出し ]
1820                                                                         //---------------------
1821                                                                         foreach (STPlugin pg in this.listプラグイン)
1822                                                                         {
1823                                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1824                                                                                 pg.plugin.Onステージ変更();
1825                                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1826                                                                         }
1827                                                                         //---------------------
1828                                                                         #endregion
1829
1830                                                                         this.tガベージコレクションを実行する();
1831                                                                 }
1832                                                                 break;
1833                                                         //-----------------------------
1834                                                         #endregion
1835
1836                                                         case (int)E演奏画面の戻り値.ステージ失敗:
1837                                                                 #region [ 演奏失敗(StageFailed) ]
1838                                                                 //-----------------------------
1839                                                                 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新("Stage failed");
1840
1841                                                                 #region [ プラグイン On演奏失敗() の呼び出し ]
1842                                                                 //---------------------
1843                                                                 foreach (STPlugin pg in this.listプラグイン)
1844                                                                 {
1845                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1846                                                                         pg.plugin.On演奏失敗(scoreIni);
1847                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1848                                                                 }
1849                                                                 //---------------------
1850                                                                 #endregion
1851
1852                                                                 DTX.t全チップの再生停止();
1853                                                                 DTX.On非活性化();
1854                                                                 r現在のステージ.On非活性化();
1855                                                                 if (bコンパクトモード)
1856                                                                 {
1857                                                                         base.Window.Close();
1858                                                                 }
1859                                                                 else
1860                                                                 {
1861                                                                         Trace.TraceInformation("----------------------");
1862                                                                         Trace.TraceInformation("■ 選曲");
1863                                                                         stage選曲.On活性化();
1864                                                                         r直前のステージ = r現在のステージ;
1865                                                                         r現在のステージ = stage選曲;
1866
1867                                                                         #region [ プラグイン Onステージ変更() の呼び出し ]
1868                                                                         //---------------------
1869                                                                         foreach (STPlugin pg in this.listプラグイン)
1870                                                                         {
1871                                                                                 Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1872                                                                                 pg.plugin.Onステージ変更();
1873                                                                                 Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1874                                                                         }
1875                                                                         //---------------------
1876                                                                         #endregion
1877
1878                                                                         this.tガベージコレクションを実行する();
1879                                                                 }
1880                                                                 break;
1881                                                         //-----------------------------
1882                                                         #endregion
1883
1884                                                         case (int)E演奏画面の戻り値.ステージクリア:
1885                                                                 #region [ 演奏クリア ]
1886                                                                 //-----------------------------
1887                                                                 STDGBSValue<CScoreIni.C演奏記録> record;
1888                                                                 record = stage演奏画面.Record;
1889
1890                                                                 double playskill = 0.0;
1891
1892                                                                 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
1893                                                                 {
1894                                                                         if (!record[inst].b全AUTOである && record[inst].n全チップ数 > 0)
1895                                                                         {
1896                                                                                 playskill = record[inst].db演奏型スキル値;
1897                                                                         }
1898                                                                 }
1899
1900                                                                 string str = "Cleared";
1901                                                                 switch (CScoreIni.t総合ランク値を計算して返す(record))
1902                                                                 {
1903                                                                         case CScoreIni.ERANK.SS:
1904                                                                                 str = string.Format("Cleared (SS: {0:F2})", playskill);
1905                                                                                 break;
1906
1907                                                                         case CScoreIni.ERANK.S:
1908                                                                                 str = string.Format("Cleared (S: {0:F2})", playskill);
1909                                                                                 break;
1910
1911                                                                         case CScoreIni.ERANK.A:
1912                                                                                 str = string.Format("Cleared (A: {0:F2})", playskill);
1913                                                                                 break;
1914
1915                                                                         case CScoreIni.ERANK.B:
1916                                                                                 str = string.Format("Cleared (B: {0:F2})", playskill);
1917                                                                                 break;
1918
1919                                                                         case CScoreIni.ERANK.C:
1920                                                                                 str = string.Format("Cleared (C: {0:F2})", playskill);
1921                                                                                 break;
1922
1923                                                                         case CScoreIni.ERANK.D:
1924                                                                                 str = string.Format("Cleared (D: {0:F2})", playskill);
1925                                                                                 break;
1926
1927                                                                         case CScoreIni.ERANK.E:
1928                                                                                 str = string.Format("Cleared (E: {0:F2})", playskill);
1929                                                                                 break;
1930
1931                                                                         case CScoreIni.ERANK.UNKNOWN:   // #23534 2010.10.28 yyagi add: 演奏チップが0個のとき
1932                                                                                 str = "Cleared (No chips)";
1933                                                                                 break;
1934                                                                 }
1935
1936                                                                 scoreIni = this.tScoreIniへBGMAdjustとHistoryとPlayCountを更新(str);
1937
1938                                                                 #region [ プラグイン On演奏クリア() の呼び出し ]
1939                                                                 //---------------------
1940                                                                 foreach (STPlugin pg in this.listプラグイン)
1941                                                                 {
1942                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1943                                                                         pg.plugin.On演奏クリア(scoreIni);
1944                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1945                                                                 }
1946                                                                 //---------------------
1947                                                                 #endregion
1948
1949                                                                 r現在のステージ.On非活性化();
1950                                                                 Trace.TraceInformation("----------------------");
1951                                                                 Trace.TraceInformation("■ 結果");
1952                                                                 stage結果.st演奏記録 = record;
1953                                                                 stage結果.r空うちドラムチップ = stage演奏画面.GetNoChipDrums();
1954                                                                 stage結果.On活性化();
1955                                                                 r直前のステージ = r現在のステージ;
1956                                                                 r現在のステージ = stage結果;
1957
1958                                                                 #region [ プラグイン Onステージ変更() の呼び出し ]
1959                                                                 //---------------------
1960                                                                 foreach (STPlugin pg in this.listプラグイン)
1961                                                                 {
1962                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
1963                                                                         pg.plugin.Onステージ変更();
1964                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
1965                                                                 }
1966                                                                 //---------------------
1967                                                                 #endregion
1968
1969                                                                 break;
1970                                                                 //-----------------------------
1971                                                                 #endregion
1972                                                 }
1973                                                 //-----------------------------
1974                                                 #endregion
1975                                                 break;
1976
1977                                         case CStage.Eステージ.結果:
1978                                                 #region [ *** ]
1979                                                 //-----------------------------
1980                                                 if (this.n進行描画の戻り値 != 0)
1981                                                 {
1982                                                         // #35417 2015.08.30 chnmr0 changed : ステージクリア処理で入れ替えるため元に戻した
1983                                                         // #35417 2015.8.18 yyagi: AUTO系のフラグ入れ替えは削除可能!?。以後AUTOフラグに全くアクセスしておらず、意味がないため。
1984                                                         if (CDTXMania.Instance.ConfigIni.bIsSwappedGuitarBass)      // #24415 2011.2.27 yyagi Gt/Bsを入れ替えていたなら、Auto状態をリザルト画面終了後に元に戻す
1985                                                         {
1986                                                                 CDTXMania.Instance.ConfigIni.SwapGuitarBassInfos_AutoFlags();   // Auto入れ替え
1987                                                         }
1988
1989                                                         DTX.t全チップの再生一時停止();
1990                                                         DTX.On非活性化();
1991                                                         r現在のステージ.On非活性化();
1992                                                         if (!bコンパクトモード)
1993                                                         {
1994                                                                 Trace.TraceInformation("----------------------");
1995                                                                 Trace.TraceInformation("■ 選曲");
1996                                                                 stage選曲.On活性化();
1997                                                                 r直前のステージ = r現在のステージ;
1998                                                                 r現在のステージ = stage選曲;
1999
2000                                                                 foreach (STPlugin pg in this.listプラグイン)
2001                                                                 {
2002                                                                         Directory.SetCurrentDirectory(pg.strプラグインフォルダ);
2003                                                                         pg.plugin.Onステージ変更();
2004                                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2005                                                                 }
2006
2007                                                                 this.tガベージコレクションを実行する();
2008                                                         }
2009                                                         else
2010                                                         {
2011                                                                 base.Window.Close();
2012                                                         }
2013                                                 }
2014                                                 //-----------------------------
2015                                                 #endregion
2016                                                 break;
2017
2018                                         case CStage.Eステージ.ChangeSkin:
2019                                                 #region [ *** ]
2020                                                 //-----------------------------
2021                                                 if (this.n進行描画の戻り値 != 0)
2022                                                 {
2023                                                         r現在のステージ.On非活性化();
2024                                                         Trace.TraceInformation("----------------------");
2025                                                         Trace.TraceInformation("■ 選曲");
2026                                                         stage選曲.On活性化();
2027                                                         r直前のステージ = r現在のステージ;
2028                                                         r現在のステージ = stage選曲;
2029                                                         this.tガベージコレクションを実行する();
2030                                                 }
2031                                                 //-----------------------------
2032                                                 #endregion
2033                                                 break;
2034
2035                                         case CStage.Eステージ.終了:
2036                                                 #region [ *** ]
2037                                                 //-----------------------------
2038                                                 if (this.n進行描画の戻り値 != 0)
2039                                                 {
2040                                                         base.Exit();
2041                                                 }
2042                                                 //-----------------------------
2043                                                 #endregion
2044                                                 break;
2045                                 }
2046                         }
2047                         this.Device.EndScene();
2048                         // Present()は game.csのOnFrameEnd()に登録された、GraphicsDeviceManager.game_FrameEnd() 内で実行されるので不要
2049                         // (つまり、Present()は、Draw()完了後に実行される)
2050 #if !GPUFlushAfterPresent
2051                         actFlushGPU.On進行描画();       // Flush GPU        // EndScene()~Present()間 (つまりVSync前) でFlush実行
2052 #endif
2053                         if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2054                         {
2055                                 Sound管理.t再生中の処理をする();   // サウンドバッファの更新; 画面描画と同期させることで、スクロールをスムーズにする
2056                         }
2057
2058                         #region [ マウスカーソル消去制御 ]
2059                         if (cMouseHideControl != null) cMouseHideControl.tHideCursorIfNeed();
2060                         #endregion
2061                         #region [ 全画面・ウインドウ切り替え ]
2062                         if (this.b次のタイミングで全画面_ウィンドウ切り替えを行う)
2063                         {
2064                                 // ConfigIni.bFullScreen.Value = !ConfigIni.bFullScreen;
2065                                 Instance.t全画面_ウィンドウモード切り替え();
2066                                 this.b次のタイミングで全画面_ウィンドウ切り替えを行う = false;
2067                         }
2068                         #endregion
2069                         #region [ 垂直基線同期切り替え ]
2070                         if (this.b次のタイミングで垂直帰線同期切り替えを行う)
2071                         {
2072                                 bool bIsMaximized = this.Window.IsMaximized;                                            // #23510 2010.11.3 yyagi: to backup current window mode before changing VSyncWait
2073                                 currentClientSize = this.Window.ClientSize;                                             // #23510 2010.11.3 yyagi: to backup current window size before changing VSyncWait
2074                                 DeviceSettings currentSettings = Instance.GraphicsDeviceManager.CurrentSettings;
2075                                 currentSettings.EnableVSync = ConfigIni.bVSyncWait;
2076                                 Instance.GraphicsDeviceManager.ChangeDevice(currentSettings);
2077                                 this.b次のタイミングで垂直帰線同期切り替えを行う = false;
2078                                 base.Window.ClientSize = new Size(currentClientSize.Width, currentClientSize.Height);   // #23510 2010.11.3 yyagi: to resume window size after changing VSyncWait
2079                                 if (bIsMaximized)
2080                                 {
2081                                         this.Window.WindowState = FormWindowState.Maximized;                                // #23510 2010.11.3 yyagi: to resume window mode after changing VSyncWait
2082                                 }
2083                         }
2084                         #endregion
2085
2086                         GC.Collect( 0, GCCollectionMode.Optimized, false );             // Rel105で処理が重くなっていることに対する、暫定処置。
2087                                                                                                                                         // 重くなっている原因に対する適切な処置をして、処理が104程度に軽くなったら、
2088                                                                                                                                         // この暫定処置は削除します。
2089                 }
2090
2091                 /// <summary>
2092                 /// XML ファイルからオブジェクトを生成します。
2093                 /// </summary>
2094                 /// <param name="xmlfile">オブジェクトが記述される XML のパス。これは DataContract によってシリアライズされていなければなりません。</param>
2095                 /// <returns>生成したオブジェクト。正しく生成できなかった場合 null 。</returns>
2096                 public static object DeserializeXML(string xmlpath, Type t)
2097                 {
2098                         object ret = null;
2099                         try
2100                         {
2101                                 if (File.Exists(xmlpath))
2102                                 {
2103                                         using (XmlReader xr = XmlReader.Create(xmlpath))
2104                                         {
2105                                                 DataContractSerializer serializer = new DataContractSerializer(t);
2106                                                 ret = serializer.ReadObject(xr);
2107                                         }
2108                                 }
2109                         }
2110                         catch (Exception e)
2111                         {
2112                                 Trace.TraceWarning( e.Message );
2113                                 ret = null;
2114                         }
2115                         return ret;
2116                 }
2117
2118                 /// <summary>
2119                 /// オブジェクトから XML ファイルを生成します。
2120                 /// </summary>
2121                 /// <param name="xmlfile">XML ファイルのパス。</param>
2122                 /// <param name="obj">XML としてシリアライズするオブジェクト。DataContract 属性を持つクラスからインスタンス化されたオブジェクトです。</param>
2123                 public static void SerializeXML(string xmlpath, object obj)
2124                 {
2125                         XmlWriterSettings settings = new XmlWriterSettings();
2126                         settings.IndentChars = "  ";
2127                         settings.Indent = true;
2128                         settings.NewLineChars = Environment.NewLine;
2129                         settings.Encoding = new System.Text.UTF8Encoding(false);
2130             using (FileStreamSSD fsssd = new FileStreamSSD(xmlpath))
2131             {
2132                 using (XmlWriter xw = XmlWriter.Create(fsssd, settings))
2133                 {
2134                     DataContractSerializer serializer = new DataContractSerializer(obj.GetType());
2135                     serializer.WriteObject(xw, obj);
2136                 }
2137             }
2138                 }
2139
2140                 public void SaveConfig()
2141                 {
2142                         #region [ Skinパスの絶対パス→相対パス変換 ]
2143                         string _strSystemSkinSubfolderPath = ConfigIni.strSystemSkinSubfolderPath.Value;
2144                         Uri uriRoot = new Uri( System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar ) );
2145                         if ( ConfigIni.strSystemSkinSubfolderPath.Value != null && ConfigIni.strSystemSkinSubfolderPath.Value.Length == 0 )
2146                         {
2147                                 // Config.iniが空の状態でDTXManiaをViewerとして起動・終了すると、strSystemSkinSubfolderFullName が空の状態でここに来る。
2148                                 // → 初期値として Default/ を設定する。
2149                                 ConfigIni.strSystemSkinSubfolderPath.Value = System.IO.Path.Combine( this.strEXEのあるフォルダ, "System" + System.IO.Path.DirectorySeparatorChar + "Default" + System.IO.Path.DirectorySeparatorChar );
2150                         }
2151
2152                         // 起動直後は(Loadの前にSaveを通るため)Skinパスには初期値の相対パスが入っている場合がある。
2153                         // そのため、以下の処理を通すために、いったん絶対パスに変換
2154                         if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2155                         {
2156                                 ConfigIni.strSystemSkinSubfolderPath.Value =
2157                                         Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2158                         }
2159
2160                         Uri uriPath = new Uri( System.IO.Path.Combine( ConfigIni.strSystemSkinSubfolderPath.Value, "." + System.IO.Path.DirectorySeparatorChar ) );
2161                         string relPath = uriRoot.MakeRelativeUri( uriPath ).ToString();                         // 相対パスを取得
2162                         relPath = System.Web.HttpUtility.UrlDecode( relPath );                                          // デコードする
2163                         relPath = relPath.Replace( '/', System.IO.Path.DirectorySeparatorChar );        // 区切り文字が\ではなく/なので置換する
2164                         ConfigIni.strSystemSkinSubfolderPath.Value = relPath;
2165                         #endregion
2166                         ConfigIni.strDTXManiaVersion.Value = CDTXMania.VERSION;
2167
2168                         CDTXMania.SerializeXML( strEXEのあるフォルダ + "Config.xml", ConfigIni );
2169
2170                         // 元の絶対パスに戻す
2171                         ConfigIni.strSystemSkinSubfolderPath.Value = _strSystemSkinSubfolderPath;
2172                 }
2173
2174                 public void LoadConfig()
2175                 {
2176                         string path = strEXEのあるフォルダ + "Config.xml";
2177
2178                         if (!File.Exists(path))
2179                         {
2180                                 SaveConfig();
2181                         }
2182                         if (File.Exists(path))
2183                         {
2184                                 ConfigIni = (CConfigXml)CDTXMania.DeserializeXML(path, typeof(CConfigXml));
2185                                 if (ConfigIni == null)
2186                                 {
2187                                         ConfigIni = new CConfigXml();
2188                                         SaveConfig();
2189                                 }
2190                                 // Skinパスの相対パスを、絶対パスに変換
2191                                 if ( !System.IO.Path.IsPathRooted( ConfigIni.strSystemSkinSubfolderPath.Value ) )
2192                                 {
2193                                         ConfigIni.strSystemSkinSubfolderPath.Value =
2194                                                 Path.Combine( Path.Combine( this.strEXEのあるフォルダ, "System" ), ConfigIni.strSystemSkinSubfolderPath );
2195                                 }
2196                         }
2197                 }
2198                 /// <summary>
2199                 /// 座標値を読み込む。Coordinates メンバ初期化後いつ呼び出しても構わない。
2200                 /// </summary>
2201                 public void UpdateCoordinates()
2202                 {
2203                         string coordXml = strEXEのあるフォルダ + "Coordinates.xml";
2204  
2205                         // デシリアライズ
2206                         if (File.Exists(coordXml))
2207                         {
2208                                 using (XmlReader xr = XmlReader.Create(coordXml))
2209                                 {
2210                                         DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2211                                         try
2212                                         {
2213                                                 Coordinates = (Coordinates.CCoordinates) serializer.ReadObject( xr );
2214                                         }
2215                                         catch (SerializationException e)
2216                                         {
2217                                                 Trace.TraceWarning( "Rel107以前の古いフォーマットのCoordinates.xmlが読み込まれました。無視します。\n" + e.Message );
2218                                         }
2219                                 }
2220                         }
2221                         // シリアライズ
2222                         XmlWriterSettings settings = new XmlWriterSettings();
2223                         settings.IndentChars = "  ";
2224                         settings.Indent = true;
2225                         settings.NewLineChars = Environment.NewLine;
2226                         settings.Encoding = new System.Text.UTF8Encoding( false );
2227                         using ( XmlWriter xw = XmlTextWriter.Create( coordXml, settings ) )
2228                         {
2229                                 //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
2230                                 //ns.Add( String.Empty, String.Empty );
2231
2232                                 //StreamWriter sw = new StreamWriter( "test2.xml", false, Encoding.UTF8 );
2233                                 //serializer.Serialize( sw, item, ns );
2234                                 //sw.Close
2235
2236                                 DataContractSerializer serializer = new DataContractSerializer( typeof( Coordinates.CCoordinates ) );
2237                                 serializer.WriteObject( xw, Coordinates );
2238                                 //serializer.WriteStartObject( xw, Coordinates );
2239                                 //xw.WriteAttributeString( "xmlns", "d1p1", "http://www.w3.org/2000/xmlns/",
2240                                 //      "http://schemas.microsoft.com/2003/10/Serialization/" );
2241                                 //serializer.WriteObjectContent( xw, Coordinates );
2242                                 //serializer.WriteEndObject( xw );
2243                         }
2244
2245                         // もう一度デシリアライズ
2246                         if (File.Exists(coordXml))
2247                         {
2248                                 using (XmlReader xr = XmlReader.Create(coordXml))
2249                                 {
2250                                         DataContractSerializer serializer = new DataContractSerializer(typeof(Coordinates.CCoordinates));
2251                                         Coordinates = (Coordinates.CCoordinates)serializer.ReadObject(xr);
2252                                 }
2253                         }
2254                 }
2255
2256
2257                 /// <summary>
2258                 /// 保存するxmlからnamespaceを削除するためのXmlTextWriter
2259                 /// </summary>
2260                 //public class MyXmlTextWriter : XmlTextWriter
2261                 //{
2262                 //      private bool _ignoreAttr = false;
2263
2264                 //      public MyXmlTextWriter( TextWriter w  )
2265                 //              : base( w )
2266                 //      {
2267                 //              Debug.WriteLine( "create" );
2268                 //      }
2269
2270                 //      public override string LookupPrefix( string ns )
2271                 //      {
2272                 //              Debug.WriteLine( "luprefix" );
2273                 //              return string.Empty;
2274                 //      }
2275
2276                 //      public override void WriteStartAttribute( string prefix, string localName, string ns )
2277                 //      {
2278                 //              Debug.WriteLine( "writestartattribute" );
2279                 //              if ( String.Compare( prefix, "xmlns", true ) == 0 )
2280                 //              {
2281                 //                      Debug.WriteLine( "[!]" );
2282                 //                      this._ignoreAttr = true;
2283                 //                      return;
2284                 //              }
2285                 //      }
2286
2287                 //      public override void WriteEndAttribute()
2288                 //      {
2289                 //              if ( this._ignoreAttr )
2290                 //              {
2291                 //                      this._ignoreAttr = false;
2292                 //                      return;
2293                 //              }
2294                 //              base.WriteEndAttribute();
2295                 //      }
2296
2297                 //      public override void WriteString( string text )
2298                 //      {
2299                 //              Debug.WriteLine( "ws" );
2300                 //              if ( String.Compare( text, "http://www.w3.org/2001/XMLSchema-instance", true ) == 0 )
2301                 //              {
2302                 //                      return;
2303                 //              }
2304                 //              base.WriteString( text );
2305                 //      }
2306
2307                 //      public override void WriteStartElement( string prefix, string localName, string ns )
2308                 //      {
2309                 //              Debug.WriteLine( "wse" );
2310                 //              base.WriteStartElement( null, localName, null );
2311                 //      }
2312                 //}
2313
2314                 public void ShowWindowTitleWithSoundType()
2315                 {
2316                         string delay = "";
2317                         if (Sound管理.CurrentSoundDeviceType != ESoundDeviceType.DirectSound)
2318                         {
2319                                 delay = "(" + Sound管理.GetSoundDelay() + "ms)";
2320                         }
2321                         base.Window.Text = strWindowTitle;
2322                         if (!this.DTX2WAVmode.Enabled)
2323                         {
2324                                 base.Window.Text += " (" + Sound管理.GetCurrentSoundDeviceType() + delay + ")";
2325                         }
2326                 }
2327
2328                 #region [ private ]
2329                 //-----------------
2330                 private bool b終了処理完了済み;
2331                 private static CDTX dtx;
2332                 private List<CActivity> listトップレベルActivities;
2333                 private int n進行描画の戻り値;
2334                 private MouseButtons mb = System.Windows.Forms.MouseButtons.Left;
2335                 private string strWindowTitle
2336                 {
2337                         get
2338                         {
2339                                 if (DTXVmode.Enabled)
2340                                 {
2341                                         return "DTXMViewer release " + VERSION;
2342                                 }
2343                                 else if (DTX2WAVmode.Enabled)
2344                                 {
2345                                         return "DTX2WAV (" + VERSION + "): " + Path.GetFileName(this.DTX2WAVmode.dtxfilename);
2346                                 }
2347                                 else
2348                                 {
2349                                         return "DTXMania .NET style release " + VERSION;
2350                                 }
2351                         }
2352                 }
2353                 private CSound previewSound;
2354                 private CMouseHideControl cMouseHideControl = null;
2355
2356                 private void t終了処理()
2357                 {
2358                         if (!this.b終了処理完了済み)
2359                         {
2360                                 Trace.TraceInformation("----------------------");
2361                                 Trace.TraceInformation("■ アプリケーションの終了");
2362                                 #region[ 電源プランの復元 ]
2363                                 CPowerPlan.RestoreCurrentPowerPlan();           // 電源プランを元のものに戻す
2364                                 #endregion
2365                                 #region [ 曲検索の終了処理 ]
2366                                 //---------------------
2367                                 if (actEnumSongs != null)
2368                                 {
2369                                         Trace.TraceInformation("曲検索actの終了処理を行います。");
2370                                         Trace.Indent();
2371                                         try
2372                                         {
2373                                                 actEnumSongs.On非活性化();
2374                                                 actEnumSongs = null;
2375                                                 Trace.TraceInformation("曲検索actの終了処理を完了しました。");
2376                                         }
2377                                         catch (Exception e)
2378                                         {
2379                                                 Trace.TraceError(e.Message);
2380                                                 Trace.TraceError("曲検索actの終了処理に失敗しました。");
2381                                         }
2382                                         finally
2383                                         {
2384                                                 Trace.Unindent();
2385                                         }
2386                                 }
2387                                 //---------------------
2388                                 #endregion
2389                                 #region [ 現在のステージの終了処理 ]
2390                                 //---------------------
2391                                 if (CDTXMania.Instance.r現在のステージ != null && CDTXMania.Instance.r現在のステージ.b活性化してる)     // #25398 2011.06.07 MODIFY FROM
2392                                 {
2393                                         Trace.TraceInformation("現在のステージを終了します。");
2394                                         Trace.Indent();
2395                                         try
2396                                         {
2397                                                 r現在のステージ.On非活性化();
2398                                                 Trace.TraceInformation("現在のステージの終了処理を完了しました。");
2399                                         }
2400                                         finally
2401                                         {
2402                                                 Trace.Unindent();
2403                                         }
2404                                 }
2405                                 //---------------------
2406                                 #endregion
2407
2408                                 #region [ 選曲ステージの終了処理 ]
2409                                 stage選曲.On非活性化();
2410                                 #endregion
2411
2412                                 #region [ プラグインの終了処理 ]
2413                                 //---------------------
2414                                 if (this.listプラグイン != null && this.listプラグイン.Count > 0)
2415                                 {
2416                                         Trace.TraceInformation("すべてのプラグインを終了します。");
2417                                         Trace.Indent();
2418                                         try
2419                                         {
2420                                                 foreach (STPlugin st in this.listプラグイン)
2421                                                 {
2422                                                         Directory.SetCurrentDirectory(st.strプラグインフォルダ);
2423                                                         st.plugin.OnUnmanagedリソースの解放();
2424                                                         st.plugin.OnManagedリソースの解放();
2425                                                         st.plugin.On終了();
2426                                                         Directory.SetCurrentDirectory(CDTXMania.Instance.strEXEのあるフォルダ);
2427                                                 }
2428                                                 PluginHost = null;
2429                                                 Trace.TraceInformation("すべてのプラグインの終了処理を完了しました。");
2430                                         }
2431                                         finally
2432                                         {
2433                                                 Trace.Unindent();
2434                                         }
2435                                 }
2436                                 //---------------------
2437                                 #endregion
2438                                 #region [ 曲リストの終了処理 ]
2439                                 //---------------------
2440                                 if (Songs管理 != null)
2441                                 {
2442                                         Trace.TraceInformation("曲リストの終了処理を行います。");
2443                                         Trace.Indent();
2444                                         try
2445                                         {
2446                                                 Songs管理 = null;
2447                                                 Trace.TraceInformation("曲リストの終了処理を完了しました。");
2448                                         }
2449                                         catch (Exception exception)
2450                                         {
2451                                                 Trace.TraceError(exception.Message);
2452                                                 Trace.TraceError("曲リストの終了処理に失敗しました。");
2453                                         }
2454                                         finally
2455                                         {
2456                                                 Trace.Unindent();
2457                                         }
2458                                 }
2459                                 CAvi.t終了();
2460                                 //---------------------
2461                                 #endregion
2462                                 #region [ スキンの終了処理 ]
2463                                 //---------------------
2464                                 if (Skin != null)
2465                                 {
2466                                         Trace.TraceInformation("スキンの終了処理を行います。");
2467                                         Trace.Indent();
2468                                         try
2469                                         {
2470                                                 Skin.Dispose();
2471                                                 Skin = null;
2472                                                 Trace.TraceInformation("スキンの終了処理を完了しました。");
2473                                         }
2474                                         catch (Exception exception2)
2475                                         {
2476                                                 Trace.TraceError(exception2.Message);
2477                                                 Trace.TraceError("スキンの終了処理に失敗しました。");
2478                                         }
2479                                         finally
2480                                         {
2481                                                 Trace.Unindent();
2482                                         }
2483                                 }
2484                                 //---------------------
2485                                 #endregion
2486                                 #region [ DirectSoundの終了処理 ]
2487                                 //---------------------
2488                                 if (Sound管理 != null)
2489                                 {
2490                                         Trace.TraceInformation("DirectSound の終了処理を行います。");
2491                                         Trace.Indent();
2492                                         try
2493                                         {
2494                                                 Sound管理.Dispose();
2495                                                 Sound管理 = null;
2496                                                 Trace.TraceInformation("DirectSound の終了処理を完了しました。");
2497                                         }
2498                                         catch (Exception exception3)
2499                                         {
2500                                                 Trace.TraceError(exception3.Message);
2501                                                 Trace.TraceError("DirectSound の終了処理に失敗しました。");
2502                                         }
2503                                         finally
2504                                         {
2505                                                 Trace.Unindent();
2506                                         }
2507                                 }
2508                                 //---------------------
2509                                 #endregion
2510                                 #region [ パッドの終了処理 ]
2511                                 //---------------------
2512                                 if (Pad != null)
2513                                 {
2514                                         Trace.TraceInformation("パッドの終了処理を行います。");
2515                                         Trace.Indent();
2516                                         try
2517                                         {
2518                                                 Pad = null;
2519                                                 Trace.TraceInformation("パッドの終了処理を完了しました。");
2520                                         }
2521                                         catch (Exception exception4)
2522                                         {
2523                                                 Trace.TraceError(exception4.Message);
2524                                                 Trace.TraceError("パッドの終了処理に失敗しました。");
2525                                         }
2526                                         finally
2527                                         {
2528                                                 Trace.Unindent();
2529                                         }
2530                                 }
2531                                 //---------------------
2532                                 #endregion
2533                                 #region [ DirectInput, MIDI入力の終了処理 ]
2534                                 //---------------------
2535                                 if (Input管理 != null)
2536                                 {
2537                                         Trace.TraceInformation("DirectInput, MIDI入力の終了処理を行います。");
2538                                         Trace.Indent();
2539                                         try
2540                                         {
2541                                                 Input管理.Dispose();
2542                                                 Input管理 = null;
2543                                                 Trace.TraceInformation("DirectInput, MIDI入力の終了処理を完了しました。");
2544                                         }
2545                                         catch (Exception exception5)
2546                                         {
2547                                                 Trace.TraceError(exception5.Message);
2548                                                 Trace.TraceError("DirectInput, MIDI入力の終了処理に失敗しました。");
2549                                         }
2550                                         finally
2551                                         {
2552                                                 Trace.Unindent();
2553                                         }
2554                                 }
2555                                 //---------------------
2556                                 #endregion
2557                                 #region [ 文字コンソールの終了処理 ]
2558                                 //---------------------
2559                                 if (act文字コンソール != null)
2560                                 {
2561                                         Trace.TraceInformation("文字コンソールの終了処理を行います。");
2562                                         Trace.Indent();
2563                                         try
2564                                         {
2565                                                 act文字コンソール.On非活性化();
2566                                                 act文字コンソール = null;
2567                                                 Trace.TraceInformation("文字コンソールの終了処理を完了しました。");
2568                                         }
2569                                         catch (Exception exception6)
2570                                         {
2571                                                 Trace.TraceError(exception6.Message);
2572                                                 Trace.TraceError("文字コンソールの終了処理に失敗しました。");
2573                                         }
2574                                         finally
2575                                         {
2576                                                 Trace.Unindent();
2577                                         }
2578                                 }
2579                                 //---------------------
2580                                 #endregion
2581                                 #region [ FPSカウンタの終了処理 ]
2582                                 //---------------------
2583                                 Trace.TraceInformation("FPSカウンタの終了処理を行います。");
2584                                 Trace.Indent();
2585                                 try
2586                                 {
2587                                         if (FPS != null)
2588                                         {
2589                                                 FPS = null;
2590                                         }
2591                                         Trace.TraceInformation("FPSカウンタの終了処理を完了しました。");
2592                                 }
2593                                 finally
2594                                 {
2595                                         Trace.Unindent();
2596                                 }
2597                                 //---------------------
2598                                 #endregion
2599                                 #region [ タイマの終了処理 ]
2600                                 //---------------------
2601                                 Trace.TraceInformation("タイマの終了処理を行います。");
2602                                 Trace.Indent();
2603                                 try
2604                                 {
2605                                         if (Timer != null)
2606                                         {
2607                                                 Timer.Dispose();
2608                                                 Timer = null;
2609                                                 Trace.TraceInformation("タイマの終了処理を完了しました。");
2610                                         }
2611                                         else
2612                                         {
2613                                                 Trace.TraceInformation("タイマは使用されていません。");
2614                                         }
2615                                 }
2616                                 finally
2617                                 {
2618                                         Trace.Unindent();
2619                                 }
2620                                 //---------------------
2621                                 #endregion
2622                                 #region [ Config.iniの出力 ]
2623                                 //---------------------
2624                                 Trace.TraceInformation("Config.xml を出力します。");
2625                                 //                              if ( ConfigIni.bIsSwappedGuitarBass )                   // #24063 2011.1.16 yyagi ギターベースがスワップしているときは元に戻す
2626                                 if (ConfigIni.bIsSwappedGuitarBass_AutoFlagsAreSwapped) // #24415 2011.2.21 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、AUTOのフラグをswapして戻す
2627                                 {
2628                                         ConfigIni.SwapGuitarBassInfos_AutoFlags();
2629                                 }
2630                                 /*
2631                                         if (ConfigIni.bIsSwappedGuitarBass_PlaySettingsAreSwapped)  // #35417 2015/8/18 yyagi FLIP中かつ演奏中にalt-f4で終了したときは、演奏設定のフラグをswapして戻す
2632                                         {
2633                                                         ConfigIni.SwapGuitarBassInfos_PlaySettings();
2634                                         }
2635                                  */
2636                                 string str = strEXEのあるフォルダ + "Config.xml";
2637                                 Trace.Indent();
2638                                 try
2639                                 {
2640                                         if (DTXVmode.Enabled)
2641                                         {
2642                                                 DTXVmode.tUpdateConfigIni();
2643                                                 Trace.TraceInformation("DTXVモードの設定情報を、Config.xmlに保存しました。");
2644                                         }
2645                                         else if (DTX2WAVmode.Enabled)
2646                                         {
2647                                                 DTX2WAVmode.tUpdateConfigIni();
2648                                                 Trace.TraceInformation("DTX2WAVモードの設定情報を、Config.xmlに保存しました。");
2649                                         }
2650                                         else
2651                                         {
2652                                                 CDTXMania.Instance.SaveConfig();
2653                                                 Trace.TraceInformation("保存しました。({0})", str);
2654                                         }
2655                                 }
2656                                 catch (Exception e)
2657                                 {
2658                                         Trace.TraceError(e.Message);
2659                                         Trace.TraceError("Config.xml の出力に失敗しました。({0})", str);
2660                                 }
2661                                 finally
2662                                 {
2663                                         Trace.Unindent();
2664                                 }
2665                                 //---------------------
2666                                 #endregion
2667                                 #region [ DTXVmodeの終了処理 ]
2668                                 //---------------------
2669                                 //Trace.TraceInformation( "DTXVモードの終了処理を行います。" );
2670                                 //Trace.Indent();
2671                                 try
2672                                 {
2673                                         if (DTXVmode != null)
2674                                         {
2675                                                 DTXVmode = null;
2676                                                 //Trace.TraceInformation( "DTXVモードの終了処理を完了しました。" );
2677                                         }
2678                                         else
2679                                         {
2680                                                 //Trace.TraceInformation( "DTXVモードは使用されていません。" );
2681                                         }
2682                                 }
2683                                 finally
2684                                 {
2685                                         //Trace.Unindent();
2686                                 }
2687                                 //---------------------
2688                                 #endregion
2689                                 #region [ DirectXの終了処理 ]
2690                                 //---------------------
2691                                 base.GraphicsDeviceManager.Dispose();
2692                                 //---------------------
2693                                 #endregion
2694                                 Trace.TraceInformation( "アプリケーションの終了処理を完了しました。" );
2695
2696
2697                                 this.b終了処理完了済み = true;
2698                         }
2699                 }
2700                 private CScoreIni tScoreIniへBGMAdjustとHistoryとPlayCountを更新(string str新ヒストリ行)
2701                 {
2702                         STDGBSValue<bool> isUpdated = new STDGBSValue<bool>();
2703                         string strFilename = DTX.strファイル名の絶対パス + ".score.ini";
2704                         CScoreIni ini = new CScoreIni(strFilename);
2705                         if (!File.Exists(strFilename))
2706                         {
2707                                 ini.stファイル.Title = DTX.TITLE;
2708                                 ini.stファイル.Name = DTX.strファイル名;
2709                                 ini.stファイル.Hash = CScoreIni.tファイルのMD5を求めて返す(DTX.strファイル名の絶対パス);
2710                                 for (EPart i = EPart.Drums; i <= EPart.Bass; ++i)
2711                                 {
2712                                         ini.stセクション.HiScore[i].nPerfectになる範囲ms = nPerfect範囲ms;
2713                                         ini.stセクション.HiScore[i].nGreatになる範囲ms = nGreat範囲ms;
2714                                         ini.stセクション.HiScore[i].nGoodになる範囲ms = nGood範囲ms;
2715                                         ini.stセクション.HiScore[i].nPoorになる範囲ms = nPoor範囲ms;
2716
2717                                         ini.stセクション.HiSkill[i].nPerfectになる範囲ms = nPerfect範囲ms;
2718                                         ini.stセクション.HiSkill[i].nGreatになる範囲ms = nGreat範囲ms;
2719                                         ini.stセクション.HiSkill[i].nGoodになる範囲ms = nGood範囲ms;
2720                                         ini.stセクション.HiSkill[i].nPoorになる範囲ms = nPoor範囲ms;
2721
2722                                         ini.stセクション.LastPlay[i].nPerfectになる範囲ms = nPerfect範囲ms;
2723                                         ini.stセクション.LastPlay[i].nGreatになる範囲ms = nGreat範囲ms;
2724                                         ini.stセクション.LastPlay[i].nGoodになる範囲ms = nGood範囲ms;
2725                                         ini.stセクション.LastPlay[i].nPoorになる範囲ms = nPoor範囲ms;
2726                                 }
2727                         }
2728                         ini.stファイル.BGMAdjust = DTX.nBGMAdjust;
2729                         isUpdated = CScoreIni.t更新条件を取得する();
2730                         if (isUpdated.Drums || isUpdated.Guitar || isUpdated.Bass)
2731                         {
2732                                 if (isUpdated.Drums)
2733                                 {
2734                                         ini.stファイル.PlayCountDrums++;
2735                                 }
2736                                 if (isUpdated.Guitar)
2737                                 {
2738                                         ini.stファイル.PlayCountGuitar++;
2739                                 }
2740                                 if (isUpdated.Bass)
2741                                 {
2742                                         ini.stファイル.PlayCountBass++;
2743                                 }
2744                                 ini.tヒストリを追加する(str新ヒストリ行);
2745                                 if (!bコンパクトモード)
2746                                 {
2747                                         stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Drums = ini.stファイル.PlayCountDrums;
2748                                         stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Guitar = ini.stファイル.PlayCountGuitar;
2749                                         stage選曲.r現在選択中のスコア.譜面情報.演奏回数.Bass = ini.stファイル.PlayCountBass;
2750                                         for (int j = 0; j < ini.stファイル.History.Length; j++)
2751                                         {
2752                                                 stage選曲.r現在選択中のスコア.譜面情報.演奏履歴[j] = ini.stファイル.History[j];
2753                                         }
2754                                 }
2755                         }
2756                         if (ConfigIni.bScoreIni)
2757                         {
2758                                 ini.t書き出し(strFilename);
2759                         }
2760
2761                         return ini;
2762                 }
2763                 private void tガベージコレクションを実行する()
2764                 {
2765                         GC.Collect(0, GCCollectionMode.Optimized, true );
2766                         GC.WaitForPendingFinalizers();
2767                         GC.Collect(0, GCCollectionMode.Forced, true );
2768                         GC.WaitForPendingFinalizers();
2769                 }
2770                 private void tプラグイン検索と生成()
2771                 {
2772                         this.listプラグイン = new List<STPlugin>();
2773
2774                         string strIPluginActivityの名前 = typeof(IPluginActivity).FullName;
2775                         string strプラグインフォルダパス = strEXEのあるフォルダ + "Plugins\\";
2776
2777                         this.t指定フォルダ内でのプラグイン検索と生成(strプラグインフォルダパス, strIPluginActivityの名前);
2778
2779                         if (this.listプラグイン.Count > 0)
2780                                 Trace.TraceInformation(this.listプラグイン.Count + " 個のプラグインを読み込みました。");
2781                 }
2782
2783                 private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
2784                 {
2785                         var domain = (AppDomain)sender;
2786
2787                         foreach (var assembly in domain.GetAssemblies())
2788                         {
2789                                 if (assembly.FullName == args.Name)
2790                                         return assembly;
2791                         }
2792                         return null;
2793                 }
2794                 private void t指定フォルダ内でのプラグイン検索と生成(string strプラグインフォルダパス, string strプラグイン型名)
2795                 {
2796                         // 指定されたパスが存在しないとエラー
2797                         if (!Directory.Exists(strプラグインフォルダパス))
2798                         {
2799                                 Trace.TraceWarning("プラグインフォルダが存在しません。(" + strプラグインフォルダパス + ")");
2800                                 return;
2801                         }
2802
2803                         AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2804
2805
2806                         // (1) すべての *.dll について…
2807                         string[] strDLLs = System.IO.Directory.GetFiles(strプラグインフォルダパス, "*.dll");
2808                         foreach (string dllName in strDLLs)
2809                         {
2810                                 if (Path.GetExtension(dllName).ToLower() != ".dll")
2811                                 {
2812                                         continue;
2813                                 }
2814                                 try
2815                                 {
2816                                         // (1-1) dll をアセンブリとして読み込む。
2817                                         System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllName);
2818
2819                                         // (1-2) アセンブリ内のすべての型について、プラグインとして有効か調べる
2820                                         foreach (Type t in asm.GetTypes())
2821                                         {
2822                                                 //  (1-3) ↓クラスであり↓Publicであり↓抽象クラスでなく↓IPlugin型のインスタンスが作れる 型を持っていれば有効
2823                                                 if (t.IsClass && t.IsPublic && !t.IsAbstract && t.GetInterface(strプラグイン型名) != null)
2824                                                 {
2825                                                         // (1-4) クラス名からインスタンスを作成する
2826                                                         var st = new STPlugin()
2827                                                         {
2828                                                                 plugin = (IPluginActivity)asm.CreateInstance(t.FullName),
2829                                                                 strプラグインフォルダ = Path.GetDirectoryName(dllName),
2830                                                                 strアセンブリ簡易名 = asm.GetName().Name,
2831                                                                 Version = asm.GetName().Version,
2832                                                         };
2833
2834                                                         // (1-5) プラグインリストへ登録
2835                                                         this.listプラグイン.Add(st);
2836                                                         Trace.TraceInformation("プラグイン {0} ({1}, {2}, {3}) を読み込みました。", t.FullName, Path.GetFileName(dllName), st.strアセンブリ簡易名, st.Version.ToString());
2837                                                 }
2838                                         }
2839                                 }
2840                                 catch (System.Reflection.ReflectionTypeLoadException e)
2841                                 {
2842                                         Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2843                                         Trace.TraceInformation(e.ToString());
2844                                         Trace.TraceInformation(e.Message);
2845                                         {
2846                                                 StringBuilder sb = new StringBuilder();
2847                                                 foreach (Exception exSub in e.LoaderExceptions)
2848                                                 {
2849                                                         sb.AppendLine(exSub.Message);
2850                                                         FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
2851                                                         if (exFileNotFound != null)
2852                                                         {
2853                                                                 if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
2854                                                                 {
2855                                                                         sb.AppendLine("Fusion Log:");
2856                                                                         sb.AppendLine(exFileNotFound.FusionLog);
2857                                                                 }
2858                                                         }
2859                                                         sb.AppendLine();
2860                                                 }
2861                                                 string errorMessage = sb.ToString();
2862                                                 //Display or log the error based on your application.
2863                                                 Trace.TraceInformation(errorMessage);
2864                                         }
2865                                 }
2866                                 catch (Exception e)
2867                                 {
2868                                         Trace.TraceInformation(dllName + " からプラグインを生成することに失敗しました。スキップします。");
2869                                         Trace.TraceInformation(e.ToString());
2870                                         Trace.TraceInformation(e.Message);
2871                                 }
2872                         }
2873
2874                         // (2) サブフォルダがあれば再帰する
2875                         string[] strDirs = Directory.GetDirectories(strプラグインフォルダパス, "*");
2876                         foreach (string dir in strDirs)
2877                                 this.t指定フォルダ内でのプラグイン検索と生成(dir + "\\", strプラグイン型名);
2878                 }
2879                 //-----------------
2880                 #region [ Windowイベント処理 ]
2881                 private void Window_ApplicationActivated( object sender, EventArgs e )
2882                 {
2883                         this.bApplicationActive = true;
2884                 }
2885                 private void Window_ApplicationDeactivated(object sender, EventArgs e)
2886                 {
2887                         this.bApplicationActive = false;
2888                         if (cMouseHideControl != null) cMouseHideControl.Show();
2889                 }
2890                 private void Window_KeyDown(object sender, KeyEventArgs e)
2891                 {
2892                         if (e.KeyCode == Keys.Menu)
2893                         {
2894                                 e.Handled = true;
2895                                 e.SuppressKeyPress = true;
2896                         }
2897                         else if ((e.KeyCode == Keys.Return) && e.Alt)
2898                         {
2899                                 if (ConfigIni != null)
2900                                 {
2901                                         ConfigIni.bウィンドウモード = !ConfigIni.bウィンドウモード;
2902                                         this.t全画面_ウィンドウモード切り替え();
2903                                 }
2904                                 e.Handled = true;
2905                                 e.SuppressKeyPress = true;
2906                         }
2907                         else
2908                         {
2909                                 for (int i = 0; i < CConfigXml.AssignableCodes; i++)
2910                                 {
2911                                         var captureCode = (SlimDX.DirectInput.Key) ConfigIni.KeyAssign[ EPad.Capture ][ i ].コード;
2912
2913                                         if( (int) captureCode > 0 &&
2914                                                 e.KeyCode == DeviceConstantConverter.KeyToKeys( captureCode ) )
2915                                         {
2916                                                 // Debug.WriteLine( "capture: " + string.Format( "{0:2x}", (int) e.KeyCode ) + " " + (int) e.KeyCode );
2917                                                 string strFullPath =
2918                                                                  Path.Combine( CDTXMania.Instance.strEXEのあるフォルダ, "Capture_img" );
2919                                                 strFullPath = Path.Combine( strFullPath, DateTime.Now.ToString( "yyyyMMddHHmmss" ) + ".png" );
2920                                                 SaveResultScreen( strFullPath );
2921                                         }
2922                                 }
2923                         }
2924                 }
2925                 private void Window_MouseUp(object sender, MouseEventArgs e)
2926                 {
2927                         mb = e.Button;
2928                 }
2929
2930                 private void Window_MouseDoubleClick(object sender, MouseEventArgs e)   // #23510 2010.11.13 yyagi: to go full screen mode
2931                 {
2932                         if (mb.Equals(MouseButtons.Left) && ConfigIni.bIsAllowedDoubleClickFullscreen)  // #26752 2011.11.27 yyagi
2933                         {
2934                                 ConfigIni.bウィンドウモード = false;
2935                                 this.t全画面_ウィンドウモード切り替え();
2936                         }
2937                 }
2938                 private void Window_MouseMove(object sender, MouseEventArgs e)
2939                 {
2940                         if (cMouseHideControl != null) cMouseHideControl.tResetCursorState(ConfigIni.bウィンドウモード, this.bApplicationActive);
2941                 }
2942
2943                 private void Window_ResizeEnd(object sender, EventArgs e)               // #23510 2010.11.20 yyagi: to get resized window size
2944                 {
2945                         if (ConfigIni.bウィンドウモード)
2946                         {
2947                                 ConfigIni.rcWindow.X = base.Window.Location.X; // #30675 2013.02.04 ikanick add
2948                                 ConfigIni.rcWindow.Y = base.Window.Location.Y; //
2949                         }
2950
2951                         ConfigIni.rcWindow.W = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Width : currentClientSize.Width;   // #23510 2010.10.31 yyagi add
2952                         ConfigIni.rcWindow.H = (ConfigIni.bウィンドウモード) ? base.Window.ClientSize.Height : currentClientSize.Height;
2953                 }
2954                 #endregion
2955
2956                 //Stopwatch sw = new Stopwatch();
2957                 //List<int> swlist1, swlist2, swlist3, swlist4, swlist5;
2958
2959                 #endregion
2960
2961                 private class CMouseHideControl
2962                 {
2963                         private Point lastPosition;
2964                         private CCounter ccMouseShow;
2965                         private bool bマウスカーソル表示中;
2966
2967                         /// <summary>
2968                         /// コンストラクタ
2969                         /// </summary>
2970                         public CMouseHideControl()
2971                         {
2972                                 ccMouseShow = new CCounter();
2973                                 lastPosition = Cursor.Position;
2974                                 bマウスカーソル表示中 = true;
2975                                 t開始();
2976                         }
2977
2978                         public void t開始()
2979                         {
2980                                 ccMouseShow.t開始(0, 20, 100, CDTXMania.instance.Timer);
2981                         }
2982
2983                         public void tHideCursorIfNeed()
2984                         {
2985                                 ccMouseShow.t進行();
2986 //Trace.TraceInformation("n現在の経過時間ms" + ccMouseShow.n現在の経過時間ms + ", n現在の値=" + ccMouseShow.n現在の値 + ", b終了値に達した=" + ccMouseShow.b終了値に達した);
2987                                 if (bマウスカーソル表示中 && ccMouseShow.b終了値に達した)
2988                                 {
2989                                         Point client_point = CDTXMania.Instance.Window.PointToClient(Cursor.Position);
2990                                         if (client_point.Y >= 0)        // タイトルバー上にマウスカーソルがある場合は、隠さない
2991                                         {
2992                                                 Hide();
2993                                         }
2994                                 }
2995
2996                         }
2997
2998                         public void tResetCursorState(bool bWindowed, bool bApplicationActive)
2999                         {
3000 //Trace.TraceInformation("マウス移動: " + Cursor.Position.X + "," + Cursor.Position.Y);
3001                                 if ((bWindowed == true && bマウスカーソル表示中 == false) || bApplicationActive == false)   // #36168 2016.3.19 yyagi: do not to show mouse cursor in full screen mode
3002                                 {
3003                                         Point currentPosition = Cursor.Position;
3004 //Trace.TraceInformation("current=" + currentPosition.ToString() + ", last=" + lastPosition.ToString());
3005                                         if (lastPosition != currentPosition)
3006                                         {
3007 //Trace.TraceInformation("移動発生");
3008                                                 lastPosition = currentPosition;
3009                                                 Show();
3010                                                 t開始();
3011                                         }
3012                                 }
3013                         }
3014
3015                         public void Show()
3016                         {
3017                                 Cursor.Show();
3018                                 bマウスカーソル表示中 = true;
3019                         }
3020                         public void Hide()
3021                         {
3022                                 Cursor.Hide();
3023                                 bマウスカーソル表示中 = false;
3024                         }
3025                 }
3026
3027                 /// <summary>
3028                 /// システム環境のログを出力する
3029                 /// </summary>
3030                 private void PutSystemLog()
3031                 {
3032                         System.Management.ManagementClass mc =
3033                                 new System.Management.ManagementClass("Win32_Processor");
3034                         System.Management.ManagementObjectCollection moc = mc.GetInstances();
3035                         foreach (System.Management.ManagementObject mo in moc)
3036                         {
3037                                 Trace.TraceInformation("-------------------------");
3038                                 Trace.TraceInformation("CPU Information:");
3039                                 //Trace.TraceInformation("DeviceID      = {0}", mo["DeviceID"]);
3040                                 Trace.TraceInformation("Name          = {0}", mo["Name"]);
3041                                 Trace.TraceInformation("MaxClockSpeed = {0}MHz", mo["MaxClockSpeed"]);
3042                                 Trace.TraceInformation("L2CacheSize   = {0}KB", mo["L2CacheSize"]);
3043                                 Trace.TraceInformation("L3CacheSize   = {0}KB", mo["L3CacheSize"]);
3044                                 Trace.TraceInformation("NumberOfLogicalProcessors = {0}", mo["NumberOfLogicalProcessors"]);
3045                         }
3046                         moc.Dispose();
3047                         moc.Dispose();
3048
3049                         //System.Management.ManagementClass mc =
3050                         //      new System.Management.ManagementClass("Win32_OperatingSystem");
3051                         //System.Management.ManagementObjectCollection moc = mc.GetInstances();
3052                         mc =
3053                                 new System.Management.ManagementClass("Win32_OperatingSystem");
3054                         moc = mc.GetInstances();
3055                         foreach (System.Management.ManagementObject mo in moc)
3056                         {
3057                                 Trace.TraceInformation("-------------------------");
3058                                 Trace.TraceInformation("OS Information:");
3059                                 //簡単な説明(Windows 8.1では「Microsoft Windows 8.1 Pro」等)
3060                                 Trace.TraceInformation("OS: " + mo["Caption"]);
3061                                 //バージョン(Windows 8.1では、「6.3.9600」)
3062                                 Trace.TraceInformation("Version: " + mo["Version"]);
3063                                 //ビルド番号(Windows 8.1では「9600」)
3064                                 //Trace.TraceInformation( "BuildNumber: " + mo["BuildNumber"]);
3065
3066                                 //サービスパック(Windows 8.1ではNULL)
3067                                 Trace.TraceInformation("CSDVersion (ServicePack): " + mo["CSDVersion"]);
3068                                 //言語(日本語は「1041」)
3069                                 Trace.TraceInformation("OSLanguage: " + mo["OSLanguage"]);
3070
3071                                 Trace.TraceInformation("OSArchitecture: " + mo["OSArchitecture"]);
3072
3073                                 //Trace.TraceInformation("TotalVisibleMemorySize = {0}", mo["TotalVisibleMemorySize"]);
3074                         }
3075                         moc.Dispose();
3076                         mc.Dispose();
3077
3078                         Trace.TraceInformation("-------------------------");
3079                         Trace.TraceInformation("General Environment Information:");
3080                         //Trace.TraceInformation("OS Version: " + Environment.OSVersion);       // fake version will be returned (due to the lack of manifest settings)
3081                         //Trace.TraceInformation("ProcessorCount: " + Environment.ProcessorCount.ToString());
3082                         Trace.TraceInformation("CLR Version: " + Environment.Version.ToString());
3083                         Trace.TraceInformation("SystemPageSize: " + Environment.SystemPageSize.ToString());
3084
3085                         var cominfo = new Microsoft.VisualBasic.Devices.ComputerInfo();
3086                         Trace.TraceInformation("TotalPhysicalMemorySize: {0:F2}GB", (cominfo.TotalPhysicalMemory / 1024f / 1024f / 1024f));
3087                         Trace.TraceInformation("VirtialMemorySize: {0:F2}GB", (cominfo.TotalVirtualMemory / 1024f / 1024f / 1024f));
3088                         Trace.TraceInformation("FreePhysicalMemorySize: {0:F2}MB", (cominfo.AvailablePhysicalMemory / 1024f / 1024f));
3089                         Trace.TraceInformation("FreeVirtualMemorySize: {0:F2}MB", (cominfo.AvailableVirtualMemory / 1024f / 1024f));
3090                         //Trace.TraceInformation(cominfo.OSFullName + ", " + cominfo.OSPlatform + ", " + cominfo.OSVersion);
3091
3092                         mc = new System.Management.ManagementClass("Win32_PhysicalMemory");
3093                         moc = mc.GetInstances();
3094                         Trace.TraceInformation("-------------------------");
3095                         Trace.TraceInformation("Physical Memory Information:");
3096                         foreach (System.Management.ManagementObject mo in moc)
3097                         {
3098                                 Trace.TraceInformation("Capacity: {0:F2}GB", (Convert.ToInt64(mo["Capacity"]) / 1024f / 1024f / 1024f));
3099                         }
3100                         moc.Dispose();
3101                         mc.Dispose();
3102
3103                         mc = new System.Management.ManagementClass("Win32_DisplayControllerConfiguration");
3104                         moc = mc.GetInstances();
3105                         foreach (System.Management.ManagementObject mo in moc)
3106                         {
3107                                 Trace.TraceInformation("-------------------------");
3108                                 Trace.TraceInformation("Display Adapter Information:");
3109                                 Trace.TraceInformation("Name: " + mo["Name"]);
3110                                 Trace.TraceInformation("VideoMode: " + mo["VideoMode"]);
3111                                 Trace.TraceInformation("HorizontalResolution: " + mo["HorizontalResolution"]);
3112                                 Trace.TraceInformation("VerticalResolution: " + mo["VerticalResolution"]);
3113                                 Trace.TraceInformation("RefreshRate: " + mo["RefreshRate"]);
3114                         }
3115                         moc.Dispose();
3116                         mc.Dispose();
3117
3118                         mc = new System.Management.ManagementClass("Win32_VideoController");
3119                         moc = mc.GetInstances();
3120                         foreach (System.Management.ManagementObject mo in moc)
3121                         {
3122                                 Trace.TraceInformation("-------------------------");
3123                                 Trace.TraceInformation("Video Controller Information:");
3124                                 Trace.TraceInformation("Description: " + mo["Description"]);
3125                                 Trace.TraceInformation("AdapterRAM: {0}MB", (Convert.ToInt64(mo["AdapterRAM"]) / 1024f / 1024f));
3126                                 Trace.TraceInformation("CapabilityDescriptions: " + mo["CapabilityDescriptions"]);
3127                         }
3128                         moc.Dispose();
3129                         mc.Dispose();
3130
3131                         mc = new System.Management.ManagementClass("Win32_DesktopMonitor");
3132                         moc = mc.GetInstances();
3133                         foreach (System.Management.ManagementObject mo in moc)
3134                         {
3135                                 Trace.TraceInformation("-------------------------");
3136                                 Trace.TraceInformation("Display Information:");
3137                                 Trace.TraceInformation("Description: " + mo["Description"]);
3138                                 Trace.TraceInformation("PixelsPerXLogicalInch: " + mo["PixelsPerXLogicalInch"]);
3139                                 Trace.TraceInformation("PixelsPerYLogicalInch: " + mo["PixelsPerYLogicalInch"]);
3140                                 Trace.TraceInformation("ScreenWidth: " + mo["ScreenWidth"]);
3141                                 Trace.TraceInformation("ScreenHeight: " + mo["ScreenHeight"]);
3142                         }
3143                         moc.Dispose();
3144                         mc.Dispose();
3145
3146                         mc = new System.Management.ManagementClass("Win32_SoundDevice");
3147                         moc = mc.GetInstances();
3148                         foreach (System.Management.ManagementObject mo in moc)
3149                         {
3150                                 Trace.TraceInformation("-------------------------");
3151                                 Trace.TraceInformation("Sound Information:");
3152                                 //Trace.TraceInformation("Caption: " + mo["Caption"]);
3153                                 Trace.TraceInformation("ProductName: " + mo["ProductName"]);
3154                                 //Trace.TraceInformation("DMABufferSize: " + mo["DMABufferSize"]);
3155                         }
3156                         moc.Dispose();
3157                         mc.Dispose();
3158
3159                         Trace.TraceInformation("----------------------");
3160                         Trace.TraceInformation("DTXMania settings:");
3161                         Trace.TraceInformation("VSyncWait: " + ConfigIni.bVSyncWait.ToString());
3162                         Trace.TraceInformation("Fullscreen: " + ConfigIni.bFullScreen.ToString());
3163                         Trace.TraceInformation("----------------------");
3164                 }
3165
3166         }
3167 }