첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ AnimationBase.cs

using System;
using System.Windows;
using System.Windows.Media.Animation;

namespace TestProject
{
    /// <summary>
    /// 애니메이션 베이스
    /// </summary>
    public abstract class AnimationBase
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Declaration
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region Event

        /// <summary>
        /// 완료시
        /// </summary>
        public event EventHandler Completed;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 타겟 엘리먼트 - TargetElement

        /// <summary>
        /// 타겟 엘리먼트
        /// </summary>
        public UIElement TargetElement
        {
            get;
            set;
        }

        #endregion
        #region 스토리보드 - Storyboard

        /// <summary>
        /// 스토리보드
        /// </summary>
        public Storyboard Storyboard
        {
            get;
            set;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - AnimationBase(targetUIElement)

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="targetUIElement">타겟 UIElement</param>
        public AnimationBase(UIElement targetUIElement)
        {
            TargetElement = targetUIElement ?? throw new NullReferenceException("pTargetUIElement이 null 입니다.");

            Storyboard = new Storyboard();

            Storyboard.Completed += new EventHandler(Storyboard_Completed);

            Storyboard.SetTarget(Storyboard, TargetElement);

            SetAnimation();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 애니메이션 설정하기 - SetAnimation()

        /// <summary>
        /// 애니메이션 설정하기
        /// </summary>
        public abstract void SetAnimation();

        #endregion
        #region 시작하기 - Begin()

        /// <summary>
        /// 시작하기
        /// </summary>
        public virtual void Begin()
        {
            Storyboard.Begin();
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Privae

        #region 스토리보드 완료시 처리하기 - Storyboard_Completed(sender, e)

        /// <summary>
        /// 스토리보드 완료시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Storyboard_Completed(object sender, EventArgs e)
        {
            Completed?.Invoke(sender, e);
        }

        #endregion
    }
}

 

728x90

 

▶ Animaitor.cs

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media.Animation;

namespace TestProject
{
    /// <summary>
    /// 애니메이터
    /// </summary>
    public class Animaitor
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 시작 시간 - BeginTime

        /// <summary>
        /// 시작 시간
        /// </summary>
        public TimeSpan? BeginTime
        {
            get;
            set;
        }

        #endregion
        #region 지속 시간 - Duration

        /// <summary>
        /// 지속 시간
        /// </summary>
        public Duration Duration
        {
            get;
            set;
        }

        #endregion
        #region 속도 비율 - SpeedRatio

        /// <summary>
        /// 속도 비율
        /// </summary>
        public double SpeedRatio
        {
            get;
            set;
        }

        #endregion
        #region 반복 행동 - RepeatBehavior

        /// <summary>
        /// 반복 행동
        /// </summary>
        public RepeatBehavior RepeatBehavior
        {
            get;
            set;
        }

        #endregion
        #region 자동 되돌리기 - AutoReverse

        /// <summary>
        /// 자동 되돌리기
        /// </summary>
        public bool AutoReverse
        {
            get;
            set;
        }

        #endregion
        #region 채우기 행동 - FillBehavior

        /// <summary>
        /// 채우기 행동
        /// </summary>
        public FillBehavior FillBehavior
        {
            get;
            set;
        }

        #endregion
        #region 애니메이션 베이스 리스트 - AnimationBaseList

        /// <summary>
        /// 애니메이션 베이스 리스트
        /// </summary>
        public List<AnimationBase> AnimationBaseList
        {
            get;
            set;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - Animaitor()

        /// <summary>
        /// 생성자
        /// </summary>
        public Animaitor()
        {
            SpeedRatio        = 1;
            RepeatBehavior    = new RepeatBehavior(1);
            AnimationBaseList = new List<AnimationBase>();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 시작하기 - Begin()

        /// <summary>
        /// 시작하기
        /// </summary>
        public void Begin()
        {
            foreach(AnimationBase animationBase in AnimationBaseList)
            {
                SetValue(animationBase);
            }

            foreach(AnimationBase animationBase in AnimationBaseList)
            {
                animationBase.Begin();
            }
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 값 설정하기 - SetValue(animationBase)

        /// <summary>
        /// 값 설정하기
        /// </summary>
        /// <param name="animationBase">애니메이션 베이스</param>
        private void SetValue(AnimationBase animationBase)
        {
            animationBase.Storyboard.BeginTime      = BeginTime;
            animationBase.Storyboard.Duration       = Duration;
            animationBase.Storyboard.SpeedRatio     = SpeedRatio;
            animationBase.Storyboard.RepeatBehavior = RepeatBehavior;
            animationBase.Storyboard.AutoReverse    = AutoReverse;
            animationBase.Storyboard.FillBehavior   = FillBehavior;
        }

        #endregion
    }
}

 

300x250

 

▶ OpacityAnimation.cs

using System.Windows;
using System.Windows.Media.Animation;

namespace TestProject
{
    /// <summary>
    /// 투명 애니메이션
    /// </summary>
    public class OpacityAnimation : AnimationBase
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 애니메이션 - Animation

        /// <summary>
        /// 애니메이션
        /// </summary>
        public DoubleAnimation Animation
        {
            get;
            set;
        }

        #endregion
        #region 시작 - From

        /// <summary>
        /// 시작
        /// </summary>
        public double? From
        {
            get;
            set;
        }

        #endregion
        #region 종료 - To

        /// <summary>
        /// 종료
        /// </summary>
        public double? To
        {
            get;
            set;
        }

        #endregion
        #region 지속 시간 - Duration

        /// <summary>
        /// 지속 시간
        /// </summary>
        public Duration Duration
        {
            get;
            set;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - OpacityAnimation(targetUIElement)

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="targetUIElement">타겟 UIElement</param>
        public OpacityAnimation(UIElement targetUIElement) : base(targetUIElement) 
        {
            From = null;
            To   = 0;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 애니메이션 설정하기 - SetAnimation()

        /// <summary>
        /// 애니메이션 설정하기
        /// </summary>
        public override void SetAnimation()
        {
            Animation = new DoubleAnimation();

            Storyboard.SetTargetProperty(Animation, new PropertyPath("(UIElement.Opacity)"));
 
            Storyboard.Children.Add(Animation);
        }

        #endregion
        #region 시작하기 - Begin()

        /// <summary>
        /// 시작하기
        /// </summary>
        public override void Begin()
        {
            Animation.From     = From;
            Animation.To       = To;
            Animation.Duration = Duration;

            base.Begin();
        }

        #endregion
    }
}

 

▶ RotateAnimation.cs

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace TestProject
{
    /// <summary>
    /// 회전 애니메이션
    /// </summary>
    public class RotateAnimation : AnimationBase
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 애니메이션 - Animation

        /// <summary>
        /// 애니메이션
        /// </summary>
        public DoubleAnimation Animation
        {
            get;
            set;
        }

        #endregion
        #region 시작 - From

        /// <summary>
        /// 시작
        /// </summary>
        public double? From
        {
            get;
            set;
        }

        #endregion
        #region 종료 - To

        /// <summary>
        /// 종료
        /// </summary>
        public double? To
        {
            get;
            set;
        }

        #endregion
        #region 지속 시간 - Duration

        /// <summary>
        /// 지속 시간
        /// </summary>
        public Duration Duration
        {
            get;
            set;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - RotateAnimation(targetUIElement)

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="targetUIElement">타겟 UI 요소</param>
        public RotateAnimation(UIElement targetUIElement) : base(targetUIElement) 
        {
            From = null;
            To   = 0;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 애니메이션 설정하기 - SetAnimation()

        /// <summary>
        /// 애니메이션 설정하기
        /// </summary>
        public override void SetAnimation()
        {
            Animation = new DoubleAnimation();

            if(TargetElement.RenderTransform is TransformGroup)
            {
                int index = -1;

                foreach(Transform transform in (TargetElement.RenderTransform as TransformGroup).Children)
                {
                    index++;

                    if(transform is RotateTransform)
                    {
                        Storyboard.SetTargetProperty
                        (
                            Animation,
                            new PropertyPath
                            (
                                string.Format
                                (
                                    "(UIElement.RenderTransform).(TransformGroup.Children)[{0}].(RotateTransform.Angle)",
                                    index
                                )
                            )
                        );

                        break;
                    }
                }
            }
            else
            {
                if(!(TargetElement.RenderTransform is RotateTransform))
                {
                    throw new NullReferenceException("RotateTransform 객체를 찾을 수 없습니다.");
                }

                Storyboard.SetTargetProperty
                (
                    Animation,
                    new PropertyPath("(UIElement.RenderTransform).(RotateTransform.Angle)")
                );
            }

            Storyboard.Children.Add(Animation);
        }

        #endregion
        #region 시작하기 - Begin()

        /// <summary>
        /// 시작하기
        /// </summary>
        public override void Begin()
        {
            Animation.From     = From;
            Animation.To       = To;
            Animation.Duration = Duration;

            base.Begin();
        }

        #endregion
    }
}

 

▶ ScaleAnimation.cs

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace TestProject
{
    /// <summary>
    /// 스케일 애니메이션
    /// </summary>
    public class ScaleAnimation : AnimationBase
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 배율 X 애니메이션 - ScaleXAnimation

        /// <summary>
        /// 배율 X 애니메이션
        /// </summary>
        public DoubleAnimation ScaleXAnimation
        {
            get;
            set;
        }

        #endregion
        #region 배율 Y 애니메이션 - ScaleYAnimation

        /// <summary>
        /// 배율 Y 애니메이션
        /// </summary>
        public DoubleAnimation ScaleYAnimation
        {
            get;
            set;
        }

        #endregion
        #region 배율 X 시작 - ScaleXFrom

        /// <summary>
        /// 배율 X 시작
        /// </summary>
        public double? ScaleXFrom
        {
            get;
            set;
        }

        #endregion
        #region 배율 X 종료 - ScaleXTo

        /// <summary>
        /// 배율 X 종료
        /// </summary>
        public double? ScaleXTo
        {
            get;
            set;
        }

        #endregion
        #region 배율 Y 시작 - ScaleYFrom

        /// <summary>
        /// 배율 Y 시작
        /// </summary>
        public double? ScaleYFrom
        {
            get;
            set;
        }

        #endregion
        #region 배율 Y 종료 - ScaleYTo

        /// <summary>
        /// 배율 Y 종료
        /// </summary>
        public double? ScaleYTo
        {
            get;
            set;
        }

        #endregion
        #region 지속 시간 - Duration

        /// <summary>
        /// 지속 시간
        /// </summary>
        public Duration Duration
        {
            get;
            set;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - ScaleAnimation(targetUIElement)

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="targetUIElement">타겟 UIElement</param>
        public ScaleAnimation(UIElement targetUIElement) : base(targetUIElement) 
        {
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 애니메이션 설정하기 - SetAnimation()

        /// <summary>
        /// 애니메이션 설정하기
        /// </summary>
        public override void SetAnimation()
        {
            ScaleXAnimation = new DoubleAnimation();
            ScaleYAnimation = new DoubleAnimation();

            if(TargetElement.RenderTransform is TransformGroup)
            {
                int index = -1;

                foreach(Transform transform in (TargetElement.RenderTransform as TransformGroup).Children)
                {
                    index++;

                    if(transform is ScaleTransform)
                    {
                        Storyboard.SetTargetProperty
                        (
                            ScaleXAnimation,
                            new PropertyPath
                            (
                                string.Format
                                (
                                    "(UIElement.RenderTransform).(TransformGroup.Children)[{0}].(ScaleTransform.ScaleX)",
                                    index
                                )
                            )
                        );

                        Storyboard.SetTargetProperty
                        (
                            ScaleYAnimation,
                            new PropertyPath
                            (
                                string.Format
                                (
                                    "(UIElement.RenderTransform).(TransformGroup.Children)[{0}].(ScaleTransform.ScaleY)",
                                    index
                                )
                            )
                        );

                        break;
                    }
                }
            }
            else
            {
                if(!(TargetElement.RenderTransform is ScaleTransform))
                {
                    throw new NullReferenceException("ScaleTransform 객체를 찾을 수 없습니다.");
                }

                Storyboard.SetTargetProperty
                (
                    ScaleXAnimation,
                    new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleX)")
                );

                Storyboard.SetTargetProperty
                (
                    ScaleYAnimation,
                    new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleY)")
                );
            }

            Storyboard.Children.Add(ScaleXAnimation);
            Storyboard.Children.Add(ScaleYAnimation);
        }

        #endregion
        #region 시작하기 - Begin()

        /// <summary>
        /// 시작하기
        /// </summary>
        public override void Begin()
        {
            ScaleXAnimation.From     = ScaleXFrom;
            ScaleXAnimation.To       = ScaleXTo;
            ScaleXAnimation.Duration = Duration;

            ScaleYAnimation.From     = ScaleYFrom;
            ScaleYAnimation.To       = ScaleYTo;
            ScaleYAnimation.Duration = Duration;
            
            base.Begin();
        }

        #endregion
    }
}

 

▶ SkewAnimation.cs

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace TestProject
{
    /// <summary>
    /// SKEW 애니메이션
    /// </summary>
    public class SkewAnimation : AnimationBase
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 편향 X 애니메이션 - SkewXAnimation

        /// <summary>
        /// 편향 X 애니메이션
        /// </summary>
        public DoubleAnimation SkewXAnimation
        {
            get;
            set;
        }

        #endregion
        #region 편향 Y 애니메이션 - SkewYAnimation

        /// <summary>
        /// 편향 Y 애니메이션
        /// </summary>
        public DoubleAnimation SkewYAnimation
        {
            get;
            set;
        }

        #endregion
        #region 편향 X 시작 - SkewXFrom

        /// <summary>
        /// 편향 X 시작
        /// </summary>
        public double? SkewXFrom
        {
            get;
            set;
        }

        #endregion
        #region 편향 X 종료 - SkewXTo

        /// <summary>
        /// 편향 X 종료
        /// </summary>
        public double? SkewXTo
        {
            get;
            set;
        }

        #endregion
        #region 편향 Y 시작 - SkewYFrom

        /// <summary>
        /// 편향 Y 시작
        /// </summary>
        public double? SkewYFrom
        {
            get;
            set;
        }

        #endregion
        #region 편향 Y 종료 - SkewYTo

        /// <summary>
        /// 편향 Y 종료
        /// </summary>
        public double? SkewYTo
        {
            get;
            set;
        }

        #endregion
        #region 지속 시간 - Duration

        /// <summary>
        /// 지속 시간
        /// </summary>
        public Duration Duration
        {
            get;
            set;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - SkewAnimation(targetUIElement)

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="targetUIElement">타겟 UIElement</param>
        public SkewAnimation(UIElement targetUIElement) : base(targetUIElement) 
        {
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 애니메이션 설정하기 - SetAnimation()

        /// <summary>
        /// 애니메이션 설정하기
        /// </summary>
        public override void SetAnimation()
        {
            SkewXAnimation = new DoubleAnimation();
            SkewYAnimation = new DoubleAnimation();

            if(TargetElement.RenderTransform is TransformGroup)
            {
                int index = -1;

                foreach(Transform transform in (TargetElement.RenderTransform as TransformGroup).Children)
                {
                    index++;

                    if(transform is SkewTransform)
                    {
                        Storyboard.SetTargetProperty
                        (
                            SkewXAnimation,
                            new PropertyPath
                            (
                                string.Format
                                (
                                    "(UIElement.RenderTransform).(TransformGroup.Children)[{0}].(SkewTransform.AngleX)",
                                    index
                                )
                            )
                        );

                        Storyboard.SetTargetProperty
                        (
                            SkewYAnimation,
                            new PropertyPath
                            (
                                string.Format
                                (
                                    "(UIElement.RenderTransform).(TransformGroup.Children)[{0}].(SkewTransform.AngleY)",
                                    index
                                )
                            )
                        );

                        break;
                    }
                }
            }
            else
            {
                if(!(TargetElement.RenderTransform is SkewTransform))
                {
                    throw new NullReferenceException("SkewTransform 객체를 찾을 수 없습니다.");
                }

                Storyboard.SetTargetProperty
                (
                    SkewXAnimation,
                    new PropertyPath("(UIElement.RenderTransform).(SkewTransform.AngleX)")
                );

                Storyboard.SetTargetProperty
                (
                    SkewYAnimation,
                    new PropertyPath("(UIElement.RenderTransform).(SkewTransform.AngleY)")
                );
            }

            Storyboard.Children.Add(SkewXAnimation);
            Storyboard.Children.Add(SkewYAnimation);
        }

        #endregion
        #region 시작하기 - Begin()

        /// <summary>
        /// 시작하기
        /// </summary>
        public override void Begin()
        {
            SkewXAnimation.From     = SkewXFrom;
            SkewXAnimation.To       = SkewXTo;
            SkewXAnimation.Duration = Duration;

            SkewYAnimation.From     = SkewYFrom;
            SkewYAnimation.To       = SkewYTo;
            SkewYAnimation.Duration = Duration;
            
            base.Begin();
        }

        #endregion
    }
}

 

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="800"
    Height="600"
    Title="애니메이션 사용하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        Width="640"
        Height="480"
        Background="Black">
        <StackPanel
            HorizontalAlignment="Center"
            VerticalAlignment="Top"
            Height="30"
            Orientation="Horizontal">
            <Button Padding="5 0 5 0" Content="투명" Click="opacityButton_Click" />
            <Button Padding="5 0 5 0" Content="회전" Click="rotateButton_Click"  />
            <Button Padding="5 0 5 0" Content="배율" Click="scaleButton_Click"   />
            <Button Padding="5 0 5 0" Content="편향" Click="skewButton_Click"    />
        </StackPanel>
        <Image x:Name="sourceImage"
            Width="200"
            Height="200"
            RenderTransformOrigin="0.5,0.5"
            Source="SilverlightLogo.png" />
    </Grid>
</Window>

 

▶ MainWindow.xaml.cs

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 투명 버튼 클릭시 처리하기 - opacityButton_Click(sender, e)

        /// <summary>
        /// 투명 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void opacityButton_Click(object sender, RoutedEventArgs e)
        {
            OpacityAnimation animation = new OpacityAnimation(this.sourceImage);

            animation.From                    = 1;
            animation.To                      = 0;
            animation.Storyboard.FillBehavior = FillBehavior.Stop;

            animation.Begin();
        }

        #endregion
        #region 회전 버튼 클릭시 처리하기 - rotateButton_Click(sender, e)

        /// <summary>
        /// 회전 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void rotateButton_Click(object sender, RoutedEventArgs e)
        {
            this.sourceImage.RenderTransform       = new RotateTransform();
            this.sourceImage.RenderTransformOrigin = new Point(0.5, 0.5);

            RotateAnimation animation = new RotateAnimation(this.sourceImage);

            animation.Storyboard.FillBehavior = FillBehavior.Stop;
            animation.To                      = 360;

            animation.Begin();
        }

        #endregion
        #region 배율 버튼 클릭시 처리하기 - scaleButton_Click(sender, e)

        /// <summary>
        /// 배율 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void scaleButton_Click(object sender, RoutedEventArgs e)
        {
            this.sourceImage.RenderTransform = new ScaleTransform();

            ScaleAnimation animation = new ScaleAnimation(this.sourceImage);

            animation.Storyboard.FillBehavior = FillBehavior.Stop;
            animation.ScaleXTo                = 2;

            animation.Begin();
        }

        #endregion
        #region 편향 버튼 클릭시 처리하기 - skewButton_Click(sender, e)

        /// <summary>
        /// 편향 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void skewButton_Click(object sender, RoutedEventArgs e)
        {
            this.sourceImage.RenderTransform = new SkewTransform();

            SkewAnimation animation = new SkewAnimation(this.sourceImage);

            animation.Storyboard.FillBehavior = FillBehavior.Stop;
            animation.SkewXTo                 = 30;

            animation.Begin();
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요