OSDN Git Service

二重起動イベントを受け取るよう修正(未実装)。
authorくまかみ工房 <kumakamikoubou@gmail.com>
Fri, 14 Oct 2016 05:22:50 +0000 (14:22 +0900)
committerくまかみ工房 <kumakamikoubou@gmail.com>
Fri, 14 Oct 2016 05:27:59 +0000 (14:27 +0900)
Microsoft.VisualBasic を参照する。

FDK24/ApplicationBase.cs
FDK24/FDK24.csproj
StrokeStyleT/Program.cs
StrokeStyleT/StrokeStyleT.cs
StrokeStyleT/StrokeStyleT.csproj

index 5bfc808..2109e6e 100644 (file)
@@ -4,13 +4,14 @@ using System.ComponentModel;
 using System.Diagnostics;
 using System.Linq;
 using System.Windows.Forms;
+using Microsoft.VisualBasic.ApplicationServices;
 
 namespace FDK
 {
        /// <summary>
        /// アプリケーションフォームの基礎クラス。デバイスリソースを持つ。
        /// </summary>
-       public class ApplicationBase
+       public class ApplicationBase : Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase
        {
                public System.Windows.Forms.Form Window => ( this.bs_Window );
                public bool 全画面モードである
@@ -24,9 +25,13 @@ namespace FDK
                        protected set { this.全画面モードである = !value; }
                }
 
-               public ApplicationBase()
+               public ApplicationBase() : base()
                {
-                       this.bs_Window = new Form();
+                       this.EnableVisualStyles = true;
+                       this.IsSingleInstance = true;   // 単一インスタンスである
+                       this.MainForm = new Form();
+
+                       this.bs_Window = this.MainForm;
                        this.bs_Window.Load += OnLoad;
                        this.bs_Window.FormClosing += OnClosing;
                        this.bs_Window.ClientSizeChanged += OnClientSizeChanged;
@@ -130,6 +135,17 @@ namespace FDK
                {
                        // デバイスリソースはまだ再構築されていない。
                }
+               /// <summary>
+               /// アプリが二重起動されたときに発生するイベント。
+               /// </summary>
+               /// <remarks>
+               /// 後続のインスタンスは起動せず、既存のインスタンスに対してこのイベントが発生する。
+               /// eventArg.CommandLine で、後続のインスタンスのコマンドライン引数を確認することができる。
+               /// </remarks>
+               protected override void OnStartupNextInstance( StartupNextInstanceEventArgs eventArgs )
+               {
+                       base.OnStartupNextInstance( eventArgs );
+               }
 
                #region " バックストア。"
                //----------------
index b63c7fc..36eccf6 100644 (file)
@@ -36,6 +36,7 @@
       <HintPath>..\packages\CSCore.1.1.0\lib\net35-client\CSCore.dll</HintPath>
       <Private>True</Private>
     </Reference>
+    <Reference Include="Microsoft.VisualBasic" />
     <Reference Include="SharpDX, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
       <HintPath>..\packages\SharpDX.3.0.2\lib\net45\SharpDX.dll</HintPath>
       <Private>True</Private>
index 106f510..486cbca 100644 (file)
@@ -9,11 +9,10 @@ namespace SST
        static class Program
        {
                [STAThread]
-               static void Main()
+               static void Main( string[] args )
                {
-                       Application.EnableVisualStyles();
-                       Application.SetCompatibleTextRenderingDefault( false );
-                       Application.Run( new StrokeStyleT().Window );
+                       var sst = new StrokeStyleT();
+                       sst.Run( args );
                }
        }
 }
index e611c57..786df21 100644 (file)
@@ -4,6 +4,7 @@ using System.ComponentModel;
 using System.Diagnostics;
 using System.Linq;
 using System.Windows.Forms;
+using Microsoft.VisualBasic.ApplicationServices;
 
 namespace SST
 {
@@ -403,6 +404,17 @@ namespace SST
 
                        FDK.Log.EndInfo( $"{FDK.Utilities.現在のメソッド名}" );
                }
+               /// <summary>
+               /// アプリが二重起動されたときに発生するイベント。
+               /// </summary>
+               /// <remarks>
+               /// 後続のインスタンスは起動せず、既存のインスタンスに対してこのイベントが発生する。
+               /// eventArg.CommandLine で、後続のインスタンスのコマンドライン引数を確認することができる。
+               /// </remarks>
+               protected override void OnStartupNextInstance( StartupNextInstanceEventArgs eventArgs )
+               {
+                       base.OnStartupNextInstance( eventArgs );
+               }
 
                // 各ステージの、唯一のインスタンス。最終的に null を代入するので、readonlyにはしない。
                protected SST.ステージ.ステージ 最初のダミーステージ = new ステージ.ステージ();
index 86606e8..e02c5d3 100644 (file)
@@ -39,6 +39,7 @@
       <HintPath>..\packages\CSCore.1.1.0\lib\net35-client\CSCore.dll</HintPath>
       <Private>True</Private>
     </Reference>
+    <Reference Include="Microsoft.VisualBasic" />
     <Reference Include="SharpDX, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
       <HintPath>..\packages\SharpDX.3.0.2\lib\net45\SharpDX.dll</HintPath>
       <Private>True</Private>