logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
castg  
#1 Posted : Thursday, September 29, 2016 2:39:46 AM(UTC)
castg

Rank: Newbie

Groups: Registered
Joined: 9/22/2016(UTC)
Posts: 1

Hi! I want to invoke an Animation or a Storyboard from the title's class in a similar way that @doggy did here: http://forums.vmix.com/d...ts&m=14066#post14066
I have a testing title with two rectangles, one white (header) and one red (bg_descuento). Also there are a Textblock for input a Trigger string that toggles the position of red rectangle (for hide or show it).



Code:
<UserControl x:Class="UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:my="clr-namespace:vMixTitleLibrary;assembly=vMixTitleLibrary"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" Width="720" Height="480">
    <UserControl.Resources>
        <Storyboard x:Key="sb_empty">
        	<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="bg_descuento">
        		<SplineDoubleKeyFrame KeyTime="0:0:0.01" Value="0"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="storyboard_leave">
        	<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="bg_descuento">
        		<SplineDoubleKeyFrame KeyTime="0" Value="42"/>
        		<SplineDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="storyboard_enter">
        	<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="bg_descuento">
        		<SplineDoubleKeyFrame KeyTime="0" Value="0"/>
        		<SplineDoubleKeyFrame KeyTime="0:0:1" Value="42"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>
	<UserControl.Triggers>
		<EventTrigger RoutedEvent="FrameworkElement.Loaded">
			<BeginStoryboard x:Name="storyboard_leave_BeginStoryboard" Storyboard="{StaticResource sb_empty}"/>
		</EventTrigger>
	</UserControl.Triggers>
    <Grid Margin="0,0,84,96" Width="720" Height="480">
    	<Rectangle x:Name="bg_descuento" Fill="Red" HorizontalAlignment="Left" Height="36.5" Margin="435.5,33.5,0,0" Stroke="Black" VerticalAlignment="Top" Width="123" StrokeThickness="0" RenderTransformOrigin="0.5,0.5">
    		<Rectangle.RenderTransform>
    			<TransformGroup>
    				<ScaleTransform/>
    				<SkewTransform/>
    				<RotateTransform/>
    				<TranslateTransform/>
    			</TransformGroup>
    		</Rectangle.RenderTransform>
    	</Rectangle>

    	<Rectangle x:Name="header" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="42" Margin="46.5,28,0,0" Stroke="Black" VerticalAlignment="Top" Width="512" RenderTransformOrigin="0.5,0.5" StrokeThickness="0">
    		<Rectangle.RenderTransform>
    			<TransformGroup>
    				<ScaleTransform/>
    				<SkewTransform/>
    				<RotateTransform/>
    				<TranslateTransform/>
    			</TransformGroup>
    		</Rectangle.RenderTransform>
    	</Rectangle>
    	<TextBlock x:Name="_hidden_value" Text="" Margin="0,184,215,77" Background="Red" RenderTransformOrigin="0.5,0.5" Visibility="hidden" >
    		<TextBlock.RenderTransform>
    			<TransformGroup>
    				<ScaleTransform/> 
    				<SkewTransform/>
    				<RotateTransform/>
    				<TranslateTransform/>
    			</TransformGroup>
    		</TextBlock.RenderTransform></TextBlock>
    </Grid>
</UserControl>



And the class:


Code:
Imports System
Imports System.IO
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Media
Imports System.Windows.Media.Animation

Public Class UserControl1 
	Public Sub handler_vmix(ByVal sender As Object, ByVal e As EventArgs) Handles Me.LayoutUpdated
		Dim my_storyboard As Storyboard
		
		if _hidden_value.Text = "cat" then
			my_storyboard = DirectCast(FindResource("storyboard_enter"), Storyboard)
		else
			my_storyboard = DirectCast(FindResource("storyboard_leave"), Storyboard)
		end if
	
		my_storyboard.Begin()
	end sub
End Class




But i can't put it to work correctly.
First, when i Overlay.On the title, the red rectangle "Slide.off", and i want that since the beginning hidden.
Second, the condition works and trigger "something", because the animation never ocurrs but yes toggles the red rectangle.

Sorry my english.
I will thank you your help.

Tomi
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.