zoukankan      html  css  js  c++  java
  • WPF 动画效果

    线性插值动画、关键帧动画、路径动画

    1. (Visibility)闪烁三下,停下两秒,循环:

    XAML:

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Label Name="WarningShineLabel" Content="充电" Background="DarkRed"></Label>
        </Grid>

    CS

         private void SetVisibilityShine()
            {
                ObjectAnimationUsingKeyFrames okf = new ObjectAnimationUsingKeyFrames();
                okf.Duration = new TimeSpan(0, 0, 0, 0, 4500);
                okf.RepeatBehavior = RepeatBehavior.Forever;
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Hidden, new TimeSpan(0, 0, 0)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Visible, new TimeSpan(0, 0, 0, 0, 500)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Hidden, new TimeSpan(0, 0, 0, 0, 1000)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Visible, new TimeSpan(0, 0, 0, 0, 1500)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Hidden, new TimeSpan(0, 0, 0, 0, 2000)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Visible, new TimeSpan(0, 0, 0, 0, 2500)));
                okf.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Hidden, new TimeSpan(0, 0, 0, 0, 4500)));
    
                WarningShineLabel.BeginAnimation(Label.VisibilityProperty, okf);
            }

    2. 平移:

    XAML

           <Label  Name="AirOutAnimation">
                    <Label.Content>
                        <Image Source="../Icons/flow.png"></Image> <!--一张图片-->
                    </Label.Content>
                </Label>

    CS

            ThicknessAnimation ta = new ThicknessAnimation();
                ta.From = new Thickness(60, 0, 0, 0);
                ta.To = new Thickness(0, 0, 0, 0);
                ta.Duration = TimeSpan.FromSeconds(1.5);
                ta.RepeatBehavior = RepeatBehavior.Forever;
                AirOutAnimation.BeginAnimation(Label.MarginProperty, ta);
  • 相关阅读:
    linux ubuntu装机到可实现java(eclipse,intellij IDEA,android)开发全过程
    浅谈线程同步的几种方法
    KMP算法,这是我看到的最简单的最好理解的KMP算法
    常用基础算法C++实现
    堆内存和栈内存详解(转载)
    数据结构=。= 链表
    倒排索引--资料1
    倒排索引简单理解
    简单理解Socket
    8.结构体的使用 2015.12.3
  • 原文地址:https://www.cnblogs.com/pangkang/p/6251594.html
Copyright © 2011-2022 走看看