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

相关文章

SpringBoot 多环境开发实战(从配置、管理与控制)

《SpringBoot多环境开发实战(从配置、管理与控制)》本文详解SpringBoot多环境配置,涵盖单文件YAML、多文件模式、MavenProfile分组及激活策略,通过优先级控制灵活切换环境... 目录一、多环境开发基础(单文件 YAML 版)(一)配置原理与优势(二)实操示例二、多环境开发多文件版

使用docker搭建嵌入式Linux开发环境

《使用docker搭建嵌入式Linux开发环境》本文主要介绍了使用docker搭建嵌入式Linux开发环境,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录1、前言2、安装docker3、编写容器管理脚本4、创建容器1、前言在日常开发全志、rk等不同

从入门到精通详解Python虚拟环境完全指南

《从入门到精通详解Python虚拟环境完全指南》Python虚拟环境是一个独立的Python运行环境,它允许你为不同的项目创建隔离的Python环境,下面小编就来和大家详细介绍一下吧... 目录什么是python虚拟环境一、使用venv创建和管理虚拟环境1.1 创建虚拟环境1.2 激活虚拟环境1.3 验证虚

Python实战之SEO优化自动化工具开发指南

《Python实战之SEO优化自动化工具开发指南》在数字化营销时代,搜索引擎优化(SEO)已成为网站获取流量的重要手段,本文将带您使用Python开发一套完整的SEO自动化工具,需要的可以了解下... 目录前言项目概述技术栈选择核心模块实现1. 关键词研究模块2. 网站技术seo检测模块3. 内容优化分析模

基于Java开发一个极简版敏感词检测工具

《基于Java开发一个极简版敏感词检测工具》这篇文章主要为大家详细介绍了如何基于Java开发一个极简版敏感词检测工具,文中的示例代码简洁易懂,感兴趣的小伙伴可以跟随小编一起学习一下... 目录你是否还在为敏感词检测头疼一、极简版Java敏感词检测工具的3大核心优势1.1 优势1:DFA算法驱动,效率提升10

Python多线程实现大文件快速下载的代码实现

《Python多线程实现大文件快速下载的代码实现》在互联网时代,文件下载是日常操作之一,尤其是大文件,然而,网络条件不稳定或带宽有限时,下载速度会变得很慢,本文将介绍如何使用Python实现多线程下载... 目录引言一、多线程下载原理二、python实现多线程下载代码说明:三、实战案例四、注意事项五、总结引

C#使用Spire.XLS快速生成多表格Excel文件

《C#使用Spire.XLS快速生成多表格Excel文件》在日常开发中,我们经常需要将业务数据导出为结构清晰的Excel文件,本文将手把手教你使用Spire.XLS这个强大的.NET组件,只需几行C#... 目录一、Spire.XLS核心优势清单1.1 性能碾压:从3秒到0.5秒的质变1.2 批量操作的优雅

Java List 使用举例(从入门到精通)

《JavaList使用举例(从入门到精通)》本文系统讲解JavaList,涵盖基础概念、核心特性、常用实现(如ArrayList、LinkedList)及性能对比,介绍创建、操作、遍历方法,结合实... 目录一、List 基础概念1.1 什么是 List?1.2 List 的核心特性1.3 List 家族成

Python开发简易网络服务器的示例详解(新手入门)

《Python开发简易网络服务器的示例详解(新手入门)》网络服务器是互联网基础设施的核心组件,它本质上是一个持续运行的程序,负责监听特定端口,本文将使用Python开发一个简单的网络服务器,感兴趣的小... 目录网络服务器基础概念python内置服务器模块1. HTTP服务器模块2. Socket服务器模块

Mybatis-Plus 3.5.12 分页拦截器消失的问题及快速解决方法

《Mybatis-Plus3.5.12分页拦截器消失的问题及快速解决方法》作为Java开发者,我们都爱用Mybatis-Plus简化CRUD操作,尤其是它的分页功能,几行代码就能搞定复杂的分页查询... 目录一、问题场景:分页拦截器突然 “失踪”二、问题根源:依赖拆分惹的祸三、解决办法:添加扩展依赖四、分页