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

TestProject.zip
0.01MB

▶ AnimationType.cs

namespace TestProject
{
    /// <summary>
    /// 애니메이션 타입
    /// </summary>
    public enum AnimationType
    {
        /// <summary>
        /// None
        /// </summary>
        None = 0,

        /// <summary>
        /// Random
        /// </summary>
        Random,

        /// <summary>
        /// Scale In
        /// </summary>
        ScaleIn,

        /// <summary>
        /// Scale Out
        /// </summary>
        ScaleOut,

        /// <summary>
        /// Scale Vertical
        /// </summary>
        ScaleVertical,

        /// <summary>
        /// Scale Horizontal
        /// </summary>
        ScaleHorizontal,

        /// <summary>
        /// Rotate Clockwise
        /// </summary>
        RotateClockwise,

        /// <summary>
        /// Rotate Counter Clockwise
        /// </summary>
        RotateCounterClockwise,

        /// <summary>
        /// Slide Right
        /// </summary>
        SlideRight,

        /// <summary>
        /// Slide Left
        /// </summary>
        SlideLeft,

        /// <summary>
        /// Slide Top
        /// </summary>
        SlideTop,

        /// <summary>
        /// Slide Bottom
        /// </summary>
        SlideBottom,

        /// <summary>
        /// Fade
        /// </summary>
        Fade,

        /// <summary>
        /// Twist
        /// </summary>
        Twist,

        /// <summary>
        /// Skew 1
        /// </summary>
        Skew1,

        /// <summary>
        /// Skew 2
        /// </summary>
        Skew2,

        /// <summary>
        /// Skew 3
        /// </summary>
        Skew3,

        /// <summary>
        /// Skew 4
        /// </summary>
        Skew4,

        /// <summary>
        /// Flip
        /// </summary>
        Flip
    }
}

 

728x90

 

▶ AnimationMessageControl.xaml

<UserControl x:Class="TestProject.AnimationMessageControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Focusable="True"
    IsHitTestVisible="False"
    Opacity="0">
    <UserControl.Resources>
        <Storyboard x:Key="Reset">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>

        <Storyboard x:Key="NoneIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                BeginTime="00:00:00"
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="ScaleInIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="0.0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="0.00" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="ScaleOutIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="10.0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="10.00" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="ScaleHorizontalIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="0.00" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="ScaleVerticalIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="0.00" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="RotateClockwiseIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                BeginTime="00:00:00"
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="-45" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="RotateCounterClockwiseIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="45" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="SlideLeftIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="-2000" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.197 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="SlideTopIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="-2000" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.197 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="SlideRightIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="2000" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.197 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="SlideBottomIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="2000" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.197 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="FadeIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                BeginTime="00:00:00"
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="TwistIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="-20" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="0.5" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="0.05" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="-200" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="-100" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Skew1In"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="70" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Skew2In"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="-70" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Skew3In"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                BeginTime="00:00:00"
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="70" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Skew4In"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="-70" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="FlipIn"
            Completed="showStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="70" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="0"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"    Value="0.00" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.35" Value="1"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>

        <Storyboard x:Key="NoneOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="ScaleInOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0.0"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0.0"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="ScaleOutOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="10.0"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="10.0"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="ScaleHorizontalOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0.0"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="ScaleVerticalOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0.0"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="RotateClockwiseOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                BeginTime="00:00:00"
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="45"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="RotateCounterClockwiseOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                BeginTime="00:00:00"
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="-45"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="SlideLeftOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="-2000"
                    KeySpline="0 0 1 0" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="SlideTopOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="-2000"
                    KeySpline="0 0 1 0" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="SlideRightOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="2000"
                    KeySpline="0 0 1 0" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="SlideBottomOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="2000"
                    KeySpline="0 0 1 0" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="FadeOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="TwistOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="30"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0.5"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0.05"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="200"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"         Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="-100"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Skew1Out"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="70"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Skew2Out"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="-70"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Skew3Out"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="70"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Skew4Out"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="-70"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="FlipOut"
            Completed="hideStoryboard_Completed">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="{x:Null}"
                Storyboard.TargetProperty="(UIElement.Opacity)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="70"
                    KeySpline="0 0 0.505 1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetName="canvas"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:00"   Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0.0"
                    KeySpline="0.5 0 1 1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>
    <Grid Background="Transparent">
        <Rectangle Name="blockRectangle"
            Stroke="Black"
            Fill="Black"
            Opacity="0.5" />
        <Canvas Name="canvas"
            Background="{x:Null}"
            RenderTransformOrigin="0.5 0.5">
            <Canvas.RenderTransform>
                <TransformGroup>
                    <ScaleTransform x:Name="ScalingTransform"
                        ScaleX="1"
                        ScaleY="1" />
                    <SkewTransform x:Name="SkewingTransform"
                        AngleX="0"
                        AngleY="0" />
                    <RotateTransform x:Name="RotatingTransform"
                        Angle="0" />
                    <TranslateTransform x:Name="TranslatingTransform"
                        X="0"
                        Y="0" />
                </TransformGroup>
            </Canvas.RenderTransform>
        </Canvas>
    </Grid>
</UserControl>

 

300x250

 

▶ AnimationMessageControl.xaml.cs

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

namespace TestProject
{
    /// <summary>
    /// 애니메이션 메시지 컨트롤
    /// </summary>
    public partial class AnimationMessageControl : UserControl
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 인스턴스
        /// </summary>
        private static AnimationMessageControl _instance;

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Instance
        //////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 소스 엘리먼트
        /// </summary>
        private FrameworkElement sourceElement;

        /// <summary>
        /// 비화성화 엘리먼트
        /// </summary>
        private FrameworkElement disableElement;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Public

        #region 인스턴스 - Instance

        /// <summary>
        /// 인스턴스
        /// </summary>
        public static AnimationMessageControl Instance
        {
            get
            {
                return _instance;
            }
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Instance
        //////////////////////////////////////////////////////////////////////////////// Public

        #region 배경 불투명도 - BackgroundOpacity

        /// <summary>
        /// 배경 불투명도
        /// </summary>
        public double BackgroundOpacity
        {
            set
            {
                this.blockRectangle.Opacity = value;
            }
        }

        #endregion
        #region 애니메이션 타입 - AnimationType

        /// <summary>
        /// 애니메이션 타입
        /// </summary>
        public AnimationType AnimationType { get; set; }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Static

        #region 생성자 - AnimationMessageControl()

        /// <summary>
        /// 생성자
        /// </summary>
        static AnimationMessageControl()
        {
            _instance = new AnimationMessageControl();
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Instance
        //////////////////////////////////////////////////////////////////////////////// Protected

        #region 생성자 - AnimationMessageControl()

        /// <summary>
        /// 생성자
        /// </summary>
        protected AnimationMessageControl()
        {
            InitializeComponent();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public
        //////////////////////////////////////////////////////////////////////////////// Function

        #region 초기화하기 - Initialize(parentPanel, disablePanel)

        /// <summary>
        /// 초기화하기
        /// </summary>
        /// <param name="parentPanel">부모 패널</param>
        /// <param name="disablePanel">비활성화 패널</param>
        public void Initialize(Panel parentPanel, Panel disablePanel)
        {
            Panel parent = parentPanel;

            parent.Children.Add(this);

            this.disableElement = disablePanel;
        }

        #endregion
        #region 표시하기 - Show(sourceElement, animationType)

        /// <summary>
        /// 표시하기
        /// </summary>
        /// <param name="sourceElement">소스 엘리먼트</param>
        /// <param name="animationType">애니메이션 타입</param>
        public void Show(FrameworkElement sourceElement, AnimationType animationType)
        {
            this.sourceElement = sourceElement;

            this.canvas.Width  = this.sourceElement.Width;
            this.canvas.Height = this.sourceElement.Height;

            this.canvas.Children.Clear();

            this.canvas.Children.Add(this.sourceElement);

            IsHitTestVisible = true;

            if(this.disableElement != null)
            {
                this.disableElement.IsEnabled = false;
            }

            ExecuteShowAnimation(animationType);

            this.sourceElement.Focus();
        }

        #endregion
        #region 표시하기 - Show(sourceElement)

        /// <summary>
        /// 표시하기
        /// </summary>
        /// <param name="sourceElement">소스 엘리먼트</param>
        public void Show(FrameworkElement sourceElement)
        {
            Show(sourceElement, AnimationType);
        }

        #endregion
        #region 숨기기 - Hide(animationType)

        /// <summary>
        /// 숨기기
        /// </summary>
        /// <param name="animationType">애니메이션 타입</param>
        public void Hide(AnimationType animationType)
        {
            if(this.disableElement != null)
            {
                this.disableElement.IsEnabled = true;
            }

            IsHitTestVisible = false;

            ExecuteHideAnimation(animationType);
        }

        #endregion
        #region 숨기기 - Hide()

        /// <summary>
        /// 숨기기
        /// </summary>
        public void Hide()
        {
            Hide(AnimationType);
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

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

        /// <summary>
        /// 표시하기 스토리보드 완료시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void showStoryboard_Completed(object sender, EventArgs e)
        {
            if(this.sourceElement != null)
            {
                this.sourceElement.Focus();
            }
        }

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

        /// <summary>
        /// 숨기기 스토리보드 완료시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void hideStoryboard_Completed(object sender, EventArgs e)
        {
            this.sourceElement = null;

            this.canvas.Children.Clear();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 애니메이션 실행하기 - ExecuteAnimation(resourceKey)

        /// <summary>
        /// 애니메이션 실행하기
        /// </summary>
        /// <param name="resourceKey">리소스 키</param>
        private void ExecuteAnimation(string resourceKey)
        {
            Storyboard storyboard = Resources[resourceKey] as Storyboard;

            storyboard.Begin(this);
        }

        #endregion
        #region 변환 리셋하기 - ResetTransformation()

        /// <summary>
        /// 변환 리셋하기
        /// </summary>
        private void ResetTransformation()
        {
            ExecuteAnimation("Reset");
        }

        #endregion
        #region 임의 애니메이션 타입 구하기 - GetRandomAnimationType()

        /// <summary>
        /// 임의 애니메이션 타입 구하기
        /// </summary>
        /// <returns>애니메이션 타입</returns>
        private static AnimationType GetRandomAnimationType()
        {
            return (AnimationType)(new Random().Next(1, Enum.GetValues(typeof(AnimationType)).Length - 1));
        }

        #endregion
        #region 표시하기 애니메이션 실행하기 - ExecuteShowAnimation(animationType)

        /// <summary>
        /// 표시하기 애니메이션 실행하기
        /// </summary>
        /// <param name="animationType">애니메이션 타입</param>
        private void ExecuteShowAnimation(AnimationType animationType)
        {
            ResetTransformation();

            if(animationType == AnimationType.Random)
            {
                ExecuteShowAnimation(GetRandomAnimationType());
            }
            else
            {
                ExecuteAnimation(animationType.ToString() + "In");
            }
        }

        #endregion
        #region 숨기기 애니메이션 실행하기 - ExecuteHideAnimation(animationType)

        /// <summary>
        /// 숨기기 애니메이션 실행하기
        /// </summary>
        /// <param name="animationType">애니메이션 타입</param>
        private void ExecuteHideAnimation(AnimationType animationType)
        {
            ResetTransformation();

            if(animationType == AnimationType.Random)
            {
                ExecuteHideAnimation(GetRandomAnimationType());
            }
            else
            {
                ExecuteAnimation(animationType.ToString() + "Out");
            }
        }

        #endregion
    }
}

 

▶ PopupControl.xaml

<UserControl x:Class="TestProject.PopupControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="500"
    Height="300"
    Background="White"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <Button Name="closeButton"
            Width="150"
            Height="30"
            IsDefault="True"
            IsCancel="True"
            Content="닫기" />
        <Border
            Margin="5"
            BorderThickness="2"
            BorderBrush="DarkGray" />
    </Grid>
</UserControl>

 

▶ PopupControl.xaml.cs

using System.Windows;
using System.Windows.Controls;

namespace TestProject
{
    /// <summary>
    /// 팝업 컨트롤
    /// </summary>
    public partial class PopupControl : UserControl
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - PopupControl()

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

            Loaded                 += UserControl_Loaded;
            this.closeButton.Click += closeButton_Click;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 사용자 컨트롤 로드시 처리하기 - UserControl_Loaded(sender, e)

        /// <summary>
        /// 사용자 컨트롤 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.closeButton.Focus();
        }

        #endregion
        #region 닫기 버튼 클릭시 처리하기 - closeButton_Click(sender, e)

        /// <summary>
        /// 닫기 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void closeButton_Click(object sender, RoutedEventArgs e)
        {
            AnimationMessageControl.Instance.Hide();
        }

        #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 Name="rootGrid">
        <Border
            Margin="5"
            BorderThickness="2"
            BorderBrush="DarkGray" />
        <Grid Name="contentGrid">
            <StackPanel
                HorizontalAlignment="Center"
                VerticalAlignment="Center">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="10"   />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10"   />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10"   />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Grid.Column="0"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Center"
                        Text="배경 불투명도" />
                    <Slider Name="backgroundOpacitySlider" Grid.Row="0" Grid.Column="2"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center"
                        Width="300"
                        Height="25"
                        Minimum="0"
                        Maximum="1.0"
                        Value="0.5" />
                    <TextBlock Grid.Row="2" Grid.Column="0"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Center"
                        Text="애니메이션 타입" />
                    <ComboBox Name="animationTypeComboBox" Grid.Row="2" Grid.Column="2"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center"
                        Width="150"
                        Height="25"
                        VerticalContentAlignment="Center"
                        SelectedIndex="1"
                        SelectionChanged="animationTypeComboBox_SelectionChanged">
                        <ComboBox.Items>
                            <ComboBoxItem Content="None"                   />
                            <ComboBoxItem Content="Random"                 />
                            <ComboBoxItem Content="ScaleIn"                />
                            <ComboBoxItem Content="ScaleOut"               />
                            <ComboBoxItem Content="ScaleHorizontal"        />
                            <ComboBoxItem Content="ScaleVertical"          />
                            <ComboBoxItem Content="RotateClockwise"        />
                            <ComboBoxItem Content="RotateCounterClockwise" />
                            <ComboBoxItem Content="SlideLeft"              />
                            <ComboBoxItem Content="SlideTop"               />
                            <ComboBoxItem Content="SlideRight"             />
                            <ComboBoxItem Content="SlideBottom"            />
                            <ComboBoxItem Content="Fade"                   />
                            <ComboBoxItem Content="Twist"                  />
                            <ComboBoxItem Content="Skew1"                  />
                            <ComboBoxItem Content="Skew2"                  />
                            <ComboBoxItem Content="Skew3"                  />
                            <ComboBoxItem Content="Skew4"                  />
                            <ComboBoxItem Content="Flip"                   />
                        </ComboBox.Items>
                    </ComboBox>
                    <Button Name="showButton" Grid.Row="4" Grid.Column="2"
                        HorizontalAlignment="Left"
                        Width="100"
                        Height="30"
                        Content="표시하기" />
                </Grid>
            </StackPanel>
        </Grid>
    </Grid>
</Window>

 

▶ MainWindow.xaml.cs

using System;
using System.Windows;
using System.Windows.Controls;

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

        #region 생성자 - MainWindow()

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

            Loaded                                      += Window_Loaded;
            this.backgroundOpacitySlider.ValueChanged   += backgroundOpacitySlider_ValueChanged;
            this.animationTypeComboBox.SelectionChanged += animationTypeComboBox_SelectionChanged;
            this.showButton.Click                       += showButton_Click;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 윈도우 로드시 처리하기 - Window_Loaded(sender, e)

        /// <summary>
        /// 윈도우 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            AnimationMessageControl.Instance.Initialize(this.rootGrid, this.contentGrid);
        }

        #endregion
        #region 배경 불투명도 슬라이더 값 변경시 처리하기 - backgroundOpacitySlider_ValueChanged(sender, e)

        /// <summary>
        /// 배경 불투명도 슬라이더 값 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void backgroundOpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            AnimationMessageControl.Instance.BackgroundOpacity = e.NewValue;
        }

        #endregion
        #region 애니메이션 타입 콤보 박스 선택 변경시 처리하기 - animationTypeComboBox_SelectionChanged(sender, e)

        /// <summary>
        /// 애니메이션 타입 콤보 박스 선택 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void animationTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string value = (this.animationTypeComboBox.SelectedItem as ComboBoxItem).Content.ToString();

            AnimationType animationType = (AnimationType)Enum.Parse(typeof(AnimationType), value);

            AnimationMessageControl.Instance.AnimationType = animationType;
        }

        #endregion
        #region 표시하기 버튼 클릭시 처리하기 - showButton_Click(sender, e)

        /// <summary>
        /// 표시하기 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void showButton_Click(object sender, RoutedEventArgs e)
        {
            PopupControl control = new PopupControl();

            AnimationMessageControl.Instance.Show(control);
        }

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

댓글을 달아 주세요