Display Annotations with storyboard effect
authorsarias
Fri, 16 Oct 2009 21:37:16 +0200
changeset 163 d5148710e229
parent 162 0b9f989bcb37
child 164 09700eb26702
Display Annotations with storyboard effect
src/FingersDance.Control.Player/UserControlPlayer.xaml
src/FingersDance.Control.Player/UserControlPlayer.xaml.cs
--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml	Fri Oct 16 21:06:25 2009 +0200
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml	Fri Oct 16 21:37:16 2009 +0200
@@ -124,7 +124,43 @@
 				</Style>
 			</Style.BasedOn>
 		</Style>
+		<Storyboard x:Key="Rect1Annotation">
+			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rect1" Storyboard.TargetProperty="(UIElement.Opacity)">
+				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
+				<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1" KeySpline="0,0,0.5,1"/>
+				<SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
+			</DoubleAnimationUsingKeyFrames>
+		</Storyboard>
+		<Storyboard x:Key="Rect2Annotation">
+			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rect2" Storyboard.TargetProperty="(UIElement.Opacity)">
+				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
+				<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1" KeySpline="0,0,0.5,1"/>
+				<SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
+			</DoubleAnimationUsingKeyFrames>
+		</Storyboard>
+		<Storyboard x:Key="Rect3Annotation">
+			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rect3" Storyboard.TargetProperty="(UIElement.Opacity)">
+				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
+				<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
+				<SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
+			</DoubleAnimationUsingKeyFrames>
+		</Storyboard>
+		<Storyboard x:Key="Rect4Annotation">
+			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rect4" Storyboard.TargetProperty="(UIElement.Opacity)">
+				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
+				<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1" KeySpline="0,0,0.5,1"/>
+				<SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
+			</DoubleAnimationUsingKeyFrames>
+		</Storyboard>
 	</UserControl.Resources>
+	<UserControl.Triggers>
+		<EventTrigger RoutedEvent="FrameworkElement.Loaded">
+			<BeginStoryboard Storyboard="{StaticResource Rect1Annotation}"/>
+			<BeginStoryboard Storyboard="{StaticResource Rect2Annotation}"/>
+			<BeginStoryboard Storyboard="{StaticResource Rect3Annotation}"/>
+			<BeginStoryboard Storyboard="{StaticResource Rect4Annotation}"/>
+		</EventTrigger>
+	</UserControl.Triggers>
     <Grid x:Name="LayoutRoot" Width="{Binding ActualWidth, ElementName=UserControl, Mode=Default}" Height="{Binding ActualHeight, ElementName=UserControl, Mode=Default}" Background="{x:Null}">
     	<Viewbox Margin="0,0,0,0" Width="{Binding ActualWidth, ElementName=UserControl, Mode=Default}" Height="{Binding ActualHeight, ElementName=UserControl, Mode=Default}" Stretch="Uniform" AllowDrop="True">
     		<Grid Width="560" Height="400" HorizontalAlignment="Left" x:Name="GridPlayer">
@@ -137,11 +173,11 @@
                                       Style="{DynamicResource FingersDance.Control.PlayerButton}" Margin="0,0,54,0"/>
     			<Custom:SurfaceButton x:Name="Play_Pause_area" ContactDown="ButtonPlayPause_ContactDown" Click="ButtonPlayPause_Click" Foreground="{x:Null}" 
                                       Background="#FFFFFFFF" BorderBrush="{x:Null}" Margin="72,0,126,0" Style="{DynamicResource FingersDance.Control.PlayerButton}" Opacity="0"/>
-    			<StackPanel Opacity="1" HorizontalAlignment="Right" Width="50" Background="#FF0046F6" x:Name="StackPanelAnnotation" VerticalAlignment="Bottom" Height="Auto">
-    				<Rectangle x:Name="rect1" Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
-    				<Rectangle x:Name="rect2" Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
-    				<Rectangle x:Name="rect3" Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
-    				<Rectangle x:Name="rect4" Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000" VerticalAlignment="Bottom"/>
+    			<StackPanel Opacity="1" HorizontalAlignment="Right" Width="50" Background="{x:Null}" x:Name="StackPanelAnnotation" VerticalAlignment="Bottom" Height="Auto">
+    				<Rectangle x:Name="rect1" Width="50" Height="50" Fill="{x:Null}" Stroke="#FF000000"/>
+    				<Rectangle x:Name="rect2" Width="50" Height="50" Fill="{x:Null}" Stroke="#FF000000"/>
+    				<Rectangle x:Name="rect3" Width="50" Height="50" Fill="{x:Null}" Stroke="#FF000000"/>
+    				<Rectangle x:Name="rect4" Width="50" Height="50" Fill="{x:Null}" Stroke="#FF000000" VerticalAlignment="Bottom"/>
     			</StackPanel>
     		</Grid>
     	</Viewbox>
--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs	Fri Oct 16 21:06:25 2009 +0200
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs	Fri Oct 16 21:37:16 2009 +0200
@@ -260,12 +260,26 @@
         //This function Sets a brush in a specific rectangle of the StackPanelAnnotation
         public void displayStackPanelAnnotations(int id, Brush brushAnnotation)
         {
+            Object o = null;
             switch (id)
             {
-                case 1: rect1.Fill = brushAnnotation; break;
-                case 2: rect2.Fill = brushAnnotation; break;
-                case 3: rect3.Fill = brushAnnotation; break;
-                case 4: rect4.Fill = brushAnnotation; break;
+                case 1: 
+                    rect1.Fill = brushAnnotation;
+                    o = rect1.FindResource("Rect1Annotation");
+                    rect1.BeginStoryboard((Storyboard)o);
+                    break;
+                case 2: rect2.Fill = brushAnnotation;
+                    o = rect2.FindResource("Rect2Annotation");
+                    rect2.BeginStoryboard((Storyboard)o);
+                    break;
+                case 3: rect3.Fill = brushAnnotation;
+                    o = rect3.FindResource("Rect3Annotation");
+                    rect3.BeginStoryboard((Storyboard)o);
+                    break;
+                case 4: rect4.Fill = brushAnnotation;
+                    o = rect4.FindResource("Rect4Annotation");
+                    rect4.BeginStoryboard((Storyboard)o);
+                    break;
                 default: break;
             }
         }