首页 技术 正文
技术 2022年11月12日
0 收藏 320 点赞 3,164 浏览 4308 个字
using demo02.Common;using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.ApplicationSettings;
using System.Threading.Tasks;
using Windows.UI.Notifications;
using demo02.DataStructure;
using Windows.Data.Xml.Dom;
using Windows.Storage.Streams;
using Windows.Storage;
using Windows.Networking.BackgroundTransfer;
using Windows.Storage.Pickers;
using Newtonsoft.Json;
using System.Collections.ObjectModel;
using demo02.Helper;
using WhereWeGo.Helper;
using System.Net.Http;
using System.Net;
using Windows.Networking.PushNotifications;
using Microsoft.WindowsAzure.Messaging;//“中心应用程序”模板在 http://go.microsoft.com/fwlink/?LinkId=321221 上有介绍namespace demo02
{ sealed partial class App : Application
{ public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
} protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null)
{
rootFrame = new Frame();
SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
try
{
await SuspensionManager.RestoreAsync();
}
catch (SuspensionManagerException)
{ }
} SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
Window.Current.Content = rootFrame;
} if (rootFrame.Content == null)
{ rootFrame.Navigate(typeof(HubPage), e.Arguments);
} await ConfigureNotifications(); //动态磁贴的调用 Window.Current.Activate();
} private async static Task ConfigureNotifications()
{
// Send local notifications
//TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueueForSquare310x310(true); var topRated = await demo02.DataModel.WWGDataSource.GetTileUAsync(); //获得动态磁贴的数据来源 foreach (var recipe in topRated.Universities) //topRated.Universities是个ObservableCollection<OfflinePicUri>
{
var templateContent = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare310x310BlockAndText02); //设定动态磁贴採用的模板//将图片绑定到动态磁贴上
//特别注意:图片不能太大,否则不能显示
var imageAttributes = templateContent.GetElementsByTagName("image");
((XmlElement)imageAttributes[0]).SetAttribute("src", "ms-appx:///" + recipe.TileImagePath);
//System.Diagnostics.Debug.WriteLine(recipe.TileImagePath);
((XmlElement)imageAttributes[0]).SetAttribute("alt", recipe.Name);//给动态磁贴加入文字
var tileTextAttributes = templateContent.GetElementsByTagName("text");
tileTextAttributes[1].InnerText = recipe.Name;
//tileTextAttributes[3].InnerText = "Brief Info";
tileTextAttributes[4].InnerText = recipe.Summary;
//tileTextAttributes[5].InnerText = recipe.Summary;
tileTextAttributes[6].InnerText = recipe.Stars + " stars";//这里要特别注意:要使得各Id互不同样,否则会显示不出
var tileNotification = new TileNotification(templateContent);
tileNotification.Tag = recipe.Id; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); } } }}/*********************************************************************************///附上:上面topRated.Universities集合中元素University的类/*********************************************************************************/
using demo02.Helper;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace demo02.DataModel
{ public class University : Base
{ public University(String id, String name, String summary, String imagePath, String category, double stars, String tileImagePath)
: base(id, name, summary, imagePath)
{
this.Category = category;
this.Stars = stars;
this.Projects = new ObservableCollection<Project>();
this.Images = new ImageHelper();
this.TileImagePath = tileImagePath;
} public string TileImagePath { get; set; }
public string Category { get; set; }
public double Stars { get; set; }
public ObservableCollection<Project> Projects { get; set; } public int ClickTimes { get; set; }
//兼容
public ImageHelper Images { get; set; } }}

要注意,同台磁贴用到的namespace有:

using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using System.Threading.Tasks;
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,110
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,584
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,431
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,202
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,837
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,920