tags:

views:

269

answers:

1

The project is a GNOME aplication not a ASP.NET. I need to load a welcome.html file into the main page of the UI. Just like MonoDevelop does. But I dont know how to make international versions that will load ased on locality. And I dont know how to bundle it into the binary using some sort of resource management.

+1  A: 

MonoDevelop used to use HTML for the welcome page, but at the time (about 18 months ago) we found a GTK+ web browser to be an awkward dependency for cross-platform use, so switched to plain GTK# with some custom background rendering.

That said, it's pretty easy to use HTML using Webkit-GTK & the Webkit# wrapper. Create a WebKit.WebView widget, then use the LoadHtml method to load HTML from a string.

Reading an embedded text resource from an assembly is pretty easy:

string text;
using (var stream = typeof(SomeTypeInYourAssembly).Assembly.GetManifestResourceStream (resourceId))
    using (var sr = new StreamReader (stream))
        text = sr.ReadToEnd ();

This will read a resource embedded with the C# compiler argument /res:FILE[,ID] or using the "Embedded Resource" build action in MonoDevelop. You can set the resource ID in MD using the proeprty pad if you don't like the default.

Localisation is trickier. The ".NET way" would be to use localised satellite assemblies containing localised resources. However, we what we did in MD was to use an XSLT file to convert an XML file into HTML. We could then localise the XML file quite easily, using Gettext and the XML DOM classes.

mhutch
First, thanks for the answer, I am trying to implement this, and I am having a hard time.I switched the build action to "Embed as resource", and its called welcome.html and its in the "Resources" folder of the project. But I think I need to put something in the .resources file, but its an empty xml file and I have no idea what to put in there. I assume it contains the file, mime-type and resourceId. I feel like I am missing some vital piece of info.
Ronaldo Nascimento
Digging further, thanks to your code there, i was able to figure it out.
Ronaldo Nascimento