OSDN Git Service

フォルダ SSTformatTest1 を削除。
[strokestylet/CsWin10Desktop3.git] / FDK / UI / Image.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Drawing;
4 using System.Linq;
5 using System.Text;
6 using System.Threading.Tasks;
7 using SharpDX;
8 using SharpDX.Direct2D1;
9 using FDK;
10 using FDK.メディア;
11
12 namespace FDK.UI
13 {
14         public class Image : Element
15         {
16                 public Size2F Size
17                 {
18                         get
19                                 => this._画像.サイズ;
20                 }
21
22
23                 public Image( グラフィックデバイス gd, string imagePath )
24                 {
25                         this._画像 = new 描画可能画像( imagePath );
26                         this._画像.活性化する( gd );
27                 }
28                 public Image( グラフィックデバイス gd, Size2F size )
29                 {
30                         this._画像 = new 描画可能画像( new Size2( (int) size.Width, (int) size.Height ) );
31                         this._画像.活性化する( gd );
32                 }
33
34                 protected override void OnDispose()
35                 {
36                         this._画像?.非活性化する( null );   // このクラスは null でも OK
37                         this._画像 = null;
38                 }
39
40                 public void DrawToImage( グラフィックデバイス gd, Action<DeviceContext1> action )
41                 {
42                         this._画像.画像へ描画する( gd, action );
43                 }
44
45                 protected override void OnRender( グラフィックデバイス gd, PointF upperLeft )
46                 {
47                         upperLeft += new SizeF( this.Location );
48                         this._画像.描画する( gd, upperLeft.X, upperLeft.Y );
49                 }
50
51
52                 protected 描画可能画像 _画像 = null;
53         }
54 }