Windows Phone 8开发快速入门(七)

2024-06-12 21:08

本文主要是介绍Windows Phone 8开发快速入门(七),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!



主要内容:图块和通知(图块==磁贴)

Windows Phone 8的图块

图块:为用户提供最关注的信息。图块API支持应用创建和更新图块。

图块模板:翻转,图标,循环

翻转图块模板:小型图块不翻转FlipCycleTile*.png

循环图块模板:小型图块不循环FlipCycleTile*.png

图块大小:小型,中型,大型IconicTile*.png

主图块和次级图块(Create(Uri,ShellTileData)方法创建次级模块至开始屏幕)

定义应用的图块:双击WMAppMainifest.xml-->Application UI

 

本地图块

更新使用ShellTileSchedule

创建图块

Public static void SetTile(RecipeDataItem item,string NavSource)

{

FlipTileData tileData=new FlipTileData()

{

//Front square data

Title=item.Title,

BackgroundImage=newUri("ms-appx:///background1.png",UriKind.Relative),

SmallBackgroundImage=newUri("ms-appx:///smallbackground1.png",UriKind.Relative),

//Back square data

BackTitle=item.Title,

BackContent=item.Ingredients,

BackBackgroundImage=newUri("ms-app0x:///background1.png",UriKind.Relative),

//Wide tile data

WideBackgroundImage=newUri("ms-appx:///widebackground1.png",UriKind.Relative),

WideBackBackgroundImage=newUri("ms-appx:///widebackbackground1.png",Urikind.Relative),

WideBackContent=item.Direction

};

//Create Tile and pin it to Start. Causes a navigation to start anda deactivation of our application

ShellTile.Create(newUri("/RecipePage.xaml?DefaultTitle=FromTile",UriKind.Relative),titleData,true);

}

 

使用ShellTileSchedule更新图块

更新图块

//Find the Tile we want to update.

ShellTileTileToFind=ShellTile.ActiveTiles.FirstOrDefault(x=>x.NavigationUri.ToString().Contains("DefaultTitle=FromTile"));

//If the Tile was found , then updata the Title.

If(TileToFind!=null)

{

FlipTileData NewTileData=new FlipTileData

{

Title=textBoxTitle.Text

};

TileToFind.Update(NewTileData);

Updating the Application Tile

Public static void UpdateMainTile(RecipeDataGroup group)

{

//Get application's main tile-application tile always first item inthe ActiveTiles collection whether it is pinned or not

Var mainTile=ShellTile.ActiveTiles.FirstOrDefault();

IconicTileData tileDaa=new IconicTileData()

{

Count=group.RecipesCount,

BackgroundColor=Color.FromArgb(255,195,61,39),

Title="Contoso Cookbooks",

IconImage=newUri("ms-appx:///local/shared/shellcontent/newMedLogo.png",UriKind.RelativeOrAbsolute),

SmallIconImage=newUri("ms-appx:///local/shared/shellcontent/newSmlLogo.pg",UriKind.RelativeOrAbsolute),

WideContent1="Recent activity:",

WideContent2="Browsed"+group.Title+"group",

WideContent3="with totalof"+group.RecipesCount+"recipes"

};

mainTile.Updata(tileData);

}

后台代理更新图块

可以使用ShellTileSchedule来更新应用图块背景图像和次要图块

 

Windows Phone 8的锁定屏幕通知

创建锁定屏幕图标

XML编辑器中修改WMAppManifest.xml

<Tokens>

<PrimaryToken TokenId="PhoneApp4Token"TaskName="_default">

<TemplateFlip>

……

<DeviceLockImageURI>MyLockIcon.png</DeviceLockImageURI>

</TemplateFlip>

</PrimaryToken>

</Tokens>

更改应用程序清单

XML编辑器中修改WMAppManifest.xml

<Extensions>

<ExtensionExtensionName="LockScreen_Notification_IconCount"ConsumerID="{111DFF24-AA15-4A96-8006-2BFF122084f}"TaskID="_default"/>

<ExtensionExtensionName="LockScreen_Notification_TextField"ConsumerID="{111DFF24-AA15-4A96-8006-2BFF122084f}"TaskID="_default"/>

</Extensions>

在模拟器仪表板中测试

VS-->Tools-->SimulationDashboard-->Lock Screen

 

Windows Phone 8的锁定屏幕背影

更新应用程序清单文件

XML编辑器中修改WMAppManifest.xml

<Extensions>

<ExtensionExtensionName="LockScreen_Background"ConsumerID="{111DFF24-AA15-4A96-8006-2BFF122084f}"TaskID="_default"/>

</Extensions>

添加代码以更改锁定屏幕背景

Private async void lockHelper(Uri backgroundImageUri,stringbackgroundAction)

{

Try

{

//If you're not the provider, this call will prompt the user forpermission.

//Calling RequestAccdessAsync from a background agent is notallowed.

Var op=await LockScreenManager.RequestAccessAsync();

//Check the status to make sure we were given permission.

Boo isProvider=LockScreenManager.IsProvidedByCurrentApplication;

If(isProvider)

{

//Do the update.

Windows.Phone.System.UserProfile.LockScreen.SetImageUri(backgroundImageUri);

System.Diagnostics.Debug.WriteLine("New current image set to{0}",backgroundImageUri.ToString());

}

Else

{

MessxageBox.Show("You said no, so I can't update yourbackground.");

}

}

Catch(System.Exception ex)

{

System.Diagnostics.Debug.WriteLine(ex.ToString());

}

}

//If you're not the provider, this call will prompt the user forpermission.

//Calling RequestAccessAsync from a background agent is not allowed.

Var op=await LockScreenManager.RequestAccessAsync();

访问本地文件

应用程序的图片,采用ms-appx:///

Uri imageUri=newUri("ms-appx:///background1.png",UriKind.RelativeOrAbsolute);

LockScreen.SetImageUri(imageUri);

本地文件夹中的图片,采用ms-appdata:///local/shared/shellcontent

Uri imageUri=newUri("ms-appdata:///local/shared/shellcontent/background2.png",UriKind.RelativeOrAbsolute);

LockScreen.SetImageUri(imageUri);

 

这篇关于Windows Phone 8开发快速入门(七)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1055342

相关文章

一文教你如何解决Python开发总是import出错的问题

《一文教你如何解决Python开发总是import出错的问题》经常朋友碰到Python开发的过程中import包报错的问题,所以本文将和大家介绍一下可编辑安装(EditableInstall)模式,可... 目录摘要1. 可编辑安装(Editable Install)模式到底在解决什么问题?2. 原理3.

POI从入门到实战轻松完成EasyExcel使用及Excel导入导出功能

《POI从入门到实战轻松完成EasyExcel使用及Excel导入导出功能》ApachePOI是一个流行的Java库,用于处理MicrosoftOffice格式文件,提供丰富API来创建、读取和修改O... 目录前言:Apache POIEasyPoiEasyExcel一、EasyExcel1.1、核心特性

Python+Tkinter实现Windows Hosts文件编辑管理工具

《Python+Tkinter实现WindowsHosts文件编辑管理工具》在日常开发和网络调试或科学上网场景中,Hosts文件修改是每个开发者都绕不开的必修课,本文将完整解析一个基于Python... 目录一、前言:为什么我们需要专业的Hosts管理工具二、工具核心功能全景图2.1 基础功能模块2.2 进

Python+PyQt5开发一个Windows电脑启动项管理神器

《Python+PyQt5开发一个Windows电脑启动项管理神器》:本文主要介绍如何使用PyQt5开发一款颜值与功能并存的Windows启动项管理工具,不仅能查看/删除现有启动项,还能智能添加新... 目录开篇:为什么我们需要启动项管理工具功能全景图核心技术解析1. Windows注册表操作2. 启动文件

使用Python开发Markdown兼容公式格式转换工具

《使用Python开发Markdown兼容公式格式转换工具》在技术写作中我们经常遇到公式格式问题,例如MathML无法显示,LaTeX格式错乱等,所以本文我们将使用Python开发Markdown兼容... 目录一、工具背景二、环境配置(Windows 10/11)1. 创建conda环境2. 获取XSLT

使用Python创建一个功能完整的Windows风格计算器程序

《使用Python创建一个功能完整的Windows风格计算器程序》:本文主要介绍如何使用Python和Tkinter创建一个功能完整的Windows风格计算器程序,包括基本运算、高级科学计算(如三... 目录python实现Windows系统计算器程序(含高级功能)1. 使用Tkinter实现基础计算器2.

Android开发环境配置避坑指南

《Android开发环境配置避坑指南》本文主要介绍了Android开发环境配置过程中遇到的问题及解决方案,包括VPN注意事项、工具版本统一、Gerrit邮箱配置、Git拉取和提交代码、MergevsR... 目录网络环境:VPN 注意事项工具版本统一:android Studio & JDKGerrit的邮

Python开发文字版随机事件游戏的项目实例

《Python开发文字版随机事件游戏的项目实例》随机事件游戏是一种通过生成不可预测的事件来增强游戏体验的类型,在这篇博文中,我们将使用Python开发一款文字版随机事件游戏,通过这个项目,读者不仅能够... 目录项目概述2.1 游戏概念2.2 游戏特色2.3 目标玩家群体技术选择与环境准备3.1 开发环境3

Windows系统宽带限制如何解除?

《Windows系统宽带限制如何解除?》有不少用户反映电脑网速慢得情况,可能是宽带速度被限制的原因,只需解除限制即可,具体该如何操作呢?本文就跟大家一起来看看Windows系统解除网络限制的操作方法吧... 有不少用户反映电脑网速慢得情况,可能是宽带速度被限制的原因,只需解除限制即可,具体该如何操作呢?本文

Python中模块graphviz使用入门

《Python中模块graphviz使用入门》graphviz是一个用于创建和操作图形的Python库,本文主要介绍了Python中模块graphviz使用入门,具有一定的参考价值,感兴趣的可以了解一... 目录1.安装2. 基本用法2.1 输出图像格式2.2 图像style设置2.3 属性2.4 子图和聚