WPF WebBrowser NavigateToStream & images - wpf

I'm planning to use thw WebBrowser component to display html that is created on the fly. The perfect choice for this is NavigateToString or NavigateToStream methods. There's only one single problem - I need to load images / css styles / js files too. How do I accomplish this while using string/stream?
As an option I'm also considering writing/finding simple http server and running it on some port, but that's an additional work and requirements(open ports) so I'd like to avoid that if it's possible.

You can cast WebBrowser.Document to IPersistMoniker and load a moniker that implements GetDisplayName. Check http://csexwb2.googlecode.com/svn/trunk/cEXWB.cs for example code.

Faced with this same problem I created my own solution. You can see it here:
Reference an image imbedded in a WPF application from within an HTML file used as help content

Related

XAML WebBrowser emulation without registry change

I am trying to render some HTML page of mine hosted on a NodeJS in a WPF app.
I have tried few things and the following option seems the most convenient:
C# webbrowser Ajax call
However it is modifying the registry which I cannot (company policy).
Therefore would there be a way to do the same on the fly? ie. load the WebBrowser with this setup without updating the registry?
Thank you
You might be able to do this with the XUA compatible meta tag.
<meta http-equiv="x-ua-compatible" content="IE=11">
I don't know if you have access to the site's content or not. If you do, then just put in right there in the HTML.
If you do not own the page, there are ways modify the page and dynamically inject this tag with a bit of com interop from mshtml.
Therefore would there be a way to do the same on the fly? ie. load the WebBrowser with this setup without updating the registry?
I am afraid not. There is no property or method of the WebBrowser control itself that you can set or call.
Changing the registry keys or use another (third-party) control are your only options I would say.

Iconsets paths in 2SXC

Is possible to use the font icon picker in a regular content template? I only got it to work inside 2SXC Apps but not inside regular Token Content. All examples I found where using the [App:Path] token to load the iconset. For regular Content Templates as there is no AppPath I tried [Portal:HomeDirectory] but I can't get it to load the icons. Is it limited to be used in Apps?
Thanks for help.
[App.Path] and #App.Path should also work on content templates, it's certainly not disabled on purpose. The path will always point to the Portals/x/2sxc/Content, so you can also hardwire it - but it should work.

How to serve separate page (Orchard template) for phones

Using Orchard 1.8.1 I have written a simple image gallery that displays thumbnails and a lightbox. It is just a template that is driven by an Orchard Projection, using a Shape Layout. Works just fine. However, for phone users there is no point displaying thumbnails and it's better to just display the lightbox (with touch support). So I have also implemented that in a separate template. But how can I get Orchard to switch templates depending on the UserAgent string?
I have tried implementing Theme switching (http://weblogs.asp.net/bleroy/dynamically-switching-the-theme-in-orchard), but it's a really ugly solution when I really want to just replace one view, and still enable implementers to switch themes. This is NOT an issue of styling; it's an issue of changing the content based on the device.
I tried implementing DisplayModeProvider as described here: http://www.campusmvp.net/blog/displaymodes-in-mvc-4. But although the filter was called, it had no effect on view names.
Are Projections problematic here because the shape name is set? Is there a better way to go about this?
Create an alternate when you see a mobile browser, preferably from a shape table provider.

Aspose PDF viewer

I am using the Aspose PDF tools and have successfully got it to print the pdf which is great, but ideally I want to be able to add a wpf control to display this as well.
I would have assumed that the PdfViewer class would have something, but I can't tell.
So far I have needed to use a different control MoonPdfPanel which is annoying as I would have preferred 1 tool to do both jobs.
Does anyone know of a control I can use to hook into the aspose?
Thanks
We have developed an HTML5 PDF Editor application using Aspose.Pdf for .NET API which you can use in your application as a PDF Viewer as well. You can get the details and complete source code here. You can use the source code to edit the viewer as per your requirement.
P.S. I am working as social media developer at Aspose.
Well, if you are interesting in viewing the PDF file, you may convert the file to HTML and display it using an IFrame in your application. I have developed a sample application which performs different operations including viewing a PDF file in IFrame. Download it and try it at your end. Another option is that you can convert the PDF file to images and display in Imageviewer in your application (Code is available in the above application).
P.S. I am working as social media developer at Aspose.

Is there a "Browser Control" to host a website inside Flash/Silverlight?

I'm looking for something similar to the VB6 / .Net Winforms "Browser Control", that let's you show a browser inside your application.
I don't want to just render a page, I want it to be a fully-functional browser, in which people can click links, will run Javascript, etc.
In essence, what I want is an IFrame, only that it runs inside a Flash app, or a Silverlight app.
The ultimate reason for this is that I want to defeat IFrame busters. I'm making a web app that lets you see other sites inside of it, and I'm running into a bunch of sites that have this code:
var t=top.location,w=window.location;if(t!=w) t.replace(w);
(that's from eBay BTW)
which essentially pops the user out of my site and into theirs.
My hope is that by using a "browser control" of some sort, inside a plugin sandbox, "top", will be top for that browser control, and not for my site.
Of course, if you have any other ideas to achieve the same, they'll be more than welcome.
Edit: I've tried the Component One control suggested by Bill, but it didn't work for these purposes, because it's creating an IFrame outside of the SilverLight control, so it executes in the same context as the page hosting Silverlight, which is what I'm trying to avoid.
Northcode SWF Studio allows you to add browser window on the stage in Flash. I personally use SWF Studio as a third party SWF2EXE tool to extend the power of Flash projectors. It's quite stable and powerful. As far as browser control is concerned here is the example you can download and test if it serves your purpose. Check the Browser APT here.
We've not built a component to enable folks to do this but we're open to suggestions here. That being said, easiest solution is an iFrame, but word of caution in that when you overlay an iFrame over the the top of Silverlight we've seen customers experience perf issues as a result (mostly due to alpha transparency of the iframe etc).
This isn't isolated to Silverlight, Flash suffers the same issue as it has to do with browsers and rendering within the given operating system.
HTH.
Scott Barnes / Rich Platforms Product Manager / Microsoft.
I use the HTML control created by Component One. It has the limitation that the Silverlight object in the page should be set to windowless, but otherwise it works very well.
It's an old post but I'll add my tupence answer. I used the DivElements free control for Silverlight link text and it works quite nicely. It just positions the div accurately so that it looks like it's on top.
As for the other such controls, you've got to set the windowless property of the Silverlight container to true.
It works really well for me and I'm able to seemlessly have Google maps and the Acrobat plugin displayed side by side with my Silverlight application.
PS: because the component just adds a <div> to the page, you can't do stuff like having it load dynamically Javascript file like in the <header> tag.
PPS: when setting the HTML code "by hand", be sure to hook up on the DocumentReady or Loaded event before playing with the HTML DOM.
Hope that helps someone.

Resources