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 ...
随机推荐
- SQLServer 学习笔记之超详细基础SQL语句 Part 5
Sqlserver 学习笔记 by:授客 QQ:1033553122 -----------------------接Part 4------------------- 21使用默认 默认(也称默认值 ...
- springcloud 入门 2 (Enreka的服务和注册)
spring cloud eureka: eureka 用以服务发现.服务注册,比较流行的有consul(后面再介绍) eureka介绍: eureka为netflix开源软件,分为三个部分: eur ...
- 【Python】控制鼠标点击
from pymouse import PyMouse m = PyMouse() a = m.position() #获取当前坐标的位置 print(a) m.move(50, 500) #鼠标移动 ...
- Linux 安装MongoDB 并设置防火墙,使用远程客户端访问
1. 下载 MongoDB 提供了 linux 各发行版本 64 位的安装包 下载地址:https://www.mongodb.com/download-center#community 2. 安装 ...
- Spring Boot 集成 thymeleaf 模版引擎
Spring Boot 建议使用 HTML 来完成动态页面.Spring Boot 提供了大量的模版引擎,包括 Thymeleaf.FreeMarker.Velocity等. Spring Boot ...
- 【Ansible 文档】【译文】入门教程
http://docs.ansible.com/ansible/latest/intro_getting_started.html Foreword 前言 到这里,你应该已经安装了Ansible,是时 ...
- ansible(一)
Ansible简介 Ansible:Ansible的核心程序Host Lnventory:记录了每一个由Ansible管理的主机信息,信息包括ssh端口,root帐号密码,ip地址等等.可以通过fil ...
- MySql详解(五)
MySql详解(五) MySql库的管理 一.创建库 create database [if not exists] 库名[ character set 字符集名]; 二.修改库 alter data ...
- Vuex状态管理详解
什么是Vuex 专门为vue应用程序开发的状态管理模式,采用集中式存储管理应用的所有组件的状态(数据),以相应的规则保证状态以一种可预测的方式发生改变 Vuex的作用(什么样的情况下使用Vuex) 多 ...
- Android开发之自定义局部导航菜单
如今,要实现导航功能方案有很多.比如: 1.用3.0+自带的Toolbar + Fragment导航. 2.用Tabhost实现导航.小弟学浅,就只用过这两种方案实现导航. 但是这两种方案都有一个很明 ...