C# Класс CefSharp.WebBrowserExtensions

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AddWordToDictionary ( this cefBrowser, string word ) : void

Add the specified word to the spelling dictionary.

Back ( this browser ) : void

Navigates back, must check IWebBrowser.CanGoBack before calling this method.

CloseDevTools ( this cefBrowser ) : void

Explicitly close the developer tools window if one exists for this browser instance.

Copy ( this browser ) : void

Execute Copy on the focused frame

Cut ( this browser ) : void

Execute Cut on the focused frame

Delete ( this browser ) : void

Execute Delete on the focused frame

EvaluateScriptAsync ( this browser, System.TimeSpan timeout, string methodName ) : Task

Evaluate some Javascript code in the context of this WebBrowser using the specified timeout. The script will be executed asynchronously and the method returns a Task encapsulating the response from the Javascript This simple helper extension will encapsulate params in single quotes (unless int, uint, etc)

EvaluateScriptAsync ( this browser, string methodName ) : Task

Evaluate some Javascript code in the context of this WebBrowser. The script will be executed asynchronously and the method returns a Task encapsulating the response from the Javascript This simple helper extension will encapsulate params in single quotes (unless int, uint, etc)

EvaluateScriptAsync ( this browser, string script, System.TimeSpan timeout = null ) : Task
ExecuteScriptAsync ( this browser, string methodName ) : void

Execute some Javascript code in the context of this WebBrowser. As the method name implies, the script will be executed asynchronously, and the method therefore returns before the script has actually been executed. This simple helper extension will encapsulate params in single quotes (unless int, uint, etc)

Find ( this cefBrowser, int identifier, string searchText, bool forward, bool matchCase, bool findNext ) : void

Search for text within the current page.

Forward ( this browser ) : void

Navigates forward, must check IWebBrowser.CanGoForward before calling this method.

GetFocusedFrame ( this webBrowser ) : IFrame

Returns the focused frame for the browser window.

GetMainFrame ( this webBrowser ) : IFrame

Returns the main (top-level) frame for the browser window.

GetSourceAsync ( this browser ) : Task

Retrieve the main frame's HTML source using a Task{String}.

GetTextAsync ( this browser ) : Task

Retrieve the main frame's display text using a Task{String}.

GetZoomLevelAsync ( this cefBrowser ) : Task

Asynchronously gets the current Zoom Level.

LoadHtml ( this browser, string html, string url ) : void

Registers and loads a ResourceHandler that represents the HTML content.

`Cef` Native `LoadHtml` is unpredictable and only works sometimes, this method wraps the provided HTML in a ResourceHandler and loads the provided url using the IWebBrowser.Load method. Defaults to using Encoding.UTF8 for character encoding The url must start with a valid schema, other uri's such as about:blank are invalid A valid example looks like http://test/page

LoadHtml ( this browser, string html, string url, Encoding encoding ) : void

Registers and loads a ResourceHandler that represents the HTML content.

`Cef` Native `LoadHtml` is unpredictable and only works sometimes, this method wraps the provided HTML in a ResourceHandler and loads the provided url using the IWebBrowser.Load method.

LoadString ( this browser, string html, string url ) : void

Load the string contents with the specified dummy url. Web security restrictions may not behave as expected.

Paste ( this browser ) : void

Execute Paste on the focused frame

Print ( this cefBrowser ) : void

Opens a Print Dialog which if used (can be user cancelled) will print the browser contents.

PrintToPdfAsync ( this cefBrowser, string path, CefSharp.PdfPrintSettings settings = null ) : Task

Asynchronously prints the current browser contents to the PDF file specified. The caller is responsible for deleting the file when done.

Redo ( this browser ) : void

Execute Redo on the focused frame

RegisterResourceHandler ( this browser, string url, Stream stream, string mimeType = ResourceHandler.DefaultMimeType ) : void

Register a ResourceHandler. Can only be used when browser.ResourceHandlerFactory is an instance of DefaultResourceHandlerFactory

Reload ( this browser ) : void

Reloads the page being displayed. This method will use data from the browser's cache, if available.

Reload ( this browser, bool ignoreCache ) : void

Reloads the page being displayed, optionally ignoring the cache (which means the whole page including all .css, .js etc. resources will be re-fetched).

ReplaceMisspelling ( this cefBrowser, string word ) : void

If a misspelled word is currently selected in an editable node calling this method will replace it with the specified word.

SelectAll ( this browser ) : void

Execute SelectAll on the focused frame

SendMouseWheelEvent ( this browser, int x, int y, int deltaX, int deltaY, CefEventFlags modifiers ) : void
SetAsPopup ( this browser ) : void
SetZoomLevel ( this cefBrowser, double zoomLevel ) : void

Change the ZoomLevel to the specified value. Can be set to 0.0 to clear the zoom level.

If called on the CEF UI thread the change will be applied immediately. Otherwise, the change will be applied asynchronously on the CEF UI thread. The CEF UI thread is different to the WPF/WinForms UI Thread

ShowDevTools ( this cefBrowser ) : void

Open developer tools in its own window.

Stop ( this browser ) : void

Stops loading the current page.

StopFinding ( this cefBrowser, bool clearSelection ) : void

Cancel all searches that are currently going on.

ThrowExceptionIfBrowserNotInitialized ( this browser ) : void
UnRegisterResourceHandler ( this browser, string url ) : void

Unregister a ResourceHandler. Can only be used when browser.ResourceHandlerFactory is an instance of DefaultResourceHandlerFactory

Undo ( this browser ) : void

Execute Undo on the focused frame

ViewSource ( this browser ) : void

Opens up a new program window (using the default text editor) where the source code of the currently displayed web page is shown.

Приватные методы

Метод Описание
GetScript ( string methodName, object args ) : string

Transforms the methodName and arguments into valid Javascript code. Will encapsulate params in single quotes (unless int, uint, etc)

ThrowExceptionIfBrowserHostNull ( IBrowserHost browserHost ) : void
ThrowExceptionIfBrowserNull ( IBrowser browser ) : void
ThrowExceptionIfFrameNull ( IFrame frame ) : void

Описание методов

AddWordToDictionary() публичный статический Метод

Add the specified word to the spelling dictionary.
public static AddWordToDictionary ( this cefBrowser, string word ) : void
cefBrowser this The ChromiumWebBrowser instance this method extends
word string The new word that will be added to the dictionary.
Результат void

Back() публичный статический Метод

Navigates back, must check IWebBrowser.CanGoBack before calling this method.
public static Back ( this browser ) : void
browser this
Результат void

CloseDevTools() публичный статический Метод

Explicitly close the developer tools window if one exists for this browser instance.
public static CloseDevTools ( this cefBrowser ) : void
cefBrowser this The ChromiumWebBrowser instance this method extends
Результат void

Copy() публичный статический Метод

Execute Copy on the focused frame
public static Copy ( this browser ) : void
browser this The ChromiumWebBrowser instance this method extends
Результат void

Cut() публичный статический Метод

Execute Cut on the focused frame
public static Cut ( this browser ) : void
browser this The ChromiumWebBrowser instance this method extends
Результат void

Delete() публичный статический Метод

Execute Delete on the focused frame
public static Delete ( this browser ) : void
browser this The ChromiumWebBrowser instance this method extends
Результат void

EvaluateScriptAsync() публичный статический Метод

Evaluate some Javascript code in the context of this WebBrowser using the specified timeout. The script will be executed asynchronously and the method returns a Task encapsulating the response from the Javascript This simple helper extension will encapsulate params in single quotes (unless int, uint, etc)
public static EvaluateScriptAsync ( this browser, System.TimeSpan timeout, string methodName ) : Task
browser this The ChromiumWebBrowser instance this method extends
timeout System.TimeSpan The timeout after which the Javascript code execution should be aborted.
methodName string The javascript method name to execute
Результат Task

EvaluateScriptAsync() публичный статический Метод

Evaluate some Javascript code in the context of this WebBrowser. The script will be executed asynchronously and the method returns a Task encapsulating the response from the Javascript This simple helper extension will encapsulate params in single quotes (unless int, uint, etc)
public static EvaluateScriptAsync ( this browser, string methodName ) : Task
browser this The ChromiumWebBrowser instance this method extends
methodName string The javascript method name to execute
Результат Task

EvaluateScriptAsync() публичный статический Метод

public static EvaluateScriptAsync ( this browser, string script, System.TimeSpan timeout = null ) : Task
browser this
script string
timeout System.TimeSpan
Результат Task

ExecuteScriptAsync() публичный статический Метод

Execute some Javascript code in the context of this WebBrowser. As the method name implies, the script will be executed asynchronously, and the method therefore returns before the script has actually been executed. This simple helper extension will encapsulate params in single quotes (unless int, uint, etc)
public static ExecuteScriptAsync ( this browser, string methodName ) : void
browser this The ChromiumWebBrowser instance this method extends
methodName string The javascript method name to execute
Результат void

Find() публичный статический Метод

Search for text within the current page.
public static Find ( this cefBrowser, int identifier, string searchText, bool forward, bool matchCase, bool findNext ) : void
cefBrowser this The ChromiumWebBrowser instance this method extends
identifier int Can be used in can conjunction with searchText to have multiple /// searches running simultaneously.
searchText string search text
forward bool indicates whether to search forward or backward within the page.
matchCase bool indicates whether the search should be case-sensitive.
findNext bool indicates whether this is the first request or a follow-up.
Результат void

Forward() публичный статический Метод

Navigates forward, must check IWebBrowser.CanGoForward before calling this method.
public static Forward ( this browser ) : void
browser this
Результат void

GetFocusedFrame() публичный статический Метод

Returns the focused frame for the browser window.
public static GetFocusedFrame ( this webBrowser ) : IFrame
webBrowser this
Результат IFrame

GetMainFrame() публичный статический Метод

Returns the main (top-level) frame for the browser window.
public static GetMainFrame ( this webBrowser ) : IFrame
webBrowser this
Результат IFrame

GetSourceAsync() публичный статический Метод

Retrieve the main frame's HTML source using a Task{String}.
public static GetSourceAsync ( this browser ) : Task
browser this The ChromiumWebBrowser instance this method extends
Результат Task

GetTextAsync() публичный статический Метод

Retrieve the main frame's display text using a Task{String}.
public static GetTextAsync ( this browser ) : Task
browser this The ChromiumWebBrowser instance this method extends
Результат Task

GetZoomLevelAsync() публичный статический Метод

Asynchronously gets the current Zoom Level.
public static GetZoomLevelAsync ( this cefBrowser ) : Task
cefBrowser this
Результат Task

LoadHtml() публичный статический Метод

Registers and loads a ResourceHandler that represents the HTML content.
`Cef` Native `LoadHtml` is unpredictable and only works sometimes, this method wraps the provided HTML in a ResourceHandler and loads the provided url using the IWebBrowser.Load method. Defaults to using Encoding.UTF8 for character encoding The url must start with a valid schema, other uri's such as about:blank are invalid A valid example looks like http://test/page
public static LoadHtml ( this browser, string html, string url ) : void
browser this The ChromiumWebBrowser instance this method extends
html string The HTML content.
url string The URL that will be treated as the address of the content.
Результат void

LoadHtml() публичный статический Метод

Registers and loads a ResourceHandler that represents the HTML content.
`Cef` Native `LoadHtml` is unpredictable and only works sometimes, this method wraps the provided HTML in a ResourceHandler and loads the provided url using the IWebBrowser.Load method.
public static LoadHtml ( this browser, string html, string url, Encoding encoding ) : void
browser this The ChromiumWebBrowser instance this method extends
html string The HTML content.
url string The URL that will be treated as the address of the content.
encoding System.Text.Encoding Character Encoding
Результат void

LoadString() публичный статический Метод

Load the string contents with the specified dummy url. Web security restrictions may not behave as expected.
public static LoadString ( this browser, string html, string url ) : void
browser this The ChromiumWebBrowser instance this method extends
html string html string to load
url string the url should have a standard scheme (for example, http scheme) or behaviors like link clicks
Результат void

Paste() публичный статический Метод

Execute Paste on the focused frame
public static Paste ( this browser ) : void
browser this The ChromiumWebBrowser instance this method extends
Результат void

Print() публичный статический Метод

Opens a Print Dialog which if used (can be user cancelled) will print the browser contents.
public static Print ( this cefBrowser ) : void
cefBrowser this The ChromiumWebBrowser instance this method extends
Результат void

PrintToPdfAsync() публичный статический Метод

Asynchronously prints the current browser contents to the PDF file specified. The caller is responsible for deleting the file when done.
public static PrintToPdfAsync ( this cefBrowser, string path, CefSharp.PdfPrintSettings settings = null ) : Task
cefBrowser this The object this method extends.
path string Output file location.
settings CefSharp.PdfPrintSettings Print Settings.
Результат Task

Redo() публичный статический Метод

Execute Redo on the focused frame
public static Redo ( this browser ) : void
browser this The ChromiumWebBrowser instance this method extends
Результат void

RegisterResourceHandler() публичный статический Метод

Register a ResourceHandler. Can only be used when browser.ResourceHandlerFactory is an instance of DefaultResourceHandlerFactory
public static RegisterResourceHandler ( this browser, string url, Stream stream, string mimeType = ResourceHandler.DefaultMimeType ) : void
browser this The ChromiumWebBrowser instance this method extends
url string the url of the resource to unregister
stream Stream Stream to be registered, the stream should not be shared with any other instances of DefaultResourceHandlerFactory
mimeType string the mimeType
Результат void

Reload() публичный статический Метод

Reloads the page being displayed. This method will use data from the browser's cache, if available.
public static Reload ( this browser ) : void
browser this
Результат void

Reload() публичный статический Метод

Reloads the page being displayed, optionally ignoring the cache (which means the whole page including all .css, .js etc. resources will be re-fetched).
public static Reload ( this browser, bool ignoreCache ) : void
browser this The ChromiumWebBrowser instance this method extends
ignoreCache bool true A reload is performed ignoring browser cache; false A reload is /// performed using files from the browser cache, if available.
Результат void

ReplaceMisspelling() публичный статический Метод

If a misspelled word is currently selected in an editable node calling this method will replace it with the specified word.
public static ReplaceMisspelling ( this cefBrowser, string word ) : void
cefBrowser this The ChromiumWebBrowser instance this method extends
word string The new word that will replace the currently selected word.
Результат void

SelectAll() публичный статический Метод

Execute SelectAll on the focused frame
public static SelectAll ( this browser ) : void
browser this The ChromiumWebBrowser instance this method extends
Результат void

SendMouseWheelEvent() публичный статический Метод

public static SendMouseWheelEvent ( this browser, int x, int y, int deltaX, int deltaY, CefEventFlags modifiers ) : void
browser this
x int
y int
deltaX int
deltaY int
modifiers CefEventFlags
Результат void

SetAsPopup() публичный статический Метод

public static SetAsPopup ( this browser ) : void
browser this
Результат void

SetZoomLevel() публичный статический Метод

Change the ZoomLevel to the specified value. Can be set to 0.0 to clear the zoom level.
If called on the CEF UI thread the change will be applied immediately. Otherwise, the change will be applied asynchronously on the CEF UI thread. The CEF UI thread is different to the WPF/WinForms UI Thread
public static SetZoomLevel ( this cefBrowser, double zoomLevel ) : void
cefBrowser this The ChromiumWebBrowser instance this method extends
zoomLevel double zoom level
Результат void

ShowDevTools() публичный статический Метод

Open developer tools in its own window.
public static ShowDevTools ( this cefBrowser ) : void
cefBrowser this The ChromiumWebBrowser instance this method extends
Результат void

Stop() публичный статический Метод

Stops loading the current page.
public static Stop ( this browser ) : void
browser this
Результат void

StopFinding() публичный статический Метод

Cancel all searches that are currently going on.
public static StopFinding ( this cefBrowser, bool clearSelection ) : void
cefBrowser this The ChromiumWebBrowser instance this method extends
clearSelection bool clear the current search selection
Результат void

ThrowExceptionIfBrowserNotInitialized() публичный статический Метод

public static ThrowExceptionIfBrowserNotInitialized ( this browser ) : void
browser this
Результат void

UnRegisterResourceHandler() публичный статический Метод

Unregister a ResourceHandler. Can only be used when browser.ResourceHandlerFactory is an instance of DefaultResourceHandlerFactory
public static UnRegisterResourceHandler ( this browser, string url ) : void
browser this The ChromiumWebBrowser instance this method extends
url string the url of the resource to unregister
Результат void

Undo() публичный статический Метод

Execute Undo on the focused frame
public static Undo ( this browser ) : void
browser this The ChromiumWebBrowser instance this method extends
Результат void

ViewSource() публичный статический Метод

Opens up a new program window (using the default text editor) where the source code of the currently displayed web page is shown.
public static ViewSource ( this browser ) : void
browser this The ChromiumWebBrowser instance this method extends
Результат void