Click here to Skip to main content
15,896,501 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 69.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.
<UserControl
	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"
	xmlns:Properties="clr-namespace:KinectReception.Properties" mc:Ignorable="d"
	x:Class="KinectReception.KinectSettings"
	x:Name="UserControl" Height="450" Width="600" Loaded="UserControlLoaded">

    <UserControl.Resources>
        <Style x:Key="FireStyle" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <ControlTemplate.Resources>
                            <Storyboard x:Key="OnClick1"/>
                        </ControlTemplate.Resources>
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Shape.StrokeThickness)">
                                                <EasingDoubleKeyFrame KeyTime="00:00:00.1000000" Value="6"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse1" Storyboard.TargetProperty="(FrameworkElement.Margin)">
                                                <DiscreteObjectKeyFrame KeyTime="00:00:00.1000000">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Thickness>2,2,3,4</Thickness>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse1" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                <EasingDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ellipse1" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>

                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Shape.StrokeThickness)">
                                                <EasingDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>

                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver"/>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused"/>
                                    <VisualState x:Name="Unfocused"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="0.08*"/>
                                <RowDefinition Height="0.84*"/>
                                <RowDefinition Height="0.08*"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0.08*"/>
                                <ColumnDefinition Width="0.84*"/>
                                <ColumnDefinition Width="0.08*"/>
                            </Grid.ColumnDefinitions>
                            <Ellipse Grid.ColumnSpan="3" Grid.RowSpan="3" Margin="1,1,1,1" Stroke="#FF8C8C8C">
                                <Ellipse.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF343434" Offset="0.63"/>
                                        <GradientStop Color="#FFFFFFFF" Offset="0.158"/>
                                        <GradientStop Color="#FFB3B3B3" Offset="1"/>
                                        <GradientStop Color="#FFE0E0E0" Offset="0"/>
                                    </LinearGradientBrush>
                                </Ellipse.Fill>
                            </Ellipse>
                            <Grid Grid.Column="1" Grid.ColumnSpan="1" Grid.Row="1" Grid.RowSpan="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="0.033*"/>
                                    <RowDefinition Height="0.6*"/>
                                    <RowDefinition Height="0.367*"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.114*"/>
                                    <ColumnDefinition Width="0.772*"/>
                                    <ColumnDefinition Width="0.114*"/>
                                </Grid.ColumnDefinitions>
                                <Ellipse StrokeThickness="2" VerticalAlignment="Stretch" Grid.ColumnSpan="3" Grid.RowSpan="3" x:Name="ellipse" Fill="{TemplateBinding Background}">
                                    <Ellipse.Stroke>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FF6A6A6A" Offset="0"/>
                                            <GradientStop Color="#FFFFFFFF" Offset="0.482"/>
                                            <GradientStop Color="#FF515151" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Ellipse.Stroke>
                                </Ellipse>
                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="3" Grid.RowSpan="3"/>
                                <Ellipse Stroke="#FF000000" StrokeThickness="0" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Grid.Column="1" Grid.Row="1" x:Name="ellipse1">
                                    <Ellipse.Fill>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#D8FFFFFF" Offset="0"/>
                                            <GradientStop Color="#15FFFFFF" Offset="0.845"/>
                                        </LinearGradientBrush>
                                    </Ellipse.Fill>
                                </Ellipse>
                            </Grid>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <EventTrigger RoutedEvent="ButtonBase.Click"/>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="FontSize" Value="18.667"/>
        </Style>
    </UserControl.Resources>
    <Border CornerRadius="30" BorderThickness="5" BorderBrush="Black">
    	<Border.Background>
    		<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
    			<GradientStop Color="#FF6C6C6C"/>
    			<GradientStop Color="White" Offset="0.451"/>
    		</LinearGradientBrush>
    	</Border.Background>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="138*" />
                <RowDefinition Height="302*" />
            </Grid.RowDefinitions>
            <Button x:Name="btnKinectStatus" Content="Start"  Height="100" Style="{StaticResource FireStyle}" VerticalAlignment="Top" FontFamily="Segoe WP" FontSize="18" HorizontalAlignment="Left" Width="100" Click="BtnKinectStatusClick" Foreground="White" Margin="245,5,0,0">
                <Button.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="Black" Offset="0"/>
                        <GradientStop Color="#FF71FF00" Offset="1"/>
                    </LinearGradientBrush>
                </Button.Background>
            </Button>
            <StackPanel Grid.Row="1" CanVerticallyScroll="True" x:Name="Expanders" Margin="0,0,0,25.96">
                <ScrollViewer Height="276" IsDeferredScrollingEnabled="False" VerticalScrollBarVisibility="Auto">
                	<StackPanel>
                		<Expander Header="Kinect" Height="Auto" Margin="0,6,0,0" x:Name="expanderKinectSettings" VerticalAlignment="Top" Width="555">
                			<Grid/>
                		</Expander>
                		<Expander Header="Camera" Margin="0,6,0,0" x:Name="expanderCamera" VerticalAlignment="Top" Width="555">
                			<Grid>
                				<TextBlock FontSize="28" HorizontalAlignment="Left" Margin="12,9.001,0,0" x:Name="txtCameraAngle" Text="0" TextAlignment="Center" Width="94" Height="46" VerticalAlignment="Top" />
                				<Image Height="44" HorizontalAlignment="Left" Margin="127,6,0,0" x:Name="BtnAngleUp" Stretch="Fill" VerticalAlignment="Top" Width="34" Source="/KinectReception;component/Images/Up.png" Cursor="Hand" MouseLeftButtonDown="BtnAngleUpMouseLeftButtonDown" />
                				<Image Height="44" HorizontalAlignment="Left" Margin="165,6,0,0" x:Name="BtnAngleDown" Source="/KinectReception;component/Images/down.png" Stretch="Fill" VerticalAlignment="Top" Width="34" Cursor="Hand" MouseLeftButtonDown="BtnAngleDownMouseLeftButtonDown" />
                			</Grid>
                		</Expander>
                		<Expander Header="Pictures" Height="Auto" x:Name="expanderPhotosSettings" VerticalAlignment="Top" Width="555" Margin="0,6,0,0">
                			<Grid>                        
                				<TextBlock HorizontalAlignment="Left" Margin="6,6,0,38"  Text="Please define folder to store all pictures" TextAlignment="Left" Width="247.5" d:LayoutOverrides="HorizontalAlignment" />
                				<TextBox HorizontalAlignment="Left" Margin="6,30,0,8" x:Name="txtPicturesLibPath" Text="{Binding PicturesLibrary, Mode=OneWay, Source={x:Static Properties:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" Width="489" IsReadOnly="True" d:LayoutOverrides="VerticalAlignment" />
                				<Button Content="Browse" Height="23" HorizontalAlignment="Right" Margin="0,30,8,0" x:Name="btnBrowsePictures" VerticalAlignment="Top" Width="46" Click="BtnBrowsePicturesClick" />
                			</Grid>
                		</Expander>
                		<Expander Header="Videos" Height="Auto" Margin="0,6,0,0" x:Name="expanderVideosSettings" VerticalAlignment="Top" Width="555">
                			<Grid>
                				<TextBlock Margin="8,8,8,0"  Text="Please define the location of the Videos and if you have also define Enter and Leave videos" TextAlignment="Left" Height="26" VerticalAlignment="Top" />
                				<TextBox Height="23" HorizontalAlignment="Left" Margin="60.667,38,0,0" Text="{Binding VideosLibraryFolder, Mode=OneWay, Source={x:Static Properties:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" x:Name="txtVideosLibPath" VerticalAlignment="Top" Width="434.333" IsReadOnly="True" d:LayoutOverrides="VerticalAlignment" />
                				<Button Content="Browse" Height="23" HorizontalAlignment="Right" Margin="0,38,6,0" x:Name="btnBrowseVideos" VerticalAlignment="Top" Width="46" Click="BtnBrowseVideosClick" />

                				<TextBox Height="23" HorizontalAlignment="Left" Margin="60.667,65,0,0" x:Name="txtVideosLibLeave" Text="{Binding VideosLibraryLeaveFile, Mode=OneWay, Source={x:Static Properties:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="434.333" IsReadOnly="True" />
                				<Button Content="Browse" Height="23" HorizontalAlignment="Right" Margin="0,65,6,0" x:Name="btnBrowseVideosLeave" VerticalAlignment="Top" Width="46" Click="BtnBrowseVideosLeaveClick" />
                				<TextBlock Height="23" HorizontalAlignment="Left" Margin="6,65,0,0" Text="Leave:" TextAlignment="Left" VerticalAlignment="Top" Width="50.667" />

                				<TextBox HorizontalAlignment="Left" Margin="60.667,92,0,15.015" x:Name="txtVideosLibEnter" Text="{Binding VideosLibraryEnterFile, Mode=OneWay, Source={x:Static Properties:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" Width="435.333" IsReadOnly="True" />
                				<Button Content="Browse" Height="23" HorizontalAlignment="Right" Margin="0,92,6,0" x:Name="btnBrowseVideosEnter" VerticalAlignment="Top" Width="46" Click="BtnBrowseVideosEnterClick" />
                				<TextBlock Height="23" HorizontalAlignment="Left" Margin="6,92,0,0" Text="Enter:" TextAlignment="Left" VerticalAlignment="Top" Width="50.667" />
                				<TextBlock HorizontalAlignment="Left" Margin="6,38,0,0"  Text="Videos:" TextAlignment="Left" Width="50.667" Height="23" VerticalAlignment="Top" d:LayoutOverrides="VerticalAlignment" />
                			</Grid>
                		</Expander>
                		<Expander Header="Sensitivity" Height="Auto" Margin="0,6,0,0" x:Name="expanderSensitivitySettings" VerticalAlignment="Top" Width="555">
                			<Grid/>
                		</Expander>
                	</StackPanel>
                </ScrollViewer>
            </StackPanel>
            <Label Content="X" Height="28" HorizontalAlignment="Right" Margin="0,6,8,0" Name="btnClose" VerticalAlignment="Top" Cursor="Hand" MouseDown="BtnCloseMouseDown" />
            <TextBlock Height="23" Margin="18,0,17,0" Name="txtStatus" Text="N/A" VerticalAlignment="Bottom" TextAlignment="Center" />
            <Label Content="Developed By Shai Raiten (http://tinyurl.com/shai-rai)" Margin="18,0,17,0" Grid.Row="1" VerticalAlignment="Bottom"/>
        </Grid>
    </Border>
</UserControl>

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