Is there a way to embed HTML into a windows forms custom usercontrol? I want to create a lightweight control to be used in a .NET 4.0 application, but since the contents of it is viable to change, I was thinking using HTML to lay it out might be easiest. Is there a way to achieve this in windows forms? There are some other topics with C# and HTML but pretty sure non involves creating a control that parses HTML and displays it.
Thanks
You could use a WebBrowser, but I'd recommend not going down that path. Just use traditional controls to accomplish what you need, if at all possible, maybe combined with a little GDI+.
A WebBrowser would be your best bet in terms of ease of use and maintenance. You can have further control over the contents themselves by accessing the browser.Document.DomDocument interfaces and events. I would not recommend using GDI since it can become a pain to maintain and manage custom rendering in the long run.
I have been trying to do a similar thing and have found awesomium. They have a dotnet and mono wrapper and quite fine grain control over the whole thing acts. It is also free as long as your company makes less than 100k a year.
Forgot to mention it is a browser that you basically embed in your application so you don't need to worry about the user not having it installed or anything and is consistant over pc's and OS's
Related
Since WPF and Silverlight are very close to each other(in terms of syntax).
My query is , do we have any tool that can convert wpf control to silverlight control and vice versa.
I understand that everything in WPF shall not be expected to run on Silverlight, but since the come from the same code base, is aconversion possible.
In theory you could write a converter that would work in many cases but it would never work in all cases because the two implementations are not completely compatible. That being the case there would likely be so many issues it could not automatically solve at conversion it would be quicker to just port it manually instead. That is probably why there are no converters available. Not to mention that there is little demand for such a tool.
WPF controls are built on top of the full .Net.
Silverlight controls are built on top of a subset of .Net.
If the WPF controls were restricted in their use of .Net then it is feasible that a conversion would be possible, but quite frankly I think there would be too many exceptions to make it worthwhile.
Where we need to share code (not controls) between WPF & Silverlight we "link" to files from a common library (the library is only a repository and not built). The Xaml we can cut & paste.
I am not able to apply 3D effects on WPF's built-in WebBrowser, because it is just a thin wrapper around the native ActiveX-Webbrowser, which isn't based on WPF. I saw most of the places people suggested about one Link ,but I m not able to make it work in my application and it is having so many dlls which I don't want. Can anybody suggest me any other good alternative solution present then?
Maybe you forget to copy the needed awesomium.dll & AwesomiumProcess.exe with your executing assembly (which are not .Net assemblies).
I also have some difficulties to run with awesomium but it's not impossible.
I can recommand you the Troymium/TroymiumNet which is actively maintain by its developers.
I use it on Microsoft Surface to connect people to their facebook account.
I've never used it, but you could try Berkelium with berkelium-sharp.
What are the limitations of WPF web browser control? Is it good enough for a real-life browser implementation? And is it a fully managed implementation?
The WPF WebBrowser control is just an interop layer hosting the IE ActiveX control. It should be very robust, and usable for a real-life browser (since it's really IE). It is not a managed implementation.
Its main limitations are due to the fact that it's using an HwndHost internally. This means that it has the WPF/Native airspace issues, as well as some minor issues with event handling.
It is good enough for Real-life use, and I agree with Reeds view on the matter.
Additionaly, If a person does not have certain IE files on their computer the control is rendered useless. Here are a few observed limitations I have found:
I have found with the WebBrowser controls is it's hatred of IE6 on a computer whilst trying to perform JavaScript insertions within the control. (Very machine-specific though, so you could say lack of total compatibility?)
The fact that you will need to actually reference the main assemblies of IE to get certain functionality, such as getting something more useful than a HtmlElement.
The lack of support for some of its 2.0 counterparts functions, such as to Suppress Script Errors.
Doesn't work nicely with the WPF layout system
Again due to the fact that its a wrapper for IE, all the compatibility issues in things like CSS stay put, as well as most, if not all the IE issues that exist.
All in all, the control could be greatly improved, and to honest it would be fantastic to see the .NET team make a fully managed version of this component.
Cheers,
Kyle
Adding to the answers by #Kyle and #Reed, below are my observations as limitations.
We can't render PDF in this WebBrowser control.
Underneath engine is IE. We can't replace IE engine with latest Microsoft Edge.
I've been using Google's Annotated Time Line Visualization component for the last couple of weeks and I love it! I've been able to make plots with about 10k points without much trouble.
Do you know of a desktop component I could plug into my application that delivers the same WOW factor that Google's component does? I don't care what the language/toolkit is. I prefer C#,Java,Ruby,C++ or Python... (in that order) however any other's would apply. I also prefer it to be free and open source, but if it's not that's OK as well.
Thanks for your time!
Note: This doesn't have to be cross-platform. Windows is fine.
Edit (2009-08-07):
Even if I can only plot 10k points, I am fine with that. I would just like a desktop control that delivers the same "wow" factor and works in a similar manner (zooming, scrolling, annotations, etc) that the Google component does.
Edit (2009-09-03):
I really prefer the language to be C#. I started a bounty to see if anyone can find some good ones. I want it to be almost identical to Google's Annotated Timeline Component. I would use Google's Component, but I want a desktop component... and I don't want to run into performance limitations because of the browser. Using Adobe Air is out of the question.
Edit (2009-09-03):
Do not recommend Visifire. I have evaluated it, and it doesn't support zooming. Remember, it must be very close to Google's component in terms of functionality and "wow" factor.
This WPF-based chart control at codeproject may put you in the right direction. It's got smooth panning/zooming/scrolling :
WPF Chart Control With Pan, Zoom and More By John Stewien
If you're needing to plot millions of points, you're going to run into performance issues quickly if the control doesn't have a mechanism for loading/sampling only what it needs to display. Even then, that's a very large number of data point to want to access in one control.
Hm i am not sure if this is what you are looking for, but for java there is the very good library JFreeChart which is not exactly as interactive as the one you mentioned but it is really easy to use and pretty flexible for you to subclass and tweak to your preference.
Perhaps you could take a look at matplotlib. It's a python based library, however it's very flexible in that it can take it's input from a variety of sources.
An alternative is to embed a web browser control in you wpf application. You'll probably need access to the DOM, so you might have to use the WebBrowser in a WinForm. A good article descibing how this is done can be found here.
Microsoft also has free chart control you can get at http://www.microsoft.com/downloads/details.aspx?FamilyId=130F7986-BF49-4FE5-9CA8-910AE6EA442C&displaylang=en. It's pretty good--especially for being free.
I have used Dundas charts in the past. They are excellent but pricey. There are several other vendors with good chart controls including DotNetCharting, Telerik, Component Art, and Infragistics.
How can I implement ActiveX Document on C#/.NET? (ActiveX Document can draw itself in IE)
Update: I need a solution for drawing my own document type in IE windows (like MS Word or MS Excel draw its documents in IE).
You need to dive into OLE for that purpose.
Things like IOleDocument, IOleInPlaceSite (see MSDN for that). Figure out which interfaces are needed for the client (as IE would be the container and will need to communicate with your interface implementations), and how the communication is going on, e.g. what gets called when.It's not rocket science, but I believe still a fair amount of work.
Look at http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.domdocument.aspx, it's .NET wrapper for DOM Document
My first thought is that you could use a WPF Page, which can be hosted in a WPF window or in IE.
From MSDN:
Encapsulates a page of content that can be
navigated to and hosted by Windows
Internet Explorer, NavigationWindow,
and Frame.
This is possible but it is tough.. What is bad is the lack of documentation... Microsoft has no interest in supporting this scenario. Another difficult part is debugging the boundaries between the HTML/DOM and the ActiveX control.
For what you're doing, it sounds like Silverlight would be a better choice. It only supports a subset of .Net, but it supports drawing graphics. It'll be a lot easier for you to find documentation. And it will run on non-Windows computers.
But maybe you need something Silverlight doesn't do (like audio input support). If thats the case, there's various blogs on the subject of varying quality. Here are the two that stood out as most helpful to me:
http://www.codeproject.com/KB/cs/CreateActiveXDotNet.aspx
http://blog.ianchivers.com/wordpress/?p=22
I do recommend using OleView to inspect the type libraries you produce, and make sure its what you expect. You can also do this to see how to break event properties into get/set functions, which is something I had to do to debug some scenarios.
Also be cognizant of the difference of "attaching debugger to process" with scripted or managed debugging. At some point you'll attach with one when you think you've used the other.