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 ...
随机推荐
- 2018-10-17 22:20:39 c language
2018-10-17 22:20:39 c language C语言中的空白符 空格.制表符.换行符等统称为空白符,它们只用来占位,并没有实际的内容,也显示不出具体的字符. 制表符分为水平制表符和垂 ...
- 5,注释、分支结构、循环结构、伪“选择结构”
注释: python使用#作为行注释符,使用三引号作为多行注释符 分支结构: if-else: a=int(input("你的成绩是:")) if a>60: print(& ...
- Docker相关概念
一.概念 ①云计算:是一种资源的服务模式,该模式可以实现随时随地,便捷按需地从可配置计算资源共享池中获取所需的资源(如网络.服务器.存储.应用及服务),资源能够快速供应并释放,大大减少了资源管理工作的 ...
- LeetCode 题解之Goat Latin
1.问题描述 2.问题分析 将句子拆分成单词,然后放入vector中,对每一个单词做改变,最后连成句子返回. 3.代码 string toGoatLatin(string S) { vector< ...
- 蓝魔i7s刷机
,电脑管家,豌豆荚之类的PC工具 5. 安装MFT6.0.43.exe, 注意:MFT6.0.43需要对应的ISOC和USB驱动,不可使用其它版本 6. 将CUSTOM_CONFIG..INI文件复制 ...
- innodb索引统计信息
以下分析基于mysql5.6.10 统计信息相关字典表 information_schema.statistics mysql.innodb_table_stats mysql.innodb_inde ...
- .NET中低版本程序调用高版本DLL
在.NET项目开发中,有时需要对旧的程序进行二次开发,但是有些DLL是高版本的,如果对旧程序升级高版本,则需要改动的地方比较多,在项目比较急,开发时间短的情况下,可以通过下面方法让低版本程序调用高版本 ...
- [转]Java学习---7大经典的排序算法总结实现
[原文]https://www.toutiao.com/i6591634652274885128/ 常见排序算法总结与实现 本文使用Java实现这几种排序. 以下是对排序算法总体的介绍. 冒泡排序 比 ...
- 使用C#获取Windows Phone手机的各种数据(转)
转自:http://www.sum16.com/desinger/use-c-sharp-get-windows-phone-information.html 使用C#获取Windows Phone手 ...
- XtraEditors六、ListBoxControl、CheckedListBoxControl、ImageListBoxControl
ListBoxControl 效果如下: 示例代码: string[] girlArr = { "面码", "Saber", "Mathilda&qu ...