基本信息
源码名称:C# WPF缩放 示例源码
源码大小:0.06M
文件格式:.rar
开发语言:C#
更新时间:2017-09-26
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

using System;
using System.Collections.Generic;
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.Shapes;
using System.Windows.Media.Animation;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for SimpleAnimation.xaml
    /// </summary>

    public partial class CodeAnimation : System.Windows.Window
    {

        public CodeAnimation()
        {
            InitializeComponent();
        }


        private void cmdGrow_Click(object sender, RoutedEventArgs e)
        {
            DoubleAnimation widthAnimation = new DoubleAnimation();
            widthAnimation.To = this.Width - 30;
            widthAnimation.Duration = TimeSpan.FromSeconds(5);
            widthAnimation.Completed  = animation_Completed;

            DoubleAnimation heightAnimation = new DoubleAnimation();
            heightAnimation.To = (this.Height - 50)/3;
            heightAnimation.Duration = TimeSpan.FromSeconds(5);

            cmdGrow.BeginAnimation(Button.WidthProperty, widthAnimation);
            cmdGrow.BeginAnimation(Button.HeightProperty, heightAnimation);    
        }
        private void animation_Completed(object sender, EventArgs e)
        {
            //double currentWidth = cmdGrow.Width;
            //cmdGrow.BeginAnimation(Button.WidthProperty, null);
            //cmdGrow.Width = currentWidth;

            //MessageBox.Show("Completed!");
        }

        private void cmdShrink_Click(object sender, RoutedEventArgs e)
        {
            DoubleAnimation widthAnimation = new DoubleAnimation();
            widthAnimation.Duration = TimeSpan.FromSeconds(5);            
            DoubleAnimation heightAnimation = new DoubleAnimation();
            heightAnimation.Duration = TimeSpan.FromSeconds(5);
            
            cmdGrow.BeginAnimation(Button.WidthProperty, widthAnimation);
            cmdGrow.BeginAnimation(Button.HeightProperty, heightAnimation);
        }

        private void cmdGrowIncrementally_Click(object sender, RoutedEventArgs e)
        {
            DoubleAnimation widthAnimation = new DoubleAnimation();
            widthAnimation.By = 10;
            widthAnimation.Duration = TimeSpan.FromSeconds(0.5);                       

            cmdGrowIncrementally.BeginAnimation(Button.WidthProperty, widthAnimation);            
        }
        private void BT_Save_Click(object sender, RoutedEventArgs e)
        {
            DoubleAnimation widthAnimation = new DoubleAnimation();
            widthAnimation.By = 100;
            widthAnimation.Duration = TimeSpan.FromSeconds(0.5);
            BT_Save.BeginAnimation(Button.WidthProperty, widthAnimation);

            //widthAnimation = new DoubleAnimation();
            //widthAnimation.By = -10;
            //widthAnimation.Duration = TimeSpan.FromSeconds(0.5);
            //BT_Save.BeginAnimation(Button.WidthProperty, widthAnimation);
        }
    }
}