OSDN Git Service

Config.xmlに物理画面細部を追加。
authorくまかみ工房 <kumakamikoubou@gmail.com>
Tue, 4 Oct 2016 04:04:24 +0000 (13:04 +0900)
committerくまかみ工房 <kumakamikoubou@gmail.com>
Tue, 4 Oct 2016 04:04:24 +0000 (13:04 +0900)
StrokeStyleT/StrokeStyleT.cs
StrokeStyleT/設定/Config.cs
StrokeStyleT/設定/XML.cs

index 61ef9fe..90168bb 100644 (file)
@@ -58,7 +58,7 @@ namespace SST
                        //----------------
                        #endregion
 
-                       this.Window.ClientSize = new System.Drawing.Size( 1280, 720 );  // 物理画面サイズpx
+                       this.Window.ClientSize = new System.Drawing.Size( StrokeStyleT.Config.物理画面サイズpx.Width, StrokeStyleT.Config.物理画面サイズpx.Height );
 
                        #region " System.Stopwatch が高解像度タイマを使わないならエラー。"
                        //-----------------
index 375e1cc..22f75c3 100644 (file)
@@ -10,6 +10,7 @@ namespace SST.設定
        class Config
        {
                public bool 垂直帰線待ちを行う { get; set; }
+               public SharpDX.Size2 物理画面サイズpx { get; set; }
 
                public Config()
                {
@@ -23,24 +24,28 @@ namespace SST.設定
                {
                        try
                        {
-                               var XML文書 = new XDocument( new XDeclaration( version: "1.0", encoding: "utf-8", standalone: "yes" ) );
+                               var XML文書 = new XDocument( new XDeclaration( version: "1.0", encoding: "utf-8", standalone: "yes" ),
+
+                                       new XElement( nameof( XML.Root ),
+
+                                               new XElement( nameof( XML.Config ),
 
-                               // <Root>
-                               var Root要素 = new XElement( nameof( XML.Root ) );
-                               {
-                                       // <Config>
-                                       var Config要素 = new XElement( nameof( XML.Config ) );
-                                       {
-                                               // <WaitForVerticalBlank>
-                                               Config要素.Add(
                                                        new XComment( "垂直帰線待ちを行う場合はtrue、行わない場合はfalseを設定します。" ),
-                                                       new XElement( nameof( XML.WaitForVerticalBlank ), this.垂直帰線待ちを行う ) );
-                                       }
-                                       Root要素.Add( Config要素 );
-                               }
-                               XML文書.Add( Root要素 );
+                                                       new XElement( nameof( XML.WaitForVerticalBlank ), this.垂直帰線待ちを行う ),
+
+                                                       new XComment( "画面に関する設定を行います。" ),
+                                                       new XElement( nameof( XML.Screen ),
+
+                                                               new XComment( "画面の幅を設定します。" ),
+                                                               new XElement( nameof( XML.Width ), this.物理画面サイズpx.Width ),
+
+                                                               new XComment( "画面の高さを設定します。" ),
+                                                               new XElement( nameof( XML.Height ), this.物理画面サイズpx.Height )
+                                                       )
+                                               )
+                                       )
+                               );
 
-                               // ファイルに保存する。
                                XML文書.Save( ファイルパス );
                        }
                        catch( Exception e )
@@ -85,6 +90,37 @@ namespace SST.設定
                                                }
                                                //----------------
                                                #endregion
+
+                                               // <Screen>*
+                                               foreach( var Screen要素 in Config要素.Elements( nameof( XML.Screen ) ) )
+                                               {
+                                                       #region " <Width> "
+                                                       //----------------
+                                                       try
+                                                       {
+                                                               int width = (int) Screen要素.Element( nameof( XML.Width ) );
+                                                               this.物理画面サイズpx = new SharpDX.Size2( width, this.物理画面サイズpx.Height );
+                                                       }
+                                                       catch( Exception e )
+                                                       {
+                                                               FDK.Log.ERROR( $"<{XML.Config}>.<{XML.Screen}>.<{XML.Width}> の読み込みに失敗しました。{e.Message}" );
+                                                       }
+                                                       //----------------
+                                                       #endregion
+                                                       #region " <Height> "
+                                                       //----------------
+                                                       try
+                                                       {
+                                                               int height = (int) Screen要素.Element( nameof( XML.Height ) );
+                                                               this.物理画面サイズpx = new SharpDX.Size2( this.物理画面サイズpx.Width, height );
+                                                       }
+                                                       catch( Exception e )
+                                                       {
+                                                               FDK.Log.ERROR( $"<{XML.Config}>.<{XML.Screen}>.<{XML.Height}> の読み込みに失敗しました。{e.Message}" );
+                                                       }
+                                                       //----------------
+                                                       #endregion
+                                               }
                                        }
                                }
                        }
@@ -96,12 +132,12 @@ namespace SST.設定
 
                protected readonly string ConfigXmlファイルパス = @"$(AppData)\Config.xml";
 
-               /// <summary>
-               /// 既定の設定値で初期化する。
-               /// </summary>
                private void 初期化する()
                {
+                       // 各メンバの規定値を設定する。
+
                        this.垂直帰線待ちを行う = true;
+                       this.物理画面サイズpx = new SharpDX.Size2( 1280, 720 );
                }
        }
 }
index af1686a..8eb3f00 100644 (file)
@@ -11,5 +11,9 @@ namespace SST.設定
                Root,
                Config,
                WaitForVerticalBlank,
+               Screen,
+               Size,
+               Width,
+               Height,
        }
 }