Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Kinect Reception

, 12 Jan 2012
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:my="clr-namespace:KinectReception.Controls" 
	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" xmlns:System="clr-namespace:System;assembly=mscorlib"
	xmlns:Nui="clr-namespace:Microsoft.Research.Kinect.Nui;assembly=Microsoft.Research.Kinect"
        xmlns:Enums="clr-namespace:KinectReception.Enums" mc:Ignorable="d"
	x:Class="KinectReception.Controls.KinectSettings"
	x:Name="UserControl" Height="501" Width="600" Loaded="UserControlLoaded" WindowStyle="None" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" AllowsTransparency="True" Background="{x:Null}" KeyDown="UserControlKeyDown">

    <Window.Resources>
        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}" x:Key="JointIDs">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="Nui:JointID"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}" x:Key="VecList">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="Enums:Vectors"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}" x:Key="OpList">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="Enums:Operators"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}" x:Key="Resolutions">
        <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="Nui:ImageResolution"/>
        </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}" x:Key="Stretchs">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="Stretch"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
                      
        <Storyboard x:Key="Load">
        	<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="border">
        		<EasingDoubleKeyFrame KeyTime="0" Value="10"/>
        		<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="501"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Window.Resources>
	<Window.Triggers>
		<EventTrigger RoutedEvent="FrameworkElement.Loaded">
			<BeginStoryboard Storyboard="{StaticResource Load}"/>
		</EventTrigger>
	</Window.Triggers>
    <Border x:Name="border" BorderThickness="5" BorderBrush="Black" CornerRadius="15" Height="10" HorizontalAlignment="Left" Width="600">
    	<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 HorizontalAlignment="Left">
            <Grid.RowDefinitions>
                <RowDefinition Height="129" />
                <RowDefinition Height="204*" />
                <RowDefinition Height="20*" />
            </Grid.RowDefinitions>
            <Button x:Name="btnKinectStatus" Content="Start"  Height="100" Style="{DynamicResource CustomButton}" VerticalAlignment="Top" FontFamily="Segoe WP" FontSize="18" Click="BtnKinectStatusClick" Foreground="White" Margin="234,6,0,0" Cursor="Hand" HorizontalAlignment="Left" Width="100">
                <Button.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="{Binding KinectButtonColor, Mode=TwoWay, Source={x:Static Properties:Settings.Default}}" Offset="0"/>
                        <GradientStop Color="{Binding KinectButtonColorOnline, Mode=TwoWay, Source={x:Static Properties:Settings.Default}}" Offset="1"/>
                    </LinearGradientBrush>
                </Button.Background>
            </Button>
            <StackPanel Grid.Row="1" CanVerticallyScroll="True" x:Name="Expanders">
                <ScrollViewer IsDeferredScrollingEnabled="False" VerticalScrollBarVisibility="Auto" Height="329">
                	<StackPanel>
                		<Expander Header="Kinect" Height="Auto" Margin="0,6,0,0" x:Name="expanderKinectSettings" VerticalAlignment="Top">
                            <Grid>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="106,6,0,0" SelectedItem="{Binding KinectResolution, Mode=TwoWay, Source={x:Static Properties:Settings.Default}}" Name="comboResolutions" ItemsSource="{Binding Source={StaticResource Resolutions}}" VerticalAlignment="Top" Width="156" />
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,6,0,0" Text="Kinect Resolution:" VerticalAlignment="Top" />
                            </Grid>
                        </Expander>
                		<Expander Header="Camera" Margin="0,6,0,0" x:Name="expanderCamera" VerticalAlignment="Top">
                			<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="Timers" Height="Auto" x:Name="expanderTimersSettings" VerticalAlignment="Top" Margin="0,6,0,0">
                            <Grid>
                                <TextBox HorizontalAlignment="Left" Margin="91,10,0,0" Text="{Binding PreviewTimer, Mode=TwoWay, Source={x:Static Properties:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" Width="143" Height="25" VerticalAlignment="Top" TextAlignment="Center" />
                                <TextBox HorizontalAlignment="Left" Margin="91,41,0,0" Text="{Binding IdleTimer, Mode=TwoWay, Source={x:Static Properties:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" Width="143" Height="25" VerticalAlignment="Top" TextAlignment="Center"/>
                                <TextBox HorizontalAlignment="Left" Margin="91,72,0,0" Text="{Binding SeriousTimer, Mode=TwoWay, Source={x:Static Properties:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" Width="143" Height="25" VerticalAlignment="Top" TextAlignment="Center"/>
                                <TextBlock HorizontalAlignment="Left" Margin="8,72,0,0" Text="Serious Timer:" TextAlignment="Left" Width="84" Height="24" VerticalAlignment="Top" />
                                <TextBlock HorizontalAlignment="Left" Margin="8,44,0,0" Text="Idle Timer:" TextAlignment="Left" Width="84" Height="24" VerticalAlignment="Top" />
                                <TextBlock HorizontalAlignment="Left" Margin="8,13,0,0" Text="Camera Timer:" TextAlignment="Left" Width="84" Height="24" VerticalAlignment="Top" />
                            </Grid>
                        </Expander>
                        <Expander Header="Pictures" Height="Auto" x:Name="expanderPhotosSettings" VerticalAlignment="Top" 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">
                			<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="62,62,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,61,6,0" x:Name="btnBrowseVideos" VerticalAlignment="Top" Width="46" Click="BtnBrowseVideosClick" />

                				<TextBox Height="23" HorizontalAlignment="Left" Margin="62,91,0,0" x:Name="txtVideosLibLeave" Text="{Binding VideosLibraryOutFile, 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,90,6,0" x:Name="btnBrowseVideosLeave" VerticalAlignment="Top" Width="46" Click="BtnBrowseVideosLeaveClick" />
                				<TextBlock Height="23" HorizontalAlignment="Left" Margin="8,94,0,0" Text="Out:" TextAlignment="Left" VerticalAlignment="Top" Width="50.667" />

                				<TextBox HorizontalAlignment="Left" Margin="62,121,0,0" x:Name="txtVideosLibEnter" Text="{Binding VideosLibraryInFile, Mode=OneWay, Source={x:Static Properties:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" Width="435.333" IsReadOnly="True" Height="23" VerticalAlignment="Top" />
                				<Button Content="Browse" Height="23" HorizontalAlignment="Right" Margin="0,120,6,0" x:Name="btnBrowseVideosEnter" VerticalAlignment="Top" Width="46" Click="BtnBrowseVideosEnterClick" />
                				<TextBlock Height="23" HorizontalAlignment="Left" Margin="8,124,0,0" Text="In:" TextAlignment="Left" VerticalAlignment="Top" Width="50.667" />
                				<TextBlock HorizontalAlignment="Left" Margin="8,65,0,0"  Text="Videos:" TextAlignment="Left" Width="50.667" Height="23" VerticalAlignment="Top" d:LayoutOverrides="VerticalAlignment" />
                                <ComboBox Height="23" HorizontalAlignment="Left" SelectedItem="{Binding Source={x:Static Properties:Settings.Default}, Path=VideoStretch, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource Stretchs}}" Margin="62,33,0,0" Name="comboVideoStretch" VerticalAlignment="Top" Width="120" />
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="8,33,0,0" Text="Stretch:" VerticalAlignment="Top" />
                            </Grid>
                		</Expander>
                		<Expander Header="Rules" Margin="0,6,0,0" x:Name="expanderRulesSettings" VerticalAlignment="Top">
                            <Grid>
                            	<Grid.ColumnDefinitions>
                            		<ColumnDefinition/>
                            		<ColumnDefinition Width="74.5"/>
                            	</Grid.ColumnDefinitions>
                            	<Grid.RowDefinitions>
                            		<RowDefinition Height="0.297*"/>
                            		<RowDefinition Height="0.703*"/>
                            	</Grid.RowDefinitions>
                                <ListView x:Name="ListRules" ItemsSource="{Binding}" Margin="2.5,2.667,4.663,4" Grid.Row="1" Grid.ColumnSpan="2">
                                    <ListView.View>
                                        <GridView>
                                            <GridViewColumn Header="Source Joint" Width="130">
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <ComboBox Margin="0,0,5,0" Width="110" x:Name="Source" SelectedItem="{Binding Source}" SelectionChanged="SourceSelectionChanged" ItemsSource="{Binding Source={StaticResource JointIDs}}" />
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Vector" Width="60">
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <ComboBox Margin="0,0,5,0" Width="40" x:Name="SourceVector" SelectedItem="{Binding SourceVector}" ItemsSource="{Binding Source={StaticResource VecList}}" HorizontalAlignment="Center" />
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Operator" Width="82">
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <ComboBox Margin="0,0,5,0" Width="65" x:Name="Operator" SelectedItem="{Binding Operator}" ItemsSource="{Binding Source={StaticResource OpList}}" />
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Target Joint" Width="130" >
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <ComboBox Margin="0,0,5,0" Width="110" x:Name="Target" SelectedItem="{Binding Target}" SelectionChanged="TargetSelectionChanged" ItemsSource="{Binding Source={StaticResource JointIDs}}" />
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Vector" Width="60">
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <ComboBox Margin="0,0,5,0" Width="40" x:Name="TargetVector" SelectedItem="{Binding TargetVector}" ItemsSource="{Binding Source={StaticResource VecList}}" HorizontalAlignment="Center"/>
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Score" Width="50">
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <TextBox Width="30" Margin="0,0,5,0" Text="{Binding Score}" x:Name="Score" TextAlignment="Center"/>
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Width="30">
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Button Content="X" x:Name="btnDelete" Click="BtnDeleteClick" Tag="{Binding .}"/>
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                        </GridView>
                                    </ListView.View>
                                </ListView>
                                <TextBox x:Name="txtGoal" Text="{Binding Goal, Mode=TwoWay, Source={x:Static Properties:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" Margin="41.5,4.331,0,5.002" HorizontalAlignment="Left" Width="48.167" />
                                <TextBlock HorizontalAlignment="Left" x:Name="textBlock4" Text="Goal:" Margin="8,7.331,0,2.002" Width="29.5" />
                                <Label Content="Add" HorizontalAlignment="Right" Margin="0,2.331,8,2.002" Name="lblAdd" Foreground="Blue" Cursor="Hand" MouseLeftButtonDown="LblAddMouseLeftButtonDown" />
                                <Label Content="Help" Margin="3.243,2.331,0,2.002" x:Name="lblHelp" Foreground="Blue" Cursor="Hand" MouseLeftButtonDown="LblHelpMouseLeftButtonDown" Grid.Column="1" HorizontalAlignment="Left" />
                            </Grid>
                        </Expander>
                	</StackPanel>
                </ScrollViewer>
            </StackPanel>
            <TextBlock Height="23" Margin="18,108,0,0" Name="txtStatus" Text="N/A" VerticalAlignment="Top" TextAlignment="Center" HorizontalAlignment="Left" Width="533" Grid.RowSpan="2" />
            <Label Content="Developed By Shai Raiten (http://tinyurl.com/shai-rai)" Margin="149.47,0,0,0" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
            <Image Height="25" HorizontalAlignment="Left" Margin="559,6,0,0" Name="btnClose" Stretch="Fill" VerticalAlignment="Top" Width="25" Source="/KinectReception;component/Images/close.png" Cursor="Hand" MouseLeftButtonDown="BtnCloseMouseLeftButtonDown" />
            <Image Cursor="Hand" Height="25" HorizontalAlignment="Left" Margin="6,6,0,0" Name="btnSave" Source="/KinectReception;component/Images/save.png" Stretch="Fill" VerticalAlignment="Top" Width="25" MouseLeftButtonDown="BtnSaveMouseLeftButtonDown" />
            <my:VitruvianManControl x:Name="VitruvianMan" Margin="605,-3.5,-495,0" d:LayoutOverrides="GridBox" VerticalAlignment="Top" Height="480" Grid.RowSpan="3"/>
        </Grid>
    </Border>
</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)

About the Author

Shai Raiten
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/
Follow on   Twitter

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 12 Jan 2012
Article Copyright 2011 by Shai Raiten
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid