前言_Preface

Preface

It's been a long road to Windows Presentation Foundation, better known to many as Avalon, the in-house Microsoft code name for the new Windows Vista presentation framework.

I learned to program Windows from Programming Windows 3.1 by Charles Petzold (Microsoft Press). In those days, programming for Windows was about windows, menus, dialogs and child controls. To make it all work, we had WndProcs (windows procedure functions) and messages. We dealt with the keyboard and the mouse. If we got fancy, we would do some nonclient work. Oh, and there was the stuff in the big blank space in the middle that I could fill however I wanted with the graphics device interface (GDI), but my 2-D geometry had better be strong to get it to look right, let alone perform adequately.

-----------------------------------------------------------------------------------------------------------------------------------

前言

WPF的发展经历了漫长的历程.作为微软为Windows Vista开发的新显示框架的项目代号,"Avalon"的名字更为人所知.

我最初曾通过Charles Petzold的Programming Windows 3.1学习Windows编程.在那时候,Windows编程主要关注窗口,菜单,对话框和控件.为了让它们工作,我们使用WndProcs和消息.我们处理键盘和鼠标.而当进阶之后,我们则会做一些非客户端的工作.哦,通过GDI我可以在屏幕中间的空白绘制任何我想要的东西,不过就算要让它们看上去算是正确,我的2D几何学功底都还不够,更别谈好看了.

 

Later, I moved to MFC (the Microsoft Foundation Classes), where we had this thing called a "document" which was separate from the "view." The document could be any old data I wanted it to be, and the view, well, the view was the big blank space in the middle that I could fill however I wanted with the MFC wrappers around GDI.

Later still, there was this thing called DirectX, which was finally about providing tools for filling in the space with hardware-accelerated 3-D polygons, but DirectX was built for writing full-screen games, so building content visualization and management applications just made my head hurt.

Windows Forms, on the other hand, was such a huge productivity boost and I loved it so much that I wrote a book about it (as did my co-author). Windows Forms was built on top of .NET, a managed environment that took a lot of programming minutiae off my hands so that I could concentrate on the content. Plus, Windows Forms itself gave me all kinds of great tools for laying out my windows, menus, dialogs and child controls. And the inside of the windows where I showed my content? Well, if the controls weren't already there to do what I wanted, I could draw the content however I wanted using the GDI+ wrappers in System.Drawing, which was essentially the same drawing model Windows programmers had been using for the last 20 years, before even hardware graphics acceleration in 2-D, let alone 3-D.

----------------------------------------------------------------------------------------------------------------------

在此之后,我转而学习MFC(Microsoft Foundation Classes).此时,我们将那些与"视图"相区分的东西叫做"文档".文档可以是我希望的任何旧的数据,而视图则是中间那块我可以使用被MFC封装的GDI涂鸦的大片空白.

再然后,出现了最终用于为使用硬件加速的3D多边形填充空白而提供工具的DirectX.不过DirectX是为了全屏显示的游戏而生的,用它构建满意的可视化程序和管理程序只会让我伤心罢了.

另一方面,Windows Forms则能够为生产力带来巨大的提升.我非常喜欢它,以至于为它写了一本书——对于我的合著者来说,也是这样.Windows Forms建立在.Net之上,是一个将我从大量的细枝末节中解放出来的受控的环境.因此,我能够将我的注意力完全集中在程序的内容上.除此之外,Windows Forms自身还为我提供了各种工具来设计窗口,菜单,对话框和子控件.在窗口之内,我应该在何处安置我的内容呢?如果并没有合适的控件做我所需要的事情,我可以自己使用System.Drawing中封装的GDI+绘制内容,而这正是Windows开发者过去20年中一直使用的模型.不过即便是2D图形也有硬件加速,更不用说3D的了.

 

In the meantime, a whole other way of interacting with content came along: HTML was great at letting me arrange my content, both text and graphics, and it would flow it and reflow it according to the preferences of the user. Further, with the recent emergence of AJAX (Asynchronous Java And XML), this environment got even more capable. Still, HTML isn't great if you want to control more of the user experience than just the content or if you want to do anything Windows-specificboth things that even Windows 3.1 programmers took for granted.

More recently, Windows Presentation Foundation (WPF) happened. Initially it felt like another way to create my windows, menus, dialogs and child controls. However, WPF shares a much deeper love for content than has yet been provided by any other Windows programming framework.

To support content at the lowest levels, WPF merges controls and graphics into one programming model; both are placed into the same element tree in the same way. And while these primitives are built on top of DirectX to leverage the 3-D hardware acceleration that's dormant when you're not running the latest twitch game, they're also built in .NET, providing the same productivity boost to WPF programmers that Windows Forms programmers enjoy.

------------------------------------------------------------------------------------------------------------

在此同时,另一种完全不同的与内容交互的方式也开始崛起:HTML善于让我放置包括文本和图形的各种内容,而它会根据用户的需要前进或者返回.况且,随着AJAX技术的渐渐流行,这种环境开始具备更多能力.不过,如果相对于呈现内容,你更关心用户体验,或者希望能够像Windows 3.1程序员那样能够控制Windows的细节,HTML就显得不太合适了.

而在最近,WPF出现了.最初它像是另外一种创建窗口,菜单,对话框和子控件的方式.不过,相对于任何其他已经存在的Windows编程框架,WPF对于内容的依赖性更强.

为了在底层支持内容,WPF在一个编程模型当中混合了控制机构和图形;它们全都被以相同的方式置入到相同的元素树中.这些原始要素建立在DirectX的基础之上,而使3D硬件加速在运行较新的游戏之外能够找到其他的用武之地.而这些均建立在.Net平台的基础之上,从而使WPF开发者能够像Windows Forms开发者一样享受到生产力的巨大提升.

One level up, WPF provides its "content model," which allows any control to host any group of other controls. You don't have to build special BitmapButton or IconComboBox classes; you put as many images, shapes, videos, 3-D models or whatever into a Button or a ComboBox as suit your fancy.

To arrange the content, whether in fixed or flow layout, WPF provides container elements that implement various layout algorithms in a way that is completely independent of the content they're holding.

To visualize the content, WPF provides data binding, styles and animation. Data binding produces and synchronizes visual elements on the fly based on your content. Styles allows you to replace the complete look of a control while maintaining its behavior. Animation brings your application to life, giving your users immediate feedback as they interact with it. These features give you the power to produce data visualizations so far beyond the capabilities of the data grid, the pinnacle most applications aspire to, that even Edward Tufte would be proud.

----------------------------------------------------------------------------------------------------------

一项进步是,WPF提供了它的内容模型.这一模型允许任何控件作为其它任何控件组的宿主(?).你不一定非要专门创建BitmapButton或者IconComboBox类型;你可以凭借你的想象力将任何图像,视频,3D模型或者其它任何东西放入到Button或者ComboBox当中.

为了安排这些内容,无论在固定的或者流动的布局当中,WPF提供了能够执行完全独立于其所作用的内容的各种布局原则的容器元素.

为了呈现这些内容,WPF提供了数据绑定,各种风格和动画制作的能力.数据绑定在数据发生改变时基于你的内容产生和同步可视化的元素.风格允许你在维护控件的行为时完全改变控件的外观.动画则赋予你的应用程序生命,根据用户与程序的交互为用户提供即时的反馈.这些特性呈现数据的能力超过了目前被大多数应用程序渴望的顶点——数据网格.

 

Combine these features with ClickOnce for the deployment and update of your WPF applications, both as standalone clients and as applications blended with your web site inside the browser, and you've got the foundation of the next generation of Windows applications.

The next generation of applications is going to blaze a trail into the unknown. WPF represents the best of the control-based Windows and content-based web worlds, combined with the performance of DirectX and the deployment capabilities of ClickOnce, building for us a vehicle just itching to be taken for a spin. And, like the introduction of fonts to the PC, which produced "ransom note" office memos, and the invention of HTML, which produced blinking online brochures, WPF is going to produce its own accidents along the road. Before we learn just what we've got in WPF, we're going to see a lot of strange and wonderful sights. I can't tell you where we're going to end up, but, with this book, I hope to fill your luggage rack so that you can make the journey.

-----------------------------------------------------------------------------------------------------------

 通过在这些特性中包含用于部署和升级你的WPF应用程序的ClickOnce技术,无论是单独的客户端还是应用程序都会在浏览器中与您的网站合而为一.而这正是下一代Windows应用程序的基础.

下一代应用程序还需要在黑暗中摸索道路.WPF则描绘了一个极好的与DirectX相结合,具备ClickOnce部署能力的,基于控制的窗口应用程序和基于内容的网页应用程序的世界,为我们构造全新的应用程序提供了强大的手段.正如对于PC字体的介绍创造出了"ransom note"字体,HTML的产生创造了(blinking online brochures,这是啥呀?),WPF也会在它自己的发展道路中创造新的机遇.在我们真正开始学习WPF之前,我们将首先看一些奇特而美妙的场景.我无法告诉你我们将如何结束,但是,通过这本书,我希望能够为你的WPF之旅提供方便.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值