Vectorlight News

  • Chat App Converted to HTML and JQuery
    Sep 08, 2011

    Converted from Silverlight to HTML and Javascript/JQuery is the Vectorlight Chat App. Login using your Vectorlight password to chat using your username and avatar.

  • HTML5 iPhone,Android Big Guns Tower Defense
    Jul 02, 2011

    Big Guns has made the leap from Windows Phone 7 (XNA) to HTML5 so you can now play it on your iPhone, Android and other HTML5 compatible devices.

  • HTML5 Games - Word Poppers and Batty
    Jun 04, 2011

    As the take-up of HTML5 quickens (74% of users currently have a browser capable of HTML5 Canvas) we present two more games for both your browser and mobile.

  • Big Guns Tower Defense on Windows Phone 7
    May 06, 2011

    Coming soon to Windows Phone 7 is an XNA port of the popular Vectorlight tower defense game Super Tower Defense. Whilst retaining many of the graphical and gameplay features of the original Silverlight game.

  • Wakacube WP7 Update
    Apr 26, 2011

    Released to the Windows Phone 7 marketplace today is Version 1.1 of Wakacube the 3D physics game of skill. Included in the update are more levels (30 in total) and new mode Wakatime which generates random crate structures to keep players entertained long after the levels have been completed.

  • Home Page News

Importing/Exporting HTML

This requires version 5.1.5 of the Liquid Controls Library, you can download the dll for free from the Downloads link above.

The Rich TextBox control contains a HTML property for importing/exporting, converting from HTML to RichText where the HTML provided was originally generated from RichText will give perfect results.  HTML that has either been modified from a previous conversion or is completely new cannot be guaranteed to convert, certainly a source dump of a web page will not work.

Converting from RichText to HTML

The online RichTextBox example can be used to test exporting HTML, in the screenshot below we export a snippet of RichText consisting of one heading and a line of text.

Exporting the sample RichText into HTML Using the RichTextBox Example

Converting from HTML to RichText

The basic requirements for converting a block of HTML to RichText is as follows:

  • All tags are well formed.

  • Your CSS styles are included in the same HTML file and not separate CSS files.

  • The CSS is contained within the <style> tag.

  • The HTML follows directly after the styles.

Ensuring the HTML is well formed is very important as it is parsed by an XML reader and HTML with missing or incorrectly closed tags will result in exceptions.  An example of a simple HTML document that could be imported would be:

The online RichTextBox example can be used to test importing HTML.

Importing the sample HTML into the RichTextBox

As you can see if you attempt to import the above into the RichTextBox using our online example you will notice the text with the class contains the correct styling after importation, however the text with the inline style is rendered without any bold styling.  It is also important to note that only a few CSS style commands and possible values are accepted during the conversion, these are as follows:

  • font-family:Any Silverlight Font

  • font-size:Npx

  • text-align:left|center|right

  • color:#RGB

  • font-weight:bold

  • text-decoration:underline

  • font-style:Italic

  • vertical-align:Sub|Super

There are lots of possibilities for using the RichTextBox in HTML editing scenarios and it won't be long before we start seeing Silverlight powered forums and CMS systems.

Rate this: 

1 Star 2 Star 3 Star 4 Star 5 Star
39 Ratings / 3.7 Average