Click here to Skip to main content
15,885,244 members
Articles / Desktop Programming / WPF

Kinect Reception

Rate me:
Please Sign up or sign in to vote.
4.94/5 (34 votes)
12 Jan 2012Ms-PL5 min read 68.2K   2K   80  
TV Screen in the Reception, When nothing happens (no one is in the reception) we can display videos on the screen but when someone enters the frame show him the Kinect Image, and if the user is doing something funny, capture his image and save it.
<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="KinectReception.MainWindow"
	x:Name="Window"
	Title="Kinect"
	Width="1147" Height="692" WindowStyle="None" WindowState="Maximized" WindowStartupLocation="CenterScreen" Loaded="WindowLoaded" Closed="WindowClosed"
        xmlns:Controls="clr-namespace:KinectReception.Controls"
        xmlns:Properties="clr-namespace:KinectReception.Properties"
        xmlns:converters="clr-namespace:KinectReception.Converters" KeyDown="WindowKeyDown">
	<Window.Resources>
        <converters:IBoolToVisibleConverter x:Key="BoolToVisibleConverter" />
        
		<ControlTemplate x:Key="SettingsButtonControlTemplate" TargetType="{x:Type Button}">
			<ControlTemplate.Resources>
				<Storyboard x:Key="OnMouseEnter1">
					<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="ellipse">
						<EasingColorKeyFrame KeyTime="0:0:0.5" Value="#FF88FF00"/>
					</ColorAnimationUsingKeyFrames>
				</Storyboard>
				<Storyboard x:Key="OnMouseLeave1">
					<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="ellipse">
						<EasingColorKeyFrame KeyTime="0" Value="#FF42FF00"/>
						<EasingColorKeyFrame KeyTime="0:0:0.5" Value="Red"/>
					</ColorAnimationUsingKeyFrames>
				</Storyboard>
			</ControlTemplate.Resources>
			<Grid Margin="0,0,4.833,0">
				<Ellipse x:Name="ellipse" Margin="0" Stroke="Black" HorizontalAlignment="Left" Width="50">
					<Ellipse.Fill>
						<RadialGradientBrush>
                            <GradientStop Color="Black" Offset="0"/>
                            <GradientStop Color="Red" Offset="1"/>
						</RadialGradientBrush>
					</Ellipse.Fill>
				</Ellipse>
			</Grid>
			<ControlTemplate.Triggers>
				<EventTrigger RoutedEvent="Mouse.MouseLeave">
					<BeginStoryboard x:Name="OnMouseLeave1_BeginStoryboard" Storyboard="{StaticResource OnMouseLeave1}"/>
				</EventTrigger>
				<EventTrigger RoutedEvent="Mouse.MouseEnter">
					<BeginStoryboard Storyboard="{StaticResource OnMouseEnter1}"/>
				</EventTrigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
		<Storyboard x:Key="OnMouseEnter1">
			<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="button">
				<EasingColorKeyFrame KeyTime="0" Value="White"/>
				<EasingColorKeyFrame KeyTime="0:0:0.3" Value="#FF42FF00"/>
			</ColorAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="button">
				<EasingDoubleKeyFrame KeyTime="0" Value="30"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="60"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="button">
				<EasingDoubleKeyFrame KeyTime="0" Value="30"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="60"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="image">
				<EasingDoubleKeyFrame KeyTime="0" Value="15"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="35"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="image">
				<EasingDoubleKeyFrame KeyTime="0" Value="15"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="35"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Storyboard x:Key="OnMouseLeave1">
			<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="button">
				<EasingColorKeyFrame KeyTime="0" Value="#FF42FF00"/>
				<EasingColorKeyFrame KeyTime="0:0:0.3" Value="White"/>
			</ColorAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="button">
				<EasingDoubleKeyFrame KeyTime="0" Value="60"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="30"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="button">
				<EasingDoubleKeyFrame KeyTime="0" Value="60"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="30"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="image">
				<EasingDoubleKeyFrame KeyTime="0" Value="35"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="15"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="image">
				<EasingDoubleKeyFrame KeyTime="0" Value="35"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="15"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
	</Window.Resources>
	<Window.Triggers>
		<EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="button">
			<BeginStoryboard x:Name="OnMouseEnter1_BeginStoryboard" Storyboard="{StaticResource OnMouseEnter1}"/>
		</EventTrigger>
		<EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="button">
			<BeginStoryboard x:Name="OnMouseLeave1_BeginStoryboard" Storyboard="{StaticResource OnMouseLeave1}"/>
		</EventTrigger>
	</Window.Triggers>

    <Grid x:Name="LayoutRoot">
        <Image x:Name="KinectImage" Stretch="Fill" Visibility="{Binding IsPlaying,Converter={StaticResource BoolToVisibleConverter}}" HorizontalAlignment="Center" Width="Auto" d:LayoutOverrides="GridBox" />
        <MediaElement x:Name="VideoPreview" Stretch="{Binding Source={x:Static Properties:Settings.Default}, Path=VideoStretch}" Visibility="{Binding ShowVideo,Converter={StaticResource BoolToVisibleConverter}}" />
        <Button x:Name="button"  Height="30" Style="{StaticResource CustomButton}" VerticalAlignment="Bottom" FontFamily="Segoe WP" Click="BtnSettingsClick" FontSize="18" HorizontalAlignment="Left" Width="30" Foreground="White" d:LayoutOverrides="HorizontalAlignment, VerticalAlignment">
        	<Button.Background>
        		<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="White" Offset="1"/>
        		</LinearGradientBrush>
        	</Button.Background>
            <Button.Content>
                <Image x:Name="image" Source="/KinectReception;component/Images/settings.png" Stretch="Uniform" Width="15" Height="15" />
            </Button.Content>
        </Button>

        <Label Content="Developed By Shai Raiten (http://tinyurl.com/shai-rai)" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="297"/>
        <Controls:IndicatorControl Height="100" HorizontalAlignment="Right" x:Name="indicatorControl" VerticalAlignment="Top" Width="100" Visibility="{Binding ShowindicatorControl,Converter={StaticResource BoolToVisibleConverter}}"  />
        
        <TextBlock Height="68" HorizontalAlignment="Left" Margin="46,0,0,0" Name="txtCount" Text="TextBlock" VerticalAlignment="Bottom" Width="241" FontSize="48" Visibility="Hidden" />
        <ProgressBar x:Name="ScoreProgressBar" Maximum="{Binding Source={x:Static Properties:Settings.Default}, Path=Goal}" HorizontalAlignment="Right" Margin="0,12,8,25.96" Width="49" Visibility="{Binding IsPlaying,Converter={StaticResource BoolToVisibleConverter}}" Orientation="Vertical" Value="0" Foreground="#FF0004FF"/>

        <Controls:CameraView Height="Auto" HorizontalAlignment="Center" Margin="0" x:Name="cameraView" VerticalAlignment="Center" Width="Auto" Visibility="Hidden" />
    </Grid>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Architect Sela
Israel Israel
Shai Raiten is VS ALM MVP, currently working for Sela Group as a ALM senior consultant and trainer specializes in Microsoft technologies especially Team System and .NET technology. He is currently consulting in various enterprises in Israel, planning and analysis Load and performance problems using Team System, building Team System customizations and adjusts ALM processes for enterprises. Shai is known as one of the top Team System experts in Israel. He conducts lectures and workshops for developers\QA and enterprises who want to specialize in Team System.

My Blog: http://blogs.microsoft.co.il/blogs/shair/

Comments and Discussions