39
MBL352 MBL352 Windows Mobile 5.0 Windows Mobile 5.0 中中中中 中中中中 中中中 中中中 中中 中中 中中中中中中中中中中 中中中中中中中中中中 中中中中中中中 中中中中中中中 中中 中中中 中中中中 () 中中 中中中 中中中中 ()

MBL352 Windows Mobile 5.0 中的开发新特性

Embed Size (px)

DESCRIPTION

MBL352 Windows Mobile 5.0 中的开发新特性. 张炜 移动解决方案技术专家 移动产品事业部 微软(中国)有限公司. Windows Mobile 5.0 主要新特性. 易用性提升 集成的多媒体 更强的定制功能. Windows Mobile 5.0 主要新特性 … 开发人员. 开发效率提升 集成多媒体 更强的定制功能. 强大的开发工具以及新的模拟器引擎 ! 统一的安装器 状态及通知代理程序 增强的模拟器. 相机以及图片 API DirectDraw, DirectShow, D3D MediaPlayer 10 OCX. - PowerPoint PPT Presentation

Citation preview

Page 1: MBL352 Windows Mobile 5.0 中的开发新特性

MBL352MBL352Windows Mobile 5.0Windows Mobile 5.0 中的中的开发新特性开发新特性

张炜张炜移动解决方案技术专家移动解决方案技术专家移动产品事业部移动产品事业部微软(中国)有限公司微软(中国)有限公司

Page 2: MBL352 Windows Mobile 5.0 中的开发新特性
Page 3: MBL352 Windows Mobile 5.0 中的开发新特性

Windows Mobile 5.0 Windows Mobile 5.0 主要新特主要新特性性

易用性提升易用性提升集成的多媒体集成的多媒体更强的定制功能更强的定制功能

Page 4: MBL352 Windows Mobile 5.0 中的开发新特性

Windows Mobile 5.0Windows Mobile 5.0 主要新特主要新特性性…… 开发人员开发人员开发效率提升开发效率提升

集成多媒体集成多媒体更强的定制功能更强的定制功能

强大的开发工具以强大的开发工具以及新的模拟器引擎及新的模拟器引擎 !!

统一的安装器统一的安装器状态及通知代理程状态及通知代理程

序序增强的模拟器增强的模拟器

相机以及图片相机以及图片 APIAPIDirectDraw, DirectDraw,

DirectShow, D3DDirectShow, D3DMediaPlayer 10 MediaPlayer 10

OCXOCX

集成的集成的 .NET CF .NET CF v1.3v1.3

开放核心功能开放核心功能Windows Windows

MobileMobile 托管 托管 APIsAPIs

Page 5: MBL352 Windows Mobile 5.0 中的开发新特性

HTC UniversalHTC Universal

FlextronicsFlextronics

SamsungSamsung

Windows Mobile 5.0 Windows Mobile 5.0 手机手机

Page 6: MBL352 Windows Mobile 5.0 中的开发新特性

从 从 Windows DirectX API Windows DirectX API 迁移过来迁移过来快速的快速的 APIAPI 迁移迁移广泛的支持基础广泛的支持基础

.NET CF v2 .NET CF v2 支持部分托管支持部分托管 D3D, use:D3D, use:Microsoft.WindowsMobile.DirectX.Direct3D快速的快速的 3D3D 应用开发部署应用开发部署需要 需要 Windows Mobile v5Windows Mobile v5

Windows Mobile 5 SDK Windows Mobile 5 SDK 以及 以及 Visual Studio Visual Studio 文档包括很多示例程序文档包括很多示例程序 . . 绝大部分可以在模拟器上运行绝大部分可以在模拟器上运行支持支持 Mobile DirectX Mobile DirectX 是 是 Windows Windows Mobile 5 Mobile 5 硬件设备必须满足的一项要求硬件设备必须满足的一项要求 !!

Mobile DirectXMobile DirectX

Page 7: MBL352 Windows Mobile 5.0 中的开发新特性

OutlookSession os = new OutlookSession();Folder contactFolder = os.Contacts;

OutlookSessionOutlookSession

属性返回相应的属性返回相应的 folderfolder 值值

Page 8: MBL352 Windows Mobile 5.0 中的开发新特性

Folders and CollectionsFolders and Collections

OutlookSession os = new OutlookSession(); int contactCount = os.Contacts.Items.Count;

Items Items 属性返回相应的属性返回相应的PimItemCollectionPimItemCollection

Page 9: MBL352 Windows Mobile 5.0 中的开发新特性

OutlookSession os = new OutlookSession();Contact c = new Contact();c.FullName = “Larry Lieberman”;o.Contacts.Items.Add(c);c.JobTitle = “Program Manager”;c.Update();

约会约会 , , 联系人以及任务联系人以及任务

Page 10: MBL352 Windows Mobile 5.0 中的开发新特性

约会及任务约会及任务 : : 循环循环

t = (Task)this.comboBox1.SelectedItem;label2.Text = Convert.ToString(t.IsRecurring);if (t.IsRecurring){label4.Text = Convert.ToString(t.RecurrencePattern.RecurrenceType);}

Page 11: MBL352 Windows Mobile 5.0 中的开发新特性

定制的定制的 PIM PIM 属性属性

注意注意 : : 定制项无法与定制项无法与 ExchangeExchange 服务器服务器同步同步

Contact myCustomer;// ...if(!myCustomer.Properties.Contains(“Employee ID”)){myCustomer.Properties.Add("Employee ID",typeof(string));}myCustomer.Properties["Employee ID"] = "ABC1234";

Page 12: MBL352 Windows Mobile 5.0 中的开发新特性

用 用 Phone.Talk Phone.Talk 进行语音呼叫进行语音呼叫

Dim phone As New Phonephone.Talk(“425-555-0101”,False)

Page 13: MBL352 Windows Mobile 5.0 中的开发新特性

SmsMessage msg;msg.To.Add(new Recipient(“555-5309"));msg.Body = “Hello World!";msg.Send();

发送 发送 E-mail E-mail 及短消息及短消息

Page 14: MBL352 Windows Mobile 5.0 中的开发新特性

Contact myCustomer;// ...EmailMessage msg = new EmailMessage();msg.To.Add(myCustomer); // This won’t compile!msg.To.Add(new Recipient(myCustomer.Email2Address));

联系人不是接收人联系人不是接收人

Page 15: MBL352 Windows Mobile 5.0 中的开发新特性

对电子邮件添加附件对电子邮件添加附件

OutlookSession os = new OutlookSession();EmailMessage msg = new EmailMessage();Attachment at = new Attachment(“\Stuff.doc");msg.Attachments.Add(at);

Page 16: MBL352 Windows Mobile 5.0 中的开发新特性

Appointment appt = new Appointment();appt.Subject = "Launch Windows Mobile 5.0!";appt.AllDayEvent = true;appt.Start = new DateTime(2005, 5, 10);outlook.Appointments.Items.Add(appt);appt.ShowDialog();

使用 使用 Outlook MobileOutlook Mobile

Page 17: MBL352 Windows Mobile 5.0 中的开发新特性

ChooseContact ChooseContact 对话框对话框

ChooseContactDialog cChooser = newChooseContactDialog();

If (cChooser.ShowDialog() == DialogResult.OK){// Specify what happens on a// successful return here}

Page 18: MBL352 Windows Mobile 5.0 中的开发新特性

SelectPictureSelectPicture 对话框对话框

SelectPictureDialog pChooser = new SelectPictureDialog();

If (pChooser.ShowDialog() == DialogResult.OK){// Specify what happens on a// successful return here}

Page 19: MBL352 Windows Mobile 5.0 中的开发新特性

CameraCaptureCameraCapture 对话框对话框

CameraCaptureDialog cam = new CameraCaptureDialog();

If (cam.ShowDialog() == DialogResult.OK){// Specify what happens on a// successful return here}

Page 20: MBL352 Windows Mobile 5.0 中的开发新特性

托管配置管理器托管配置管理器

XmlDocument configDoc = new XmlDocument(); configDoc.LoadXml(

"<wap-provisioningdoc>"+ "<characteristic type=\"BrowserFavorite\">"+ "<characteristic type=\"Microsoft\">"+ "<parm name=\"URL\"

value=\"http://www.microsoft.com\"/>"+ "</characteristic>"+ "</characteristic>"+ "</wap-provisioningdoc>"

); ConfigurationManager.ProcessConfiguration(configDoc, false);

接受任何格式的接受任何格式的DMProcessConfig DMProcessConfig XMLXML

Page 21: MBL352 Windows Mobile 5.0 中的开发新特性

控制消息应用控制消息应用

初始化同步操作初始化同步操作显示收件箱显示收件箱显示撰写表单显示撰写表单

public static void DisplayComposeForm( string accountName, string toAddresses, string ccAddresses, string bccAddresses, string subject, string body, string[] attachments );

Page 22: MBL352 Windows Mobile 5.0 中的开发新特性

//======================================================================// MonitorThread - Monitors event for timer notification //DWORD WINAPI MonitorThread (PVOID pArg) { TEXT_PROVIDER_SPECIFIC_DATA tpsd; SMS_HANDLE smshHandle = (SMS_HANDLE)pArg; PMYMSG_STRUCT pNextMsg; BYTE bBuffer[MAXMESSAGELEN]; PBYTE pIn; SYSTEMTIME st; HANDLE hWait[2]; HRESULT hr; int rc; DWORD dwInSize, dwSize, dwRead = 0;

hWait[0] = g_hReadEvent; // Need two events since it isn't hWait[1] = g_hQuitEvent; // allowed for us to signal SMS event.

while (g_fContinue) { rc = WaitForMultipleObjects (2, hWait, FALSE, INFINITE); if (!g_fContinue || (rc != WAIT_OBJECT_0)) break; // Point to the next free entry in the array pNextMsg = &g_pMsgDB->pMsgs[g_pMsgDB->nMsgCnt];

// Get the message size hr = SmsGetMessageSize (smshHandle, &dwSize); if (hr != ERROR_SUCCESS) continue;

// Check for message larger than std buffer if (dwSize > sizeof (pNextMsg->wcMessage)) { if (dwSize > MAXMESSAGELEN) continue; pIn = bBuffer; dwInSize = MAXMESSAGELEN; } else { pIn = (PBYTE)pNextMsg->wcMessage; dwInSize = sizeof (pNextMsg->wcMessage); } // Set up provider specific data tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE; tpsd.psMessageClass = PS_MESSAGE_CLASS0; tpsd.psReplaceOption = PSRO_NONE; tpsd.dwHeaderDataSize = 0; // Read the message hr = SmsReadMessage (smshHandle, NULL, &pNextMsg->smsAddr, &st, (PBYTE)pIn, dwInSize, (PBYTE)&tpsd, sizeof(TEXT_PROVIDER_SPECIFIC_DATA), &dwRead);

if (hr == ERROR_SUCCESS) { // Convert GMT message time to local time FILETIME ft, ftLocal; SystemTimeToFileTime (&st, &ft); FileTimeToLocalFileTime (&ft, &ftLocal); FileTimeToSystemTime (&ftLocal, &pNextMsg-

>stMsg);

// If using alt buffer, copy to std buff if ((DWORD)pIn == (DWORD)pNextMsg-

>wcMessage) { pNextMsg->nSize = (int) dwRead; } else { memset (pNextMsg->wcMessage, 0, sizeof(pNextMsg->wcMessage)); memcpy (pNextMsg->wcMessage, pIn, sizeof(pNextMsg->wcMessage)-2); pNextMsg->nSize = sizeof(pNextMsg-

>wcMessage); } // Increment message count if (g_pMsgDB->nMsgCnt < MAX_MSGS-1) { if (g_hMain) PostMessage (g_hMain,

MYMSG_TELLNOTIFY, 1, g_pMsgDB->nMsgCnt); g_pMsgDB->nMsgCnt++; } } else { ErrorBox (g_hMain, TEXT("Error %x (%d)

reading msg"), hr, GetLastError()); break; } } SmsClose (smshHandle); return 0;}

在本地代码中截获在本地代码中截获 SMS SMS 消息消息

Page 23: MBL352 Windows Mobile 5.0 中的开发新特性

MessageInterceptor sms;

void Form_Load( ... ){ sms = new MessageInterceptor(); //... Optional: set interception condition here sms.MessageReceived += new EventHandler(sms_MessageReceived);}

void sms_MessageReceived(...){ //... Handle incoming message}

在托管代码中截获在托管代码中截获 SMS SMS 消息消息

Page 24: MBL352 Windows Mobile 5.0 中的开发新特性

用状态及通知代理器开发智能的用状态及通知代理器开发智能的移动应用移动应用

Page 25: MBL352 Windows Mobile 5.0 中的开发新特性

在以前获取状态信息是比较困难的在以前获取状态信息是比较困难的

问题问题 ::访问不同的属性数据,调用的是不同的访问不同的属性数据,调用的是不同的 APIsAPIs

不同的属性数据,又不同的更改通知机制不同的属性数据,又不同的更改通知机制很多属性没有开放(特别是在很多属性没有开放(特别是在 .NET CF.NET CF 中中 ))

没有定义一个标准的方式,允许没有定义一个标准的方式,允许 OEMsOEMs 和开和开发人员来定义他们自己属性发人员来定义他们自己属性

Page 26: MBL352 Windows Mobile 5.0 中的开发新特性

状态及通知代理器策略状态及通知代理器策略

将有用的数据存放在文档制定的地方将有用的数据存放在文档制定的地方本地 本地 APIs APIs 支持注册表中的任何数据更改支持注册表中的任何数据更改后,可以得到通知后,可以得到通知对本地对本地 APIsAPIs 的托管封装的托管封装

Page 27: MBL352 Windows Mobile 5.0 中的开发新特性

RegistryRegistry

Interesting ValuesInteresting Values

SNAPI.hSNAPI.hRegExt.hRegExt.h

Microsoft.WindowsMobile.StatusMicrosoft.WindowsMobile.Status

状态及通知代理器体系结构状态及通知代理器体系结构

Page 28: MBL352 Windows Mobile 5.0 中的开发新特性

电源与电池电源与电池约会约会媒体播放器媒体播放器连接性连接性ActiveSyncActiveSync

消息消息电话电话硬件硬件任务任务ShellShell

总共有超过总共有超过 100100 个系统属性个系统属性

Page 29: MBL352 Windows Mobile 5.0 中的开发新特性

1.1. 动态动态

2.2. 静态静态

Contact c = SystemState.PhoneIncomingCallerContact;

SystemState callerId = new SystemState( SystemProperty.PhoneIncomingCallerContact);

Contact c = (Contact)callerId.CurrentValue;

两种办法查询当前值两种办法查询当前值

Page 30: MBL352 Windows Mobile 5.0 中的开发新特性

SystemState callerId = new SystemState( SystemProperty.PhoneIncomingCallerContact);

callerId.Changed += new ChangeEventHandler(callerId_Changed);

void callerId_Changed(object sender, ChangeEventArgs args){ // ...}

获取更改通知获取更改通知

1.1. 创建一个创建一个 SystemState SystemState 对象对象2.2. 关联相应的关联相应的 event handlerevent handler

Page 31: MBL352 Windows Mobile 5.0 中的开发新特性

新问题:不固定的注册表值新问题:不固定的注册表值问题问题 : :

例如:即时消息(例如:即时消息( MSNMSN )客户端软件,在注)客户端软件,在注册表中存储了一项“在线联系人数目”值,用册表中存储了一项“在线联系人数目”值,用户登录后,例如设置为户登录后,例如设置为 1515 ,当用户登出后,,当用户登出后,该项值就不能准确反映真实数据该项值就不能准确反映真实数据

解决方案解决方案 : : 不固定的注册表值不固定的注册表值同普通注册表一样,但是不同的是当设备关机同普通注册表一样,但是不同的是当设备关机时自动删除时自动删除更好的性能更好的性能

总是在内存中总是在内存中永远不存储到固定的存储空间永远不存储到固定的存储空间

Page 32: MBL352 Windows Mobile 5.0 中的开发新特性

可扩展性可扩展性 !!

发布你自己的状态数据发布你自己的状态数据获得任何注册表值得更新通知获得任何注册表值得更新通知

public class MyClass {RegistryState state; // defined globally to class private void Form1_Load(object sender, EventArgs e) {

// RegistryState state; // This instance will go out of scope if defined here!RegistryState state =

new RegistryState("HKEY_LOCAL_MACHINE\\MyKey", "MyValue");

state.Changed += new ChangeEventHandler(state_Changed); }

}

Page 33: MBL352 Windows Mobile 5.0 中的开发新特性

当应用程序不在运行状态时,如何获当应用程序不在运行状态时,如何获取状态更新通知取状态更新通知适用于:适用于:

SMS SMS 拦截拦截状态及更新代理器状态及更新代理器

当一个更改发生当一个更改发生Windows Mobile Windows Mobile 启动应用程序启动应用程序应用程序关联一个应用程序关联一个 event handerevent hander

事件被触发事件被触发

Page 34: MBL352 Windows Mobile 5.0 中的开发新特性

SystemState missedCall;SystemState missedCall;

void Form_Load( … )void Form_Load( … ){{ if(!SystemState.IsApplicationLauncherEnabled(“if(!SystemState.IsApplicationLauncherEnabled(“MyApp.MissedCall”))”)) { { // ... Initialize missedCall// ... Initialize missedCall missedCall.EnableApplicationLauncher( “missedCall.EnableApplicationLauncher( “MyApp.MissedCall” );” ); }} elseelse {{ SystemState missedCall = new SystemState(“MyApp.MissedCall”); }} missedCall.Changed += new EventHandler( missedCall_Changed );missedCall.Changed += new EventHandler( missedCall_Changed );}}

SystemState missedCall;SystemState missedCall;

void Form_Load( … )void Form_Load( … ){{ // TODO: Initialize missedCall// TODO: Initialize missedCall

missedCall.Changed += new EventHandler( missedCall_Changed );missedCall.Changed += new EventHandler( missedCall_Changed );}

SystemState missedCall;SystemState missedCall;

void Form_Load( … )void Form_Load( … ){{ if(!if(!SystemState.IsApplicationLauncherEnabled(“MyApp.MissedCall”))) { {

}} elseelse {{

}} missedCall.Changed += new EventHandler( missedCall_Changed );missedCall.Changed += new EventHandler( missedCall_Changed );}}

SystemState missedCall;SystemState missedCall;

void Form_Load( … )void Form_Load( … ){{ if(!SystemState.IsApplicationLauncherEnabled(“if(!SystemState.IsApplicationLauncherEnabled(“MyApp.MissedCall”))”)) { { // ... Initialize missedCall missedCall.EnableApplicationLauncher( “MyApp.MissedCall” ); }} elseelse {{

}} missedCall.Changed += new EventHandler( missedCall_Changed );missedCall.Changed += new EventHandler( missedCall_Changed );}}

Persisted NotificationsPersisted Notifications

MyApp.MissedCallAnotherApp.IncommingCallAnotherApp.IncommingCall

AnotherApp.LowBatteryAnotherApp.LowBatteryMyApp.LostPhoneSMSMyApp.LostPhoneSMS ……

当应用程序不在运行状态时,如何获当应用程序不在运行状态时,如何获取状态更新通知取状态更新通知

Page 35: MBL352 Windows Mobile 5.0 中的开发新特性

SystemState missedCall;SystemState missedCall;

void Form_Load( … )void Form_Load( … ){{ if(!SystemState.IsApplicationLauncherEnabled(“if(!SystemState.IsApplicationLauncherEnabled(“MyApp.MissedCall”))”)) { { // ... Initialize missedCall// ... Initialize missedCall missedCall.EnableApplicationLauncher( “missedCall.EnableApplicationLauncher( “MyApp.MissedCall” );” ); }} elseelse {{ SystemState missedCall = new SystemState(“SystemState missedCall = new SystemState(“MyApp.MissedCall”);”);

missedCall.ComparisonType = StatusComparisonType.Equal; missedCall.ComparisonValue = true;

}} missedCall.Changed += new EventHandler( missedCall_Changed );missedCall.Changed += new EventHandler( missedCall_Changed );}

设置条件,避免不必要的通知设置条件,避免不必要的通知

Page 36: MBL352 Windows Mobile 5.0 中的开发新特性

新的工具新的工具

本地和托管代码开发使用统一的,集成的本地和托管代码开发使用统一的,集成的开发工具开发工具提高用户界面设计器使用提高用户界面设计器使用增强了数据设计工具增强了数据设计工具多平台开发多平台开发增强的调试器增强的调试器新的 新的 ARM ARM 设备模拟引擎设备模拟引擎新的设备新的设备 CAB CAB 项目类型项目类型

Page 37: MBL352 Windows Mobile 5.0 中的开发新特性

安装 安装 Visual Studio 2005Visual Studio 2005

安装 安装 Windows Mobile 5.0 SDKsWindows Mobile 5.0 SDKs

马上开始开发移动设备应用马上开始开发移动设备应用 !!

Page 38: MBL352 Windows Mobile 5.0 中的开发新特性

msdn.microsoft.com/msdn.microsoft.com/ embeddedembedded

microsoft.public.microsoft.public. windowsxp.embeddedwindowsxp.embedded windowsce.platbuilderwindowsce.platbuilder windowsce.embedded.vcwindowsce.embedded.vc

blogs.msdn.com/blogs.msdn.com/ mikehallmikehall

Windows CE 5.0 Eval KitWindows CE 5.0 Eval KitWindows XP Embedded Eval KitWindows XP Embedded Eval Kit

msdn.microsoft.com/msdn.microsoft.com/ mobilitymobility

microsoft.public.microsoft.public. pocketpc.developer pocketpc.developer smartphone.developer smartphone.developer dotnet.framework.compactframeworkdotnet.framework.compactframework

blogs.msdn.com/blogs.msdn.com/ windowsmobilewindowsmobile vsdteamvsdteam netcfteamnetcfteam

Windows Mobile 5.0 Eval KitWindows Mobile 5.0 Eval Kit

WebsitesWebsites

NewsgroupsNewsgroups

BlogsBlogs

ToolsTools

BuildBuild DevelopDevelop

Page 39: MBL352 Windows Mobile 5.0 中的开发新特性