@@ -15,7 +15,7 @@ public unsafe class Window : ComponentBase, IHandle<HWND>, ILayoutHandler
15
15
private static readonly object s_lock = new ( ) ;
16
16
private static readonly ConcurrentDictionary < HWND , WeakReference < Window > > s_windows = new ( ) ;
17
17
private static readonly WindowClass s_defaultWindowClass = new ( className : $ "DefaultWindowClass_{ Guid . NewGuid ( ) } ") ;
18
- protected static Factory ? Direct2dFactory { get ; private set ; }
18
+
19
19
public static Rectangle DefaultBounds { get ; }
20
20
= new ( Interop . CW_USEDEFAULT , Interop . CW_USEDEFAULT , Interop . CW_USEDEFAULT , Interop . CW_USEDEFAULT ) ;
21
21
@@ -72,10 +72,10 @@ protected bool IsDirect2dEnabled([NotNullWhen(true)] out HwndRenderTarget? rende
72
72
return IsDirect2dEnabled ( ) ;
73
73
}
74
74
75
- /// <summary>
76
- /// The window handle. This will be <see cref="HWND.Null"/> after the window is destroyed.
77
- /// </summary>
78
- public HWND Handle => _handle ;
75
+ /// <summary>
76
+ /// The window handle. This will be <see cref="HWND.Null"/> after the window is destroyed.
77
+ /// </summary>
78
+ public HWND Handle => _handle ;
79
79
80
80
public event WindowsMessageEvent ? MessageHandler ;
81
81
@@ -101,11 +101,6 @@ public Window(
101
101
_text = text ;
102
102
_features = features ;
103
103
104
- if ( _features . AreFlagsSet ( Features . EnableDirect2d ) )
105
- {
106
- Direct2dFactory ??= new ( ) ;
107
- }
108
-
109
104
try
110
105
{
111
106
_handle = _windowClass . CreateWindow (
@@ -194,14 +189,9 @@ public void SetFont(string typeFace, int pointSize)
194
189
[ MemberNotNull ( nameof ( Direct2dRenderTarget ) ) ]
195
190
private void UpdateRenderTarget ( HWND window , Size size )
196
191
{
197
- if ( Direct2dFactory is null )
198
- {
199
- throw new InvalidOperationException ( "Should never call UpdateRenderTarget without a factory." ) ;
200
- }
201
-
202
192
if ( Direct2dRenderTarget is null )
203
193
{
204
- Direct2dRenderTarget = HwndRenderTarget . CreateForWindow ( Direct2dFactory , window , size ) ;
194
+ Direct2dRenderTarget = HwndRenderTarget . CreateForWindow ( Application . Direct2dFactory , window , size ) ;
205
195
RenderTargetCreated ( Direct2dRenderTarget ) ;
206
196
}
207
197
else
0 commit comments