背水一战 Windows 10 (106) - 通知(Toast): 通过 toast 打开协议, 通过 toast 选择在指定的时间之后延迟提醒或者取消延迟提醒
作者:webabcd
介绍
背水一战 Windows 10 之 通知(Toast)
- 通过 toast 打开协议
- 通过 toast 选择在指定的时间之后延迟提醒或者取消延迟提醒
示例
1、本例用于演示如何通过 toast 打开指定的协议
Notification/Toast/LaunchProtocol.xaml
<Page
x:Class="Windows10.Notification.Toast.LaunchProtocol"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Notification.Toast"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10"> <Button Name="buttonShowToast1" Content="显示 toast(打开 http 协议)" Click="buttonShowToast1_Click" Margin="5" /> <Button Name="buttonShowToast2" Content="显示 toast(打开 webabcd 协议)" Click="buttonShowToast2_Click" Margin="5" /> </StackPanel>
</Grid>
</Page>
Notification/Toast/LaunchProtocol.xaml.cs
/*
* 本例用于演示如何通过 toast 打开指定的协议
*
*
* 本例 xml 说明:
* activationType - 通过点击 toast 激活 app 时的激活方式,protocol 代表打开指定的协议
* launch - 协议地址
*
*
* 注:通过 toast 中的按钮打开指定协议也是类似的,示例如下
* <action content='打开' activationType='protocol' arguments='http://webabcd.cnblogs.com/' />
*/ using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace Windows10.Notification.Toast
{
public sealed partial class LaunchProtocol : Page
{
public LaunchProtocol()
{
this.InitializeComponent();
} // 弹出 toast 通知(打开 http 协议)
private void buttonShowToast1_Click(object sender, RoutedEventArgs e)
{
// 清除本 app 的之前的全部 toast 通知
// ToastNotificationManager.History.Clear(); string toastXml = @"
<toast activationType='protocol' launch='http://webabcd.cnblogs.com/'>
<visual>
<binding template='ToastGeneric'>
<text>toast - title</text>
<text>toast - content 1</text>
</binding>
</visual>
</toast>"; XmlDocument toastDoc = new XmlDocument();
toastDoc.LoadXml(toastXml); ToastNotification toastNotification = new ToastNotification(toastDoc);
ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();
toastNotifier.Show(toastNotification);
} // 弹出 toast 通知(打开 webabcd 协议)
// 关于 webabcd 协议的支持,请参见 /AssociationLaunching/ProtocolAssociation.xaml.cs
private void buttonShowToast2_Click(object sender, RoutedEventArgs e)
{
// 清除本 app 的之前的全部 toast 通知
// ToastNotificationManager.History.Clear(); string toastXml = @"
<toast activationType='protocol' launch='webabcd:data'>
<visual>
<binding template='ToastGeneric'>
<text>toast - title</text>
<text>toast - content 2</text>
</binding>
</visual>
</toast>"; XmlDocument toastDoc = new XmlDocument();
toastDoc.LoadXml(toastXml); ToastNotification toastNotification = new ToastNotification(toastDoc);
ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();
toastNotifier.Show(toastNotification);
}
}
}
2、本例用于演示如何通过 toast 选择在指定的时间之后延迟提醒或者取消延迟提醒
Notification/Toast/SnoozeAndDismiss.xaml
<Page
x:Class="Windows10.Notification.Toast.SnoozeAndDismiss"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Notification.Toast"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <StackPanel Margin="10 0 10 10"> <Button Name="buttonShowToast1" Content="弹出 snooze and dismiss toast 通知(由系统设置下拉框和按钮)" Click="buttonShowToast1_Click" Margin="5" /> <Button Name="buttonShowToast2" Content="弹出 snooze and dismiss toast 通知(自定义下拉框,由系统设置按钮文字)" Click="buttonShowToast2_Click" Margin="5" /> <Button Name="buttonShowToast3" Content="弹出 snooze and dismiss toast 通知(自定义下拉框,自定义按钮文字)" Click="buttonShowToast3_Click" Margin="5" /> </StackPanel>
</Page>
Notification/Toast/SnoozeAndDismiss.xaml.cs
/*
* 本例用于演示如何通过 toast 选择在指定的时间之后延迟提醒或者取消延迟提醒
* 单击 toast 激活 app 后(前台方式激活),如何获取相关信息请参见 Demo.xaml.cs 中的代码
*
*
* 本例 xml 说明:
* hint-systemCommands - 当此值为 SnoozeAndDismiss 时,则由系统设置下拉框和按钮,并由系统处理相关行为
* action - 按钮(以下说明以 activationType='system' 为例)
* activationType - 单击此按钮激活 app 时的激活方式,system 代表由系统处理相关行为
* content - 按钮上显示的文本,不指定的话则由系统设置
* arguments - snooze 代表延迟按钮;dismiss 代表取消按钮
* hint-inputId - 用户选择延迟时间的下拉框的 id
*
*
* 注:
* 所谓的 snooze and dismiss 指的是:snooze - 在指定的时间之后延迟提醒,dismiss - 取消延迟提醒
*/ using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace Windows10.Notification.Toast
{
public sealed partial class SnoozeAndDismiss : Page
{
public SnoozeAndDismiss()
{
this.InitializeComponent();
} // 弹出 snooze and dismiss toast 通知(由系统设置下拉框和按钮)
private void buttonShowToast1_Click(object sender, RoutedEventArgs e)
{
// 清除本 app 的之前的全部 toast 通知
// ToastNotificationManager.History.Clear(); string toastXml = @"
<toast activationType='foreground' launch='Notification-Toast-SnoozeAndDismiss-Arguments 1'>
<visual>
<binding template='ToastGeneric'>
<text>snooze and dismiss</text>
<text>单击按钮后的行为由系统处理</text>
</binding>
</visual>
<actions hint-systemCommands='SnoozeAndDismiss' />
</toast>"; XmlDocument toastDoc = new XmlDocument();
toastDoc.LoadXml(toastXml); ToastNotification toast = new ToastNotification(toastDoc);
ToastNotificationManager.CreateToastNotifier().Show(toast);
} // 弹出 snooze and dismiss toast 通知(自定义下拉框,由系统设置按钮文字)
private void buttonShowToast2_Click(object sender, RoutedEventArgs e)
{
// 清除本 app 的之前的全部 toast 通知
// ToastNotificationManager.History.Clear(); string toastXml = @"
<toast activationType='foreground' launch='Notification-Toast-SnoozeAndDismiss-Arguments 2'>
<visual>
<binding template='ToastGeneric'>
<text>snooze and dismiss</text>
<text>单击按钮后的行为由系统处理</text>
</binding>
</visual>
<actions>
<input id='snoozeTime' type='selection' defaultInput='1'>
<selection id='1' content='1 分钟'/>
<selection id='2' content='2 分钟'/>
<selection id='5' content='5 分钟'/>
</input>
<action activationType='system' arguments='snooze' hint-inputId='snoozeTime' content='' />
<action activationType='system' arguments='dismiss' content='' />
</actions>
</toast>"; XmlDocument toastDoc = new XmlDocument();
toastDoc.LoadXml(toastXml); ToastNotification toast = new ToastNotification(toastDoc);
ToastNotificationManager.CreateToastNotifier().Show(toast);
} // 弹出 snooze and dismiss toast 通知(自定义下拉框,自定义按钮文字)
private void buttonShowToast3_Click(object sender, RoutedEventArgs e)
{
// 清除本 app 的之前的全部 toast 通知
// ToastNotificationManager.History.Clear(); string toastXml = @"
<toast activationType='foreground' launch='Notification-Toast-SnoozeAndDismiss-Arguments 3'>
<visual>
<binding template='ToastGeneric'>
<text>snooze and dismiss</text>
<text>单击按钮后的行为由系统处理</text>
</binding>
</visual>
<actions>
<input id='snoozeTime' type='selection' defaultInput='1'>
<selection id='1' content='1 分钟'/>
<selection id='2' content='2 分钟'/>
<selection id='5' content='5 分钟'/>
</input>
<action activationType='system' arguments='snooze' hint-inputId='snoozeTime' content='延迟' />
<action activationType='system' arguments='dismiss' content='取消' />
</actions>
</toast>"; XmlDocument toastDoc = new XmlDocument();
toastDoc.LoadXml(toastXml); ToastNotification toast = new ToastNotification(toastDoc);
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
}
}
OK
[源码下载]
背水一战 Windows 10 (106) - 通知(Toast): 通过 toast 打开协议, 通过 toast 选择在指定的时间之后延迟提醒或者取消延迟提醒的更多相关文章
- 背水一战 Windows 10 (107) - 通知(Toast): 提示音, 特定场景
[源码下载] 背水一战 Windows 10 (107) - 通知(Toast): 提示音, 特定场景 作者:webabcd 介绍背水一战 Windows 10 之 通知(Toast) 提示音 特定场 ...
- 背水一战 Windows 10 (105) - 通知(Toast): 带按钮的 toast, 带输入的 toast(文本输入框,下拉选择框)
[源码下载] 背水一战 Windows 10 (105) - 通知(Toast): 带按钮的 toast, 带输入的 toast(文本输入框,下拉选择框) 作者:webabcd 介绍背水一战 Wind ...
- 背水一战 Windows 10 (104) - 通知(Toast): 纯文本 toast, 短时 toast, 长时 toast, 图文 toast
[源码下载] 背水一战 Windows 10 (104) - 通知(Toast): 纯文本 toast, 短时 toast, 长时 toast, 图文 toast 作者:webabcd 介绍背水一战 ...
- 背水一战 Windows 10 (103) - 通知(Toast): 基础, 按计划显示 toast 通知
[源码下载] 背水一战 Windows 10 (103) - 通知(Toast): 基础, 按计划显示 toast 通知 作者:webabcd 介绍背水一战 Windows 10 之 通知(Toast ...
- 背水一战 Windows 10 (112) - 通知(Badge): application 的 badge 通知, secondary 的 badge 通知, 轮询服务端以更新 badge 通知
[源码下载] 背水一战 Windows 10 (112) - 通知(Badge): application 的 badge 通知, secondary 的 badge 通知, 轮询服务端以更新 bad ...
- 背水一战 Windows 10 (111) - 通知(Tile): secondary tile 模板之图片, secondary tile 模板之分组
[源码下载] 背水一战 Windows 10 (111) - 通知(Tile): secondary tile 模板之图片, secondary tile 模板之分组 作者:webabcd 介绍背水一 ...
- 背水一战 Windows 10 (110) - 通知(Tile): secondary tile 模板之基础, secondary tile 模板之文本
[源码下载] 背水一战 Windows 10 (110) - 通知(Tile): secondary tile 模板之基础, secondary tile 模板之文本 作者:webabcd 介绍背水一 ...
- 背水一战 Windows 10 (109) - 通知(Tile): 按计划显示 tile 通知, 轮询服务端以更新 tile 通知
[源码下载] 背水一战 Windows 10 (109) - 通知(Tile): 按计划显示 tile 通知, 轮询服务端以更新 tile 通知 作者:webabcd 介绍背水一战 Windows 1 ...
- 背水一战 Windows 10 (108) - 通知(Tile): application tile 基础, secondary tile 基础
[源码下载] 背水一战 Windows 10 (108) - 通知(Tile): application tile 基础, secondary tile 基础 作者:webabcd 介绍背水一战 Wi ...
随机推荐
- 解决npm ERR! Unexpected end of JSON input while parsing near的方法
这两天执行 npm install 时会报错误: npm ERR! Unexpected end of JSON input while parsing near 清除cache npm cache ...
- Node.js前端程序通过Nginx部署后刷新出现404问题的解决办法
方案一 (这种方式容易被第三方劫持) location / { root /data/nginx/html; index index.html index.htm; error_page 404 /i ...
- jmeter手写脚本,使用正则获取cookie(禁用cookies管理器)
注:这里以bugfree为例 1.bugfree登录时会有重定向,这会导致每个URL都会有.因此要手动获取cookie的时候,需要去掉重定向勾选 正则获取动态PHPsession 获取到值后,放到信息 ...
- Maven 生成可执行的jar包
maven 默认打包生成的 jar 包是不能够直接运行的,因为带有 main 方法的类信息不会添加到 manifest 中,即打开 jar 文件中的 META-INF/MANIFEST.MF 文件,将 ...
- Python批量执行oracle中的insert语句
从oracle导出一个表的数据,导出的格式是insert语句,数据量30万. 直接在PL/SQL Developer中执行,速度非常慢,脚本中也是100条数据提交一次.因为需要的时间太长,每次中断后, ...
- TwinStickShooter的一些问题
TwinStickShooter模板应该是比较好的了解UE基本Pawn和Projectile的一个C++例子.以下是一些问题. 一.这个模板以纯C++编写,没有蓝图,所以第一步,我想测试下如何引用蓝图 ...
- Java学习笔记day_01
Java学习笔记(复习整理) 虽然不知道该怎么写,但是不起步就永远不知道该怎么做..刚开始可能会写的很差劲,但会一点一点变好的. 本笔记是以我按照传智播客的视频和Java核心思想来学习,前面的基础部分 ...
- 谷歌浏览器运行Flash
最近有人问我谷歌浏览器的flash总是要点击手动运行才可以使用.看了很多网上很多教程,并没有比较好的解决方案. 自己找了相关资料后,找到了一个比较好的完整的.特此在这边放出来给大家使用. 新建记事本, ...
- IOS KVO没有在delloc中移除导致奔溃
1.背景 为了监听tableview的移动 [_tableView addObserver:self forKeyPath:@"contentOffset" options:NSK ...
- php数组排序sort
php的数组分为数字索引型的数组,和关键字索引的数组.如果是数字索引的,可以这样使用:$names = ['Tom', 'Rocco','amiona'];sort($names);sort()函数只 ...