• Revista PROGRAMAR: Já está disponível a edição #53 da revista programar. Faz já o download aqui!

nero_lux

Dúvidas com o Competed do StoryBoard

4 mensagens neste tópico

Bom Dia, estou com uma dúvida no meu Window. Como poderão ver no código abaixo associei uma StoryBoard ao meu Window. Basicamente o que a StoryBoard faz é mostrar as labels, textbox etc. com alguna efeitos.

Criei um método sb_Completed (<Storyboard x:Key="Storyboard1" Completed="sb_Completed">) de modo quando a StoryBoard terminasse fosse apresentado uma Messabox dizendo Completado!.

O meu problema é que ele não mostra a StoryBoard toda antes de mostrar a MessageBox, ou seja, não visualiza a label LblMsg e label1.

Será que alguém me consegue ajudar?


<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="GestCalWPF.MainWindow"
x:Name="WinSpa"
Title="MainWindow"
Width="499" Height="351" AllowsTransparency="True" WindowStyle="None" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Background="Transparent" Foreground="Transparent" Opacity="0.915" Visibility="Visible" Loaded="WinSpa_Loaded">
<Window.Resources>
	<Storyboard x:Key="Storyboard1" Completed="sb_Completed">
		<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(Panel.Background).(LinearGradientBrush.StartPoint)">
			<DiscretePointKeyFrame KeyTime="00:00:01" Value="0.24,0.242"/>
		</PointAnimationUsingKeyFrames>
		<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(Panel.Background).(LinearGradientBrush.EndPoint)">
			<DiscretePointKeyFrame KeyTime="00:00:01" Value="0.337,0.225"/>
		</PointAnimationUsingKeyFrames>
		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textBox" Storyboard.TargetProperty="(UIElement.Visibility)">
			<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Hidden}"/>
			<DiscreteObjectKeyFrame KeyTime="00:00:01" Value="{x:Static Visibility.Visible}"/>
			<DiscreteObjectKeyFrame KeyTime="00:00:02" Value="{x:Static Visibility.Visible}"/>
		</ObjectAnimationUsingKeyFrames>
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textBox" Storyboard.TargetProperty="(UIElement.Opacity)">
			<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0.315"/>
			<SplineDoubleKeyFrame KeyTime="00:00:02" Value="1"/>
		</DoubleAnimationUsingKeyFrames>
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textBox" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
			<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
			<SplineDoubleKeyFrame KeyTime="00:00:01" Value="-19.5"/>
			<SplineDoubleKeyFrame KeyTime="00:00:02" Value="-10.2"/>
		</DoubleAnimationUsingKeyFrames>
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textBox" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
			<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
			<SplineDoubleKeyFrame KeyTime="00:00:01" Value="-3"/>
			<SplineDoubleKeyFrame KeyTime="00:00:02" Value="-3"/>
		</DoubleAnimationUsingKeyFrames>
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textBox" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
			<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
			<SplineDoubleKeyFrame KeyTime="00:00:02" Value="1.532"/>
		</DoubleAnimationUsingKeyFrames>
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textBox" Storyboard.TargetProperty="(TextElement.FontSize)">
			<SplineDoubleKeyFrame KeyTime="00:00:01" Value="32"/>
			<SplineDoubleKeyFrame KeyTime="00:00:02" Value="32"/>
		</DoubleAnimationUsingKeyFrames>
		<ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textBox" Storyboard.TargetProperty="(Border.BorderThickness)">
			<SplineThicknessKeyFrame KeyTime="00:00:01" Value="1"/>
			<SplineThicknessKeyFrame KeyTime="00:00:02" Value="0"/>
		</ThicknessAnimationUsingKeyFrames>
		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LblMsg" Storyboard.TargetProperty="(UIElement.Visibility)">
			<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Hidden}"/>
			<DiscreteObjectKeyFrame KeyTime="00:00:03" Value="{x:Static Visibility.Visible}" />
		</ObjectAnimationUsingKeyFrames>
		<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textBox" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)">
			<SplineColorKeyFrame KeyTime="00:00:00" Value="Black"/>
			<SplineColorKeyFrame KeyTime="00:00:01" Value="#FFF4EDED"/>
			<SplineColorKeyFrame KeyTime="00:00:01.5000000" Value="sc#1, 0.8879231, 0.768151164, 0.768151164"/>
			<SplineColorKeyFrame KeyTime="00:00:02" Value="Black"/>
		</ColorAnimationUsingKeyFrames>
		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="label1" Storyboard.TargetProperty="(UIElement.Visibility)">
			<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Hidden}"/>
			<DiscreteObjectKeyFrame KeyTime="00:00:03" Value="{x:Static Visibility.Visible}"/>
		</ObjectAnimationUsingKeyFrames>
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="label1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
			<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
			<SplineDoubleKeyFrame KeyTime="00:00:03" Value="73"/>
		</DoubleAnimationUsingKeyFrames>
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="label1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
			<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
			<SplineDoubleKeyFrame KeyTime="00:00:03" Value="3"/>
		</DoubleAnimationUsingKeyFrames>
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="label1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)">
			<SplineDoubleKeyFrame KeyTime="00:00:00" Value="29"/>
			<SplineDoubleKeyFrame KeyTime="00:00:03" Value="15"/>
		</DoubleAnimationUsingKeyFrames>
		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="label1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
			<SplineDoubleKeyFrame KeyTime="00:00:00" Value="79"/>
			<SplineDoubleKeyFrame KeyTime="00:00:03" Value="83"/>
		</DoubleAnimationUsingKeyFrames>
	</Storyboard>
</Window.Resources>
<Window.ContextMenu>
	<ContextMenu/>
</Window.ContextMenu>
<Window.Triggers>
	<EventTrigger RoutedEvent="FrameworkElement.Loaded">
		<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
	</EventTrigger>
</Window.Triggers>

<Grid x:Name="LayoutRoot" Margin="0,0,-1,1" RenderTransformOrigin="0.5,0.5">
	<Grid.Background>
		<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
			<GradientStop Color="Black" Offset="0"/>
			<GradientStop Color="#FFA6D0F2" Offset="1"/>
			<GradientStop Color="#FFF0F6F6" Offset="0.004"/>
		</LinearGradientBrush>
	</Grid.Background>
	<TextBox x:Name="textBox" HorizontalAlignment="Right" Margin="0,76.5,41.946,0" VerticalAlignment="Top" Text="GESTCAL.NET" TextWrapping="Wrap" Width="273.553" Background="Transparent" FontFamily="Lucida Handwriting" FontSize="32" HorizontalContentAlignment="Center" Opacity="0.315" RenderTransformOrigin="0.5,0.5" BorderThickness="0">
		<TextBox.RenderTransform>
			<TransformGroup>
				<ScaleTransform/>
				<SkewTransform/>
				<RotateTransform/>
				<TranslateTransform/>
			</TransformGroup>
		</TextBox.RenderTransform>
		<TextBox.BorderBrush>
			<LinearGradientBrush EndPoint="0,20" StartPoint="0,0" MappingMode="Absolute">
				<GradientStop Color="#FFABADB3" Offset="0.05"/>
				<GradientStop Color="#FFE2E3EA" Offset="0.07"/>
				<GradientStop Color="Transparent" Offset="1"/>
			</LinearGradientBrush>
		</TextBox.BorderBrush>
	</TextBox>
	<Label x:Name="LblMsg" Margin="176,0,3,4" Content="Verificar  Ficheiro de Configuração..." Foreground="#FFFAF6F6" FontFamily="Arial" FontWeight="Bold" VerticalAlignment="Bottom" Height="24" HorizontalContentAlignment="Right"/>
	<Label x:Name="label1" HorizontalAlignment="Left" Margin="-14,131.5,0,163" Width="156.501" Content="V. BETA" Foreground="#FFFCF6F6" FontFamily="Arial" FontSize="21.333" FontWeight="Bold" RenderTransformOrigin="0.5,0.5" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
		<Label.RenderTransform>
			<TransformGroup>
				<ScaleTransform/>
				<SkewTransform AngleX="29"/>
				<RotateTransform Angle="79"/>
				<TranslateTransform/>
			</TransformGroup>
		</Label.RenderTransform>
	</Label>
	<TextBlock x:Name="textBlock" Margin="203,138,24,56" TextWrapping="Wrap" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Lucida Handwriting" Text="Desenvolviido pelo Departamento de Informática da Armipex (DID)">
		<TextBlock.Background>
			<SolidColorBrush/>
		</TextBlock.Background>
	</TextBlock>
</Grid>
</Window>

0

Partilhar esta mensagem


Link para a mensagem
Partilhar noutros sites

Experimenta por a tua Storyboard com uma Duration de 5 segundos e valida que o completed é só disparado aos 5 segundos. Pode ser que, devido a estar automático, a Storyboard esteja a acabar mais cedo do que devia.

0

Partilhar esta mensagem


Link para a mensagem
Partilhar noutros sites

Desculpa, mas não percebi, queres que em cada "filho" da minha StoryBoard adicione a duração?  :hmm:

0

Partilhar esta mensagem


Link para a mensagem
Partilhar noutros sites

Crie uma conta ou ligue-se para comentar

Só membros podem comentar

Criar nova conta

Registe para ter uma conta na nossa comunidade. É fácil!


Registar nova conta

Entra

Já tem conta? Inicie sessão aqui.


Entrar Agora