Δευτέρα 14 Νοεμβρίου 2011

Tutorial #1 - WebKit Initialization and Page Rendering (Applies to all OpenWebKitSharp Versions)

Welcome to the OpenWebKitSharp tutorials. This is the first tutorial and the most important one for beginners.

To start with, you must firstly understand how OpenWebKitSharp works. OpenWebKitSharp is a library developed by GT Web Software which uses a manifest file in order to access the WebKit COM Objects that are included in the webkit engine and create a .NET bridge that will help you embed the engine in your .NET application.

Before you begin make sure that you have obtained the latest copy of OpenWebKitSharp archive. After that, if you are using the latest version of it please go to the folder where you have extracted the files. You should see the folder called "Core". Inside that folder you will find all the needed WebKit files by your application. You must copy them to the same folder as your executable of your project.








In order to use OpenWebKitSharp correctly you must add some references to your project. These include the following files (only DLL files), which can be found inside the "WebKit" folder:




















If you have already referenced OpenWebKitSharp.dll then you are ready to start using it inside your project! If you want to use the designer to draw a WebKitBrowser object and render pages to it then you have to add OpenWebKitSharp.dll to your Toolbox. This can be done by selecting Choose items in the right-click menu of the Visual Studio's toolbox.

From that point, rendering HTML to the WebView of the WebKitBrowser object is easier than you can imagine. If you are trying to render a page from the internet then you need to use the Navigate() method. [e.g. <WebKitBrowser>.Navigate(http://www.google.com/)]

OpenWebKitSharp also provides the ability to load content from a local file. For this reason the WebKitBroser.OpenDocument has been implemented. You can use it according to this example:
<WebKitBrowser>.OpenDocument(@"C:\test.html")

Last but not least, you can use the property <WebKitBrowser>.DocumentText in order to set the document by its source. This way the WebKitBrowser can also be used in an offline mode.

The next tutorial is going to provide you information on how to handle events related to the loading of a wepage.

1 σχόλιο: