OSDN Git Service

全画面モードとウィンドウモードへの切り替えを高速に行うとウィンドウが小さくなっていくミスを修正。
[strokestylet/CsWin10Desktop3.git] / FDK / Extensions.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Diagnostics;
4 using System.Linq;
5 using SharpDX;
6
7 namespace FDK
8 {
9         public static class Extensions
10         {
11                 // SharpDX.IUnknown 
12
13                 /// <summary>
14                 ///             COM オブジェクトの参照カウントを取得して返す。
15                 /// </summary>
16                 /// <param name="unknownObject">COMオブジェクト。</param>
17                 /// <returns>現在の参照カウントの値。</returns>
18                 public static int GetRefferenceCount( this IUnknown unknownObject )
19                 {
20                         try
21                         {
22                                 unknownObject.AddReference();
23                         }
24                         catch( InvalidOperationException )
25                         {
26                                 // すでに Dispose されている。
27                                 return 0;
28                         }
29
30                         return unknownObject.Release();
31                 }
32
33
34                 // System.String
35
36                 /// <summary>
37                 ///             文字列が Null でも空でもないなら true を返す。
38                 /// </summary>
39                 public static bool Nullでも空でもない( this string 検査対象 )
40                         => !( string.IsNullOrEmpty( 検査対象 ) );
41                 
42                 /// <summary>
43                 ///             文字列が Null または空なら true を返す。
44                 /// </summary>
45                 public static bool Nullまたは空である( this string 検査対象 )
46                         => string.IsNullOrEmpty( 検査対象 );
47
48
49                 // SharpDX.Size2F
50
51                 /// <summary>
52                 ///             SharpDX.Size2F を System.Drawing.SizeF へ変換する。
53                 /// </summary>
54                 public static System.Drawing.SizeF ToDrawingSizeF( this SharpDX.Size2F size )
55                         => new System.Drawing.SizeF( size.Width, size.Height );
56
57                 /// <summary>
58                 ///             SharpDX.Size2F を System.Drawing.Size へ変換する。
59                 /// </summary>
60                 public static System.Drawing.Size ToDrawingSize( this SharpDX.Size2F size )
61                         => new System.Drawing.Size( (int) size.Width, (int) size.Height );
62
63
64                 // SharpDX.Size2
65
66                 /// <summary>
67                 ///             SharpDX.Size2 を System.Drawing.SizeF へ変換する。
68                 /// </summary>
69                 public static System.Drawing.SizeF ToDrawingSizeF( this SharpDX.Size2 size )
70                         => new System.Drawing.SizeF( size.Width, size.Height );
71
72                 /// <summary>
73                 ///             SharpDX.Size2 を System.Drawing.Size へ変換する。
74                 /// </summary>
75                 public static System.Drawing.Size ToDrawingSize( this SharpDX.Size2 size )
76                         => new System.Drawing.Size( size.Width, size.Height );
77         }
78 }