Seven animation effects of the WPF series of games (2)

Source: Internet
Author: User

Tags: www. Out ane span hand corn children time duration

Original: The seven animated effects of the WPF series of games (2)

The previous article has animated the Close window icon, which will handle the display and closing effect of the window interface. Since all animations are for the canvas of the window interface, add some Rendertranform properties for it, which do not fill in any effects, and are later provided by storyboard and EventTrigger.

<CanvasName= "Querycanvas"Visibility= "Collapsed"Rendertransformorigin= "0.5,0.5" > <!--transformgroup are defined here --
<Canvas.rendertransform> <TransformGroup> <ScaleTransform></ScaleTransform> <RotateTransform></RotateTransform> </TransformGroup> </Canvas.rendertransform>
<!--Below is the window interface code --<BorderName= "Queryborder"borderthickness= "9"Cornerradius= "9"
Width= "920"Height= "The "Canvas.Left= "Max"Canvas.Top= ">" <ScrollViewerName= "Queryscrollviewer"
scrollviewer.verticalscrollbarvisibility= "Visible" > <StackPanelOrientation= "Vertical" >
<!--I'm the one that closes the window icon, you don't know me! -<ImageSource= "Image/close.png"Name= "Closeimage"Height= " the"Width= " the"Cursor= "Hand"Margin= "5"HorizontalAlignment= "Right" > <Image.tooltip>Close</Image.tooltip> </Image> <GridName= "Querygrid" ></Grid> </StackPanel> </ScrollViewer> </Border></Canvas>

1. Next, add storyboard for the display and close effect in Window.Resources, where Showquerycanvas is the display effect, Closequerycanvas is the off effect. The rendertransform.children[0] and [1] involved in the program are the ScaleTransform and rotatatransform in the resources above.

<window.resources> ...
<Storyboardx:Key= "Showquerycanvas" > <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Opacity" from= "0.2" to= "1"Duration= "0:0:2.5" >
</DoubleAnimation> <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Rendertransform.children[1". Angle " from= "The " to= "0"Duration= "0:0:2" >
</DoubleAnimation> <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Rendertransform.children[0". ScaleX " from= "0" to= "1"Duration= "0:0:2"
AccelerationRatio= "1" >
</DoubleAnimation> <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Rendertransform.children[0". ScaleY " from= "0" to= "1"Duration= "0:0:2"
AccelerationRatio= "1" >
</DoubleAnimation> <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Rendertransform.children[0". ScaleX " to= "0.98"BeginTime= "0:0:2"Duration= "0:0:0.05"
DecelerationRatio= "1" >
</DoubleAnimation> <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Rendertransform.children[0". ScaleY " to= "0.98"BeginTime= "0:0:2"Duration= "0:0:0.05"
DecelerationRatio= "1" >
</DoubleAnimation> <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Rendertransform.children[0". ScaleX " to= "1"BeginTime= "0:0:2.05"Duration= "0:0:0.2"
AccelerationRatio= "1" >
</DoubleAnimation> <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Rendertransform.children[0". ScaleY " to= "1"BeginTime= "0:0:2.05"Duration= "0:0:0.2"
AccelerationRatio= "1" >
</DoubleAnimation> </Storyboard> <Storyboardx:Key= "Closequerycanvas" > <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Rendertransform.children[1". Angle " to= " the"Duration= "0:0:1.5" >
</DoubleAnimation> <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Opacity" to= "0"Duration= "0:0:3" >
</DoubleAnimation> <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Rendertransform.children[0". ScaleX " to= "0"Duration= "0:0:1.5"AccelerationRatio= "1" >
</DoubleAnimation> <DoubleAnimationStoryboard.TargetName= "Querycanvas"Storyboard.TargetProperty= "Rendertransform.children[0". ScaleY " to= "0"Duration= "0:0:1.5"AccelerationRatio= "1" >
</DoubleAnimation> </Storyboard></window.resources>

2. The effect over, will start the event. The close event is already in the previous write to the Close Window icon event, this article only describes the display effect event. The display event is also defined in the window.triggers. In the program below, MyHome, Myshop, Upgradeshop, MYbank are the name values of the four icons above the program.

<window.triggers><!--Close the window icon event is written here -- ... 
< eventtrigger sourcename = "Closeimage" routedevent = "Image.mouseleftbuttondown" > < beginstoryboard name = "Closequerycanvasstoryboard"
storybo ARD = "{ staticresource closequerycanvas }";
</ beginstoryboard > </ eventtrigger >

<!--Here is the Display window event --<EventTriggerSourceName= "MyHome"RoutedEvent= "Image.mouseleftbuttondown" > <BeginStoryboardStoryboard="{StaticResourceShowquerycanvas} "></BeginStoryboard> </EventTrigger> <EventTriggerSourceName= "Myshop"RoutedEvent= "Image.mouseleftbuttondown" > <BeginStoryboardStoryboard="{StaticResourceShowquerycanvas} "></BeginStoryboard> </EventTrigger> <EventTriggerSourceName= "Upgradeshop"RoutedEvent= "Image.mouseleftbuttondown" > <BeginStoryboardStoryboard="{StaticResourceShowquerycanvas} "></BeginStoryboard> </EventTrigger> <EventTriggerSourceName= "MyBank"RoutedEvent= "Image.mouseleftbuttondown" > <BeginStoryboardStoryboard="{StaticResourceShowquerycanvas} "></BeginStoryboard> </EventTrigger></window.triggers>

3. display window effect

4. Close the window effect


Seven animation effects of the WPF series of games (2)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: