当前位置: 首页>>代码示例>>C#>>正文


C# ImageBrush.BeginAnimation方法代码示例

本文整理汇总了C#中System.Windows.Media.ImageBrush.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# ImageBrush.BeginAnimation方法的具体用法?C# ImageBrush.BeginAnimation怎么用?C# ImageBrush.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.ImageBrush的用法示例。


在下文中一共展示了ImageBrush.BeginAnimation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetBorderBackgroundSlider

        public static void SetBorderBackgroundSlider(ImageBrush image, Border border)
        {
            //Create the fade out animation. 
            DoubleAnimation fadeOutAnimation = new DoubleAnimation(0, TimeSpan.FromMilliseconds(500));
            fadeOutAnimation.AutoReverse = false;

            //wait until the first animation is complete before changing the background, or else it will appear to just "fadeIn" with now fadeout.
            fadeOutAnimation.Completed += delegate(object sender, EventArgs e)
            {
                //once the fadeout is complete set the new back ground and fade back in. 
                //Create a new background brush.
                image.Opacity = 0;

                //Set the grid background to the new brush. 
                border.Background = image;

                //Set the brush...(not the background property) with the animation. 
                DoubleAnimation fadeInAnimation = new DoubleAnimation(1, TimeSpan.FromMilliseconds(1000));
                fadeInAnimation.AutoReverse = false;
                image.BeginAnimation(Brush.OpacityProperty, fadeInAnimation);
            };

            //Fade out..before changing the background.
            var currentBackground = border.Background;
            currentBackground.BeginAnimation(Brush.OpacityProperty, fadeOutAnimation);
        }
开发者ID:msCube,项目名称:Gallery,代码行数:26,代码来源:ImageProcessing.cs

示例2: CardDragAdorner

        public CardDragAdorner(CardControl anchor, CardControl sourceCard, Vector mousePoint)
            : base(Application.Current.MainWindow.Content as UIElement)
        {
            SourceCard = sourceCard;
              bool isCardInverted = anchor.IsOnTableCanvas && (Player.LocalPlayer.InvertedTable ^ anchor.IsInverted);
              Point cardOrigin;
              if (isCardInverted)
              {
            var cardDef = Program.Game.Definition.CardDefinition;
            cardOrigin = new Point(cardDef.Width, cardDef.Height);
            mouseOffset = new Vector(cardDef.Width - mousePoint.X, cardDef.Height - mousePoint.Y);
              }
              else
              {
            cardOrigin = new Point();
            mouseOffset = mousePoint;
              }
              basePt = anchor.TranslatePoint(cardOrigin, Application.Current.MainWindow.Content as UIElement);

              _faceUp = sourceCard.IsAlwaysUp ? true : sourceCard.Card.FaceUp;
              lightRedBrush = Brushes.Red.Clone();
              faceDownBrush = new ImageBrush(sourceCard.Card.GetBitmapImage(false));
              faceUpBrush = _faceUp ?
              (Brush)new VisualBrush(sourceCard.GetCardVisual()) { Viewbox = new Rect(0, 0, sourceCard.ActualWidth, sourceCard.ActualHeight), ViewboxUnits = BrushMappingMode.Absolute } :
              (Brush)new ImageBrush(new BitmapImage(new Uri(Program.Game.Definition.CardDefinition.Front)));
              invertTransform = new ScaleTransform() { CenterX = 0.5, CenterY = 0.5 };
              faceUpBrush.RelativeTransform = invertTransform;
              if (faceUpBrush is VisualBrush)
            RenderOptions.SetCachingHint(faceUpBrush, CachingHint.Cache);

              child.BeginInit();
              child.Width = anchor.ActualWidth * CardControl.scaleFactor.Width;
              child.Height = anchor.ActualHeight * CardControl.scaleFactor.Height;
              child.Fill = _faceUp ? faceUpBrush : faceDownBrush;
              child.StrokeThickness = 3;

              var transforms = new TransformGroup();
              child.RenderTransform = transforms;
              rot = sourceCard.Card.Orientation;
              if ((rot & CardOrientation.Rot180) != 0)
              {
            rot180Transform = new RotateTransform(180, child.Width / 2, child.Height / 2);
            transforms.Children.Add(rot180Transform);
              }
              if ((rot & CardOrientation.Rot90) != 0)
              {
            rot90Transform = isCardInverted ?
              new RotateTransform(90, child.Width / 2, child.Width / 2) :
              new RotateTransform(90, child.Width / 2, child.Height - child.Width / 2);
            transforms.Children.Add(rot90Transform);
              }
              translate = new TranslateTransform();
              transforms.Children.Add(translate);

              child.IsHitTestVisible = false;
              child.EndInit();
              AddVisualChild(child);

              DoubleAnimation animation = new DoubleAnimation(0.55, 0.75, new Duration(TimeSpan.FromMilliseconds(500)));
              animation.AutoReverse = true;
              animation.RepeatBehavior = RepeatBehavior.Forever;
              animation.Freeze();

              faceUpBrush.BeginAnimation(Brush.OpacityProperty, animation);
              faceDownBrush.BeginAnimation(Brush.OpacityProperty, animation);
              lightRedBrush.BeginAnimation(Brush.OpacityProperty, animation);
        }
开发者ID:kellyelton,项目名称:octgnwlobby,代码行数:67,代码来源:CardDragAdorner.cs


注:本文中的System.Windows.Media.ImageBrush.BeginAnimation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。