File tree Expand file tree Collapse file tree 3 files changed +37
-15
lines changed Expand file tree Collapse file tree 3 files changed +37
-15
lines changed Original file line number Diff line number Diff line change @@ -789,5 +789,16 @@ public IBrowser GetBrowser()
789
789
790
790
return browser ;
791
791
}
792
+
793
+ /// <summary>
794
+ /// Gets the <see cref="ChromiumWebBrowser"/> associated with
795
+ /// a specific <see cref="IBrowser"/> instance.
796
+ /// </summary>
797
+ /// <param name="browser">browser</param>
798
+ /// <returns>returns the assocaited <see cref="ChromiumWebBrowser"/> or null if Disposed or no host found.</returns>
799
+ public static ChromiumWebBrowser FromBrowser ( IBrowser browser )
800
+ {
801
+ return FromBrowser < ChromiumWebBrowser > ( browser ) ;
802
+ }
792
803
}
793
804
}
Original file line number Diff line number Diff line change @@ -298,21 +298,7 @@ protected override void Dispose(bool disposing)
298
298
/// <returns>returns the assocaited <see cref="ChromiumHostControl"/> or null if Disposed or no host found.</returns>
299
299
public static ChromiumHostControl FromBrowser ( IBrowser browser )
300
300
{
301
- if ( browser . IsDisposed )
302
- {
303
- return null ;
304
- }
305
-
306
- var windowHandle = browser . GetHost ( ) . GetWindowHandle ( ) ;
307
-
308
- if ( windowHandle == IntPtr . Zero )
309
- {
310
- return null ;
311
- }
312
-
313
- var control = Control . FromChildHandle ( windowHandle ) as ChromiumHostControl ;
314
-
315
- return control ;
301
+ return FromBrowser < ChromiumHostControl > ( browser ) ;
316
302
}
317
303
}
318
304
}
Original file line number Diff line number Diff line change @@ -181,5 +181,30 @@ internal void RaiseIsBrowserInitializedChangedEvent()
181
181
{
182
182
IsBrowserInitializedChanged ? . Invoke ( this , EventArgs . Empty ) ;
183
183
}
184
+
185
+ /// <summary>
186
+ /// Gets the <see cref="ChromiumHostControl"/> or <see cref="ChromiumWebBrowser"/> associated with
187
+ /// a specific <see cref="IBrowser"/> instance.
188
+ /// </summary>
189
+ /// <param name="browser">browser</param>
190
+ /// <returns>returns the assocaited <see cref="ChromiumHostControl"/> or <see cref="ChromiumWebBrowser"/> or null if Disposed or no host found.</returns>
191
+ internal static T FromBrowser < T > ( IBrowser browser ) where T : ChromiumHostControlBase
192
+ {
193
+ if ( browser . IsDisposed )
194
+ {
195
+ return null ;
196
+ }
197
+
198
+ var windowHandle = browser . GetHost ( ) . GetWindowHandle ( ) ;
199
+
200
+ if ( windowHandle == IntPtr . Zero )
201
+ {
202
+ return null ;
203
+ }
204
+
205
+ var control = Control . FromChildHandle ( windowHandle ) as T ;
206
+
207
+ return control ;
208
+ }
184
209
}
185
210
}
You can’t perform that action at this time.
0 commit comments