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.Device 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 ) => {
114 Debug.Assert( null != this.MainForm );
116 SharpDX.Windows.RenderLoop.Run( this.MainForm, () => {
118 // アプリケーションの状態に応じて処理分岐。
121 case ApplicationState.起動:
123 this.State = ApplicationState.初期化;
124 break; // 初期化に移る前に、一度ウィンドウメッセージ処理を行わせて、画面を再描画させる。
126 case ApplicationState.初期化:
128 this.State = ApplicationState.進行描画;
131 case ApplicationState.進行描画:
133 if( this.State == ApplicationState.終了 )
137 case ApplicationState.終了:
145 #region " WCF サービスインターフェースの実装 "
147 // ・このサービスインターフェースは、シングルスレッド(GUIスレッド)で同期実行される。(StrokeStyleT クラスの ServiceBehavior属性を参照。)
148 // ・このサービスホストはシングルトンであり、すべてのクライアントセッションは同一(単一)のサービスインスタンスへ接続される。(Program.Main() を参照。)
156 /// <param name="path">曲ファイルパス</param>
157 /// <param name="startPart">演奏開始小節番号(0..)</param>
158 /// <param name="drumsSound">ドラムチップ音を発声させるなら true。</param>
159 public void ViewerPlay( string path, int startPart = 0, bool drumsSound = true )
161 if( StrokeStyleT.ビュアーモードではない )
164 this.ビュアーメッセージキュー.Enqueue( new ViewerMessage() {
165 種別 = ViewerMessageType.演奏開始,
167 演奏開始小節番号 = startPart,
168 ドラムチップ発声 = drumsSound,
177 public void ViewerStop()
179 if( StrokeStyleT.ビュアーモードではない )
182 this.ビュアーメッセージキュー.Enqueue( new ViewerMessage() {
183 種別 = ViewerMessageType.演奏停止,
187 /// サウンドデバイスの発声遅延[ms]を返す。
189 /// <returns>遅延量[ms]</returns>
190 public float GetSoundDelay()
192 if( StrokeStyleT.ビュアーモードではない )
195 return ( null != StrokeStyleT.Wasapiデバイス ) ? (float) ( StrokeStyleT.Wasapiデバイス.遅延sec * 1000.0 ) : 0f;
200 protected enum ApplicationState { 起動, 初期化, 進行描画, 終了 }
201 protected ApplicationState State;
202 protected SST.RenderForm MainForm = null;
203 protected SharpDX.Size2F 設計画面サイズdpx = SharpDX.Size2F.Empty;
204 protected ConcurrentQueue<ViewerMessage> ビュアーメッセージキュー = new ConcurrentQueue<ViewerMessage>();
205 protected FDK.メディア.デバイスリソース デバイスリソース = null;
206 protected SST.ステージ.ステージ 最初のダミーステージ = null;
207 protected SST.ステージ.起動.起動ステージ 起動ステージ = null;
208 protected SST.ステージ.タイトル.タイトルステージ タイトルステージ = null;
209 protected SST.ステージ.ログイン.ログインステージ ログインステージ = null;
210 protected SST.ステージ.選曲.選曲ステージ 選曲ステージ = null;
211 protected SST.ステージ.曲読込.曲読込ステージ 曲読込ステージ = null;
212 protected SST.ステージ.演奏.演奏ステージ 演奏ステージ = null;
213 protected SST.ステージ.結果.結果ステージ 結果ステージ = null;
214 protected SST.ステージ.ステージ 現在のステージ = null;
216 protected void 起動する()
218 FDK.Log.現在のスレッドに名前をつける( "Render" );
219 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
221 #region " コンフィグ を初期化する。"
223 StrokeStyleT.bs_Config = new 設定.Config();
224 StrokeStyleT.bs_Config.ConfigXmlを読み込む();
228 #region " コンフィグで指定されたウィンドウサイズに変更する。"
230 this.MainForm.ClientSize = new System.Drawing.Size( StrokeStyleT.Config.物理画面サイズpx.Width, StrokeStyleT.Config.物理画面サイズpx.Height );
233 #region " フォームタイトルと設計画面サイズを設定する。"
235 this.MainForm.Text = $"StrokeStyle<T> {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()}";
236 if( StrokeStyleT.ビュアーモードである )
237 this.MainForm.Text += " (Viewer)";
239 // 設計画面サイズは、フォームサイズ(物理画面サイズ)とは独立して固定。
240 this.設計画面サイズdpx = new SharpDX.Size2F( 1920f, 1080f );
244 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
246 protected void 初期化する()
248 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
251 Debug.Assert( null == this.デバイスリソース, "デバイスリソースの作成前であること。" );
253 StrokeStyleT.bs_ユーザ管理 = new ユーザ.ユーザ管理();
254 StrokeStyleT.bs_曲ツリー管理 = new 曲.曲ツリー管理();
256 #region " 高解像度タイマを使えないならエラー。"
258 if( false == System.Diagnostics.Stopwatch.IsHighResolution )
259 throw new SSTException( "このシステムは、高解像度タイマをサポートしていません。" );
262 #region " MediaFoundation を起動する。"
264 SharpDX.MediaFoundation.MediaManager.Startup();
267 #region " Sleep 精度を上げる。"
269 Win32.timeBeginPeriod( 1 );
273 #region " デバイスリソースを作成する。"
275 FDK.Log.Info( $"設計画面サイズ: {this.設計画面サイズdpx}" );
276 FDK.Log.Info( $"物理画面サイズ: {this.MainForm.ClientSize}" );
277 this.デバイスリソース = new FDK.メディア.デバイスリソース( this.設計画面サイズdpx );
278 this.デバイスリソース.すべてのリソースを作成する( this.MainForm.ClientSize, this.MainForm.Handle );
282 #region " ステージを生成する。"
284 this.最初のダミーステージ = new ステージ.ステージ();
285 this.起動ステージ = new ステージ.起動.起動ステージ();
286 this.タイトルステージ = new ステージ.タイトル.タイトルステージ();
287 this.ログインステージ = new ステージ.ログイン.ログインステージ();
288 this.選曲ステージ = new ステージ.選曲.選曲ステージ();
289 this.曲読込ステージ = new ステージ.曲読込.曲読込ステージ();
290 this.演奏ステージ = new ステージ.演奏.演奏ステージ();
291 this.結果ステージ = new ステージ.結果.結果ステージ();
294 this.曲読込ステージ.読込曲のファイルパスを取得する = () => ( ( StrokeStyleT.曲ツリー管理.現在選択されているノード as SST.曲.MusicNode )?.sstfファイルパス );
295 this.結果ステージ.演奏ステージインスタンスを取得する = () => ( this.演奏ステージ );
296 this.結果ステージ.BGMを終了する = () => { this.演奏ステージ.BGMを解放する(); };
299 #region " ユーザを初期化する。"
302 StrokeStyleT.ユーザ管理.UsersXmlを読み込む();
305 foreach( var ユーザ in StrokeStyleT.ユーザ管理.ユーザリスト )
306 ユーザ.SourcesXmlを読み込む();
309 #region " WASAPI デバイスを初期化する。"
311 StrokeStyleT.bs_Wasapiデバイス = new FDK.メディア.サウンド.WASAPI.Device();
312 StrokeStyleT.bs_Wasapiデバイス.初期化する( CSCore.CoreAudioAPI.AudioClientShareMode.Exclusive, 0.015 );
315 #region " キーボード入力 を初期化する。"
317 StrokeStyleT.bs_キーボード入力 = new FDK.入力.Keyboard( this.MainForm.Handle );
320 #region " MIDI入力 を初期化する。"
322 StrokeStyleT.bs_MIDI入力 = new FDK.入力.MidiIn();
326 FDK.Log.Info( "最初のダミーステージを開始します。" );
327 this.現在のステージ = this.最初のダミーステージ;
329 //#warning 全画面モード切替えを仮実装。
330 this.MainForm.KeyDown += ( target, arg ) => {
333 if( arg.KeyCode == System.Windows.Forms.Keys.F11 )
335 this.全画面モードとウィンドウモードを切り替える();
341 Debug.Assert( SharpDX.Size2F.Empty != this.設計画面サイズdpx, "設計画面サイズが設定されていません。" );
343 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
345 protected void 終了する()
347 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
348 Debug.Assert( null != this.デバイスリソース, "デバイスリソースが解放される前であること。" );
350 this.State = ApplicationState.終了;
352 #region " ステージを終了し、解放する。"
354 if( ( null != this.現在のステージ ) && ( this.現在のステージ.活性化している ) ) // 念のため
355 this.現在のステージ.非活性化する( this.デバイスリソース );
357 this.演奏ステージ.BGMを解放する();
359 this.最初のダミーステージ = null;
361 this.タイトルステージ = null;
362 this.ログインステージ = null;
370 #region " デバイスリソースを解放する。"
372 FDK.Utilities.解放する( ref this.デバイスリソース );
376 #region " MIDI入力デバイスを解放する。"
378 FDK.Log.Info( "MIDI入力デバイスを解放します。" );
379 FDK.Utilities.解放する( ref StrokeStyleT.bs_MIDI入力 );
382 #region " キーボード入力デバイスを解放する。"
384 FDK.Log.Info( "キーボード入力デバイスを解放します。" );
385 FDK.Utilities.解放する( ref StrokeStyleT.bs_キーボード入力 );
388 #region " WASAPIデバイスを解放する。"
390 FDK.Log.Info( "WASAPIデバイスを解放します。" );
391 FDK.Utilities.解放する( ref StrokeStyleT.bs_Wasapiデバイス );
395 #region " コンフィグを保存し、解放する。"
397 FDK.Log.Info( "コンフィグを解放します。" );
398 StrokeStyleT.bs_Config.ConfigXmlを保存する();
399 StrokeStyleT.bs_Config = null;
404 FDK.Utilities.解放する( ref this.MainForm );
408 #region " MediaFoundation を終了する。"
410 SharpDX.MediaFoundation.MediaManager.Shutdown();
414 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
416 protected void 進行描画する()
418 #region " D3Dデバイスが消失していれば再構築する。"
421 this.デバイスリソース.D3Dデバイスが消失していれば再構築する( out 異常発生 );
423 // 再構築不可能な異常の場合は、即終了する。
426 this.State = ApplicationState.終了;
431 #region " 描画の前処理を行う。"
434 var d3dDevice = (SharpDX.Direct3D11.Device) null;
435 using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.デバイスリソース.DXGIDeviceManager, out d3dDevice ) )
437 using( var d3dContext = d3dDevice.ImmediateContext )
439 // 既定のD3Dレンダーターゲットビューを黒でクリアする。
440 d3dContext.ClearRenderTargetView( this.デバイスリソース.D3DRenderTargetView, SharpDX.Color4.Black );
442 // 深度バッファを 1.0f でクリアする。
443 d3dContext.ClearDepthStencilView(
444 this.デバイスリソース.D3DDepthStencilView,
445 SharpDX.Direct3D11.DepthStencilClearFlags.Depth,
452 #region " 現在のステージを進行描画する。"
454 this.現在のステージ?.進行描画する( this.デバイスリソース );
457 #region " スワップチェーンを表示する。"
459 if( StrokeStyleT.Config.垂直帰線待ちを行う )
461 // We recommend that you use Flush when the CPU waits for an arbitrary amount of time
462 // (such as when you call the Sleep function).
463 // → https://msdn.microsoft.com/ja-jp/library/windows/desktop/ff476425(v=vs.85).aspx
465 var d3dDevice = (SharpDX.Direct3D11.Device) null;
466 using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.デバイスリソース.DXGIDeviceManager, out d3dDevice ) )
468 using( var d3dContext = d3dDevice.ImmediateContext )
474 this.デバイスリソース.SwapChain1.Present(
475 ( StrokeStyleT.Config.垂直帰線待ちを行う ) ? 1 : 0,
476 SharpDX.DXGI.PresentFlags.None );
480 #region " ステージの状態をチェックし、必要あれば遷移またはアプリを終了する。"
482 if( null != this.現在のステージ )
484 switch( this.現在のステージ.GetType().Name )
486 case nameof( ステージ.ステージ ):
487 #region " ビュアーモード → AutoPlayerでログインして演奏ステージへ。"
489 if( StrokeStyleT.ビュアーモードである )
492 FDK.Log.Info( "ビュアーモード: AutoPlayer ユーザでログインします。" );
493 this.ログインする( Properties.Resources.AUTOPLAYER );
496 StrokeStyleT.曲ツリー管理.現在の管理対象ツリー = null;
497 StrokeStyleT.曲ツリー管理.現在選択されているノード = null;
500 StrokeStyleT.演奏スコア = null;
503 this.演奏ステージ.活性化する( this.デバイスリソース );
504 this.現在のステージ = this.演奏ステージ;
508 #region " 通常モード → 起動ステージへ。"
512 this.起動ステージ.活性化する( this.デバイスリソース );
513 this.現在のステージ = this.起動ステージ;
519 case nameof( ステージ.起動.起動ステージ ):
520 #region " 終了 → タイトルステージへ。"
522 if( this.起動ステージ.現在のフェーズ == ステージ.起動.起動ステージ.フェーズ.終了 )
524 this.現在のステージ.非活性化する( this.デバイスリソース );
525 this.現在のステージ = this.タイトルステージ;
526 this.現在のステージ.活性化する( this.デバイスリソース );
532 case nameof( ステージ.タイトル.タイトルステージ ):
533 #region " 確定 → ログインステージへ。"
535 if( this.タイトルステージ.現在のフェーズ == ステージ.タイトル.タイトルステージ.フェーズ.確定 )
537 this.現在のステージ.非活性化する( this.デバイスリソース );
538 this.現在のステージ = this.ログインステージ;
539 this.現在のステージ.活性化する( this.デバイスリソース );
543 #region " キャンセル → アプリを終了する。"
545 else if( this.タイトルステージ.現在のフェーズ == ステージ.タイトル.タイトルステージ.フェーズ.キャンセル )
547 this.現在のステージ.非活性化する( this.デバイスリソース );
549 this.State = ApplicationState.終了;
555 case nameof( ステージ.ログイン.ログインステージ ):
556 #region " 確定 → ログイン処理を行って、選曲ステージへ。"
558 if( this.ログインステージ.現在のフェーズ == ステージ.ログイン.ログインステージ.フェーズ.確定 )
560 var user = StrokeStyleT.ユーザ管理.現在選択されているユーザ;
564 foreach( var path in user.曲の検索元フォルダパスのリスト )
565 SST.曲.曲ツリー管理.フォルダから曲を再帰的に検索して子ノードリストに追加する( user.曲ツリーのルートノード, path );
567 StrokeStyleT.曲ツリー管理.現在の管理対象ツリー = StrokeStyleT.ユーザ管理.現在選択されているユーザ.曲ツリーのルートノード;
570 this.現在のステージ.非活性化する( this.デバイスリソース );
571 this.現在のステージ = this.選曲ステージ;
572 this.現在のステージ.活性化する( this.デバイスリソース );
576 #region " キャンセル → タイトルステージへ。"
578 else if( this.ログインステージ.現在のフェーズ == ステージ.ログイン.ログインステージ.フェーズ.キャンセル )
580 this.現在のステージ.非活性化する( this.デバイスリソース );
581 this.現在のステージ = this.タイトルステージ;
582 this.現在のステージ.活性化する( this.デバイスリソース );
588 case nameof( ステージ.選曲.選曲ステージ ):
589 #region " 曲確定 → 曲読込ステージへ。"
591 if( this.選曲ステージ.現在のフェーズ == ステージ.選曲.選曲ステージ.フェーズ.曲確定 )
593 // 曲ノードが選択されていることを確認。
594 Trace.Assert( null != StrokeStyleT.曲ツリー管理.現在選択されているノード, "[バグあり] 選択曲が null です。" );
595 this.現在のステージ.非活性化する( this.デバイスリソース );
596 this.現在のステージ = this.曲読込ステージ;
597 this.現在のステージ.活性化する( this.デバイスリソース );
601 #region " キャンセル → アプリを終了する。"
603 else if( this.選曲ステージ.現在のフェーズ == ステージ.選曲.選曲ステージ.フェーズ.キャンセル )
605 this.現在のステージ.非活性化する( this.デバイスリソース );
607 this.State = ApplicationState.終了;
613 case nameof( ステージ.曲読込.曲読込ステージ ):
614 #region " 終了 → 演奏ステージへ。"
615 //--------------------
616 if( this.曲読込ステージ.現在のフェーズ == ステージ.曲読込.曲読込ステージ.フェーズ.終了 )
618 this.現在のステージ.非活性化する( this.デバイスリソース );
619 this.現在のステージ = this.演奏ステージ;
620 this.現在のステージ.活性化する( this.デバイスリソース );
622 //--------------------
626 case nameof( ステージ.演奏.演奏ステージ ):
627 if( StrokeStyleT.ビュアーモードである )
631 #region " ビュアーメッセージがあれば処理する。"
633 var msg = this.ビュアーメッセージを取得する();
635 StrokeStyleT.最後に取得したビュアーメッセージ = msg; // 保存する。(演奏ステージから参照する)
641 if( msg.種別 == ViewerMessageType.演奏開始 && (
642 this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.ビュアーメッセージ待機中 ||
643 this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.演奏中 )
648 // MusicNode を作成し、現在選択されているノードとして登録する。
649 StrokeStyleT.曲ツリー管理.現在選択されているノード = new 曲.MusicNode( msg.曲ファイルパス );
652 this.演奏ステージ.非活性化する( this.デバイスリソース );
653 this.演奏ステージ.BGMを解放する();
656 this.現在のステージ = this.曲読込ステージ;
657 this.現在のステージ.活性化する( this.デバイスリソース );
661 FDK.Log.ERROR( $"MusicNode の作成に失敗しました。" );
668 else if( msg.種別 == ViewerMessageType.演奏停止 && (
669 this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.ビュアーメッセージ待機中 ||
670 this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.演奏中 )
673 this.演奏ステージ.演奏を停止する();
674 this.演奏ステージ.現在のフェーズ.Value = ステージ.演奏.演奏ステージ.フェーズ.ビュアーメッセージ待機中;
689 #region " クリア/キャンセル → メッセージ待機へ。"
691 if( this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.クリアor失敗 ||
692 this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.キャンセル )
694 // フェーズのみ変更。BGM は止めない。
695 this.演奏ステージ.現在のフェーズ.Value = ステージ.演奏.演奏ステージ.フェーズ.ビュアーメッセージ待機中;
704 #region " 演奏終了 → 結果ステージへ。"
705 //--------------------
706 if( this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.クリアor失敗 )
708 this.現在のステージ.非活性化する( this.デバイスリソース );
709 this.現在のステージ = this.結果ステージ;
710 this.現在のステージ.活性化する( this.デバイスリソース );
712 //--------------------
714 #region " キャンセル → 選曲ステージへ。"
715 //--------------------
716 if( this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.キャンセル )
718 this.現在のステージ.非活性化する( this.デバイスリソース );
719 this.現在のステージ = this.選曲ステージ;
720 this.現在のステージ.活性化する( this.デバイスリソース );
722 //--------------------
727 case nameof( ステージ.結果.結果ステージ ):
728 #region " 終了 → 選曲ステージへ。"
729 //--------------------
730 if( this.結果ステージ.現在のフェーズ == ステージ.結果.結果ステージ.フェーズ.終了 )
732 this.現在のステージ.非活性化する( this.デバイスリソース );
733 this.現在のステージ = this.選曲ステージ;
734 this.現在のステージ.活性化する( this.デバイスリソース );
736 //--------------------
744 protected void デバイス依存リソースを解放する()
746 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
747 Debug.Assert( null != this.デバイスリソース ); // 解放前であること。
749 this.現在のステージ?.デバイス依存リソースを解放する( this.デバイスリソース );
751 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
753 protected void デバイス依存リソースを再構築する()
755 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
756 Debug.Assert( null != this.デバイスリソース ); // 再生成済みであること。
758 this.現在のステージ?.デバイス依存リソースを作成する( this.デバイスリソース );
760 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
763 private void フォームサイズが変更された( object sender, EventArgs e )
765 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
766 FDK.Log.Info( $"新しいクライアントサイズ = {this.MainForm.ClientSize}" );
770 if( null == this.デバイスリソース )
772 FDK.Log.Info( " まだ初期化されてないので、何もしません。" );
773 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
776 if( this.MainForm.WindowState == FormWindowState.Minimized )
778 FDK.Log.Info( "最小化されました。" );
779 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
782 if( this.State != ApplicationState.進行描画 )
784 FDK.Log.Info( " アプリケーションの状態が進行描画じゃないので、何もしません。" );
785 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
791 Debug.Assert( null != this.デバイスリソース, "デバイスリソースが作成済みであること。" );
793 // 現在の画面モードを取得しておく。(Alt+TABなど、勝手に全画面を解除されることもあるので。)
794 SharpDX.Mathematics.Interop.RawBool fullscreen;
795 SharpDX.DXGI.Output outputTarget;
796 this.デバイスリソース.SwapChain1.GetFullscreenState( out fullscreen, out outputTarget );
797 this.MainForm.IsFullscreen = fullscreen;
798 outputTarget?.Dispose();
799 FDK.Log.Info( $"現在、全画面モードである = {this.MainForm.IsFullscreen}" );
802 this.デバイス依存リソースを解放する();
803 this.デバイスリソース.サイズに依存するリソースを解放する();
806 this.デバイスリソース.物理画面サイズpx = new SharpDX.Size2F( this.MainForm.ClientSize.Width, this.MainForm.ClientSize.Height );
809 this.デバイスリソース.サイズに依存するリソースを作成する();
810 this.デバイス依存リソースを再構築する();
812 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
814 private void 全画面モードとウィンドウモードを切り替える()
816 FDK.Log.BeginInfo( $"{FDK.Utilities.現在のメソッド名}" );
818 this.MainForm.IsFullscreen = !this.MainForm.IsFullscreen; // 切り替え
819 this.デバイスリソース.SwapChain1.SetFullscreenState( this.MainForm.IsFullscreen, null );
821 FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
823 private void ログインする( string ユーザ名 )
825 StrokeStyleT.ユーザ管理.ユーザを選択する( ユーザ名 );
826 FDK.Log.Info( $"ユーザが選択されました。[{StrokeStyleT.ユーザ管理.現在選択されているユーザ.名前}]" );
828 /// <returns>メッセージがない場合は null を返す。</returns>
829 private ViewerMessage ビュアーメッセージを取得する()
831 var msg = (ViewerMessage) null;
833 if( StrokeStyleT.ビュアーモードである &&
834 ( 0 < this.ビュアーメッセージキュー.Count ) &&
835 this.ビュアーメッセージキュー.TryDequeue( out msg ) )
845 private static SST.フォルダ bs_フォルダ = null;
846 private static FDK.入力.Keyboard bs_キーボード入力 = null;
847 private static FDK.入力.MidiIn bs_MIDI入力 = null;
848 private static FDK.メディア.サウンド.WASAPI.Device bs_Wasapiデバイス = null;
849 private static readonly System.Random bs_乱数 = new Random( DateTime.Now.Millisecond );
850 private static SST.ユーザ.ユーザ管理 bs_ユーザ管理 = null;
851 private static SST.曲.曲ツリー管理 bs_曲ツリー管理 = null;
852 private static SST.設定.Config bs_Config = null;