Tuesday, March 28. 2006When to use WPF and when to use other technologies
WPF is not the end-all be-all of technologies (at least not yet
Since I am mainly a graphics geek, I am going to focus on WPF and the following APIs:
In future releases we will extend the functionality in WPF to cover additional scenarios, as well as improve the integration with other APIs, so the guidance here is subject to change. Your comments and requests are welcomed, to help us prioritize the scenarios that we should tackle first. The first concept that is going to be a common thread in dealing with many of these scenarios is HwndHost (HwndHost at MSDN and Nick's article on HwndHost). This enables you to take content that is drawn using other APIs and host it within your WPF application. There is a limitation with HwndHost in that you will not be able to apply some graphical transformations on the hwndhost content, like applying transparency or using it as a texture. Another limitation is that likely you are using unmanaged code to create the content in the hwnd, which means that this will not work in a XAML Browser Application (xbap). I am likely to follow up this posting with some background on the architectural decisions we made early on, as well as the big bets on technology trends we decided to place in late 2000/early 2001 as we started to design the WPF architecture. WPF and DirectShow If you want to do capture (audio or video), or have your own DirectShow filter graph, you will have to code directly to DirectShow in WPF v1. You will then take the content and host it in WPF through HwndHost. However, if all you want to do is play your own format, you can just provide a DirectShow CODEC for it, and then folks will be able to use the format through the Media element and fully integrate it as part of other WPF content, without limitations. update 05/23/07 - here is an interesting posting of using WIC for getting DShow content into your WPF application Jeremiah Morrill's blog entry. WPF and Direct3D My simple axiom on the 3D front is: if you already have domain knowledge in Direct3D (or OpenGL), you should stick with using Direct3D for WPF v1. Now, to provide more context on my guidance. We make 3D a lot easier to use in WPF, and by a much larger developer audience than the one that uses 3D today. We also make it usable on the Web (in a xbap), we make it print, we make it remote, and we make it easier to integrate 3D with 2D, UI controls, and Documents (including as part of XAML). But, in using WPF, you give up a bit of the flexibility and direct hardware control that you get with the lower level APIs. We also manage your data (sometimes I refer to this as "managed graphics", to go along with managed code) and in doing so there is a bit of overhead, which costs you some performance (this is very dependent on the scenario, and we are tunning this code to reduce the cost based on scenarios that early adopters are sending in, so don't wait if you run into problems). We did not optimize our architecture in this initial version for twitch games or high end scientific vizualization scenarios, so if you want to tackle something along those lines, give it a try and see if it meets your needs. Similar to the DirectShow case, once you get your content going, you use hwndHost to merge it with your WPF content. Some scenarios for this involve providing a new UI for a Direct3D based application, or hosting a 3D modeler/editor within your WPF application. WPF and GDI/GDI+ For those interested in factoids - GDI and GDI+ are part of our team, and some of the WPF developers/program managers/testers were part of those efforts many years ago (and many of us were involved in VML as well). If you can't let go of raster ops, need 1-pixel wide lines, or need to load EMF/WMF files, then you will likely need to use GDI/GDI+, and then HwndHost. We are looking at how to tackle raster ops through effects, as well as provide scale invariant lines, in the future. WMF and EMF are a bit trickier, as we are trying to strike towards secure by default (even at the cost of functionality) and also because of expectations in terms of compatibility. I fully expect that some of you in the develop community will add value to the platform by developing EMF/WMF CODECs to be used within WPF applications. Comments
Display comments as
(Linear | Threaded)
>Another limitation is that likely you are using unmanaged >code to create the content in the hwnd, which means that >this will not work in a XAML Browser Application (xbap).
So, you mean there is no chance to make plug-in with DirectShow capability, like WebCam/TV, by using XBAP, am I right? And, Why does it not work? If you write unmanaged code then your application is outside of "partial trust", it can no longer be considered secure (requires "full trust").
The Common Language Runtime is able to validate which calls an application is allowed to make in partial trust, and able to block calls that would be secure (writing to the disk, launching arbitrary executables). -Pablo Thanks for your answer.
One more question. How about using managed DirectShow? Can this way avoid the security limitation by using XBAP? -adam Just because an API is managed, it does not automatically work in partial trust (Windows Communication Foundation is an example within WinFX of something that is managed, but does not work in PT). One has to validate the code for security, and it is not an easy process.
I am not aware of managed wrappers on DirectShow, so I don't know if they work in Partial Trust or not. Any chance of scale invariant line widths making it into the V1 release?
I'm busy working on a vector map control and currently line widths of x at a scale to view the whole world turn into really really fat line widths of say 40x once you zoom into an area. I guess my only choice at the moment is to say databind the line width to an inverse factor of the current scale? Sorry - not for v1.
-Pablo Are we any closer to invariant line thickness in WPF?
We really need the ability to turn of the scaling of stroke thickness on zoom within our application. We are current considering the removal of WPF altogether and going back to GDI+, which I would rather not do. Any news? If you want to zoom into a line without having it's thickness change, databinding is one option. Another option I've seen folks use is to combine stroke thickness with a Geometry.Transform. For example, setting stroke thickness to 1px and LineGeometry.Transform to a ScaleTransform 2X will cause your line to be twice as long, but still only 1px in thickness.
I am creating a DrawingVisual that draws a bunch of connected lines. When I zoom in, the line widths increase but I don't want this to happen. I can't seem to find the stroke width property anywhere. Please help.
Doug What API will the Excel or Word team be using to develop Vista versions of their applications?
I will tackle this one in a future post.
Just wondering then, if I want to draw the RT Video from a capture card for instance - or a webcam - onto a WPF surface, could I code a custom Directshow CODEC which decodes the video from the capture card? This may well be a stupid suggestion I have been trying to work out how to do this for a while now. I realise that mine may be an illegitimate extension of the notion of a CODEC, so don't hesitate to berate me for being a fool if appropriate!!
That is indeed the way to do it...
Hi,
I am working on an application that needs to do a lot of GPU based video processing using a Custom Allocator-presenter. It also needs to overlay UI style elements (2D and 3D) on the result. Can I generate a texture of separate UI elements and composite them onto the video (needs to be done in a pixel shader)? This is the opposite of what is discussed here. Since this needs to be pretty fast, what are my options? Thanks in advance. Depending on your skills and how much time you want to spend on it, this seems doable.
You would have WPF render offscreen, and then compose the resulting image on top of your video, with whatever API you are using. The tricky part is handling input against your WPF components (doing your own hit testing and trigger them with automation?) and keeping the WPF and video in sync (if that is a requirement). It would help if we had an easier way to interop with Direct3D surfaces. This is a request we got from a few developers, and something that the team will take into account for the future. -Pablo Hello
Can I have a WPF control which contain a Windows Form control and surface of Windows Form Control to be render by DirectX(Direct 3d)? This link no longer works. Please update if at all possible:
Link Title: HwndHost at MSDN URL: http://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref33/html/T_System_Windows_Interop_HwndHost.asp If I wanted to create a WPF app that for one of it's needs required the ability to render a plot (similar to an Excel line chart) with on the order of a million points at a very high rate (where each point is changing every rendered frame), what would be the best way to accomplish this? Essentially, I am trying to emulate in a WPF app what a high-end scope can accomplish.
So far, I've gone down two paths. The first path was to attempt to implement a pure WPF solution, which in one form, utilized the StreamGeometry. This, as I'm sure you can imagine wasn't the most optimal solution, as what I am trying to render doesn't really suit a retained mode drawing system. I then tried to host an hWnd and use GDI+ to do the rendering. While this was faster than the pure WPF solution, it was still incredibly slower than what we were able to accomplish through GDI in our non-WPF version of the app. Should I attempt to use DirectDraw/Direct3D? Also, does GDI+ do any automatic decimation behind the scenes? Thanks in advance. -Jonathan Add Comment
|
Calendar
QuicksearchArchivesCategoriesLive SearchSyndicate This BlogXBox 360 Gamer Tag |
|||||||||||||||||||||||||||||||||||||||||||||||||



Pablo is one the most senior people on the WPF team and has been a key decision maker in deciding what...
Tracked: Mar 29, 08:17
I have been playing with WPF for quite some while now and have been involved with several applications...
Tracked: Apr 12, 17:46
Hoje descobri que Pablo Fernicola está
Tracked: May 09, 22:37
Read More...
Tracked: May 09, 22:37
Thanks to Pablo Fernicola, Program Manager on the Windows Presentation Foundation (aka Avalon) Team,...
Tracked: May 26, 00:22