c# Login UI with background picture animation
准备4张图片
UI control:
<Grid x:Class="Test1.MainBgAd"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" Margin="0" Background="Red"
d:DesignHeight="300" d:DesignWidth="300">
<Grid.Resources>
<Storyboard x:Key="sb1">
<DoubleAnimation From="0" To ="1" Storyboard.TargetName="img" Storyboard.TargetProperty="Opacity" Duration="0:0:4"></DoubleAnimation>
</Storyboard>
</Grid.Resources>
<Grid>
<Image Name="imgBg" Stretch="UniformToFill" Opacity="1" Source="/Test1;component/Assets/MianBgAd/minAd2.jpg" />
<Image Name="img" Stretch="UniformToFill" Opacity="0" Source="/Test1;component/Assets/MianBgAd/minAd1.jpg" /> </Grid>
</Grid>
code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation; namespace Test1
{
/// <summary>
/// Interaction logic for MainBgAd.xaml
/// </summary>
public partial class MainBgAd : Grid
{
public MainBgAd()
{
InitializeComponent();
loadImags();
sb=Resources["sb1"] as Storyboard;
sb.Completed += new EventHandler(sb_Completed);
Loaded += new RoutedEventHandler(MainBgAd_Loaded); } Storyboard sb;
int pIndex = 1;
int MaxIndex = 3;
List<BitmapImage> imgList = new List<BitmapImage>();
void MainBgAd_Loaded(object sender, RoutedEventArgs e)
{
Start();
} public void Start() { sb.Begin(); } void sb_Completed(object sender, EventArgs e)
{ if (pIndex > MaxIndex)
{
pIndex = 0;
} img.Opacity = 0;
img.Source=imgList[pIndex];
if (pIndex - 1 < 0)
{
imgBg.Source = imgList[MaxIndex]; }
else {
imgBg.Source = imgList[pIndex - 1];
} sb.Begin();
pIndex++; } void loadImags() { for (int i = 1; i <= 4; i++)
{
imgList.Add( new BitmapImage(new Uri("/Assets/MianBgAd/minAd"+i+".jpg", UriKind.RelativeOrAbsolute))); } } }
}
调用:
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
gridMain.Children.Insert(0, new MainBgAd());
}
c# Login UI with background picture animation的更多相关文章
- 用C3中的animation和transform写的一个模仿加载的时动画效果
用用C3中的animation和transform写的一个模仿加载的时动画效果! 不多说直接上代码; html标签部分 <div class="wrap"> <h ...
- CSS3动画属性之Animation
首先定义一个动画规则: @keyframes mymove { from {top:0px;} to {top:200px;} } @-moz-keyframes mymove /* Firefox ...
- Pyqt5.2.1生成的.ui文件转换成.py
cmd C:\>pyuic5 ui文件路径 -o 要生成的py文件路径 如下: C:\>pyuic5 c:\python33\lib\site-packages\pyqt5\uic\log ...
- 利用手上的UI资源(附免费UI工具包)
http://www.uisdc.com/how-to-use-ui-kits# 大家都知道,UI工具包里有很多好看的资源:比如按钮.滑块.面包屑.播放器.表单,甚至是一个"赞!" ...
- Semantic UI中的验证控件的事件的使用
1.Semantic UI中的验证控件,功能挺不错的,中文官网的文档写的都比较详细了,我再这里就不再进行重复了,主要是想说一下它的事件的使用方法,这个可能有部分朋友刚开始接触的时候不太了解 注意看这几 ...
- QT 入门 -QApplication QPushButton QDialog Ui类型的手工使用
QT 1.工具 assistant 帮助文档 qtconfig QT配置工具 qmake QT的make与项目文件智能创建工具 uic UI界面的设计文件的编译工具 mo ...
- CSS3集锦之新增选择器、圆角、阴影、透明度、transition动画、transform变形、animation动画
---恢复内容开始--- 一.CSS3新增选择器 1.nth-chlid(n)用法 selector:nth-chlid(n)指找到第n个子元素并且该元素为selector标签 <!DOCTYP ...
- CSS3动画以及animation事件
1.CSS3动画以及animation事件的定义 animation :name duration timing-function delay iteration-count direction an ...
- Simple scatter method in 2d picture(Qt)
Result: grayMap: MathTools: // // Created by Administrator on 2017/8/17. // #ifndef QTSCATTER_MATHTO ...
随机推荐
- JSP内置对象——session对象
举个购物流程的例子: 这整个购物过程,它是属于一次回话.那么这个session是保存在服务器内存当中,并且它保存着不同用户对应的session,一个用户对应一个session.看下面这幅图: 从图中可 ...
- Android Studio 一个完整的APP实例(附源码和数据库)
前言: 这是我独立做的第一个APP,是一个记账本APP. This is the first APP, I've ever done on my own. It's a accountbook APP ...
- Problem4-Project Euler
Largest palindrome product A palindromic number reads the same both ways. The largest palindrome m ...
- GIT回推本地commit近期版本
一次意外吧,本地add并且commit之后拉了别人错误的代码下来,后来本地又需要进行编写测试,无奈只能回推到自己刚刚commit过的代码,但是git命令除了拉去提交等其他的不是很熟悉,在度娘之后也遇到 ...
- PHP检测数组中的每个值是否含有特殊字符
本文出至:新太潮流网络博客 /** * [TestArray 检测数组是一维还是二维] * @E-mial wuliqiang_aa@163.com * @TIME 2017-04-07 * @WEB ...
- JBoss 7 更改response header中的Server参数
jboss服务器缺省情况下会在HTTP response header中显示自身的标识,如下 Server: Apache-Coyote/1.1 出于安全考虑,如果不想让人知道服务器类型,可以用以下方 ...
- 使用yum下载rpm包
查看系统有哪些可用的yum源yum repolist all yum指定本地源安装rpm包yum install <package-name> --enablerepo=<repos ...
- env :让系统决定你命令的位置
如果我们使用lua 运行脚本程序,或者使用python执行程序.我们不用明确 python的位置,可以使用env 命令来运行: env 程序介绍: NAME env - run a program i ...
- 【转】HTTP学习---TCP和UDP协议的区别与应用
[原文]https://www.toutiao.com/i6592813624689951239/ 概述 ⊙TCP/IP是个协议组,可分为三个层次:网络层.传输层和应用层. 在网络层有IP协议.ICM ...
- C++设计模式 ==> 策略模式与简单工厂模式结合
简介 策略模式相较之于简单工厂模式适用于生产方法经常变化且方法较为繁多的情况,因为生产方法时常变化就会需要频繁修改工厂类,违背了开闭原则,这时就可以用策略选择类由客户端根据需求动态切换策略.且策略模式 ...