첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ ControllableStoryboardAction 엘리먼트 사용하기

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


TestProject.zip



MainWindow.xaml

 

 

<Window x:Class="TestProject.MainWindow"

    Name="window"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Width="800"

    Height="600"

    Title="ControllableStoryboardAction 엘리먼트 사용하기"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <StackPanel

        HorizontalAlignment="Center"

        VerticalAlignment="Center">

        <Canvas

            Width="350"

            Height="200">

            <Rectangle Canvas.Left="150" Canvas.Top="50"

                Fill="Aqua"

                Width="50"

                Height="150"

                Stroke="Black"

                StrokeThickness="4">

                <Rectangle.RenderTransform>

                    <TransformGroup>

                        <RotateTransform x:Name="rotateTransform1"

                            Angle="-90"

                            CenterX="0"

                            CenterY="150" />

                        <RotateTransform x:Name="rotateTransform2"

                            CenterX="50"

                            CenterY="150" />

                    </TransformGroup>

                </Rectangle.RenderTransform>

            </Rectangle>

        </Canvas>

        <StackPanel

            Orientation="Horizontal"

            HorizontalAlignment="Center">

            <Button Name="beginButton" Margin="12" Content="시작"      />

            <Button Name="pauseButton" Margin="12" Content="정지"      />

            <Button Name="resumeButton" Margin="12" Content="재개"     />

            <Button Name="stopButton"   Margin="12" Content="중단"     />

            <Button Name="skipButton"   Margin="12" Content="끝으로"   />

            <Button Name="centerButton" Margin="12" Content="중간으로" />

        </StackPanel>

        <StackPanel.Triggers>

            <EventTrigger SourceName="beginButton" RoutedEvent="Button.Click">

                <BeginStoryboard Name="beginStoryboard">

                    <Storyboard >

                        <DoubleAnimation

                            Storyboard.TargetName="rotateTransform1"

                            Storyboard.TargetProperty="Angle"

                            From="-90"

                            To="0"

                            Duration="0:0:5" />

                        <DoubleAnimation

                            Storyboard.TargetName="rotateTransform2"

                            Storyboard.TargetProperty="Angle"

                            Duration="0:0:5"

                            BeginTime="0:0:5"

                            From="0"

                            To="90" />

                    </Storyboard>

                </BeginStoryboard>

            </EventTrigger>

            <EventTrigger

                SourceName="pauseButton"

                RoutedEvent="Button.Click">

                <PauseStoryboard BeginStoryboardName="beginStoryboard" />

            </EventTrigger>

            <EventTrigger

                SourceName="resumeButton"

                RoutedEvent="Button.Click">

                <ResumeStoryboard BeginStoryboardName="beginStoryboard" />

            </EventTrigger>

            <EventTrigger

                SourceName="stopButton"

                RoutedEvent="Button.Click">

                <StopStoryboard BeginStoryboardName="beginStoryboard" />

            </EventTrigger>

            <EventTrigger

                SourceName="skipButton"

                RoutedEvent="Button.Click">

                <SkipStoryboardToFill BeginStoryboardName="beginStoryboard" />

            </EventTrigger>

            <EventTrigger

                SourceName="centerButton"

                RoutedEvent="Button.Click">

                <SeekStoryboard BeginStoryboardName="beginStoryboard" Offset="0:0:5" />

            </EventTrigger>

        </StackPanel.Triggers>

    </StackPanel>

</Window>

 

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

Posted by 사용자 icodebroker

댓글을 달아 주세요