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

相关文章

从入门到精通C++11 <chrono> 库特性

《从入门到精通C++11<chrono>库特性》chrono库是C++11中一个非常强大和实用的库,它为时间处理提供了丰富的功能和类型安全的接口,通过本文的介绍,我们了解了chrono库的基本概念... 目录一、引言1.1 为什么需要<chrono>库1.2<chrono>库的基本概念二、时间段(Durat

解析C++11 static_assert及与Boost库的关联从入门到精通

《解析C++11static_assert及与Boost库的关联从入门到精通》static_assert是C++中强大的编译时验证工具,它能够在编译阶段拦截不符合预期的类型或值,增强代码的健壮性,通... 目录一、背景知识:传统断言方法的局限性1.1 assert宏1.2 #error指令1.3 第三方解决

SpringBoot开发中十大常见陷阱深度解析与避坑指南

《SpringBoot开发中十大常见陷阱深度解析与避坑指南》在SpringBoot的开发过程中,即使是经验丰富的开发者也难免会遇到各种棘手的问题,本文将针对SpringBoot开发中十大常见的“坑... 目录引言一、配置总出错?是不是同时用了.properties和.yml?二、换个位置配置就失效?搞清楚加

Linux如何快速检查服务器的硬件配置和性能指标

《Linux如何快速检查服务器的硬件配置和性能指标》在运维和开发工作中,我们经常需要快速检查Linux服务器的硬件配置和性能指标,本文将以CentOS为例,介绍如何通过命令行快速获取这些关键信息,... 目录引言一、查询CPU核心数编程(几C?)1. 使用 nproc(最简单)2. 使用 lscpu(详细信

从入门到精通MySQL 数据库索引(实战案例)

《从入门到精通MySQL数据库索引(实战案例)》索引是数据库的目录,提升查询速度,主要类型包括BTree、Hash、全文、空间索引,需根据场景选择,建议用于高频查询、关联字段、排序等,避免重复率高或... 目录一、索引是什么?能干嘛?核心作用:二、索引的 4 种主要类型(附通俗例子)1. BTree 索引(

Redis 配置文件使用建议redis.conf 从入门到实战

《Redis配置文件使用建议redis.conf从入门到实战》Redis配置方式包括配置文件、命令行参数、运行时CONFIG命令,支持动态修改参数及持久化,常用项涉及端口、绑定、内存策略等,版本8... 目录一、Redis.conf 是什么?二、命令行方式传参(适用于测试)三、运行时动态修改配置(不重启服务

Python中对FFmpeg封装开发库FFmpy详解

《Python中对FFmpeg封装开发库FFmpy详解》:本文主要介绍Python中对FFmpeg封装开发库FFmpy,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录一、FFmpy简介与安装1.1 FFmpy概述1.2 安装方法二、FFmpy核心类与方法2.1 FF

基于Python开发Windows屏幕控制工具

《基于Python开发Windows屏幕控制工具》在数字化办公时代,屏幕管理已成为提升工作效率和保护眼睛健康的重要环节,本文将分享一个基于Python和PySide6开发的Windows屏幕控制工具,... 目录概述功能亮点界面展示实现步骤详解1. 环境准备2. 亮度控制模块3. 息屏功能实现4. 息屏时间

MySQL DQL从入门到精通

《MySQLDQL从入门到精通》通过DQL,我们可以从数据库中检索出所需的数据,进行各种复杂的数据分析和处理,本文将深入探讨MySQLDQL的各个方面,帮助你全面掌握这一重要技能,感兴趣的朋友跟随小... 目录一、DQL 基础:SELECT 语句入门二、数据过滤:WHERE 子句的使用三、结果排序:ORDE

在Windows上使用qemu安装ubuntu24.04服务器的详细指南

《在Windows上使用qemu安装ubuntu24.04服务器的详细指南》本文介绍了在Windows上使用QEMU安装Ubuntu24.04的全流程:安装QEMU、准备ISO镜像、创建虚拟磁盘、配置... 目录1. 安装QEMU环境2. 准备Ubuntu 24.04镜像3. 启动QEMU安装Ubuntu4