Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault( false );
- string serviceUri = "net.pipe://localhost/StrokeStyleT";
- string endPointName = "Viewer";
- string endPointUri = $"{serviceUri}/{endPointName}";
-
- // アプリを生成する。
+ // アプリを生成する。ビュアーモードかどうかの判定も行う。
var app = new StrokeStyleT();
- // アプリのサービスホストを生成する。
- var serviceHost = new ServiceHost( app, new Uri( serviceUri ) );
+ if( StrokeStyleT.ビュアーモードである )
+ {
+ #region " (A) ビュアーモードでの起動(WCFサービスあり)"
+ //----------------
+ string serviceUri = "net.pipe://localhost/StrokeStyleT";
+ string endPointName = "Viewer";
+ string endPointUri = $"{serviceUri}/{endPointName}";
- // 名前付きパイプにバインドしたエンドポイントをサービスホストへ追加する。
- serviceHost.AddServiceEndpoint(
- typeof( IStrokeStyleTService ),
- new NetNamedPipeBinding( NetNamedPipeSecurityMode.None ),
- endPointName );
+ // アプリのサービスホストを生成する。
+ var serviceHost = new ServiceHost( app, new Uri( serviceUri ) );
- // サービスの受付を開始する。
- try
- {
- serviceHost.Open();
- }
- catch( AddressAlreadyInUseException )
- {
- MessageBox.Show( "同じアプリがすでに起動しています。多重起動はできません。", "SST Error", MessageBoxButtons.OK );
- return;
- }
+ // 名前付きパイプにバインドしたエンドポイントをサービスホストへ追加する。
+ serviceHost.AddServiceEndpoint(
+ typeof( IStrokeStyleTService ),
+ new NetNamedPipeBinding( NetNamedPipeSecurityMode.None ),
+ endPointName );
- // アプリを実行する。
- try
- {
- app.Run();
+ // サービスの受付を開始する。
+ try
+ {
+ serviceHost.Open();
+ }
+ catch( AddressAlreadyInUseException )
+ {
+ MessageBox.Show( "同じアプリがすでに起動しています。多重起動はできません。", "SST Error", MessageBoxButtons.OK );
+ return;
+ }
+
+ // アプリを実行する。
+ try
+ {
+ app.Run();
+ }
+ finally
+ {
+ // サービスの受付を終了する。
+ serviceHost.Close();
+ }
+ //----------------
+ #endregion
}
- finally
+ else
{
- // サービスの受付を終了する。
- serviceHost.Close();
+ #region " (B) 通常の起動(WCFサービスなし)"
+ //----------------
+ // アプリを実行する。
+ app.Run();
+ //----------------
+ #endregion
}
}
}
}
public StrokeStyleT()
{
- this.State = ApplicationState.起動;
- this.MainForm = new SharpDX.Windows.RenderForm();
- this.MainForm.AllowUserResizing = false; // ユーザはフォームサイズを変更できない。
- this.MainForm.UserResized += フォームサイズが変更された;
- }
-
- public void Run()
- {
- Debug.Assert( null != this.MainForm );
-
#region " ビュアーモードかどうかを確認する。"
//----------------
foreach( var arg in Environment.GetCommandLineArgs() )
//----------------
#endregion
+ this.State = ApplicationState.起動;
+
+ this.MainForm = new SharpDX.Windows.RenderForm();
+ this.MainForm.AllowUserResizing = false; // ユーザはフォームサイズを変更できない。
+ this.MainForm.UserResized += フォームサイズが変更された;
+ }
+
+ public void Run()
+ {
+ Debug.Assert( null != this.MainForm );
+
SharpDX.Windows.RenderLoop.Run( this.MainForm, () => {
// アプリケーションの状態に応じて処理分岐。
} );
}
- #region " サービスインターフェースの実装 "
+ #region " WCF サービスインターフェースの実装 "
//----------------
// ・このサービスインターフェースは、シングルスレッド(GUIスレッド)で同期実行される。(StrokeStyleT クラスの ServiceBehavior属性を参照。)
// ・このサービスホストはシングルトンであり、すべてのクライアントセッションは同一(単一)のサービスインスタンスへ接続される。(Program.Main() を参照。)
if( StrokeStyleT.Config.垂直帰線待ちを行う )
{
// We recommend that you use Flush when the CPU waits for an arbitrary amount of time
- // ( such as when you call the Sleep function).
- // https://msdn.microsoft.com/ja-jp/library/windows/desktop/ff476425(v=vs.85).aspx
+ // (such as when you call the Sleep function).
+ // → https://msdn.microsoft.com/ja-jp/library/windows/desktop/ff476425(v=vs.85).aspx
+
var d3dDevice = (SharpDX.Direct3D11.Device) null;
using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.デバイスリソース.DXGIDeviceManager, out d3dDevice ) )
using( d3dDevice )