2 using System.Collections.Concurrent;
3 using System.Collections.Generic;
4 using System.Diagnostics;
6 using System.ServiceModel;
7 using System.Windows.Forms;
12 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] // サービスインターフェースをシングルスレッドで呼び出す。
13 class StrokeStyleT : SST.IStrokeStyleTService
17 public static SST.フォルダ フォルダ
19 get { return StrokeStyleT.bs_フォルダ; }
21 public static FDK.メディア.サウンド.WASAPI排他.ExclusiveDevice Wasapiデバイス
23 get { return StrokeStyleT.bs_Wasapiデバイス; }
25 public static System.Random 乱数
27 get { return StrokeStyleT.bs_乱数; }
29 public static SST.ユーザ.ユーザ管理 ユーザ管理
31 get { return StrokeStyleT.bs_ユーザ管理; }
33 public static SST.曲.曲ツリー管理 曲ツリー管理
35 get { return StrokeStyleT.bs_曲ツリー管理; }
37 public static SSTFormat.スコア 演奏スコア
42 public static SST.設定.Config Config
44 get { return StrokeStyleT.bs_Config; }
46 public static bool ビュアーモードである
51 public static bool ビュアーモードではない
53 get { return !StrokeStyleT.ビュアーモードである; }
54 set { StrokeStyleT.ビュアーモードである = !value; }
56 public static SST.ViewerMessage 最後に取得したビュアーメッセージ
61 public static FDK.入力.Keyboard キーボード入力
63 get { return StrokeStyleT.bs_キーボード入力; }
65 public static FDK.入力.MidiIn MIDI入力
67 get { return StrokeStyleT.bs_MIDI入力; }
70 public static void すべての入力デバイスをポーリングする()
72 // hack: 追加の入力デバイスができたら、ここにポーリングコードを追加すること。
73 StrokeStyleT.キーボード入力?.ポーリングする();
74 StrokeStyleT.MIDI入力?.ポーリングする();
79 // フォルダ変数を真っ先に登録する。(ほかのメンバのコンストラクタでフォルダ変数を利用できるようにするため。)
80 StrokeStyleT.bs_フォルダ = new SST.フォルダ();
81 SST.フォルダ.フォルダ変数を追加する( "Static", StrokeStyleT.フォルダ.StaticFolder );
82 SST.フォルダ.フォルダ変数を追加する( "AppData", StrokeStyleT.フォルダ.AppDataFolder );
83 SST.フォルダ.フォルダ変数を追加する( "User", null );
87 #region " ビュアーモードかどうかを確認する。"
89 foreach( var arg in Environment.GetCommandLineArgs() )
91 if( ( "-v" == arg.ToLower() ) || ( "-viewer" == arg.ToLower() ) )
93 StrokeStyleT.ビュアーモードである = true;
100 this.State = ApplicationState.起動;
102 this.MainForm = new RenderForm();
103 this.MainForm.BackColor = System.Drawing.Color.Black;
104 this.MainForm.AllowUserResizing = false; // ユーザはフォームサイズを変更できない。
105 this.MainForm.UserResized += フォームサイズが変更された;
106 this.MainForm.FormClosing += ( sender, e ) => {
113 Debug.Assert( null != this.MainForm );
115 SharpDX.Windows.RenderLoop.Run( this.MainForm, () => {
117 // アプリケーションの状態に応じて処理分岐。
120 case ApplicationState.起動:
122 this.State = ApplicationState.初期化;
123 break; // 初期化に移る前に一度このラムダ式を出て、ウィンドウメッセージ処理を行わせる(画面を再描画させる)。
125 case ApplicationState.初期化:
127 this.State = ApplicationState.進行描画;
130 case ApplicationState.進行描画:
132 if( this.State == ApplicationState.終了 )
136 case ApplicationState.終了:
144 #region " WCF サービスインターフェースの実装 "
146 // ・このサービスインターフェースは、シングルスレッド(GUIスレッド)で同期実行される。(StrokeStyleT クラスの ServiceBehavior属性を参照。)
147 // ・このサービスホストはシングルトンであり、すべてのクライアントセッションは同一(単一)のサービスインスタンスへ接続される。(Program.Main() を参照。)
149 public void ViewerPlay( string path, int startPart = 0, bool drumsSound = true )
151 if( StrokeStyleT.ビュアーモードではない )
154 this.ビュアーメッセージキュー.Enqueue( new ViewerMessage() {
155 種別 = ViewerMessageType.演奏開始,
157 演奏開始小節番号 = startPart,
158 ドラムチップ発声 = drumsSound,
161 public void ViewerStop()
163 if( StrokeStyleT.ビュアーモードではない )
166 this.ビュアーメッセージキュー.Enqueue( new ViewerMessage() {
167 種別 = ViewerMessageType.演奏停止,
170 public float GetSoundDelay()
172 if( StrokeStyleT.ビュアーモードではない )
175 return ( null != StrokeStyleT.Wasapiデバイス ) ? StrokeStyleT.Wasapiデバイス.遅延ms : 0f;
180 protected enum ApplicationState { 起動, 初期化, 進行描画, 終了 }
181 protected ApplicationState State;
182 protected SST.RenderForm MainForm = null;
183 protected SharpDX.Size2F 設計画面サイズdpx = SharpDX.Size2F.Empty;
184 protected ConcurrentQueue<ViewerMessage> ビュアーメッセージキュー = new ConcurrentQueue<ViewerMessage>();
185 protected FDK.メディア.デバイスリソース デバイスリソース = null;
186 protected SST.ステージ.ステージ 最初のダミーステージ = null;
187 protected SST.ステージ.起動.起動ステージ 起動ステージ = null;
188 protected SST.ステージ.タイトル.タイトルステージ タイトルステージ = null;
189 protected SST.ステージ.ログイン.ログインステージ ログインステージ = null;
190 protected SST.ステージ.選曲.選曲ステージ 選曲ステージ = null;
191 protected SST.ステージ.曲読込.曲読込ステージ 曲読込ステージ = null;
192 protected SST.ステージ.演奏.演奏ステージ 演奏ステージ = null;
193 protected SST.ステージ.結果.結果ステージ 結果ステージ = null;
194 protected SST.ステージ.ステージ 現在のステージ = null;
196 protected void 起動する()
198 FDK.Log.現在のスレッドに名前をつける( "Render" );
199 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
201 #region " コンフィグ を初期化する。"
203 StrokeStyleT.bs_Config = new 設定.Config();
204 StrokeStyleT.bs_Config.ConfigXmlを読み込む();
208 #region " コンフィグで指定されたウィンドウサイズに変更する。"
210 this.MainForm.ClientSize = new System.Drawing.Size( StrokeStyleT.Config.物理画面サイズpx.Width, StrokeStyleT.Config.物理画面サイズpx.Height );
213 #region " フォームタイトルと設計画面サイズを設定する。"
215 this.MainForm.Text = $"StrokeStyle<T> {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()}";
216 if( StrokeStyleT.ビュアーモードである )
217 this.MainForm.Text += " (Viewer)";
219 // 設計画面サイズは、フォームサイズ(物理画面サイズ)とは独立して固定。
220 this.設計画面サイズdpx = new SharpDX.Size2F( 1920f, 1080f );
224 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
226 protected void 初期化する()
228 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
231 Debug.Assert( null == this.デバイスリソース, "デバイスリソースの作成前であること。" );
233 StrokeStyleT.bs_ユーザ管理 = new ユーザ.ユーザ管理();
234 StrokeStyleT.bs_曲ツリー管理 = new 曲.曲ツリー管理();
236 #region " 高解像度タイマを使えないならエラー。"
238 if( false == System.Diagnostics.Stopwatch.IsHighResolution )
239 throw new SSTException( "このシステムは、高解像度タイマをサポートしていません。" );
242 #region " MediaFoundation を起動する。"
244 SharpDX.MediaFoundation.MediaManager.Startup();
247 #region " Sleep 精度を上げる。"
249 Win32.timeBeginPeriod( 1 );
253 #region " デバイスリソースを作成する。"
255 FDK.Log.Info( $"設計画面サイズ: {this.設計画面サイズdpx}" );
256 FDK.Log.Info( $"物理画面サイズ: {this.MainForm.ClientSize}" );
257 this.デバイスリソース = new FDK.メディア.デバイスリソース( this.設計画面サイズdpx );
258 this.デバイスリソース.すべてのリソースを作成する( this.MainForm.ClientSize, this.MainForm.Handle );
262 #region " ステージを生成する。"
264 this.最初のダミーステージ = new ステージ.ステージ();
265 this.起動ステージ = new ステージ.起動.起動ステージ();
266 this.タイトルステージ = new ステージ.タイトル.タイトルステージ();
267 this.ログインステージ = new ステージ.ログイン.ログインステージ();
268 this.選曲ステージ = new ステージ.選曲.選曲ステージ();
269 this.曲読込ステージ = new ステージ.曲読込.曲読込ステージ();
270 this.演奏ステージ = new ステージ.演奏.演奏ステージ();
271 this.結果ステージ = new ステージ.結果.結果ステージ();
274 this.曲読込ステージ.読込曲のファイルパスを取得する = () => ( ( StrokeStyleT.曲ツリー管理.現在選択されているノード as SST.曲.MusicNode )?.sstfファイルパス );
275 this.結果ステージ.演奏ステージインスタンスを取得する = () => ( this.演奏ステージ );
276 this.結果ステージ.BGMを終了する = () => { this.演奏ステージ.BGMを解放する(); };
279 #region " ユーザを初期化する。"
282 StrokeStyleT.ユーザ管理.UsersXmlを読み込む();
285 foreach( var ユーザ in StrokeStyleT.ユーザ管理.ユーザリスト )
286 ユーザ.SourcesXmlを読み込む();
289 #region " WASAPI デバイスを初期化する。"
291 StrokeStyleT.bs_Wasapiデバイス = new FDK.メディア.サウンド.WASAPI排他.ExclusiveDevice();
292 StrokeStyleT.bs_Wasapiデバイス.初期化する( 15.0f );
295 #region " キーボード入力 を初期化する。"
297 StrokeStyleT.bs_キーボード入力 = new FDK.入力.Keyboard( this.MainForm.Handle );
300 #region " MIDI入力 を初期化する。"
302 StrokeStyleT.bs_MIDI入力 = new FDK.入力.MidiIn();
306 FDK.Log.Info( "最初のダミーステージを開始します。" );
307 this.現在のステージ = this.最初のダミーステージ;
309 //#warning 全画面モード切替えを仮実装。
310 this.MainForm.KeyDown += ( target, arg ) => {
313 if( arg.KeyCode == System.Windows.Forms.Keys.F11 )
315 this.全画面モードとウィンドウモードを切り替える();
321 Debug.Assert( SharpDX.Size2F.Empty != this.設計画面サイズdpx, "設計画面サイズが設定されていません。" );
323 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
325 protected void 終了する()
327 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
328 Debug.Assert( null != this.デバイスリソース, "デバイスリソースが解放される前であること。" );
330 this.State = ApplicationState.終了;
332 #region " ステージを終了し、解放する。"
334 if( ( null != this.現在のステージ ) && ( this.現在のステージ.活性化している ) ) // 念のため
335 this.現在のステージ.非活性化する( this.デバイスリソース );
337 this.演奏ステージ.BGMを解放する();
339 this.最初のダミーステージ = null;
341 this.タイトルステージ = null;
342 this.ログインステージ = null;
350 #region " デバイスリソースを解放する。"
352 FDK.Utilities.解放する( ref this.デバイスリソース );
356 #region " MIDI入力デバイスを解放する。"
358 FDK.Log.Info( "MIDI入力デバイスを解放します。" );
359 FDK.Utilities.解放する( ref StrokeStyleT.bs_MIDI入力 );
362 #region " キーボード入力デバイスを解放する。"
364 FDK.Log.Info( "キーボード入力デバイスを解放します。" );
365 FDK.Utilities.解放する( ref StrokeStyleT.bs_キーボード入力 );
368 #region " WASAPIデバイスを解放する。"
370 FDK.Log.Info( "WASAPIデバイスを解放します。" );
371 FDK.Utilities.解放する( ref StrokeStyleT.bs_Wasapiデバイス );
375 #region " コンフィグを保存し、解放する。"
377 FDK.Log.Info( "コンフィグを解放します。" );
378 StrokeStyleT.bs_Config.ConfigXmlを保存する();
379 StrokeStyleT.bs_Config = null;
384 FDK.Utilities.解放する( ref this.MainForm );
388 #region " MediaFoundation を終了する。"
390 SharpDX.MediaFoundation.MediaManager.Shutdown();
394 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
396 protected void 進行描画する()
398 #region " D3Dデバイスが消失していれば再構築する。"
401 this.デバイスリソース.D3Dデバイスが消失していれば再構築する( out 異常発生 );
403 // 再構築不可能な異常の場合は、即終了する。
406 this.State = ApplicationState.終了;
411 #region " 描画の前処理を行う。"
414 var d3dDevice = (SharpDX.Direct3D11.Device) null;
415 using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.デバイスリソース.DXGIDeviceManager, out d3dDevice ) )
417 using( var d3dContext = d3dDevice.ImmediateContext )
419 // 既定のD3Dレンダーターゲットビューを黒でクリアする。
420 d3dContext.ClearRenderTargetView( this.デバイスリソース.D3DRenderTargetView, SharpDX.Color4.Black );
422 // 深度バッファを 1.0f でクリアする。
423 d3dContext.ClearDepthStencilView(
424 this.デバイスリソース.D3DDepthStencilView,
425 SharpDX.Direct3D11.DepthStencilClearFlags.Depth,
432 #region " 現在のステージを進行描画する。"
434 this.現在のステージ?.進行描画する( this.デバイスリソース );
437 #region " スワップチェーンを表示する。"
439 if( StrokeStyleT.Config.垂直帰線待ちを行う )
441 // We recommend that you use Flush when the CPU waits for an arbitrary amount of time
442 // (such as when you call the Sleep function).
443 // → https://msdn.microsoft.com/ja-jp/library/windows/desktop/ff476425(v=vs.85).aspx
445 var d3dDevice = (SharpDX.Direct3D11.Device) null;
446 using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.デバイスリソース.DXGIDeviceManager, out d3dDevice ) )
448 using( var d3dContext = d3dDevice.ImmediateContext )
454 this.デバイスリソース.SwapChain1.Present(
455 ( StrokeStyleT.Config.垂直帰線待ちを行う ) ? 1 : 0,
456 SharpDX.DXGI.PresentFlags.None );
460 #region " ステージの状態をチェックし、必要あれば遷移またはアプリを終了する。"
462 if( null != this.現在のステージ )
464 switch( this.現在のステージ.GetType().Name )
466 case nameof( ステージ.ステージ ):
467 #region " ビュアーモード → AutoPlayerでログインして演奏ステージへ。"
469 if( StrokeStyleT.ビュアーモードである )
472 FDK.Log.Info( "ビュアーモード: AutoPlayer ユーザでログインします。" );
473 this.ログインする( Properties.Resources.AUTOPLAYER );
476 StrokeStyleT.曲ツリー管理.現在の管理対象ツリー = null;
477 StrokeStyleT.曲ツリー管理.現在選択されているノード = null;
480 StrokeStyleT.演奏スコア = null;
483 this.演奏ステージ.活性化する( this.デバイスリソース );
484 this.現在のステージ = this.演奏ステージ;
488 #region " 通常モード → 起動ステージへ。"
492 this.起動ステージ.活性化する( this.デバイスリソース );
493 this.現在のステージ = this.起動ステージ;
499 case nameof( ステージ.起動.起動ステージ ):
500 #region " 終了 → タイトルステージへ。"
502 if( this.起動ステージ.現在のフェーズ == ステージ.起動.起動ステージ.フェーズ.終了 )
504 this.現在のステージ.非活性化する( this.デバイスリソース );
505 this.現在のステージ = this.タイトルステージ;
506 this.現在のステージ.活性化する( this.デバイスリソース );
512 case nameof( ステージ.タイトル.タイトルステージ ):
513 #region " 確定 → ログインステージへ。"
515 if( this.タイトルステージ.現在のフェーズ == ステージ.タイトル.タイトルステージ.フェーズ.確定 )
517 this.現在のステージ.非活性化する( this.デバイスリソース );
518 this.現在のステージ = this.ログインステージ;
519 this.現在のステージ.活性化する( this.デバイスリソース );
523 #region " キャンセル → アプリを終了する。"
525 else if( this.タイトルステージ.現在のフェーズ == ステージ.タイトル.タイトルステージ.フェーズ.キャンセル )
527 this.現在のステージ.非活性化する( this.デバイスリソース );
529 this.State = ApplicationState.終了;
535 case nameof( ステージ.ログイン.ログインステージ ):
536 #region " 確定 → ログイン処理を行って、選曲ステージへ。"
538 if( this.ログインステージ.現在のフェーズ == ステージ.ログイン.ログインステージ.フェーズ.確定 )
540 var user = StrokeStyleT.ユーザ管理.現在選択されているユーザ;
544 foreach( var path in user.曲の検索元フォルダパスのリスト )
545 SST.曲.曲ツリー管理.フォルダから曲を再帰的に検索して子ノードリストに追加する( user.曲ツリーのルートノード, path );
547 StrokeStyleT.曲ツリー管理.現在の管理対象ツリー = StrokeStyleT.ユーザ管理.現在選択されているユーザ.曲ツリーのルートノード;
550 this.現在のステージ.非活性化する( this.デバイスリソース );
551 this.現在のステージ = this.選曲ステージ;
552 this.現在のステージ.活性化する( this.デバイスリソース );
556 #region " キャンセル → タイトルステージへ。"
558 else if( this.ログインステージ.現在のフェーズ == ステージ.ログイン.ログインステージ.フェーズ.キャンセル )
560 this.現在のステージ.非活性化する( this.デバイスリソース );
561 this.現在のステージ = this.タイトルステージ;
562 this.現在のステージ.活性化する( this.デバイスリソース );
568 case nameof( ステージ.選曲.選曲ステージ ):
569 #region " 曲確定 → 曲読込ステージへ。"
571 if( this.選曲ステージ.現在のフェーズ == ステージ.選曲.選曲ステージ.フェーズ.曲確定 )
573 // 曲ノードが選択されていることを確認。
574 Trace.Assert( null != StrokeStyleT.曲ツリー管理.現在選択されているノード, "[バグあり] 選択曲が null です。" );
575 this.現在のステージ.非活性化する( this.デバイスリソース );
576 this.現在のステージ = this.曲読込ステージ;
577 this.現在のステージ.活性化する( this.デバイスリソース );
581 #region " キャンセル → アプリを終了する。"
583 else if( this.選曲ステージ.現在のフェーズ == ステージ.選曲.選曲ステージ.フェーズ.キャンセル )
585 this.現在のステージ.非活性化する( this.デバイスリソース );
587 this.State = ApplicationState.終了;
593 case nameof( ステージ.曲読込.曲読込ステージ ):
594 #region " 終了 → 演奏ステージへ。"
595 //--------------------
596 if( this.曲読込ステージ.現在のフェーズ == ステージ.曲読込.曲読込ステージ.フェーズ.終了 )
598 this.現在のステージ.非活性化する( this.デバイスリソース );
599 this.現在のステージ = this.演奏ステージ;
600 this.現在のステージ.活性化する( this.デバイスリソース );
602 //--------------------
606 case nameof( ステージ.演奏.演奏ステージ ):
607 if( StrokeStyleT.ビュアーモードである )
611 #region " ビュアーメッセージがあれば処理する。"
613 var msg = this.ビュアーメッセージを取得する();
615 StrokeStyleT.最後に取得したビュアーメッセージ = msg; // 保存する。(演奏ステージから参照する)
621 if( msg.種別 == ViewerMessageType.演奏開始 && (
622 this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.ビュアーメッセージ待機中 ||
623 this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.演奏中 )
628 // MusicNode を作成し、現在選択されているノードとして登録する。
629 StrokeStyleT.曲ツリー管理.現在選択されているノード = new 曲.MusicNode( msg.曲ファイルパス );
632 this.演奏ステージ.非活性化する( this.デバイスリソース );
633 this.演奏ステージ.BGMを解放する();
636 this.現在のステージ = this.曲読込ステージ;
637 this.現在のステージ.活性化する( this.デバイスリソース );
641 FDK.Log.ERROR( $"MusicNode の作成に失敗しました。" );
648 else if( msg.種別 == ViewerMessageType.演奏停止 && (
649 this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.ビュアーメッセージ待機中 ||
650 this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.演奏中 )
653 this.演奏ステージ.演奏を停止する();
654 this.演奏ステージ.現在のフェーズ.Value = ステージ.演奏.演奏ステージ.フェーズ.ビュアーメッセージ待機中;
669 #region " クリア/キャンセル → メッセージ待機へ。"
671 if( this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.クリアor失敗 ||
672 this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.キャンセル )
674 // フェーズのみ変更。BGM は止めない。
675 this.演奏ステージ.現在のフェーズ.Value = ステージ.演奏.演奏ステージ.フェーズ.ビュアーメッセージ待機中;
684 #region " 演奏終了 → 結果ステージへ。"
685 //--------------------
686 if( this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.クリアor失敗 )
688 this.現在のステージ.非活性化する( this.デバイスリソース );
689 this.現在のステージ = this.結果ステージ;
690 this.現在のステージ.活性化する( this.デバイスリソース );
692 //--------------------
694 #region " キャンセル → 選曲ステージへ。"
695 //--------------------
696 if( this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.キャンセル )
698 this.現在のステージ.非活性化する( this.デバイスリソース );
699 this.現在のステージ = this.選曲ステージ;
700 this.現在のステージ.活性化する( this.デバイスリソース );
702 //--------------------
707 case nameof( ステージ.結果.結果ステージ ):
708 #region " 終了 → 選曲ステージへ。"
709 //--------------------
710 if( this.結果ステージ.現在のフェーズ == ステージ.結果.結果ステージ.フェーズ.終了 )
712 this.現在のステージ.非活性化する( this.デバイスリソース );
713 this.現在のステージ = this.選曲ステージ;
714 this.現在のステージ.活性化する( this.デバイスリソース );
716 //--------------------
724 protected void デバイス依存リソースを解放する()
726 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
727 Debug.Assert( null != this.デバイスリソース ); // 解放前であること。
729 this.現在のステージ?.デバイス依存リソースを解放する( this.デバイスリソース );
731 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
733 protected void デバイス依存リソースを再構築する()
735 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
736 Debug.Assert( null != this.デバイスリソース ); // 再生成済みであること。
738 this.現在のステージ?.デバイス依存リソースを作成する( this.デバイスリソース );
740 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
743 private void フォームサイズが変更された( object sender, EventArgs e )
745 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
746 FDK.Log.Info( $"新しいクライアントサイズ = {this.MainForm.ClientSize}" );
750 if( null == this.デバイスリソース )
752 FDK.Log.Info( " まだ初期化されてないので、何もしません。" );
753 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
756 if( this.MainForm.WindowState == FormWindowState.Minimized )
758 FDK.Log.Info( "最小化されました。" );
759 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
762 if( this.State != ApplicationState.進行描画 )
764 FDK.Log.Info( " アプリケーションの状態が進行描画じゃないので、何もしません。" );
765 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
771 Debug.Assert( null != this.デバイスリソース, "デバイスリソースが作成済みであること。" );
773 // 現在の画面モードを取得しておく。(Alt+TABなど、勝手に全画面を解除されることもあるので。)
774 SharpDX.Mathematics.Interop.RawBool fullscreen;
775 SharpDX.DXGI.Output outputTarget;
776 this.デバイスリソース.SwapChain1.GetFullscreenState( out fullscreen, out outputTarget );
777 this.MainForm.IsFullscreen = fullscreen;
778 outputTarget?.Dispose();
779 FDK.Log.Info( $"現在、全画面モードである = {this.MainForm.IsFullscreen}" );
782 this.デバイス依存リソースを解放する();
783 this.デバイスリソース.サイズに依存するリソースを解放する();
786 this.デバイスリソース.物理画面サイズpx = new SharpDX.Size2F( this.MainForm.ClientSize.Width, this.MainForm.ClientSize.Height );
789 this.デバイスリソース.サイズに依存するリソースを作成する();
790 this.デバイス依存リソースを再構築する();
792 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
794 private void 全画面モードとウィンドウモードを切り替える()
796 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
798 this.MainForm.IsFullscreen = !this.MainForm.IsFullscreen; // 切り替え
799 this.デバイスリソース.SwapChain1.SetFullscreenState( this.MainForm.IsFullscreen, null );
801 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
803 private void ログインする( string ユーザ名 )
805 StrokeStyleT.ユーザ管理.ユーザを選択する( ユーザ名 );
806 FDK.Log.Info( $"ユーザが選択されました。[{StrokeStyleT.ユーザ管理.現在選択されているユーザ.名前}]" );
808 /// <returns>メッセージがない場合は null を返す。</returns>
809 private ViewerMessage ビュアーメッセージを取得する()
811 var msg = (ViewerMessage) null;
813 if( StrokeStyleT.ビュアーモードである &&
814 ( 0 < this.ビュアーメッセージキュー.Count ) &&
815 this.ビュアーメッセージキュー.TryDequeue( out msg ) )
825 private static SST.フォルダ bs_フォルダ = null;
826 private static FDK.入力.Keyboard bs_キーボード入力 = null;
827 private static FDK.入力.MidiIn bs_MIDI入力 = null;
828 private static FDK.メディア.サウンド.WASAPI排他.ExclusiveDevice bs_Wasapiデバイス = null;
829 private static readonly System.Random bs_乱数 = new Random( DateTime.Now.Millisecond );
830 private static SST.ユーザ.ユーザ管理 bs_ユーザ管理 = null;
831 private static SST.曲.曲ツリー管理 bs_曲ツリー管理 = null;
832 private static SST.設定.Config bs_Config = null;