■ 3D 큐브 애니메이션 만들기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip


Trackball.cs

 

 

using System.Collections.Generic;

using System.Windows;

using System.Windows.Input;

using System.Windows.Controls;

using System.Windows.Media.Media3D;

 

namespace TestProject

{

    /// <summary>

    /// 트랙볼

    /// </summary>

    public class Trackball

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Field

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

 

        #region Field

 

        /// <summary>

        /// 뷰포트 리스트

        /// </summary>

        private List<Viewport3D> viewportList;

 

        /// <summary>

        /// 이용 가능 여부

        /// </summary>

        private bool enabled;

 

        /// <summary>

        /// 드래그 최초 포인트

        /// </summary>

        private Point dragInitialPoint;

 

        /// <summary>

        /// 회전 쿼터니언

        /// </summary>

        private Quaternion rotateQuaternion;

 

        /// <summary>

        /// 회전 여부

        /// </summary>

        private bool isRotating;

 

        /// <summary>

        /// 스케일링 여부

        /// </summary>

        private bool scaling;

 

        /// <summary>

        /// 회전 델타 쿼터니언

        /// </summary>

        private Quaternion rotateDeltaQuaternion;

 

        /// <summary>

        /// 이동 델타 벡터

        /// </summary>

        private Vector3D translateDeltaVector;

 

        /// <summary>

        /// 이동 벡터

        /// </summary>

        private Vector3D translateVector;

 

        /// <summary>

        /// 스케일

        /// </summary>

        private double scale;

 

        /// <summary>

        /// 스케일 델타

        /// </summary>

        private double scaleDelta;

 

        /// <summary>

        /// 중심 여부

        /// </summary>

        private bool isCentered;

 

        /// <summary>

        /// 중심 벡터

        /// </summary>

        private Vector3D centerVector;

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Property

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 뷰포트 리스트 - ViewportList

 

        /// <summary>

        /// 뷰포트 리스트

        /// </summary>

        public List<Viewport3D> ViewportList

        {

            get

            {

                if(this.viewportList == null)

                {

                    this.viewportList = new List<Viewport3D>();

                }

 

                return this.viewportList;

            }

            set

            {

                this.viewportList = value;

            }

        }

 

        #endregion

        #region 이용 가능 여부 - Enabled

 

        /// <summary>

        /// 이용 가능 여부

        /// </summary>

        public bool Enabled

        {

            get

            {

                return this.enabled && (this.viewportList != null) && (this.viewportList.Count > 0);

            }

            set

            {

                this.enabled = value;

            }

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - Trackball()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public Trackball()

        {

            Reset();

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 접착하기 - Attach(element)

 

        /// <summary>

        /// 접착하기

        /// </summary>

        /// <param name="element">프레임워크 엘리먼트</param>

        public void Attach(FrameworkElement element)

        {

            element.MouseMove            += element_MouseMove;

            element.MouseRightButtonDown += element_MouseRightButtonDown;

            element.MouseRightButtonUp   += element_MouseRightButtonUp;

            element.MouseWheel           += element_MouseWheel;

        }

 

        #endregion

        #region 탈착하기 - Detach(element)

 

        /// <summary>

        /// 탈착하기

        /// </summary>

        /// <param name="element">프레임워크 엘리먼트</param>

        public void Detach(FrameworkElement element)

        {

            element.MouseMove            -= element_MouseMove;

            element.MouseRightButtonDown -= element_MouseRightButtonDown;

            element.MouseRightButtonUp   -= element_MouseRightButtonUp;

            element.MouseWheel           -= element_MouseWheel;

        }

 

        #endregion

 

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

        //////////////////////////////////////////////////////////////////////////////// Event

 

        #region 엘리먼트 마우스 이동시 처리하기 - element_MouseMove(sender, e)

 

        /// <summary>

        /// 엘리먼트 마우스 이동시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void element_MouseMove(object sender, MouseEventArgs e)

        {

            if(!Enabled)

            {

                return;

            }

 

            e.Handled = true;

 

            UIElement element = sender as UIElement;

 

            if(element.IsMouseCaptured)

            {

                Vector delta = this.dragInitialPoint - e.MouseDevice.GetPosition(element);

 

                Vector3D verctor = new Vector3D();

 

                delta /= 2;

 

                Quaternion quaternion = this.rotateQuaternion;

 

                if(this.isRotating == true)

                {

                    Vector3D mouseVector = new Vector3D(delta.X, -delta.Y, 0);

 

                    Vector3D axisVector = Vector3D.CrossProduct(mouseVector, new Vector3D(0, 0, 1));

 

                    double axisVectorLength = axisVector.Length;

 

                    if(axisVectorLength < 0.00001 || this.scaling)

                    {

                        this.rotateDeltaQuaternion = new Quaternion(new Vector3D(0, 0, 1), 0);

                    }

                    else

                    {

                        this.rotateDeltaQuaternion = new Quaternion(axisVector, axisVectorLength);

                    }

 

                    quaternion = this.rotateDeltaQuaternion * this.rotateQuaternion;

                }

                else

                {

                    delta /= 20;

 

                    this.translateDeltaVector.X = delta.X * -1;

                    this.translateDeltaVector.Y = delta.Y;

                }

 

                verctor = this.translateVector + this.translateDeltaVector;

 

                UpdateViewportList(quaternion, this.scale * this.scaleDelta, verctor);

            }

        }

 

        #endregion

        #region 엘리먼트 마우스 오른쪽 버튼 DOWN 처리하기 - element_MouseRightButtonDown(sender, e)

 

        /// <summary>

        /// 엘리먼트 마우스 오른쪽 버튼 DOWN 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void element_MouseRightButtonDown(object sender, MouseButtonEventArgs e)

        {

            if(!Enabled)

            {

                return;

            }

 

            e.Handled = true;

 

            if(Keyboard.IsKeyDown(Key.F1) == true)

            {

                Reset();

 

                return;

            }

 

            UIElement element = sender as UIElement;

 

            this.dragInitialPoint = e.MouseDevice.GetPosition(element);

 

            if(!this.isCentered)

            {

                ProjectionCamera camera = (ProjectionCamera)this.viewportList[0].Camera;

 

                this.centerVector = camera.LookDirection;

 

                this.isCentered = true;

            }

 

            this.scaling = (e.MiddleButton == MouseButtonState.Pressed);

 

            if(Keyboard.IsKeyDown(Key.Space) == false)

            {

                this.isRotating = true;

            }

            else

            {

                this.isRotating = false;

            }

 

            element.CaptureMouse();

        }

 

        #endregion

        #region 엘리먼트 마우스 오른쪽 버튼 UP 처리하기 - element_MouseRightButtonUp(sender, e)

 

        /// <summary>

        /// 엘리먼트 마우스 오른쪽 버튼 UP 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void element_MouseRightButtonUp(object sender, MouseButtonEventArgs e)

        {

            if(!this.enabled)

            {

                return;

            }

 

            e.Handled = true;

 

            if(this.isRotating == true)

            {

                this.rotateQuaternion = this.rotateDeltaQuaternion * this.rotateQuaternion;

            }

            else

            {

                this.translateVector += this.translateDeltaVector;

 

                this.translateDeltaVector.X = 0;

                this.translateDeltaVector.Y = 0;

            }

 

            UIElement element = sender as UIElement;

 

            element.ReleaseMouseCapture();

        }

 

        #endregion

        #region 엘리먼트 마우스 휠 처리하기 - element_MouseWheel(sender, e)

 

        /// <summary>

        /// 엘리먼트 마우스 휠 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void element_MouseWheel(object sender, MouseWheelEventArgs e)

        {

            e.Handled = true;

 

            this.scaleDelta += (double)((double)e.Delta / (double)1000);

 

            Quaternion quaternion = this.rotateQuaternion;

 

            UpdateViewportList(quaternion, this.scale * this.scaleDelta, this.translateVector);

        }

 

        #endregion

 

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

 

        #region 뷰포트 리스트 업데이트하기 - UpdateViewportList(quaternion, scale, vector)

 

        /// <summary>

        /// 뷰포트 리스트 업데이트하기

        /// </summary>

        /// <param name="quaternion">쿼터니언</param>

        /// <param name="scale">스케일</param>

        /// <param name="vector">벡터</param>

        private void UpdateViewportList(Quaternion quaternion, double scale, Vector3D vector)

        {

            if(this.viewportList != null)

            {

                foreach(Viewport3D viewport in this.viewportList)

                {

                    ModelVisual3D modelVisual = viewport.Children[0] as ModelVisual3D;

 

                    Transform3DGroup transformGroup = modelVisual.Transform as Transform3DGroup;

 

                    ScaleTransform3D groupScaleTransform = transformGroup.Children[0] as ScaleTransform3D;

 

                    RotateTransform3D groupRotateTransform = transformGroup.Children[1] as RotateTransform3D;

 

                    TranslateTransform3D groupTranslateTransform = transformGroup.Children[2] as TranslateTransform3D;

 

                    groupScaleTransform.ScaleX = scale;

                    groupScaleTransform.ScaleY = scale;

                    groupScaleTransform.ScaleZ = scale;

 

                    groupRotateTransform.Rotation = new AxisAngleRotation3D(quaternion.Axis, quaternion.Angle);

 

                    groupTranslateTransform.OffsetX = vector.X;

                    groupTranslateTransform.OffsetY = vector.Y;

                    groupTranslateTransform.OffsetZ = vector.Z;

                }

            }

        }

 

        #endregion

        #region 리셋하기 - Reset()

 

        /// <summary>

        /// 리셋하기

        /// </summary>

        private void Reset()

        {    

            this.rotateQuaternion = new Quaternion (0, 0, 0, 1);

 

            this.scale = 1;

 

            this.translateVector.X = 0;

            this.translateVector.Y = 0;

            this.translateVector.Z = 0;

 

            this.translateDeltaVector.X = 0;

            this.translateDeltaVector.Y = 0;

            this.translateDeltaVector.Z = 0;

 

            this.rotateDeltaQuaternion = Quaternion.Identity;

 

            this.scaleDelta = 1;

 

            UpdateViewportList(this.rotateQuaternion, this.scale, this.translateVector);

        }

 

        #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="3D 큐브 애니메이션 만들기"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Window.Resources>

        <Storyboard x:Key="RotateStoryboardKey">

            <ParallelTimeline

                Storyboard.TargetName="axisAngleRotation"

                Storyboard.TargetProperty="Angle"

                RepeatBehavior="Forever">

                <DoubleAnimation

                    From="0"

                    To="360"

                    Duration="0:0:30" />

            </ParallelTimeline>

        </Storyboard>

        <MeshGeometry3D x:Key="CubeMeshKey"

            TriangleIndices="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35"

            Normals="0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1

                     0 0 1 0 0 1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 1 0 0 1 0 0

                     1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0

                     -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0"

            TextureCoordinates="1 0 1 1 0 1 0 1 0 0 1 0 0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0 1 1

                                1 1 0 1 0 0 1 0 1 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 0 0 1 0 1 1

                                0 1 0 0 1 0 1 0 1 1 0 1"

            Positions="-0.5 -0.5 -0.5 -0.5 0.5 -0.5 0.5 0.5 -0.5 0.5 0.5 -0.5 0.5 -0.5 -0.5

                       -0.5 -0.5 -0.5 -0.5 -0.5 0.5 0.5 -0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5

                       -0.5 0.5 0.5 -0.5 -0.5 0.5 -0.5 -0.5 -0.5 0.5 -0.5 -0.5 0.5 -0.5 0.5

                       0.5 -0.5 0.5 -0.5 -0.5 0.5 -0.5 -0.5 -0.5 0.5 -0.5 -0.5 0.5 0.5 -0.5

                       0.5 0.5 0.5 0.5 0.5 0.5 0.5 -0.5 0.5 0.5 -0.5 -0.5 0.5 0.5 -0.5

                       -0.5 0.5 -0.5 -0.5 0.5 0.5 -0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 -0.5

                       -0.5 0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 0.5 -0.5 -0.5 0.5 -0.5 0.5 0.5

                       -0.5 0.5 -0.5" />

        <Transform3DGroup x:Key="CubeMeshTransformKey1">

            <Transform3DGroup.Children>

                <ScaleTransform3D

                    ScaleX="10"

                    ScaleY="10"

                    ScaleZ="10" />

            </Transform3DGroup.Children>

        </Transform3DGroup>

        <Transform3DGroup x:Key="CubeMeshTransformKey2">

            <Transform3DGroup.Children>

                <ScaleTransform3D ScaleX="12" ScaleY="12" ScaleZ="12" />

            </Transform3DGroup.Children>

        </Transform3DGroup>

    </Window.Resources>

    <Grid Background="Blue">

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="Auto" />

            <ColumnDefinition Width="*"    />

        </Grid.ColumnDefinitions>

        <StackPanel>

            <Button Name="animateButton"

                Margin="10"

                Width="100"

                Height="30"

                Content="애니메이션" />

        </StackPanel>

        <Viewport3D Name="viewport3D" Grid.Row="0" Grid.Column="1"

            Focusable="true"

            ClipToBounds="true">

            <Viewport3D.Camera>

                <PerspectiveCamera

   Position="0 0 3.0"

   LookDirection="0 0 -1"

   UpDirection="0 1 0"

   NearPlaneDistance="0.25"

   FarPlaneDistance="20"

   FieldOfView="60" />

            </Viewport3D.Camera>

            <ModelVisual3D>

                <ModelVisual3D.Transform>

                    <Transform3DGroup>

                        <Transform3DGroup.Children>

                            <Transform3DCollection >

                                <ScaleTransform3D

                                    ScaleX="1"

                                    ScaleY="1"

                                    ScaleZ="1" />

                                <RotateTransform3D>

                                    <RotateTransform3D.Rotation>

                                        <AxisAngleRotation3D

                                            Axis="0 1 0"

                                            Angle="0" />

                                    </RotateTransform3D.Rotation>

                                </RotateTransform3D>

                                <TranslateTransform3D

                                    OffsetX="0"

                                    OffsetY="0"

                                    OffsetZ="0" />

                            </Transform3DCollection>

                        </Transform3DGroup.Children>

                    </Transform3DGroup>

                </ModelVisual3D.Transform>

                <ModelVisual3D.Content>

                    <Model3DGroup >

                        <Model3DGroup.Transform>

                            <Transform3DGroup>

                                <Transform3DGroup.Children>

                                    <Transform3DCollection >

                                        <ScaleTransform3D

                                            ScaleX="0.1"

                                            ScaleY="0.1"

                                            ScaleZ="0.1" />

                                        <RotateTransform3D>

                                            <RotateTransform3D.Rotation>

                                                <AxisAngleRotation3D

                                                    Axis="0 1 0"

                                                    Angle="0" />

                                            </RotateTransform3D.Rotation>

                                        </RotateTransform3D>

                                        <TranslateTransform3D

                                            OffsetX="0"

                                            OffsetY="0"

                                            OffsetZ="0" />

                                    </Transform3DCollection>

                                </Transform3DGroup.Children>

                            </Transform3DGroup>

                        </Model3DGroup.Transform>

                        <Model3DGroup.Children>

                            <Model3DGroup >

                                <Model3DGroup.Transform>

                                    <Transform3DGroup>

                                        <Transform3DGroup.Children>

                                            <Transform3DCollection >

                                                <ScaleTransform3D ScaleX="1" ScaleY="1" ScaleZ="1" />

                                                <RotateTransform3D >

                                                    <RotateTransform3D.Rotation >

                                                        <AxisAngleRotation3D x:Name="axisAngleRotation"

                                                            Axis="1 0 0"

                                                            Angle="0" />

                                                    </RotateTransform3D.Rotation>

                                                </RotateTransform3D>

                                                <TranslateTransform3D

                                                    OffsetX="0"

                                                    OffsetY="0"

                                                    OffsetZ="0" />

                                            </Transform3DCollection>

                                        </Transform3DGroup.Children>

                                    </Transform3DGroup>

                                </Model3DGroup.Transform>

                                <Model3DGroup.Children>

                                    <GeometryModel3D

                                        Transform="{StaticResource CubeMeshTransformKey1}"

                                        Geometry="{StaticResource CubeMeshKey}">

                                        <GeometryModel3D.Material>

                                            <MaterialGroup>

                                                <MaterialGroup.Children>

                                                    <EmissiveMaterial>

                                                        <EmissiveMaterial.Brush>

                                                            <ImageBrush ImageSource="Image\roundcornersheet.png">

                                                                <ImageBrush.Transform>

                                                                    <TransformGroup>

                                                                        <TransformGroup.Children>

                                                                            <RotateTransform

                                                                                CenterX="0.5"

                                                                                CenterY="0.5"

                                                                                Angle="0" />

                                                                        </TransformGroup.Children>

                                                                    </TransformGroup>

                                                                </ImageBrush.Transform>

                                                            </ImageBrush>

                                                        </EmissiveMaterial.Brush>

                                                    </EmissiveMaterial>

                                                </MaterialGroup.Children>

                                            </MaterialGroup>

                                        </GeometryModel3D.Material>

                                        <GeometryModel3D.BackMaterial>

                                            <MaterialGroup>

                                                <MaterialGroup.Children>

                                                    <EmissiveMaterial>

                                                        <EmissiveMaterial.Brush>

                                                            <ImageBrush ImageSource="Image\roundcornersheet.png">

                                                                <ImageBrush.Transform>

                                                                    <TransformGroup>

                                                                        <TransformGroup.Children>

                                                                            <RotateTransform

                                                                                CenterX="0.5"

                                                                                CenterY="0.5"

                                                                                Angle="0" />

                                                                        </TransformGroup.Children>

                                                                    </TransformGroup>

                                                                </ImageBrush.Transform>

                                                            </ImageBrush>

                                                        </EmissiveMaterial.Brush>

                                                    </EmissiveMaterial>

                                                </MaterialGroup.Children>

                                            </MaterialGroup>

                                        </GeometryModel3D.BackMaterial>

                                    </GeometryModel3D>

                                    <GeometryModel3D

                                        Transform="{StaticResource CubeMeshTransformKey2}"

                                        Geometry="{StaticResource CubeMeshKey}">

                                        <GeometryModel3D.Material>

                                            <MaterialGroup>

                                                <MaterialGroup.Children>

                                                    <EmissiveMaterial>

                                                        <EmissiveMaterial.Brush>

                                                            <ImageBrush ImageSource="Image\roundcornersheet.png">

                                                                <ImageBrush.Transform>

                                                                    <TransformGroup>

                                                                        <TransformGroup.Children>

                                                                            <RotateTransform

                                                                                CenterX="0.5"

                                                                                CenterY="0.5"

                                                                                Angle="0" />

                                                                        </TransformGroup.Children>

                                                                    </TransformGroup>

                                                                </ImageBrush.Transform>

                                                            </ImageBrush>

                                                        </EmissiveMaterial.Brush>

                                                    </EmissiveMaterial>

                                                </MaterialGroup.Children>

                                            </MaterialGroup>

                                        </GeometryModel3D.Material>

                                        <GeometryModel3D.BackMaterial>

                                            <MaterialGroup>

                                                <MaterialGroup.Children>

                                                    <EmissiveMaterial>

                                                        <EmissiveMaterial.Brush>

                                                            <ImageBrush ImageSource="Image\roundcornersheet.png">

                                                                <ImageBrush.Transform>

                                                                    <TransformGroup>

                                                                        <TransformGroup.Children>

                                                                            <RotateTransform

                                                                                CenterX="0.5"

                                                                                CenterY="0.5"

                                                                                Angle="0" />

                                                                        </TransformGroup.Children>

                                                                    </TransformGroup>

                                                                </ImageBrush.Transform>

                                                            </ImageBrush>

                                                        </EmissiveMaterial.Brush>

                                                    </EmissiveMaterial>

                                                </MaterialGroup.Children>

                                            </MaterialGroup>

                                        </GeometryModel3D.BackMaterial>

                                    </GeometryModel3D>

                                </Model3DGroup.Children>

                            </Model3DGroup>

                            <Model3DGroup>

                                <Model3DGroup.Children>

                                    <AmbientLight Color="#ffcccccc" />

                                    <DirectionalLight

                                        Color="LightGray"

                                        Direction="-1 -1 -1" />

                                </Model3DGroup.Children>

                            </Model3DGroup>

                        </Model3DGroup.Children>

                    </Model3DGroup>

                </ModelVisual3D.Content>

            </ModelVisual3D>

        </Viewport3D>

    </Grid>

</Window>

 

 

MainWindow.xaml.cs

 

 

using System;

using System.Windows;

using System.Windows.Media.Animation;

 

namespace TestProject

{

    /// <summary>

    /// 메인 윈도우

    /// </summary>

    public partial class MainWindow : Window

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Field

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

 

        #region Field

 

        /// <summary>

        /// 트랙 볼

        /// </summary>

        private Trackball trackball;

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - MainWindow()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainWindow()

        {

            InitializeComponent();

 

            Loaded                   += Window_Loaded;

            this.animateButton.Click += animateButton_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, EventArgs e)

        {

            this.trackball = new Trackball();

 

            this.trackball.Attach(this);

 

            this.trackball.ViewportList.Add(this.viewport3D);

 

            this.trackball.Enabled = true;

        }

 

        #endregion

        #region 애니메이션 버튼 클릭시 처리하기 - animateButton_Click(sender, e)

 

        /// <summary>

        /// 애니메이션 버튼 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void animateButton_Click(object sender, RoutedEventArgs e)

        {

            Storyboard storyboard = (Storyboard)FindResource("RotateStoryboardKey");

 

            BeginStoryboard(storyboard);

        }

 

        #endregion

    }

}

 

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요