【WP8】仿QQ提示消息
WP版的QQ提示消息的时候从顶部滑入,3秒后从顶部滑出,本文模仿该效果实现一个MessageToastManager类用于显示提示消息
思路很简单,就是动画而已,支持配置颜色和回掉
// *************************************************
//
// 作者:bomo
// 小组:WP开发组
// 创建日期:2014/7/7 15:18:12
// 版本号:V1.00
// 说明:
//
// *************************************************
//
// 修改历史:
// Date WhoChanges Made
// 2014/7/7 15:18:12 bomo Initial creation
//
// ************************************************* using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using System.Windows.Media.Animation; namespace XTuOne.Utility.Helpers
{
/// <summary>
/// 消息提示工具
/// </summary>
public class MessageToastManager
{
private static readonly Color defaultForegroundColor = Color.FromArgb(, , , );
private static readonly Color defaultBackgroundColor = Colors.White; public static void Show(string text, Action complete = null, double height = )
{
Show(text, defaultForegroundColor, defaultBackgroundColor, complete, height);
} public static void Show(string text, Color foregroundColor, Color backgroundColor, Action complete = null, double height = )
{
Show(text, new SolidColorBrush(foregroundColor), new SolidColorBrush(backgroundColor), complete, height);
} public static void Show(string text, Brush foregroundBrush, Brush backgroundBrush, Action complete = null, double height = )
{
var p = new Popup
{
Child = new Border
{
Width = Application.Current.Host.Content.ActualWidth,
Background = backgroundBrush,
Child = new TextBlock
{
Text = text,
Foreground = foregroundBrush,
FontSize = (double)Application.Current.Resources["PhoneFontSizeNormal"],
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(, , , )
}
}
}; Show(p, complete, height);
} private static void Show(Popup popup, Action complete = null, double height = )
{
if (!(popup.Child.RenderTransform is CompositeTransform))
{
popup.Child.RenderTransform = new CompositeTransform();
}
((CompositeTransform)popup.Child.RenderTransform).TranslateY = -height; Debug.Assert(popup.Child is FrameworkElement); var element =popup.Child as FrameworkElement;
element.Height = height; var storyboard = new Storyboard
{
AutoReverse = false
}; var doubleAnimaionUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTarget(doubleAnimaionUsingKeyFrames, popup.Child);
Storyboard.SetTargetProperty(doubleAnimaionUsingKeyFrames, new PropertyPath("(UIElement.Opacity)", new object[]));
storyboard.Children.Add(doubleAnimaionUsingKeyFrames); //0.5秒透明度从0-1
var doubleKeyFrame = new EasingDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5)),
Value = ,
EasingFunction = new CubicEase {EasingMode = EasingMode.EaseOut}
};
doubleAnimaionUsingKeyFrames.KeyFrames.Add(doubleKeyFrame);
doubleKeyFrame = new EasingDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2.4)),
Value = 0.995,
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseIn }
};
doubleAnimaionUsingKeyFrames.KeyFrames.Add(doubleKeyFrame);
doubleKeyFrame = new EasingDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds()),
Value = 0.1,
};
doubleAnimaionUsingKeyFrames.KeyFrames.Add(doubleKeyFrame); doubleAnimaionUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTarget(doubleAnimaionUsingKeyFrames, popup.Child);
Storyboard.SetTargetProperty(doubleAnimaionUsingKeyFrames, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)", new object[]));
storyboard.Children.Add(doubleAnimaionUsingKeyFrames);
doubleKeyFrame = new EasingDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5)),
Value = ,
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
};
doubleAnimaionUsingKeyFrames.KeyFrames.Add(doubleKeyFrame);
doubleKeyFrame = new EasingDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2.4)),
Value = ,
};
doubleAnimaionUsingKeyFrames.KeyFrames.Add(doubleKeyFrame);
doubleKeyFrame = new EasingDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds()),
Value = -height,
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseIn }
};
doubleAnimaionUsingKeyFrames.KeyFrames.Add(doubleKeyFrame); var objectAnimaionUsingKeyFrames = new ObjectAnimationUsingKeyFrames();
Storyboard.SetTarget(objectAnimaionUsingKeyFrames, popup);
Storyboard.SetTargetProperty(objectAnimaionUsingKeyFrames, new PropertyPath("(Popup.IsOpen)", new object[]));
storyboard.Children.Add(objectAnimaionUsingKeyFrames); var discreteObjectKeyFrame = new DiscreteObjectKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds()),
Value = true
};
objectAnimaionUsingKeyFrames.KeyFrames.Add(discreteObjectKeyFrame); discreteObjectKeyFrame = new DiscreteObjectKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds()),
Value = false
};
objectAnimaionUsingKeyFrames.KeyFrames.Add(discreteObjectKeyFrame); if (complete!=null)
{
storyboard.Completed += (s, e) => complete.Invoke();
} storyboard.Begin();
}
}
}
【WP8】仿QQ提示消息的更多相关文章
- jquery-模仿qq提示消息
( function() { var ua = navigator.userAgent.toLowerCase(); var is = (ua.match(/\b(chrome|opera|safar ...
- ZENG msgbox仿qq提示
ZENG.msgbox.show("设置成功!", 4, 2000); ZENG.msgbox.show("服务器繁忙,请稍后再试.", 1, 2000); Z ...
- wpf实现仿qq消息提示框
原文:wpf实现仿qq消息提示框 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/huangli321456/article/details/5052 ...
- SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=》提升)
SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=>提升,5个Demo贯彻全篇,感兴趣的玩才是真的学) 官方demo:http://www.asp.net/si ...
- Android 仿QQ首页的消息和电话的切换,首页的头部(完全用布局控制)
Android 仿QQ首页的消息和电话的切换,首页的头部(完全用布局控制) 首先贴上七个控制布局代码 1.title_text_sel.xml 字体颜色的切换 放到color文件夹下面 <?xm ...
- Android 高仿QQ滑动弹出菜单标记已读、未读消息
在上一篇博客<Android 高仿微信(QQ)滑动弹出编辑.删除菜单效果,增加下拉刷新功能>里,已经带着大家学习如何使用SwipeMenuListView这一开源库实现滑动列表弹出菜单,接 ...
- iOS天气动画、高仿QQ菜单、放京东APP、高仿微信、推送消息等源码
iOS精选源码 TYCyclePagerView iOS上的一个无限循环轮播图组件 iOS高仿微信完整项目源码 想要更简单的推送消息,看本文就对了 ScrollView嵌套ScrolloView解决方 ...
- Socket实现仿QQ聊天(可部署于广域网)附源码(1)-简介
1.前言 本次实现的这个聊天工具是我去年c#程序设计课程所写的Socket仿QQ聊天,由于当时候没有自己的服务器,只能在机房局域网内进行测试,最近在腾讯云上买了一台云主机(本人学生党,腾讯云有个学生专 ...
- < JAVA - 大作业(2)仿qq即时通讯软件 >
< JAVA - 大作业(2)仿qq即时通讯软件 > 背景 JAVA上机大作业:设计一个仿qq即时通讯软件 任务简要叙述:设计一款仿QQ的个人用户即时通讯软件,能够实现注册,登陆,与好友聊 ...
随机推荐
- iOS开发如何在一个透明视图上添加不透明的子控件
相信很多同学都会遇到过这个问题, 当我们弹出一个半透明的遮盖层时, 又想在遮盖层上加一些子视图, 这个时候如果你的遮盖层设置了alpha属性, 你会惊讶的发现, 加载遮盖层上的所有子控件都是透明了, ...
- composer安装与应用
操作环境:centos 6.5+32bit 1. 建立项目目录 mkdir test cd test 2. 在当前目录下安装: $ curl -sS https://getcomposer.org/i ...
- git .gitignore 文件不起作用
.gitignore 不起作用的原因是因为 git 有以前文件缓存,只要清理一次缓存即可 git rm -r --cached . // 然后再进行 git git add . git commit
- Docker常用命令<转>
创建redis服务端docker run -p 6379:6379 -d --name redis-server docker.io/redis:3.0.7 redis-server -- port ...
- Charles proxy tools 移动开发调试
简介 本文为InfoQ中文站特供稿件,首发地址为:文章链接.如需转载,请与InfoQ中文站联系. Charles是在Mac下常用的截取网络封包的工具,在做iOS开发时,我们为了调试与服务器端的网络通讯 ...
- HTML5里的input标签的required属性的提示
<input type="text" name="usr_name" required='required' oninvalid="setCus ...
- dapper支持操作函数和事物
dapper除了支持基础的CURD.存储过程以外,还支持操作函数和事物. dapper操作函数的代码如下: using Dapper; using System; using System.Colle ...
- 解决Eclipse闪退问题的方法总结
1.在C:/WINDOWS/system32 系统文件夹中ctrl+F 然后搜索java.exe,如果存在java.exe, javaw.exe etc.全部删除. 2.内存不足,打开Eclipse目 ...
- Java 代理使用及代理原理
今天再测试Socket编程时,无法连接外网.公司用的是Http的代理.上网搜索也没看太懂,所以花了大量时间来学习.看了HTTP和TCP协议的关系好,才有所明白.现在能通过Socket使用HTTP代理了 ...
- combobox无法显示选中的数据,都是undefined
$('#firstfactor').combobox({ url: '@Url.Action("GetMultiAirFactor_Day_New", ...