简体   繁体   English

独立的WPF应用程序可以创建类似于Flash接口的接口吗?

[英]Can a standalone WPF application create an interface that looks like a Flash interface?

It seems like WPF was created as the application answer to Adobe's Flash. WPF似乎是作为Adobe Flash的应用程序答案而创建的。 Silverlight is used for creating web pages. Silverlight用于创建网页。 But, can that same functionality be pulled into a standalone WPF application. 但是,可以将相同的功能引入到独立的WPF应用程序中吗? Scaleform allows Flash to be used within unmanaged C++ games. Scaleform允许Flash在非托管C ++游戏中使用。 Can WPF be used to create the same type of interfaces? WPF可以用于创建相同类型的接口吗? What I've read seems to make me believe it can. 我读过的东西似乎使我相信它可以。 But, I haven't seen any screenshots of applications that show this kind of interface. 但是,我还没有看到任何显示这种界面的应用程序的屏幕截图。

Absolutely! 绝对! WPF can do everything Flash can do in building game UIs and much, much, much more. WPF可以完成Flash在构建游戏UI方面可以做的一切,甚至更多。

WPF appliations can run several ways: WPF应用程序可以通过几种方式运行:

  • As a standalone application using pure managed code 作为使用纯托管代码的独立应用程序
  • As a standalone application using both managed and native code (including C++ code and UI) 作为使用托管代码和本机代码(包括C ++代码和UI)的独立应用程序
  • As a web application running within the browser using ClickOnce (this is known as XBAP) 作为使用ClickOnce(称为XBAP)在浏览器中运行的Web应用程序

(Silverlight is a subset of WPF that can run as a standalone application or in the browser, but cannot include native code) (Silverlight是WPF的子集,可以作为独立的应用程序运行或在浏览器中运行,但不能包含本机代码)

THe really cool thing about WPF is that, unlike Flash, it can directly and seamlessly incorporate C++ code and DirectX/OpenGL UI elements. 与Flash不同,WPF真正有趣的是,它可以直接无缝地合并C ++代码和DirectX / OpenGL UI元素。 It can also directly call the code and share data structures with unmanaged C++ code. 它还可以直接调用代码并与非托管C ++代码共享数据结构。 With Flash this requires a specialized runtime such as Scaleform and is not entirely compatible. 对于Flash,这需要专用的运行时,例如Scaleform,并且并不完全兼容。 In addition, the connection to unmanaged code is not as clean. 此外,与非托管代码的连接也不是很干净。

Because the capability to integrate with unmanaged code and UI is built directly into WPF, there is no need for an external vendor such as Scaleform to build anything. 由于与非托管代码和UI集成的功能直接内置于WPF中,因此无需像Scaleform这样的外部供应商来构建任何东西。 So nobody is collecting screen shots of games with a WPF-based UI environment because nobody is trying to sell anything. 因此,没有人使用基于WPF的UI环境收集游戏的屏幕截图,因为没有人试图出售任何东西。

Here is how it is usually done: 通常是这样做的:

<Window ...>
  <Grid>
    <WindowsFormsHost x:Name="host"/> <!-- Unmanaged code will be child of this hWnd -->
    <Grid>
      <!-- WPF UI elements here -->
    </Grid>
  </Grid>
</Window>

with code: 使用代码:

InitializeUnmanagedUI(host.Handle);

That's pretty much all there is to it. 这几乎就是它的全部。

As far as data goes, the managed and unmanaged components can easily use each other's objects: The unmanaged code can use the managed objects through IJW and C++/CLR. 就数据而言,托管和非托管组件可以轻松地使用彼此的对象:非托管代码可以通过IJW和C ++ / CLR使用托管对象。 The managed code can use and bind the unmanaged objects through COM. 托管代码可以通过COM使用和绑定非托管对象。

Yes. 是。 There's no reason why it couldn't. 没有理由不能这样做。 You'd just have to do your work to create and apply styles that make it look like whatever you want. 您只需要做工作即可创建和应用样式,使其看起来像您想要的任何样式。

It is work, but it isn't magic. 这是工作,但不是魔术。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM