mirror of
http://git.xinwangdao.com/cnnc-embedded-parts-detect/detect.git
synced 2025-06-24 05:24:12 +08:00
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System.Linq;
|
|
using Xilium.CefGlue;
|
|
|
|
namespace WebViewControl {
|
|
|
|
internal static class WebViewExtensions {
|
|
|
|
public static string[] GetFrameNames(this WebView webview) {
|
|
return webview.GetCefBrowser()?.GetFrameNames().Where(n => !webview.IsMainFrame(n)).ToArray() ?? new string[0];
|
|
}
|
|
|
|
internal static bool HasFrame(this WebView webview, string name) {
|
|
return webview.GetFrame(name) != null;
|
|
}
|
|
|
|
internal static CefFrame GetFrame(this WebView webview, string frameName) {
|
|
return webview.GetCefBrowser()?.GetFrame(frameName ?? "");
|
|
}
|
|
|
|
internal static bool IsMainFrame(this WebView webview, string frameName) {
|
|
return string.IsNullOrEmpty(frameName);
|
|
}
|
|
|
|
internal static void SendKeyEvent(this WebView webview, CefKeyEvent keyEvent) {
|
|
webview.GetCefBrowser()?.GetHost()?.SendKeyEvent(keyEvent);
|
|
}
|
|
|
|
internal static void SetAccessibilityState(this WebView webview, CefState state) {
|
|
webview.GetCefBrowser()?.GetHost()?.SetAccessibilityState(state);
|
|
}
|
|
|
|
private static CefBrowser GetCefBrowser(this WebView webview) {
|
|
return webview.UnderlyingBrowser.GetBrowser();
|
|
}
|
|
}
|
|
}
|