Render page within winforms with one of the installed browsers? - c#

I wanted to make my own "editor" to for html, css, etc, where on one side I have the code and on the other how it looks like on the browser.
I know within c# we have the handy System.Windows.Forms.WebBrowser() that could do that for me but I wanted to be able to make it render as if it was using ie or ff or chrome browsers.
How could I render the page some how as if it was using one of
those (considering they are installed and available within the
computer but to open on the c# winforms) ?

You would have to use the rendering engine that the other browsers use. For example, Chrome and Safari use Webkit. Getting this to work for older browsers like IE6, 7, will be much harder, since they don't release their layout engine. IE9 has a feature that lets you render a page as an older browser, but I'm not sure if you can use that feature using the WebBrowser control.

Related

how to create a webbroswer in wpf that supports all the sites and scripts and play video?

I have to create a webbroswer in wpf that supports all the sites and scripts and play video , I have created but some site got crashed and not supporting .
Please provide solution.
What you ran into are probably error dialogs caused by JavaScript script errors. WPF WebBrowser control currently doesn't support disabling these dialogs and ignoring the errors. The WebBrowser control is based on Internet Explorer core and will have a hard time dealing with broken JavaScript, webpages will also sometimes report the web browser as old and inform the visitor about it, like FlipKart does.
One solution is to use WindowsFormsHost and host a Windows Forms equivalent - WebBrowser control - in it. The WF WebBrowser offers a property called SupressScriptErrors, which is not implemented by the WPF WebBrowser. That will hide the error dialogs for you, but you will still occasionaly receive a warning from the website saying they don't support the web browser used. That is out of your control unless you want to take a route of hacking the control to send a different User-Agent string and that will only fool broken UA detection, feature detection will still fail for things like HTML5 video, WebRTC and the like. More on this here.
You can also choose to embed Gecko (Firefox rendering engine) or Chromium. see here for more information on embedding alternative rendering cores as an alternative to IE COM wrapper offered by the framework.
Edit: this is also a possible solution, as it would seem. You will have to test it for yourself, though. I expect it to have less overhead than the WindowsFromHost element and although this uses reflection to develop against implementation, not interface, my opinion is it's safe to say the underlaying API in unlikely to change.

building webkit on windows phone 8

I have some html containing WEBKIT content which needs to be rendered on Windows Phone 8 browser and Windows 8 Store apps webview. As windows 8 and wp8 browser control doesn't support webkit.
is there any way where:
I can map webkit to IE specific tags internally in code and then calling Webview.NavigateToString(html).
As Webkit is Open source, Can I build webkit to dll and use it as a control in my WP8/W8 to render Webkit html?
If there is any better way other than this, please suggest...
Thanks!
By webkit "content" and "specific tags" I'm assuming that you're referring to -webkit specific prefixes in the CSS.
There is no way to map these to anything that can be automatically converted to the IE specific equivalent.
Building your own browser (which is essentially what you'd be doing if you got the webkit code compiling for the phone) is likely to be masses of work. Much more than modifying the code you are displaying.
The best approach is to simply include the IE equivalent version of the vendor specific extension where one exists. This is the same as you would do if you had content that you wanted to take advantage of such extensions and run on multiple browsers. (i.e. Firefox and Opera also.)
You should also seriously consider if you need things to look identical on multiple devices. (Hint. you don't.) Your time may be better served by ensuring you are displaying content which looks appropriate on the appropriate device, rather than trying to use the code for getting something to display in a specific way on one device/browser to work on another.

HTML 5 CSS 3 Web Browser Control for C#

Is there a web browser-type control that supports much of html 5 and css 3 for C#?
Just asking as I viewed my site designed for modern browsers, but viewed it in the .NET Winforms browser, and it looked rubbish, as that control doesn't support html 5 or css 3.
Thanks, I look forward to hearing from you all.
There is Awesomium which is based on WebKit (Same as Chrome and Safari). It's not entirely free though (unless you're an indie developer making 100k or less or using it for non commercial development).
The WebBrowser control support of HTML5 and CSS3 features depends on the version of IE that is installed. (which means that you can install IE9 on the machine to get better support of these features)

Firefox C# Wrapper/Control

Is there a Firefox/Mozilla control for embedding the firefox browser in a C# .net application?
You can have the Gecko rendering engine in the form of GeckoFX.
To quote Google Code:
GeckoFX is a Windows Forms control written in clean, commented C# that embeds the Mozilla Gecko browser control in any Windows Forms Application. It also contains a simple class model providing access to the HTML and CSS DOM.
Even better, there is a fork by hindlemail, actively updated DLL for .Net, here: https://bitbucket.org/geckofx/.
Currently, there are available versions corresponding to Firefox's version 10 and 11.

Capturing the image of a web page using Firefox and Safari

I have a utility that I put together that uses the .NET Framework to capture an image of a web page so that I can use the thumbnail image to preview a page. There are sites which offer this service like websnapr.com, kwiboo.com and shrinktheweb.com. I would like to instead do it myself and leverage Firefox (Gecko) and Safari (WebKit) to render the image.
Is there anything available to do this currently? Is there a C# project that hooks into Gecko and/or WebKit to create images of a loaded web page.
My project is called WebPreview and it uses the WebBrowser control from the .NET Framework, but since that can be a bit outdated the rendered screenshots will not look as accurate as a recent Gecko or WebKit build.
http://www.smallsharptools.com/Projects/WebPreview/
Please post a comment for any Open Source projects which can help me.
I use a Firefox add-on called Screengrab
checkout http://browsershots.org/ its free and open. it says somewhere on the site what plugins and techniques they use...
You can look a this project http://www.codeplex.com/url2jpeg. It uses Internet Explorer.

Categories