OSDN Git Service

FDK.UI 名前空間の最初の実装を追加。
authorくまかみ工房 <kumakamikoubou@gmail.com>
Sat, 17 Jun 2017 11:47:00 +0000 (20:47 +0900)
committerくまかみ工房 <kumakamikoubou@gmail.com>
Sat, 17 Jun 2017 11:47:00 +0000 (20:47 +0900)
FDK/FDK.csproj
FDK/UI/Element.cs [new file with mode: 0644]
FDK/UI/Framework.cs [new file with mode: 0644]
FDK/UI/Image.cs [new file with mode: 0644]
StrokeStyleT/App.cs

index c72c3f7..f516a5e 100644 (file)
       <DependentUpon>Resources.resx</DependentUpon>
     </Compile>
     <Compile Include="SelectableList.cs" />
+    <Compile Include="UI\Image.cs" />
+    <Compile Include="UI\Element.cs" />
+    <Compile Include="UI\Framework.cs" />
     <Compile Include="XML\SerializableDictionary.cs" />
     <Compile Include="XML\Serializer.cs" />
     <Compile Include="カウンタ\Counter.cs" />
diff --git a/FDK/UI/Element.cs b/FDK/UI/Element.cs
new file mode 100644 (file)
index 0000000..174eb2d
--- /dev/null
@@ -0,0 +1,81 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using FDK;
+using FDK.メディア;
+
+namespace FDK.UI
+{
+       public class Element : IDisposable
+       {
+               public System.Drawing.PointF Location
+               {
+                       get;
+                       set;
+               } = new System.Drawing.PointF( 0f, 0f );
+
+
+               public Element()
+               {
+               }
+
+               public void Dispose()
+               {
+                       // (1) 自分を解放する。
+                       this.OnDispose();
+
+                       // (2) 子を解放する。
+                       foreach( var child in this._子要素リスト )
+                               child.Dispose();
+                       this._子要素リスト.Clear();
+               }
+
+               public void AddChild( Element child, bool isAbove, Element refChild = null )
+               {
+                       if( isAbove )
+                       {
+                               this._子要素リスト.Insert( 0, child );
+                       }
+                       else if( null != refChild )
+                       {
+                               int n = this._子要素リスト.IndexOf( refChild );
+
+                               if( 0 <= n )
+                               {
+                                       this._子要素リスト.Insert( n + 1, child );
+                               }
+                               else
+                               {
+                                       Log.ERRORandTHROW( "指定された要素が存在しません。", new ArgumentException() );
+                               }
+                       }
+                       else
+                       {
+                               Log.ERRORandTHROW( "指定された要素が無効です。", new ArgumentNullException() );
+                       }
+               }
+
+               public void Render( グラフィックデバイス gd, PointF upperLeft )
+               {
+                       // (1) 自分を描画する。
+                       this.OnRender( gd, upperLeft );
+
+                       // (2) 子要素を昇順に描画する。
+                       upperLeft += new SizeF( this.Location );
+                       for( int i = 0; i < this._子要素リスト.Count; i++ )
+                               this._子要素リスト[ i ].Render( gd, upperLeft );
+               }
+
+
+               protected readonly List<Element> _子要素リスト = new List<Element>();
+
+               // 以下、派生クラスで実装する。
+
+               protected virtual void OnRender( グラフィックデバイス gd, PointF upperLeft ) { }
+
+               protected virtual void OnDispose() { }
+       }
+}
diff --git a/FDK/UI/Framework.cs b/FDK/UI/Framework.cs
new file mode 100644 (file)
index 0000000..00478a8
--- /dev/null
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using FDK;
+using FDK.メディア;
+
+namespace FDK.UI
+{
+       public class Framework : IDisposable
+       {
+               public Element Root
+               {
+                       get;
+                       set;
+               } = null;
+
+
+               public Framework()
+               {
+               }
+
+               public void Dispose()
+               {
+                       this.Root?.Dispose();
+                       this.Root = null;
+               }
+
+               public void Render( グラフィックデバイス gd )
+               {
+                       this.Root?.Render( gd, new PointF( 0f, 0f ) );  // Root == null は OK
+               }
+       }
+}
diff --git a/FDK/UI/Image.cs b/FDK/UI/Image.cs
new file mode 100644 (file)
index 0000000..3b92a4d
--- /dev/null
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SharpDX;
+using FDK;
+using FDK.メディア;
+using System.Drawing;
+
+namespace FDK.UI
+{
+       public class Image : Element
+       {
+               public Size2F Size
+               {
+                       get
+                               => this._画像.サイズ;
+               }
+
+
+               public Image( グラフィックデバイス gd, string imagePath )
+               {
+                       this._画像 = new 画像( imagePath );
+                       this._画像.活性化する( gd );
+               }
+
+               protected override void OnDispose()
+               {
+                       this._画像?.非活性化する( null );   // このクラスは null でも OK
+                       this._画像 = null;
+               }
+
+               protected override void OnRender( グラフィックデバイス gd, PointF upperLeft )
+               {
+                       upperLeft += new SizeF( this.Location );
+                       this._画像.描画する( gd, upperLeft.X, upperLeft.Y );
+               }
+
+
+               private 画像 _画像 = null;
+       }
+}
index 8f182ed..7b09cd1 100644 (file)
@@ -123,6 +123,12 @@ namespace SST
                        protected set;
                }
 
+               public static FDK.UI.Framework UIフレームワーク
+               {
+                       get;
+                       protected set;
+               } = null;
+
                #endregion
 
 
@@ -177,6 +183,8 @@ namespace SST
                                App.最後に取得したビュアーメッセージ = null;
                                App.ビュアー用ノード = null;
 
+                               App.UIフレームワーク = new FDK.UI.Framework();
+
                                #region " メインフォームを初期化する。"
                                //----------------
                                this.Text = $"{Application.ProductName} {Application.ProductVersion}";
@@ -482,9 +490,10 @@ namespace SST
                                        //----------------
                                        #endregion
 
-                                       #region " (2) 現在のステージの進行描画を行う。"
+                                       #region " (2) ç\8f¾å\9c¨ã\81®ã\82¹ã\83\86ã\83¼ã\82¸ã\81¨UIã\83\95ã\83¬ã\83¼ã\83 ã\83¯ã\83¼ã\82¯ã\81®é\80²è¡\8cæ\8f\8fç\94»ã\82\92è¡\8cã\81\86ã\80\82"
                                        //----------------
                                        App.ステージ管理.現在のステージ.進行描画する( gd );
+                                       App.UIフレームワーク.Render( gd );
                                        //----------------
                                        #endregion
 
@@ -739,6 +748,8 @@ namespace SST
                {
                        using( Log.Block( FDKUtilities.現在のメソッド名 ) )
                        {
+                               App.UIフレームワーク.Dispose();
+
                                if( App.ステージ管理.現在のステージ?.活性化している ?? false )
                                        App.ステージ管理.現在のステージ?.非活性化する( App.グラフィックデバイス );