<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 - Discussions by Beginner91</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/Beginner91/Discussions/RSS"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 - Discussions by Beginner91</title>
		<link>http://channel9.msdn.com/Niners/Beginner91/Discussions</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Niners/Beginner91/Discussions</link>
	<language>en</language>
	<pubDate>Tue, 21 May 2013 19:59:15 GMT</pubDate>
	<lastBuildDate>Tue, 21 May 2013 19:59:15 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>0</c9:totalResults>
	<c9:pageCount>0</c9:pageCount>
	<c9:pageSize>0</c9:pageSize>
	<item>
		<title>Tech Off - Mouse Up, Mouse Down through hoverButton of kinect</title>
		<description><![CDATA[<p>Hello Everyone,</p><p>I want implement drag and drop through hoverButton of kinect.</p><p><pre class="brush: text">public partial class MainMenu : UserControl
    {
        private KinectSensor _Kinect;
        private WriteableBitmap _ColorImageBitmap;
        private Int32Rect _ColorImageBitmapRect;
        private int _ColorImageStride;
        private Skeleton[] FrameSkeletons;

        List&lt;Button&gt; buttons;
        static Button selected;

        float handX;
        float handY;

        
        


        public MainMenu()
        {

            InitializeComponent();
            InitializeButtons();

            kinectButton.Click &#43;= new RoutedEventHandler(kinectButton_Click);

            this.Loaded &#43;= (s, e) =&gt; { DiscoverKinectSensor(); };
            this.Unloaded &#43;= (s, e) =&gt; { this.Kinect = null; };

        }

        private void Number3Operator()
        {

            Random random3 = new Random();
            int randomNumber3 = random3.Next(0, 3);

        }

        #region &quot;Hand Gesture&quot;

        //initialize buttons to be checked
        private void InitializeButtons()
        {
            buttons = new List&lt;Button&gt; { GAME1, GAME2, QUIT };
        }
        //raise event for Kinect sensor status changed
        private void DiscoverKinectSensor()
        {
            KinectSensor.KinectSensors.StatusChanged &#43;= KinectSensors_StatusChanged;
            this.Kinect = KinectSensor.KinectSensors.FirstOrDefault(x =&gt; x.Status == KinectStatus.Connected);
        }


        private void KinectSensors_StatusChanged(object sender, StatusChangedEventArgs e)
        {
            switch (e.Status)
            {
                case KinectStatus.Connected:
                    if (this.Kinect == null)
                    {
                        this.Kinect = e.Sensor;
                    }
                    break;
                case KinectStatus.Disconnected:
                    if (this.Kinect == e.Sensor)
                    {
                        this.Kinect = null;
                        this.Kinect = KinectSensor.KinectSensors.FirstOrDefault(x =&gt; x.Status == KinectStatus.Connected);
                        if (this.Kinect == null)
                        {
                            MessageBox.Show(&quot;Sensor Disconnected. Please reconnect to continue.&quot;);
                        }
                    }
                    break;
            }
        }

        public KinectSensor Kinect
        {
            get { return this._Kinect; }
            set
            {
                if (this._Kinect != value)
                {
                    if (this._Kinect != null)
                    {
                        UninitializeKinectSensor(this._Kinect);
                        this._Kinect = null;
                    }
                    if (value != null &amp;&amp; value.Status == KinectStatus.Connected)
                    {
                        this._Kinect = value;
                        InitializeKinectSensor(this._Kinect);
                    }
                }
            }
        }

        private void UninitializeKinectSensor(KinectSensor kinectSensor)
        {
            if (kinectSensor != null)
            {
                kinectSensor.Stop();
                kinectSensor.ColorFrameReady -= Kinect_ColorFrameReady;
                kinectSensor.SkeletonFrameReady -= Kinect_SkeletonFrameReady;
            }
        }

        private void InitializeKinectSensor(KinectSensor kinectSensor)
        {
            if (kinectSensor != null)
            {
                ColorImageStream colorStream = kinectSensor.ColorStream;
                colorStream.Enable();
                this._ColorImageBitmap = new WriteableBitmap(colorStream.FrameWidth, colorStream.FrameHeight,
                    96, 96, PixelFormats.Bgr32, null);
                this._ColorImageBitmapRect = new Int32Rect(0, 0, colorStream.FrameWidth, colorStream.FrameHeight);
                this._ColorImageStride = colorStream.FrameWidth * colorStream.FrameBytesPerPixel;
                videoStream.Source = this._ColorImageBitmap;

                kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters()
                {
                    Correction = 0.5f,
                    JitterRadius = 0.05f,
                    MaxDeviationRadius = 0.04f,
                    Smoothing = 0.5f
                });

                kinectSensor.SkeletonFrameReady &#43;= Kinect_SkeletonFrameReady;
                kinectSensor.ColorFrameReady &#43;= Kinect_ColorFrameReady;
                kinectSensor.Start();
                this.FrameSkeletons = new Skeleton[this.Kinect.SkeletonStream.FrameSkeletonArrayLength];

            }
        }

        private void Kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            using (ColorImageFrame frame = e.OpenColorImageFrame())
            {
                if (frame != null)
                {
                    byte[] pixelData = new byte[frame.PixelDataLength];
                    frame.CopyPixelDataTo(pixelData);
                    this._ColorImageBitmap.WritePixels(this._ColorImageBitmapRect, pixelData,
                        this._ColorImageStride, 0);
                }
            }
        }

        private void Kinect_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (SkeletonFrame frame = e.OpenSkeletonFrame())
            {
                if (frame != null)
                {
                    frame.CopySkeletonDataTo(this.FrameSkeletons);
                    Skeleton skeleton = GetPrimarySkeleton(this.FrameSkeletons);

                    if (skeleton == null)
                    {
                        kinectButton.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        Joint primaryHand = GetPrimaryHand(skeleton);
                        TrackHand(primaryHand);

                    }
                }
            }
        }

        //track and display hand
        private void TrackHand(Joint hand)
        {
            if (hand.TrackingState == JointTrackingState.NotTracked)
            {
                kinectButton.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                kinectButton.Visibility = System.Windows.Visibility.Visible;
                
                //DepthImagePoint point = this.Kinect.MapSkeletonPointToDepth(hand.Position, DepthImageFormat.Resolution640x480Fps30);
                DepthImagePoint point = this.Kinect.CoordinateMapper.MapSkeletonPointToDepthPoint(hand.Position, DepthImageFormat.Resolution640x480Fps30);
                handX = (int)((point.X * LayoutRoot.ActualWidth / this.Kinect.DepthStream.FrameWidth) -
                    (kinectButton.ActualWidth / 2.0));
                handY = (int)((point.Y * LayoutRoot.ActualHeight / this.Kinect.DepthStream.FrameHeight) -
                    (kinectButton.ActualHeight / 2.0));
                Canvas.SetLeft(kinectButton, handX);
                Canvas.SetTop(kinectButton, handY);

                if (isHandOver(kinectButton, buttons)) kinectButton.Hovering();
                else kinectButton.Release();
                if (hand.JointType == JointType.HandRight)
                {
                    kinectButton.ImageSource = &quot;/Images/RightHand.png&quot;;
                    kinectButton.ActiveImageSource = &quot;/Images/RightHand.png&quot;;
                }
                else
                {
                    kinectButton.ImageSource = &quot;/Images/LeftHand.png&quot;;
                    kinectButton.ActiveImageSource = &quot;/Images/LeftHand.png&quot;;
                }
            }
        }

        //detect if hand is overlapping over any button
        private bool isHandOver(FrameworkElement hand, List&lt;Button&gt; buttonslist)
        {
            var handTopLeft = new Point(Canvas.GetLeft(hand), Canvas.GetTop(hand));
            var handX = handTopLeft.X &#43; hand.ActualWidth / 2;
            var handY = handTopLeft.Y &#43; hand.ActualHeight / 2;

            foreach (Button target in buttonslist)
            {
                Point targetTopLeft = new Point(Canvas.GetLeft(target), Canvas.GetTop(target));
                if (handX &gt; targetTopLeft.X &amp;&amp;
                    handX &lt; targetTopLeft.X &#43; target.Width &amp;&amp;
                    handY &gt; targetTopLeft.Y &amp;&amp;
                    handY &lt; targetTopLeft.Y &#43; target.Height)
                {
                    selected = target;
                    return true;
                }
            }
            return false;
        }

        //get the hand closest to the Kinect sensor
        private static Joint GetPrimaryHand(Skeleton skeleton)
        {
            Joint primaryHand = new Joint();
            if (skeleton != null)
            {
                primaryHand = skeleton.Joints[JointType.HandLeft];
                Joint rightHand = skeleton.Joints[JointType.HandRight];
                if (rightHand.TrackingState != JointTrackingState.NotTracked)
                {
                    if (primaryHand.TrackingState == JointTrackingState.NotTracked)
                    {
                        primaryHand = rightHand;
                    }
                    else
                    {
                        if (primaryHand.Position.Z &gt; rightHand.Position.Z)
                        {
                            primaryHand = rightHand;
                        }
                    }
                }
            }
            return primaryHand;
        }

        //get the skeleton closest to the Kinect sensor
        private static Skeleton GetPrimarySkeleton(Skeleton[] skeletons)
        {
            Skeleton skeleton = null;
            if (skeletons != null)
            {
                for (int i = 0; i &lt; skeletons.Length; i&#43;&#43;)
                {
                    if (skeletons[i].TrackingState == SkeletonTrackingState.Tracked)
                    {
                        if (skeleton == null)
                        {
                            skeleton = skeletons[i];
                        }
                        else
                        {
                            if (skeleton.Position.Z &gt; skeletons[i].Position.Z)
                            {
                                skeleton = skeletons[i];
                            }
                        }
                    }
                }
            }
            return skeleton;
        }

        void kinectButton_Click(object sender, RoutedEventArgs e)
        {
            selected.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, selected));
        }</pre></p><p>So far, I've done only click event, but I want to do like drag and drop, you click on a button and drag it, after that you put that button in another label or frame, holding it for 5 seconds, after that you drop it there. How can I do this, can you give me advice?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Mouse-Up-Mouse-Down-through-hoverButton-of-kinect/0692ddf3b797421fa2b4a19d0074c7a8#0692ddf3b797421fa2b4a19d0074c7a8</link>
		<pubDate>Thu, 11 Apr 2013 07:05:10 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Mouse-Up-Mouse-Down-through-hoverButton-of-kinect/0692ddf3b797421fa2b4a19d0074c7a8#0692ddf3b797421fa2b4a19d0074c7a8</guid>
		<dc:creator>Beginner91</dc:creator>
		<slash:comments>1</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Beginner91/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Replacing the key commands such as right, left with kinect gesture</title>
		<description><![CDATA[<p>@<a href="/Forums/TechOff/Replacing-the-key-commands-such-as-right-left-with-kinect-gesture#cebbbcee968324dd39158a12c0117e313">vcazan</a>:Thank you!</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Replacing-the-key-commands-such-as-right-left-with-kinect-gesture/714066fdb0f64f029242a16f0096cea4#714066fdb0f64f029242a16f0096cea4</link>
		<pubDate>Sun, 24 Feb 2013 09:09:04 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Replacing-the-key-commands-such-as-right-left-with-kinect-gesture/714066fdb0f64f029242a16f0096cea4#714066fdb0f64f029242a16f0096cea4</guid>
		<dc:creator>Beginner91</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Beginner91/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Need help with kinect button</title>
		<description><![CDATA[<p>Hello everyone,</p><p>I'm a begiiner in kinect programming, I want to do some educational application like Kineducation ---&gt;&nbsp;<a href="http://www.youtube.com/watch?feature=player_embedded&amp;v=K9_aRpPS5vo">http&#58;&#47;&#47;www.youtube.com&#47;watch&#63;feature&#61;player_embedded&#38;v&#61;K9_aRpPS5vo</a> . How can I drag and drop the button, with the hoverButton of kinect. Help please.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Need-help-with-kinect-button/581deb8667384cd78da1a16f009671dc#581deb8667384cd78da1a16f009671dc</link>
		<pubDate>Sun, 24 Feb 2013 09:07:45 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Need-help-with-kinect-button/581deb8667384cd78da1a16f009671dc#581deb8667384cd78da1a16f009671dc</guid>
		<dc:creator>Beginner91</dc:creator>
		<slash:comments>1</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Beginner91/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Replacing the key commands such as right, left with kinect gesture</title>
		<description><![CDATA[<p>Hello everyone,</p><p>I'm new to kinect, and I want to know, how to replace button commands with gesture motion, for example how can we replace the &quot;w&quot; button with gesture in games, any help will be appreciated.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Replacing-the-key-commands-such-as-right-left-with-kinect-gesture/3c820b431452456c9be0a1220083ad7b#3c820b431452456c9be0a1220083ad7b</link>
		<pubDate>Sun, 09 Dec 2012 07:59:25 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Replacing-the-key-commands-such-as-right-left-with-kinect-gesture/3c820b431452456c9be0a1220083ad7b#3c820b431452456c9be0a1220083ad7b</guid>
		<dc:creator>Beginner91</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Beginner91/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>