[源码下载]

背水一战 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 选择在指定的时间之后延迟提醒或者取消延迟提醒的更多相关文章

  1. 背水一战 Windows 10 (107) - 通知(Toast): 提示音, 特定场景

    [源码下载] 背水一战 Windows 10 (107) - 通知(Toast): 提示音, 特定场景 作者:webabcd 介绍背水一战 Windows 10 之 通知(Toast) 提示音 特定场 ...

  2. 背水一战 Windows 10 (105) - 通知(Toast): 带按钮的 toast, 带输入的 toast(文本输入框,下拉选择框)

    [源码下载] 背水一战 Windows 10 (105) - 通知(Toast): 带按钮的 toast, 带输入的 toast(文本输入框,下拉选择框) 作者:webabcd 介绍背水一战 Wind ...

  3. 背水一战 Windows 10 (104) - 通知(Toast): 纯文本 toast, 短时 toast, 长时 toast, 图文 toast

    [源码下载] 背水一战 Windows 10 (104) - 通知(Toast): 纯文本 toast, 短时 toast, 长时 toast, 图文 toast 作者:webabcd 介绍背水一战 ...

  4. 背水一战 Windows 10 (103) - 通知(Toast): 基础, 按计划显示 toast 通知

    [源码下载] 背水一战 Windows 10 (103) - 通知(Toast): 基础, 按计划显示 toast 通知 作者:webabcd 介绍背水一战 Windows 10 之 通知(Toast ...

  5. 背水一战 Windows 10 (112) - 通知(Badge): application 的 badge 通知, secondary 的 badge 通知, 轮询服务端以更新 badge 通知

    [源码下载] 背水一战 Windows 10 (112) - 通知(Badge): application 的 badge 通知, secondary 的 badge 通知, 轮询服务端以更新 bad ...

  6. 背水一战 Windows 10 (111) - 通知(Tile): secondary tile 模板之图片, secondary tile 模板之分组

    [源码下载] 背水一战 Windows 10 (111) - 通知(Tile): secondary tile 模板之图片, secondary tile 模板之分组 作者:webabcd 介绍背水一 ...

  7. 背水一战 Windows 10 (110) - 通知(Tile): secondary tile 模板之基础, secondary tile 模板之文本

    [源码下载] 背水一战 Windows 10 (110) - 通知(Tile): secondary tile 模板之基础, secondary tile 模板之文本 作者:webabcd 介绍背水一 ...

  8. 背水一战 Windows 10 (109) - 通知(Tile): 按计划显示 tile 通知, 轮询服务端以更新 tile 通知

    [源码下载] 背水一战 Windows 10 (109) - 通知(Tile): 按计划显示 tile 通知, 轮询服务端以更新 tile 通知 作者:webabcd 介绍背水一战 Windows 1 ...

  9. 背水一战 Windows 10 (108) - 通知(Tile): application tile 基础, secondary tile 基础

    [源码下载] 背水一战 Windows 10 (108) - 通知(Tile): application tile 基础, secondary tile 基础 作者:webabcd 介绍背水一战 Wi ...

随机推荐

  1. Python中__init__和self的意义和作用

    由于类可以起到模板的作用,因此,可以在创建实例的时候,把一些我们认为必须绑定的属性强制填写进去.以学生类为例,通过定义一个特殊的__init__方法,在创建实例的时候,就把name,score等属性绑 ...

  2. 使用DOS命令无法启动MySQL

    今天使用命令dos 命令 net start mysql 启动mysql的使用出现以下情况 无法正常启动mysql服务. 原因是: 启动dos命令窗口时的用户权限太低,无法正常使用 解决办法: 搜索c ...

  3. springmvd接收参数问题

    问题描述: 好久不写博客了,今天遇到一个问题,那就是post请求时,参数接收不到,当时我很纳闷,看代码: 就是这样几个参数,我使用postman请求时无法获取参数: 报错信息: "msg&q ...

  4. sparse_matrix

    (1)ndarray 与 scipy.sparse.csr.csr_matrix 的互转 import numpy as npfrom scipy import sparse 1.1 ndarry 转 ...

  5. 结果集ResultSet

    我们访问数据库时候经常见到这样遍历结果集 conn = DBHelper.getConnection(); String sql = "select * from items"; ...

  6. 使用kbmmw smarthttpservice 简单返回数据库结果

    这个很简单,直接上码. 服务器端声明过程 [kbmMW_Rest('method:get, path:querytable')] [kbmMW_Method] function querytable( ...

  7. P4178 Tree

    最简单的点分治 淀粉质的思想: “分而治之”,缩小问题规模,合并求解: #include<cstdio> #include<cmath> #include<cstring ...

  8. SpringMVC对静态资源的访问(js、css、img)

    在网上找了很多的内容,都没法解决,最后通过https://blog.csdn.net/wild46cat/article/details/52456715中内容解决的,在此记录一下. 项目结构: po ...

  9. LOJ-10109(欧拉回路)

    题目链接:传送门 思路: 就是简单的找欧拉回路,不过要注意dfs边时要将边的编号/2,不然会分不清那条边每被遍历. #include<iostream> #include<cstdi ...

  10. JAVA 8 日期工具类

    JAVA 8 日期工具类 主题描述 JAVA中日期时间的历史 代码成果 主题描述 JAVA的日期时间一直比较混乱,本来以为joda会是巅峰,但是JAVA 8改变了我的思想.但是即便在JAVA 8面前, ...