码家

Web Platform, Cloud and Mobile Application Development

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

所有翻译,一方面是自己初学,可以督促自己;另一方面,也希望能帮到和我一样的初学者(不想看英文的)

翻译说明:

1.每段英文后面的中文,是直接根据英文翻译的

2.根据原文翻译,难免拗口,所以【】里面为自己根据原文用简单的语言组织后描述,可以直接跳过其他所有内容直接看【】里的

3.有什么想法建议可以随便提

 

Chapter 1
Hello, Windows Phone 7

  

Sometimes it becomes apparent that previous approaches to a problem haven’t quite worked the way you anticipated. Perhaps you just need to clear away the smoky residue of the past, take a deep breath, and try again with a new attitude and fresh ideas. In golf, it’s known as a “mulligan”; in schoolyard sports, it’s called a “do-over”; and in the computer industry, we say it’s a “reboot.”

有时有一种现象变的很明显,之前解决问题的方法并没有像你预期的那样有效果。也许这个时候你需要清除这些过去的残余的迷茫,深呼吸一下,然后再次尝试一种新的态度和方法。在打高尔夫中的术语中,这个被叫做“让一击”( Morning test 以首洞成绩定胜负赛);在校园运动中,这个被称作“返工,重做”;在计算机的领域中,我们称为“重新启动”。

【有的时候一种方法,行不通了,我们可以试一试一种新的方法】
A reboot is what Microsoft has initiated with its new approach to the mobile phone market. With its clean look, striking fonts, and new organizational paradigms, Microsoft Windows Phone 7 not only represents a break with the Windows Mobile past but also differentiates itself from other smartphones currently in the market. Windows Phone 7 devices will be made by several manufacturers and available with a variety of cell providers.

“重新启动”就是微软所用来启动移动手机的市场的新的方法。通过全新的视角,显著的字体库,新组织的范例库,微软的Windows Phone 7不仅是过去Windows Mobile的一个突破,同时很好的不同于现在市场上存在的只能手机。Windows Phone 7这种设备将会被几个制造商制造,并且可以从各种提供商那得到。

【微软就是利用“重新尝试”来重新打开移动手机市场的,Windows Phone 7增加了很多新的功能,Windows Phone 7已经和手机制造商合作,大家现在或者将来很容易就可以买到】
For programmers, Windows Phone 7 is also exciting, for it supports two popular and modern programming platforms: Silverlight and XNA.

对于编程人员来说,Windows Phone 7也是很令人激动人心的,因为Windows Phone 7的开发支持两种现在很流行的编程平台:Silverlight和XNA。

【Windows Phone 7受程序员的欢迎,因为开发的过程用到了两种流行的程序设计平台:Silverlight和XNA】

Silverlight—a spinoff of the client-based Windows Presentation Foundation (WPF)—has already given Web programmers unprecedented power to develop sophisticated user interfaces with a mix of traditional controls, high-quality text, vector graphics, media, animation, and data binding that run on multiple platforms and browsers. Windows Phone 7 extends Silverlight to mobile devices.

Silverlight-是基于客户端的WPF(用于为不同用户界面提供统一的显示系统)的子产品-已经给网络编程的程序员空前的力量去开发精致的用户界面,通过传统控件的混合使用:高质量的文本,矢量图,媒体,动画,数据绑定,可以运行在多平台和浏览器。Windows Phone 7将Silverlight发展到了手机设备上。

【Windows Phone 7将Silverlight的技术用到了手机设备上】

XNA—the three letters stand for something like “XNA is Not an Acronym”—is Microsoft’s game platform supporting both 2D sprite-based and 3D graphics with a traditional game-loop architecture. Although XNA is mostly associated with writing games for the Xbox 360

XNA(XNA中的X表示能够在WindowsXbox和合作伙伴之间达到跨平台的强大的软件工具。N表示“下一代(Next-generation)”,A表示“架构(Architecture)”)——三个字母代表的不是一个首字母缩略词,XNA是微软的游戏平台,通过一套传统的游戏循环架构,既支持基于精灵的2D,也支持3D图形。尽管XNA和手写游戏的最微软游戏机360联系最紧密。

【XNA在这里简单的说,就是用于开发游戏的,微软游戏开发工具】

Targeting Windows Phone 7

All programs for Windows Phone 7 are written in .NET managed code. Although the sample programs in this book are written in the C# programming language, it is also possible to write Windows Phone 7 applications in Visual Basic .NET. The free downloadable Microsoft Visual Studio 2010 Express for Windows Phone includes XNA Game Studio 4.0 and an on-screen phone emulator, and also integrates with Visual Studio 2010. You can develop visuals and animations for Silverlight applications using Microsoft Expression Blend.

所有Windows Phone 7的程序都是用.NET的托管代码来写来的。尽管这个书中的示例程序都是用C#编程语言编写的,但是也可以使用Visual Basic .NET编写。免费的可下载的软件Microsoft Visual Studio 2010 Express for Windows Phone,软件包括 XNA Game Studio 4.0,以及手机屏幕仿真器,软件是和Visual Studio 2010集成的。开发人员可以使用Microsoft Expression Blend开发具有图像和动画的Silverlight应用程序。

【Windows Phone 7的开发还是基于.NET的,开发工具使用Microsoft Visual Studio 2010 Express for Windows Phone和Microsoft Expression Blend】

The Silverlight and XNA platforms for Windows Phone 7 share some libraries, and you can use some XNA libraries in a Silverlight program and vice versa. But you can’t create a program that mixes visuals from both platforms. Maybe that will be possible in the future, but not now. Before you create a Visual Studio project, you must decide whether your million-dollar idea is a Silverlight program or an XNA program.

Silverlight和XNA平台有支持Windows Phone 7的函数库,开发人员在Sliverlight程序中可以使用一些XNA的函数库,反之亦然。但是你不同创建一个程序混合使用两个平台的图形部分。将来可能可以,但是现在还不行。在你创建一个Visual Studio的项目之前,你必须决定你创造财务的点子是Silverlight程序还是XNA程序。

【开发之前要决定是用Silverlight还是XNA,(这个部分不太理解,上面说可以相互调用函数库,但是后来说不能混合使用的是什么呢?)】

Generally you’ll choose Silverlight for writing programs you might classify as applications or utilities. These programs are built from a combination of markup and code. The markup is the Extensible Application Markup Language, or XAML and pronounced “zammel.” The XAML mostly defines a layout of user-interface controls and panels. Code-behind files can also perform some initialization and logic, but are generally relegated to handling events from the controls. Silverlight is great for bringing to the Windows Phone the style of Rich Internet Applications (RIA), including media and the Web. Silverlight for Windows Phone is a version of Silverlight 3 excluding some features not appropriate for the phone, but compensating with some enhancements.

通常开发人员会选择Silverlight来写程序,可以把这些区分为应用程序,或者实用工具。这些程序建立是通过标记和代码组合起来的。这些标记就是XAML(可扩展应用程序标记语言)。XAML,主要定义了用户界面控件和面板的布局。后台代码文件能执行一些初始化和逻辑上的动作,通常提交给控件的事件处理。Silverlight在开发具有桌面应用程序特点的Windows Phone程序方面非常强大,包括媒体和网站。Windows phone 使用的是Sliverlight的版本3,不包括一些不适合于手机开发的,但是作为弥补增强了一些功能。

XNA is primarily for writing high-performance games. For 2D games, you define sprites and backgrounds based around bitmaps; for 3D games you define models in 3D space. The action of the game, which includes moving graphical objects around the screen and polling for user input, is synchronized by the built-in XNA game loop.

XNA主要用来写一些高性能的游戏。对于2D游戏来说,你可以基于位图定义精灵和背景;对于3D游戏,你可以在3D控件里定义模型。游戏的行为,包括在屏幕的周围一些移动的图像对象,还包括一些等待用户的输入,在XNA这些都可以做到同步。

The differentiation between Silverlight-based applications and XNA-based games is convenient but not restrictive. You can certainly use Silverlight for writing games and you can even write traditional applications using XNA, although doing so might sometimes be challenging.

基于Silverlight的程序和基于XNA的程序两者之间的区别是方便的但是没有限制性的。你可以使用Silverlight写游戏程序,同样你也可以使用XNA写传统的程序。当然这样做,有时候可能会遇到一些挑战。

In particular, Silverlight might be ideal for games that are less graphically oriented, or use vector graphics rather than bitmap graphics, or are paced by user-time rather than clock-time. A Tetris-type program might work quite well in Silverlight. You’ll probably find XNA to be a bit harder to stretch into Silverlight territory, however. Implementing a list box in XNA might be considered “fun” by some programmers but a torture by many others.

特别注意的是,Silverlight对于某些游戏可能是理想化的,这些游戏包括:很少有图形定向的,或者使用矢量图而不是位图,或者是通过用户时间而不是机器始终来控制步调的。一个俄罗斯方块类型的程序,可能用Sliverlight会实现的很好。然而你可能以后会发现XNA想要延伸到Silverlight的领域有点难度的。实现一个列表可能被某些程序看来会有点乐趣,但是对很多其他程序员来说那就是折磨。

The first several chapters in this book describe Silverlight and XNA together, and then the book splits into different parts for the two platforms. I suspect that some developers will stick with either Silverlight or XNA exclusively and won’t even bother learning the other environment. I hope that’s not a common attitude. The good news is that Silverlight and XNA are so dissimilar that you can probably bounce back and forth between them without confusion!

这本书的前几章,一起描述 Silverlight 和 XNA,然后这本书再分开来讲两种平台的不同部分。我猜想,可能一些开发人员将会坚持这两种平台的一种,唯一的专研,将甚至不会厌烦的去学习另一个环境。我希望这不是一个共同的态度。好消息就是Silverlight 和 XNA是如此的不同,以至于你可能会没有困惑的在两者之间来回的反弹。

Microsoft has been positioning Silverlight as the front end or “face” of the cloud, so cloud services and Windows Azure form an important part of Windows Phone 7 development. The Windows Phone is “cloud-ready.” Programs are location-aware and have access to maps and other data through Bing and Windows Live. One of the available cloud services is Xbox Live, which allows XNA-based programs to participate in online multiplayer games, and can also be accessed by Silverlight applications.

微软已经将silverlight定位成云技术的前端,所以云服务和Windows Azure(Windows Azure,是微软基于云计算的操作系统,Windows Azure的主要目标是为开发者提供一个平台,帮助开发可运行在云服务器、数据中心、Web和PC上的应用程序。微软宣布Windows Azure将在2010年1月1日正式上市,该服务将在服务器端运行客户的应用,并通过大量数据中心提供存储,从而帮助各类网站应对用户需求的增长。)形成了Windows Phone 7开发的一个重要的部分。Windows Phone 是“云的准备”。程序是本地可知的,能够接入地图和其他一些数据,通过Bing(微软的搜索引擎)和Windows Live。云服务可利用之一的就是Xbox Live(微软为其游戏主机XBOX所提供的网络服务。是一个多用户的在线对战平台),Xbox Live支持基于XNA的程序加入到在线多用户的游戏,同时Xbox Live也能被Silverlight程序访问。

Programs you write for the Windows Phone 7 will be sold and deployed through the Windows Phone Marketplace, which provides registration services and certifies that programs meet minimum standards of reliability, efficiency, and good behavior.

开发人员开发的Windows Phone 7的程序能够通过Windows Phone销售、部署,提供注册服务并且保证最低标准,最低标准包括:可靠性,有效性,行为良好。

I’ve characterized Windows Phone 7 as representing a severe break with the past. If you compare it with past versions of Windows Mobile, that is certainly true. But the support of Silverlight, XNA, and C# are not breaks with the past, but a balance of continuity and innovation. As young as they are, Silverlight and XNA have already proven themselves as powerful and popular platforms. Many skilled programmers are already working with either one framework or the other—probably not so many with both just yet—and they have expressed their enthusiasm with a wealth of online information and communities. C# has become the favorite language of many programmers (myself included), and developers can use C# to share libraries between their Silverlight and XNA programs as well as programs for other .NET environments.

我已经把Windows Phone 7的特点作为表现一种严重对过去的打破。如果你把Windows Phone 7和过去Windows Mobile的版本比较,你就会发现这是毫无疑问的。但是支持Silverlight,XNA,C#不是打破过去,而是一种平衡,平衡了连续和创新。虽然他们很年轻,Silverlight 和 XNA已经证明了他们自己是多么的强大并且是流行的平台。很多专业的开发人员已经在用一种框架或者另一种工作,可能现在同时用两种的还不是很多,并且他们也通过很多在线的消息和社区表达了他们的热情。C#已经变成了很多开发人员(包括我自己)最喜欢的语言,开发人员能够使用C#去分享Silverlight和XNA 的程序的库,就像程序分享其他.NET的环境。

The Hardware Chassis

Developers with experience targeting Windows Mobile devices of the past will find significant changes in Microsoft’s strategy for the Windows Phone 7. Microsoft has been extremely proactive in defining the hardware specification, often referred to as a “chassis.” 

有过去开发Windows Mobile设备基础的开发人员,会发现在微软的Windows Phone 7上的策略有显著变化。微软已经积极主动的去定义硬件的规格,通常把这个称做chassis(底座、底架)

Initial releases of Windows Phone 7 devices will have one consistent screen size. (A second screen size is expected in the future.) Many other hardware features are guaranteed to exist on each device.

最初发布的Windows Phone 7设备将只有一个始终同样大小的屏幕。(第二个大小的屏幕会在将来出来)。很多其他的硬件特征在各个设备上都有保证。

The front of the phone consists of a multi-touch display and three hardware buttons generally positioned in a row below the display. From left to right, these buttons are called Back, Start, and Search:

手机的前面由多点触摸显示构成,还有三个硬的按键,一般在屏幕的下面形成一排。从做到右,这些按键一次被称为“退后”,“开始”,“搜索”。


Back Programs can use this button for their own navigation needs, much like the Back button on a Web browser. From the home page of a program, the button causes the program to terminate.

程序使用这个按钮来导航,就像网页浏览器的后退按钮。从一个程序的主页,这个按钮将终止程序。

Start This button takes the user to the start screen of the phone; it is otherwise inaccessible to programs running on the phone.
这个按钮将把用户带到手机的开始页面,在另一些情况在一些运行在手机的程序中是不可以被使用的。

Search The operating system uses this button to initiate a search feature.

 操作系统使用这个按钮去开始一个搜索的特色。

The initial releases of Windows Phone 7 devices have a display size of 480 × 800 pixels. In the future, screens of 320 × 480 pixels are also expected. There are no other screen options for Windows Phone 7, so obviously these two screen sizes play a very important role in phone development.

最初发布的Windows Phone 7的设备的屏幕显示为480 × 800像素,在将来,也准备设计320 × 480像素的。Windows Phone 7的屏幕没有其他的选择了,所以这两个尺寸的屏幕在手机的开发中将有着很重要的角色

In theory, it’s usually considered best to write programs that adapt themselves to any screen size, but that’s not always possible, particularly with game development. You will probably find yourself specifically targeting these two screen sizes, even to the extent of having conditional code paths and different XAML files for layout that is size-dependent.

理论上来说,通常最好考虑写出的程序能让他们自己适应任何尺寸的屏幕,但是那总是不太可能,特别是游戏的开发。你将会可能发现你自己专注于这两个尺寸的屏幕,甚至某种程度上,使用条件语句代码路径和不同的XAML文件根据具体的屏幕的大小来布局。
I will generally refer to these two sizes as the “large” screen and the “small“ screen. The greatest common denominator of the horizontal and vertical dimensions of both screens is 160, so you can visualize the two screens as multiples of 160-pixel squares:

我就简单的将这两个尺寸的屏幕叫做“大”屏幕和“小”屏幕。两种屏幕水平和垂直距离最好的共同标准都是160,所以你能设想两种屏幕都是160像素正方体的倍数。

I’m showing these screens in portrait mode because that’s usually the way smartphones are designed. The screen of the original Zune is 240 × 320 pixels; the Zune HD is 272 × 480.

我正在用纵向模式展示这些屏幕,因为那是通常使用这种方式来设计智能手机的。最初的Zune的屏幕是240 × 320的,清晰度是272 × 480。
Of course, phones can be rotated to put the screen into landscape mode. Some programs might require the phone to be held in a certain orientation; others might be more adaptable.

当然,手机能够被旋转是屏幕变成风景模式。一些程序可能需要手机用在某个特定的方向,其他可能适应性更强。
You have complete control over the extent to which you support orientation. By default, Silverlight applications appear in portrait mode, but you’ll probably want to write your Silverlight applications so they adjust themselves to orientation changes. New events are available specifically for the purpose of detecting orientation change, and some orientation shifts are handled automatically. In contrast, game programmers can usually impose a particular orientation on the user. XNA programs use landscape mode by default, but it’s easy to override that.

你已经完成控制你支持的方向的扩展。默认的是,Silverlight应用程序出现在纵向(portrait)模式中,但是你可能想要让你写的Silverlight程序能够让程序自己去适应方向的变化。可以明确使用新的事件为了探测方向的改变,同时让一些方向改变的处理变得自动化。与此相反,游戏开发人员,能够强制让用户使用一个特别的方向。XNA程序默认使用landscape模式,但是也很容易去推翻这个原则。

In portrait mode, the small screen is half of an old VGA screen (that is, 640 × 480). In landscape mode, the large screen has a dimension sometimes called WVGA (“wide VGA”). In landscape mode, the small screen has an aspect ratio of 3:2 or 1.5; the large screen has an aspect ratio of 5:3 or 1.66…. Neither of these matches the aspect ratio of television, which for standard definition is 4:3 or 1.33… and for high-definition is 16:9 or 1.77…. The Zune HD screen has an aspect ratio of 16:9.

在portrait模式中,小屏幕是老的VGA的一半(640 × 480)。在landscape模式中,这个大屏幕有一个被称作WVGA(“wide VGA”)的尺寸。在landscape中,小的屏幕有3:2或者1.5的纵横比;大的屏幕有 5:3或者1.66的纵横比。。。这两者都不满足电视的纵横比,电视的纵横比的定义是4:3或者1.33。。。而且高清晰度的是16:9或者1.77。。。Zune的高轻度纵横比是16:9。

Like many recent phones and the Zune HD, the Windows Phone 7 displays will likely use OLED (“organic light emitting diode”) technology, although this isn’t a hardware requirement. OLEDs are different from flat displays of the past in that power consumption is proportional to the light emitted from the display. For example, an OLED display consumes less than half the power of an LCD display of the same size, but only when the screen is mostly black. For an all-white screen, an OLED consumes more than three times the power of an LCD.

正如现在的手机和Zune HD,Windows Phone 7的现实将很可能使用OLED (“organic light emitting diode”)的技术,尽管这不是硬件的需求。OLEDs不同于过去的 flat displays,耗电和现实的射出成比例。举个例子,同样大小尺寸的显示OLED display的耗电量还没有LCD display耗电量得一半,但是当只有屏幕几乎都是黑的时候。当屏幕都是全亮的时候,OLED的耗电量是LCD的三倍还多。

Because battery life is extremely important on mobile devices, this characteristic of OLED displays implies an aesthetic of mostly black backgrounds with sparse graphics and light-stroked fonts. Regardless, Windows Phone 7 users can choose between two major color themes: light text on a dark background, or dark text on a light background.

因为电池的生命期对移动设备来说是非常重要的。这个OLED displays的特点意味着一个美学:更多的黑色背景(很少图)
,同时light-stroked的字体。不管(无论如何),Windows Phone 7的用户能选择两种主要的颜色主题:亮的文本加黑色背景,或者黑色文本加亮的背景。

Most user input to a Windows Phone 7 program will come through multi-touch. The screens incorporate capacitance-touch technology, which means that they respond to a human fingertip but not to a stylus or other forms of pressure. Windows Phone 7 screens are required to respond to at least four simultaneous touch-points.

大多数的用户将通过多点触摸来向Windows Phone 7输入信息。屏幕包含电容触摸技术,这意味着屏幕对人的手指有反应,但是对笔尖或者其他的压力不起反应。Windows Phone 7屏幕对于四个点同时触摸产生反应的实现是必须的。

A hardware keyboard is optional. Keep in mind that phones can be designed in different ways, so when the keyboard is in use, the screen might be in either portrait mode or landscape mode. A Silverlight program that uses keyboard input must respond to orientation changes so that the user can both view the screen and use the keyboard without wondering what idiot designed the program sideways. An on-screen keyboard is also provided, known in Windows circles as the Soft Input Panel or SIP. XNA programs also have access to the hardware keyboard and SIP.

硬件的键盘是可以选择的。记住手机是可以用不同的方式设计的,所以当键盘使用的时候,屏幕可以是portrait mode或者 landscape mode。一个Silverlight程序使用键盘输入必须对方向的改变有反应,那样用户可以同时看着屏幕用键盘,不需要在那边好奇是哪个傻瓜设计了这个只能一边的程序。一个屏幕的键盘是可以提供的,在Windows circles中我们可以知道作为软输入的面板。XNA的程序同样接触到硬的键盘和SIP。

Sensors and Services
A Windows Phone 7 device is required to contain several other hardware features— sometimes called sensors—and provide some software services, perhaps through the assistance of hardware. These are the ones that affect developers the most:

Wi-Fi The phone has Wi-Fi for Internet access to complement 3G data access through the cell provider. Software on the phone includes a version of Internet Explorer.

Camera The phone has at least a 5-megapixel camera with flash. Programs can invoke the camera program for their own input, or register themselves as a Photos Extra  Application and appear on a menu to obtain access to photographed images, perhaps for some image processing.

Accelerometer An accelerometer detects acceleration, which in physics is a change in velocity. When the camera is still, the accelerometer responds to gravity. Programs can obtain a three-dimensional vector that indicates how the camera is oriented with respect to the earth. The accelerometer can also detect sharp movements of the phone.

Location If the user so desires, the phone can use multiple strategies for determining where it is geographically located. The phone supplements a hardware GPS device with information from the Web or cell phone towers. If the phone is moving, course and speed might also be available. Vibration The phone can be vibrated through program control.

FM Radio An FM Radio is available and accessible through program control.

Push Notifications Some Web services would normally require the phone to frequently poll the service to obtain updated information. This can drain battery life. To help out, a push notification service has been developed that will allow any required polling to occur outside the phone and for the phone to receive notifications only when data has been updated.

posted on 2011-05-17 18:32  海山  阅读(623)  评论(0编辑  收藏  举报