1 / 39

MBL352 Windows Mobile 5.0 中的开发新特性

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

Download Presentation

MBL352 Windows Mobile 5.0 中的开发新特性

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MBL352Windows Mobile 5.0中的开发新特性 张炜 移动解决方案技术专家 移动产品事业部 微软(中国)有限公司

  2. Windows Mobile 5.0 主要新特性 • 易用性提升 • 集成的多媒体 • 更强的定制功能

  3. Windows Mobile 5.0主要新特性…开发人员 开发效率提升 集成多媒体 更强的定制功能 强大的开发工具以及新的模拟器引擎! 统一的安装器 状态及通知代理程序 增强的模拟器 相机以及图片 API DirectDraw, DirectShow, D3D MediaPlayer 10 OCX 集成的 .NET CF v1.3 开放核心功能 Windows Mobile托管 APIs

  4. HTC Universal Samsung Flextronics Windows Mobile 5.0 手机

  5. Mobile DirectX • 从 Windows DirectX API 迁移过来 • 快速的API迁移 • 广泛的支持基础 • .NET CF v2 支持部分托管 D3D, use: Microsoft.WindowsMobile.DirectX.Direct3D • 快速的3D应用开发部署 • 需要 Windows Mobile v5 • Windows Mobile 5 SDK 以及 Visual Studio 文档包括很多示例程序. 绝大部分可以在模拟器上运行 • 支持Mobile DirectX 是 Windows Mobile 5 硬件设备必须满足的一项要求!

  6. OutlookSession 属性返回相应的folder值 OutlookSession os = new OutlookSession(); Folder contactFolder = os.Contacts;

  7. Folders and Collections Items 属性返回相应的PimItemCollection OutlookSession os = new OutlookSession(); int contactCount = os.Contacts.Items.Count;

  8. 约会, 联系人以及任务 OutlookSession os = new OutlookSession(); Contact c = new Contact(); c.FullName = “Larry Lieberman”; o.Contacts.Items.Add(c); c.JobTitle = “Program Manager”; c.Update();

  9. 约会及任务: 循环 t = (Task)this.comboBox1.SelectedItem; label2.Text = Convert.ToString(t.IsRecurring); if (t.IsRecurring) { label4.Text =Convert.ToString(t.RecurrencePattern.RecurrenceType); }

  10. 定制的 PIM 属性 注意: 定制项无法与Exchange服务器同步 Contact myCustomer; // ... if(!myCustomer.Properties.Contains(“Employee ID”)) { myCustomer.Properties.Add("Employee ID",typeof(string)); } myCustomer.Properties["Employee ID"] = "ABC1234";

  11. 用 Phone.Talk 进行语音呼叫 Dim phone As New Phone phone.Talk(“425-555-0101”,False)

  12. 发送 E-mail 及短消息 SmsMessage msg; msg.To.Add(new Recipient(“555- 5309")); msg.Body = “Hello World!"; msg.Send();

  13. 联系人不是接收人 Contact myCustomer; // ... EmailMessage msg = new EmailMessage(); msg.To.Add(myCustomer); // This won’t compile! msg.To.Add(new Recipient(myCustomer.Email2Address));

  14. 对电子邮件添加附件 OutlookSession os = new OutlookSession(); EmailMessage msg = new EmailMessage(); Attachment at = new Attachment(“\Stuff.doc"); msg.Attachments.Add(at);

  15. 使用 Outlook Mobile 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();

  16. ChooseContact 对话框 • ChooseContactDialog cChooser = new • ChooseContactDialog(); • If (cChooser.ShowDialog() == DialogResult.OK) • { • // Specify what happens on a • // successful return here • }

  17. SelectPicture对话框 • SelectPictureDialog pChooser = new • SelectPictureDialog(); • If (pChooser.ShowDialog() == DialogResult.OK) • { • // Specify what happens on a • // successful return here • }

  18. CameraCapture对话框 • CameraCaptureDialog cam = new CameraCaptureDialog(); • If (cam.ShowDialog() == DialogResult.OK) • { • // Specify what happens on a • // successful return here • }

  19. 托管配置管理器 接受任何格式的 DMProcessConfig XML 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);

  20. 控制消息应用 • 初始化同步操作 • 显示收件箱 • 显示撰写表单 public static void DisplayComposeForm( string accountName, string toAddresses, string ccAddresses, string bccAddresses, string subject, string body, string[] attachments );

  21. 在本地代码中截获 SMS 消息 //====================================================================== // 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; }

  22. 在托管代码中截获 SMS 消息 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 }

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

  24. 在以前获取状态信息是比较困难的 • 问题: • 访问不同的属性数据,调用的是不同的APIs • 不同的属性数据,又不同的更改通知机制 • 很多属性没有开放(特别是在.NET CF中) • 没有定义一个标准的方式,允许OEMs和开发人员来定义他们自己属性

  25. 状态及通知代理器策略 • 将有用的数据存放在文档制定的地方 • 本地 APIs 支持注册表中的任何数据更改后,可以得到通知 • 对本地APIs的托管封装

  26. 状态及通知代理器体系结构 Microsoft.WindowsMobile.Status RegExt.h SNAPI.h Interesting Values Registry

  27. 总共有超过100个系统属性 • 电源与电池 • 约会 • 媒体播放器 • 连接性 • ActiveSync • 消息 • 电话 • 硬件 • 任务 • Shell

  28. 两种办法查询当前值 • 动态 • 静态 SystemState callerId = new SystemState( SystemProperty.PhoneIncomingCallerContact); Contact c = (Contact)callerId.CurrentValue; Contact c = SystemState.PhoneIncomingCallerContact;

  29. 获取更改通知 • 创建一个 SystemState 对象 • 关联相应的 event handler SystemState callerId = new SystemState( SystemProperty.PhoneIncomingCallerContact); callerId.Changed += new ChangeEventHandler(callerId_Changed); void callerId_Changed(object sender, ChangeEventArgs args) { // ... }

  30. 新问题:不固定的注册表值 • 问题: • 例如:即时消息(MSN)客户端软件,在注册表中存储了一项“在线联系人数目”值,用户登录后,例如设置为15,当用户登出后,该项值就不能准确反映真实数据 • 解决方案: 不固定的注册表值 • 同普通注册表一样,但是不同的是当设备关机时自动删除 • 更好的性能 • 总是在内存中 • 永远不存储到固定的存储空间

  31. 可扩展性! • 发布你自己的状态数据 • 获得任何注册表值得更新通知 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); } }

  32. 当应用程序不在运行状态时,如何获取状态更新通知当应用程序不在运行状态时,如何获取状态更新通知 • 适用于: • SMS 拦截 • 状态及更新代理器 • 当一个更改发生 • Windows Mobile 启动应用程序 • 应用程序关联一个 event hander • 事件被触发

  33. AnotherApp.LowBattery … MyApp.LostPhoneSMS AnotherApp.IncommingCall 当应用程序不在运行状态时,如何获取状态更新通知 SystemState missedCall; void Form_Load( … ) { if(!SystemState.IsApplicationLauncherEnabled(“MyApp.MissedCall”)) { // ... Initialize missedCall missedCall.EnableApplicationLauncher( “MyApp.MissedCall” ); } else { SystemState missedCall = new SystemState(“MyApp.MissedCall”); } missedCall.Changed += new EventHandler( missedCall_Changed ); } SystemState missedCall; void Form_Load( … ) { // TODO: Initialize missedCall missedCall.Changed += new EventHandler( missedCall_Changed ); } SystemState missedCall; void Form_Load( … ) { if(!SystemState.IsApplicationLauncherEnabled(“MyApp.MissedCall”)) { } else { } missedCall.Changed += new EventHandler( missedCall_Changed ); } SystemState missedCall; void Form_Load( … ) { if(!SystemState.IsApplicationLauncherEnabled(“MyApp.MissedCall”)) { // ... Initialize missedCall missedCall.EnableApplicationLauncher( “MyApp.MissedCall” ); } else { } missedCall.Changed += new EventHandler( missedCall_Changed ); } Persisted Notifications MyApp.MissedCall

  34. 设置条件,避免不必要的通知 SystemState missedCall; void Form_Load( … ) { if(!SystemState.IsApplicationLauncherEnabled(“MyApp.MissedCall”)) { // ... Initialize missedCall missedCall.EnableApplicationLauncher( “MyApp.MissedCall” ); } else { SystemState missedCall = new SystemState(“MyApp.MissedCall”); missedCall.ComparisonType = StatusComparisonType.Equal; missedCall.ComparisonValue = true; } missedCall.Changed += new EventHandler( missedCall_Changed ); }

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

  36. 安装 Visual Studio 2005 • 安装 Windows Mobile 5.0 SDKs • 马上开始开发移动设备应用!

  37. Build Develop Websites msdn.microsoft.com/embedded msdn.microsoft.com/mobility Newsgroups microsoft.public.pocketpc.developer smartphone.developer dotnet.framework.compactframework microsoft.public.windowsxp.embedded windowsce.platbuilder windowsce.embedded.vc Blogs blogs.msdn.com/mikehall blogs.msdn.com/windowsmobilevsdteamnetcfteam Tools Windows Mobile 5.0 Eval Kit Windows CE 5.0 Eval KitWindows XP Embedded Eval Kit

More Related