WP7 Launcher 启动器

 

在WindowsPhone中需要调用系统资源的话需要用到启动器(Launcher)和选择器(Choosers)。

其实已经很多人写过了,最近正好用到,再总结下吧…

先写启动器(Launcher),等下周有时间再写选择器(Choosers)。

1,Launchers

 

 

目前WindowsPhone启动器一共有15个

其中7.0支持的有10个:

EmailComposeTask

MarketplaceDetailTask

MarketplaceHubTask

MarketplaceReviewTask

MarketplaceSearchTask

MediaPlayerLauncher

PhoneCallTask

SearchTask

SmsComposeTask

WebBrowserTask

 

7.1新增了5个:

BingMapsDirectionsTask

BingMapsTask

ConnectionSettingsTask

ShareLinkTask

ShareStatusTask


 

2,BingMapsDirectionsTask

BingMapsDirectionsTask的功能是一个基于bing地图的路径导航,属性有两个(起点和终点),值类型为LabeledMapLocation

 NameDescription
Public propertyEndThe ending location for which driving directions are displayed.
Public propertyStartThe starting location for which driving directions are displayed.

用法也很简单:

BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();            
GeoCoordinate spaceNeedleLocation = new GeoCoordinate(0,0);
LabeledMapLocation spaceNeedleLML1 = new LabeledMapLocation("Somewhere", spaceNeedleLocation);
LabeledMapLocation spaceNeedleLML2 = new LabeledMapLocation("qingdao", null);
bingMapsDirectionsTask.End = spaceNeedleLML2;
bingMapsDirectionsTask.Start = spaceNeedleLML1;
bingMapsDirectionsTask.Show();

其中LabeledMapLocation的第二个参数为地理坐标,如果为NULL的话,bing地图会根据第一个参数的字符串进行搜索

另外如果不设置bingMapsDirectionsTask.Start的话,默认以当前GPS定位为出发地址。

效果:

image

最后,bing map在米国貌似不错,天朝比较坑爹…路径导航基本没戏….

还有手机区域语言选中国,基本不工作,选英国、米国都正常…

 

 

3,BingMapsTask


BingMapsTask的功能就是一个比较简单的bing地图调用,你可以设置地图的中间点、缩放级别或者领用bing地图搜索。

 NameDescription
Public propertyCenterGets or sets the location that will be used as the center point for the map.
Public propertySearchTermGets or sets the search term that is used to find and tag locations on the map.
Public propertyZoomLevelGets or sets the initial zoom level of the map.
BingMapsTask bingMapsTask = new BingMapsTask();
bingMapsTask.Center = new GeoCoordinate(47.6204,-122.3493);
//bingMapsTask.SearchTerm = "qingdao";
bingMapsTask.ZoomLevel = 50;
bingMapsTask.Show();

其中ZoomLevel是double型,而且必须大于0

效果:

image

 

 

4,ConnectionSettingsTask

ConnectionSettingsTask功能是快速导航到WP的网络设置(包括WIFI、数据连接、蓝牙和飞行模式)
NameDescription
Public propertyConnectionSettingsTypeGets or sets the type of network connection settings that will be displayed.
ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
//connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.AirplaneMode;
//connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
//connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Cellular;
connectionSettingsTask.Show();

效果就不加了,相当于快捷方式而已

 

 

5,EmailComposeTask


EmailComposeTask功能是调用绑定的邮箱发送邮件。

 NameDescription
Public propertyBccGets or sets the recipients on the Bcc line of the new email message.
Public propertyBodyGets or sets the body of the new email message.
Public propertyCcGets or sets the recipients on the Cc line of the new email message.
Public propertyCodePageGets or sets the character set that will be used to display the message content.
Public propertySubjectGets or sets the subject of the new email message.
Public propertyToGets or sets the recipients on the To line of the new email message.

 

EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.Subject = "message subject";
emailComposeTask.Body = "message body";
emailComposeTask.To = "recipient@example.com";
emailComposeTask.Cc = "cc@example.com";
emailComposeTask.Bcc = "bcc@example.com";
emailComposeTask.Show();

标题、正文、收件人、抄送、密送,不多说了..

效果:

imageimage

 

 

6,MarketplaceDetailTask


MarketplaceDetailTask功能是导航到市场上的软件(软件推荐或者提示用户下载其他账户发布的新版本或相关应用的时候很有用)

 NameDescription
Public propertyContentIdentifierGets or sets the unique identifier for the product to be displayed.
Public propertyContentTypeGets or sets the type of content displayed in the Windows Phone Marketplace client application.
MarketplaceDetailTask marketplaceDetailTask = new MarketplaceDetailTask();
marketplaceDetailTask.ContentIdentifier = "c14e93aa-27d7-df11-a844-00237de2db9e";
//marketplaceDetailTask.ContentType = MarketplaceContentType.Applications;
marketplaceDetailTask.Show();
ContentType默认为MarketplaceContentType.Applications,不用设置就可以
效果:
 

7,MarketplaceHubTask

MarketplaceHubTask功能很简单,就是导航到Marketplace,可以选择Application或者Music。
 NameDescription
Public propertyContentTypeGets or sets the type of content displayed in the Windows Phone Marketplace client application.
MarketplaceHubTask marketplaceHubTask = new MarketplaceHubTask();
marketplaceHubTask.ContentType = MarketplaceContentType.Music;
//marketplaceHubTask.ContentType = MarketplaceContentType.Applications;
marketplaceHubTask.Show();

效果:

image

 

 

8,MarketplaceReviewTask


MarketplaceReviewTask功能是导航到该应用的应用评分界面(一般应用的about里估计会用到)

MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();

效果:

image

 

 

9,MarketplaceSearchTask


MarketplaceSearchTask功能是市场搜索

NameDescription
Public propertyContentTypeGets or sets the type of content displayed in the Windows Phone Marketplace client application.
Public propertySearchTermsGets or sets the search terms.
MarketplaceSearchTask marketplaceSearchTask = new MarketplaceSearchTask();
//marketplaceSearchTask.ContentType = MarketplaceContentType.Applications;
marketplaceSearchTask.ContentType = MarketplaceContentType.Music;
marketplaceSearchTask.SearchTerms = "be what you wanna be";
marketplaceSearchTask.Show();
ContentType依旧默认为Applications,另外搜索中文乱码…
效果: 
 
 

10,MediaPlayerLauncher

MediaPlayerLauncher可以调用手机播放器来播放音乐、视频。
 NameDescription
Public propertyControlsGets or sets the flags that determine which controls are displayed in the media player application.
Public propertyLocationSets the location of the media file to be played. The MediaLocationType enumeration is used to specify either isolated storage or the application’s installation folder.
Public propertyMediaGets or sets the media played with the media player application.
Public propertyOrientationGets or sets the orientation in which the media player will be displayed when launched.
 
 
MediaPlayerLauncher mediaPlayerLauncher = new MediaPlayerLauncher();
//mediaPlayerLauncher.Media = new Uri("Trouble Is A Friend.mp3", UriKind.Relative);
mediaPlayerLauncher.Media = new Uri("Wildlife.wmv", UriKind.Relative);
mediaPlayerLauncher.Location = MediaLocationType.Install;
mediaPlayerLauncher.Controls = MediaPlaybackControls.Pause | MediaPlaybackControls.Stop;
mediaPlayerLauncher.Orientation = MediaPlayerOrientation.Portrait;
mediaPlayerLauncher.Show();
Location需要选择是在隔离存储空间(MediaLocationType.Data)还是安装目录(MediaLocationType.Install)
效果:

image

 

 

11,PhoneCallTask

PhoneCallTask功能就是拨打电话

 NameDescription
Public propertyDisplayNameGets or sets the name that is displayed when the Phone application is launched.
Public propertyPhoneNumberGets or sets the phone number that is dialed when the Phone application is launched.
PhoneCallTask phoneCallTask = new PhoneCallTask();
phoneCallTask.PhoneNumber = "2065550123";
phoneCallTask.DisplayName = "Gage";
phoneCallTask.Show();

效果:

imageimage

 

 

12,SearchTask

SearchTask功能是调用搜索(貌似依旧是bing…)

 NameDescription
Public propertySearchQueryGets or sets the search query that the Web Search application will use when it is launched.
SearchTask searchTask = new SearchTask();
searchTask.SearchQuery = "外汇";
searchTask.Show();

显示结果为网络、本地和图片,终于支持中文了

效果:

imageimage

 

 

13,ShareLinkTask


ShareLinkTask可以调用你绑定的账户(Live、Facebook、Twitter)分享消息

 NameDescription
Public propertyLinkUriGets or sets the link URI that will be displayed in the link sharing dialog.
Public propertyMessageGets or sets the message that will accompany the link when it is shared.
Public propertyTitleGets or sets the title of the link to be shared.
ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "Code Samples";
shareLinkTask.LinkUri = new Uri("http://msdn.microsoft.com/en-us/library/ff431744(v=VS.92).aspx", UriKind.Absolute);
shareLinkTask.Message = "Here are some great code samples for Windows Phone.";
shareLinkTask.Show();

不用多说,看名字就知道各个属性咋用了,要是啥时候微博、QQ能加入就NB了…

效果:

imageimage

 

 

14,ShareStatusTask


ShareStatusTask功能是分享状态,其实和上面ShareLinkTask类似。

 NameDescription
Public propertyStatusGets or sets the status message to be shared.
ShareStatusTask shareStatusTask = new ShareStatusTask();
shareStatusTask.Status = "I'm developing a Windows Phone application!";
shareStatusTask.Show();

还是和上面一样,能加微博就无敌了…

效果:

image

 

 

15,SmsComposeTask


SmsComposeTask功能就是发送短信。

 NameDescription
Public propertyBodyGets or sets the body text of the new SMS message.
Public propertyToGets or sets the recipient list for the new SMS message.
SmsComposeTask smsComposeTask = new SmsComposeTask();
smsComposeTask.To = "2065550123";
smsComposeTask.Body = "Try this new application. It's great!";
smsComposeTask.Show();

不多说了..

效果:

image

 

16,WebBrowserTask


WebBrowserTask功能就是调用浏览器。

 NameDescription
Public propertyUriGets or sets the URI to which the web browser application will navigate when it is launched.
Public propertyURLObsolete. Gets or sets the URL to which the web browser application will navigate when it is launched.
WebBrowserTask webBrowserTask = new WebBrowserTask();
//webBrowserTask.URL = "http://msdn.microsoft.com";
webBrowserTask.Uri = new Uri("http://msdn.microsoft.com", UriKind.Absolute);
webBrowserTask.Show();

url虽然提示过时,不过也能用,不过推荐用Uri。

效果:

image

 

 

15个启动器介绍完毕,下周有时间再写下选择器。

参考: http://msdn.microsoft.com/en-us/library/ff769550(v=vs.92).aspx

 

实例源码:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值