示例#1
0
        public static void DrawPoint(this Canvas canvas, Joint joint, CoordinateMapper mapper)
        {
            if (joint.TrackingState == TrackingState.NotTracked) return;

            Point point = joint.Scale(mapper);

            Ellipse ellipse = new Ellipse
            {
                Width = 20,
                Height = 20,
                Fill = new SolidColorBrush(Colors.Red)
            };

            Canvas.SetLeft(ellipse, point.X - ellipse.Width / 2);
            Canvas.SetTop(ellipse, point.Y - ellipse.Height / 2);

            canvas.Children.Add(ellipse);
        }
示例#2
0
        public static void DrawLine(this Canvas canvas, Joint first, Joint second, CoordinateMapper mapper)
        {
            if (first.TrackingState == TrackingState.NotTracked || second.TrackingState == TrackingState.NotTracked) return;

            Point firstPoint = first.Scale(mapper);
            Point secondPoint = second.Scale(mapper);

            Line line = new Line
            {
                X1 = firstPoint.X,
                Y1 = firstPoint.Y,
                X2 = secondPoint.X,
                Y2 = secondPoint.Y,
                StrokeThickness = 8,
                Stroke = new SolidColorBrush(Colors.Red)
            };

            canvas.Children.Add(line);
        }
示例#3
0
        public static void DrawHand(this Canvas canvas, Joint hand, CoordinateMapper mapper)
        {
            if (hand.TrackingState == TrackingState.NotTracked) return;

            Point point = hand.Scale(mapper);

            Ellipse ellipse = new Ellipse
            {
                Width = 100,
                Height = 100,
                Stroke = new SolidColorBrush(Colors.Red),
                StrokeThickness = 7 //4
            };

            Canvas.SetLeft(ellipse, point.X - ellipse.Width / 2);
            Canvas.SetTop(ellipse, point.Y - ellipse.Height / 2);

            canvas.Children.Add(ellipse);
        }
示例#4
0
        public static void DrawThumb(this Canvas canvas, Joint thumb, CoordinateMapper mapper)
        {
            if (thumb.TrackingState == TrackingState.NotTracked) return;

            Point point = thumb.Scale(mapper);

            Ellipse ellipse = new Ellipse
            {
                Width = 40,
                Height = 40,
                Fill = new SolidColorBrush(Colors.LightBlue),
                Opacity = 0.7
            };

            Canvas.SetLeft(ellipse, point.X - ellipse.Width / 2);
            Canvas.SetTop(ellipse, point.Y - ellipse.Height / 2);

            canvas.Children.Add(ellipse);
        }
        //kalibrierung
        void CheckInitialConditions(Joint head){            
		    if (head.Position.Z > 1.1 && head.Position.Z < 1.31){

                Point headPoint = head.Scale(_sensor.CoordinateMapper);
			    Point invisibleHeadPoint = canvas.PointFromScreen(InvisibleHead.PointToScreen(new Point()));

			    invisibleHeadPoint.X = (float)(invisibleHeadPoint.X + InvisibleHead.Width / 2);
			    invisibleHeadPoint.Y = (float)(invisibleHeadPoint.Y + InvisibleHead.Height / 2);

			    double distance = Math.Sqrt(
				    Math.Pow(
					    headPoint.X > invisibleHeadPoint.X ?
					    invisibleHeadPoint.X - headPoint.X :
					    headPoint.X - invisibleHeadPoint.X
				    , 2)
				     +
				    Math.Pow(
					    headPoint.Y > invisibleHeadPoint.Y ?
					    invisibleHeadPoint.Y - headPoint.Y :
					    headPoint.Y - invisibleHeadPoint.Y
				    , 2)
			    );

			    if (distance < 61){
				    pink.Visibility = System.Windows.Visibility.Hidden;
				    green.Visibility = System.Windows.Visibility.Visible;

				    if (countdownIsStored){
				        int elapsed =  5 - countdown.Elapsed.Seconds;

				        Countdown.Text = elapsed.ToString();

				        if (elapsed < 1){
					        countdown.Reset();
					        countdown.Start();

					        Countdown.Text = "STAAAART";

					        green.Visibility = System.Windows.Visibility.Hidden;
					        

					        actualState = GameState.ShowStart;
				        }
				    } 
				    else{
		                countdown.Reset();
				        countdown.Start();
				        countdownIsStored = true;
				    }
			    }
			    else{
				    countdownIsStored = false;

				    pink.Visibility = System.Windows.Visibility.Visible;
				    green.Visibility = System.Windows.Visibility.Hidden;

				    Countdown.Text = "Depth is OK";
			    }

		    }
		    else{
			    if (head.Position.Z < 1.1)
			        Countdown.Text = "Back!!!!";
			    else
			        Countdown.Text = "Forwardddd!!!!";

			    countdownIsStored = false;

			    pink.Visibility = System.Windows.Visibility.Visible;
			    green.Visibility = System.Windows.Visibility.Hidden;
		    }
        }