public void SetPosition(Joint joint)
        {
            Joint scaledJoint = joint.ScaleTo(1270 - 88, 750 - 38, 0.5f, 0.5f);

            Canvas.SetLeft(this, scaledJoint.Position.X);
            Canvas.SetTop(this, scaledJoint.Position.Y);
        }
Exemplo n.º 2
0
        static private void SetEllipsePosition(Ellipse ellipse, Joint joint)
        {
            var scaledJoint = joint.ScaleTo(1500, 900, k_xMaxJointScale, k_yMaxJointScale);

            Canvas.SetLeft(ellipse, scaledJoint.Position.X - (double)ellipse.GetValue(Canvas.WidthProperty) / 2);
            Canvas.SetTop(ellipse, scaledJoint.Position.Y - (double)ellipse.GetValue(Canvas.WidthProperty) / 2);
            Canvas.SetZIndex(ellipse, (int)Math.Floor(scaledJoint.Position.Z * 100));
            /*if (joint.ID == JointID.HandLeft || joint.ID == JointID.HandRight)
            {
                byte val = (byte)(Math.Floor((joint.Position.Z - 0.8) * 255 / 2));
                ellipse.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(val, val, val));
            }*/
        }
Exemplo n.º 3
0
        public static void DrawPoint(this Canvas canvas, Joint joint)
        {
            if (joint.TrackingState == TrackingState.NotTracked) return;

            joint = joint.ScaleTo(canvas.ActualWidth, canvas.ActualHeight);

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

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

            canvas.Children.Add(ellipse);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Draws an ellipse to the specified joint.
        /// </summary>
        /// <param name="canvas">The Canvas element to draw the ellipse.</param>
        /// <param name="joint">The joint represented by the ellipse.</param>
        /// <param name="color">The desired color for the ellipse.</param>
        /// <param name="radius">The desired length for the ellipse.</param>
        public static void DrawPoint(this Canvas canvas, Joint joint, Color color, double radius)
        {
            if (joint.TrackingState == JointTrackingState.NotTracked) return;

            joint = joint.ScaleTo(canvas.ActualWidth, canvas.ActualHeight);

            Ellipse ellipse = new Ellipse
            {
                Tag = TAG,
                Width = radius,
                Height = radius,
                Fill = new SolidColorBrush(color)
            };

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

            canvas.Children.Add(ellipse);
        }
Exemplo n.º 5
0
        public static void DrawLine(this Canvas canvas, Joint first, Joint second)
        {
            if (first.TrackingState == TrackingState.NotTracked || second.TrackingState == TrackingState.NotTracked) return;

            first = first.ScaleTo(canvas.ActualWidth, canvas.ActualHeight);
            second = second.ScaleTo(canvas.ActualWidth, canvas.ActualHeight);

            Line line = new Line
            {
                X1 = first.Position.X,
                Y1 = first.Position.Y,
                X2 = second.Position.X,
                Y2 = second.Position.Y,
                StrokeThickness = 8,
                Stroke = new SolidColorBrush(Colors.LightBlue)
            };

            canvas.Children.Add(line);
        }
        private JPoint JointLocation(Joint joint)
        {
            JPoint tmp;
            var scaledJoint = joint.ScaleTo(CanvasWidth, CanvasHeight /*, .3f, .3f*/);

            tmp.X = scaledJoint.Position.X;
            tmp.Y = CanvasWidth - scaledJoint.Position.Y;

            return tmp;
        }
Exemplo n.º 7
0
        private void ScalePosition(FrameworkElement element, Joint joint)
        {
            //convert the value to X/Y
            //Joint scaledJoint = joint.ScaleTo(1280, 720);

            //convert & scale (.3 = means 1/3 of joint distance)
            Joint scaledJoint = joint.ScaleTo(1366, 768, RHSensitivity[0], RHSensitivity[1]);
            Canvas.SetLeft(element, scaledJoint.Position.X-element.Width/2 + CursorDisplacement[0]);
            Canvas.SetTop(element, scaledJoint.Position.Y-element.Height/2 + CursorDisplacement[1]);
            textBox.RightPos = (int)scaledJoint.Position.X + " " + (int)scaledJoint.Position.Y + "\n";
            RHPos[0] = scaledJoint.Position.X;
            RHPos[1] = scaledJoint.Position.Y;
        }
        private void ScalePosition(FrameworkElement element, Joint joint)
        {
            //convert the value to X/Y
            //Joint scaledJoint = joint.ScaleTo(1280, 720);

            //convert & scale (.3 = means 1/3 of joint distance)
            Joint scaledJoint = joint.ScaleTo(1280, 720, .3f, .3f);

            Canvas.SetLeft(element, scaledJoint.Position.X);
            Canvas.SetTop(element, scaledJoint.Position.Y);
        }
 // Faire correspondre les gestes aux canvas
 //
 public static Joint scaleCanvas(Joint joint)
 {
     return joint.ScaleTo(610, 523);
 }
Exemplo n.º 10
0
        public void setCursorPosition(HandCursor hand, Joint joint)
        {
            Global.canGesture = false;
            Joint scaledJoint = joint.ScaleTo((int)Global.windowWidth, (int)Global.windowHeight, (float)0.3, (float)0.4);
            if ((scaledJoint.Position.X > radialX + 100 || scaledJoint.Position.X < radialX - 100) &&
                (Math.Abs(scaledJoint.Position.Y - radialY) < Math.Abs(scaledJoint.Position.X - radialX)))
            {
                cursorX = (double)Math.Max(radialX - ActualWidth / 2 + hand.ActualWidth / 2,
                    Math.Min(scaledJoint.Position.X, radialX + ActualWidth / 2 - hand.ActualWidth / 2));
                cursorY = radialY;
                if (cursorX > radialX && (lastHovering != "Right"))
                {
                    stopHovering(lastHovering);
                    lastHovering = "Right";
                    setZindex(lastHovering);
                    startHovering(RadialHighRight, lastHovering);
                }
                else if (cursorX < radialX && (lastHovering != "Left"))
                {
                    stopHovering(lastHovering);
                    lastHovering = "Left";
                    setZindex(lastHovering);
                    startHovering(RadialHighLeft, lastHovering);
                }

            }
            else if ((scaledJoint.Position.Y < radialY - 100 || scaledJoint.Position.Y > radialY + 100) &&
                     (Math.Abs(scaledJoint.Position.Y - radialY) > Math.Abs(scaledJoint.Position.X - radialX)))
            {
                cursorX = radialX;
                cursorY = (double)Math.Max(radialY - ActualHeight / 2 + hand.ActualHeight / 2,
                    Math.Min(scaledJoint.Position.Y, radialY + ActualHeight / 2 - hand.ActualHeight / 2));
                if (cursorY > radialY && (lastHovering != "Bottom"))
                {
                    stopHovering(lastHovering);
                    lastHovering = "Bottom";
                    setZindex(lastHovering);
                    startHovering(RadialHighBottom, lastHovering);
                }
                else if (cursorY < radialY && (lastHovering != "Top"))
                {
                    stopHovering(lastHovering);
                    lastHovering = "Top";
                    setZindex(lastHovering);
                    startHovering(RadialHighTop, lastHovering);
                }

            }
            else
            {
                cursorX = radialX;
                cursorY = radialY;
                stopHovering(lastHovering);
            }
            hand.setCursor(cursorX, cursorY);
        }
Exemplo n.º 11
0
        private void TrackHand2SimulateMouseMove(Joint hand)
        {
            if (hand.TrackingState != JointTrackingState.Tracked)
                return;

            //获得屏幕的宽度和高度
            int screenWidth = (int)SystemParameters.PrimaryScreenWidth;
            int screenHeight = (int)SystemParameters.PrimaryScreenHeight;

            //将部位“手”的骨骼坐标映射为屏幕坐标
            //float posX = joinCursorHand.ScaleTo(screenWidth, screenHeight).Position.X;
            //float posY = joinCursorHand.ScaleTo(screenWidth, screenHeight).Position.Y;

            //将部位“手”的骨骼坐标映射为屏幕坐标;手只需要在有限范围内移动即可覆盖整个屏幕区域
            float posX = hand.ScaleTo(screenWidth, screenHeight, 0.2f, 0.2f).Position.X;
            float posY = hand.ScaleTo(screenWidth, screenHeight, 0.2f, 0.2f).Position.Y;
                        
            Joint scaledCursorJoint = new Joint
            {
                TrackingState = JointTrackingState.Tracked,
                Position = new SkeletonPoint
                {
                    X = posX,
                    Y = posY,
                    Z = hand.Position.Z
                }
            };

            int x = Convert.ToInt32(scaledCursorJoint.Position.X);
            int y = Convert.ToInt32(scaledCursorJoint.Position.Y);

            //MouseToolkit.SetCursorPos(Convert.ToInt32(scaledCursorJoint.Position.X), 
            //    Convert.ToInt32(scaledCursorJoint.Position.Y));

            int mouseX = Convert.ToInt32(x * 65536 / screenWidth);
            int mouseY = Convert.ToInt32(y * 65536 / screenHeight);

            MouseToolkit.mouse_event(MouseToolkit.MouseEventFlag.Absolute | MouseToolkit.MouseEventFlag.Move,
                mouseX, mouseY, 0, 0);

        }
 private Joint ScaleJoint(Joint joint)
 {
     return joint.ScaleTo((int) this.ActualWidth, (int) this.ActualHeight, .4f, .4f);
 }
Exemplo n.º 13
0
        /*Start of playlist functions
         * 
         */

        private void ScalePosition(FrameworkElement element, Joint joint)
        {
            //convert the value to X/Y
            //Joint scaledJoint = joint.ScaleTo(1280, 720); 

            //convert & scale (.3 = means 1/3 of joint distance)
            Joint scaledJoint = joint.ScaleTo(1280, 720, .3f, .3f);

            Canvas.SetLeft(element, scaledJoint.Position.X);
            Canvas.SetTop(element, scaledJoint.Position.Y);
            UIElement covered = null;
            covered = selectComponent(new Point(Canvas.GetLeft(element), Canvas.GetTop(element)));
            if (covered != null) focusElement(covered);
            else
            {
                focusedElement = null;
                focusedElementBorder.Visibility = Visibility.Hidden;
            }
        }
Exemplo n.º 14
0
        private Point SetUiPosition(Joint joint)
        {
            if (ActualWidth > 0 && ActualHeight > 0)
            {
                Joint scaledJoint = joint.ScaleTo((int)ActualWidth, (int)ActualHeight, 1f, 1f);
                return new Point
                {
                    X = scaledJoint.Position.X, // - ui.ActualWidth / 2,
                    Y = scaledJoint.Position.Y // - ui.ActualHeight / 2
                };
            }

            return new Point();
        }
Exemplo n.º 15
0
 private void ScalePosition(FrameworkElement element, Joint joint)
 {
     //convert the value to X/Y
     Joint scaledJoint = joint.ScaleTo(SystemInformation.PrimaryMonitorSize.Width, SystemInformation.PrimaryMonitorSize.Width);
     Canvas.SetLeft(element, scaledJoint.Position.X);
     Canvas.SetTop(element, scaledJoint.Position.Y);
 }
Exemplo n.º 16
0
        /// <summary>
        /// Draws a line connecting the specified joints.
        /// </summary>
        /// <param name="canvas">The Canvas element to draw the line.</param>
        /// <param name="first">The first joint (start of the line).</param>
        /// <param name="second">The second joint (end of the line)</param>
        /// <param name="color">The desired color for the line.</param>
        /// <param name="thickness">The desired line thickness.</param>
        public static void DrawLine(this Canvas canvas, Joint first, Joint second, Color color, double thickness)
        {
            if (first.TrackingState == JointTrackingState.NotTracked || second.TrackingState == JointTrackingState.NotTracked) return;

            first = first.ScaleTo(canvas.ActualWidth, canvas.ActualHeight);
            second = second.ScaleTo(canvas.ActualWidth, canvas.ActualHeight);

            Line line = new Line
            {
                Tag = TAG,
                X1 = first.Position.X,
                Y1 = first.Position.Y,
                X2 = second.Position.X,
                Y2 = second.Position.Y,
                StrokeThickness = thickness,
                Stroke = new SolidColorBrush(color)
            };

            canvas.Children.Add(line);
        }
Exemplo n.º 17
0
        private void UpdateCursor(Joint hand)
        {
            /// The x,y values are used for Gesture Tracking,
            /// while the _newHand.Position X,Y values are used
            /// for scaling the hands' positions to the screen

            var point = _kinectSensor.MapSkeletonPointToDepth(hand.Position, _kinectSensor.DepthStream.Format);
            float x = point.X;
            float y = point.Y;
            float z = point.Depth;
            Joint _NewHand = hand.ScaleTo(WIDTH, HEIGHT, SCALE, SCALE);
            SetHandTrackingActivated();

            Point cursorPoint = new Point(_NewHand.Position.X, _NewHand.Position.Y);
            HandleGestureTracking(x, y, z);
            HandleCursorEvents(cursorPoint, z, hand);
            _cursorAdornder.UpdateCursor(cursorPoint);
        }
Exemplo n.º 18
0
		private void ScalePosition(FrameworkElement element, Joint joint)
		{
			//convert the value to X/Y
			//convert & scale (.3 = means 1/3 of joint distance)
            //scale to width/height of window - can also set manually 1280x720
			Joint scaledJoint = joint.ScaleTo((int)this.ActualWidth, (int)this.ActualHeight, .3f, .3f);

			Canvas.SetLeft(element, scaledJoint.Position.X);
			Canvas.SetTop(element, scaledJoint.Position.Y);
		}
Exemplo n.º 19
0
        void drawpoint(Joint j1, Joint j2)
        {


            ////실질적인 스케일 변환
            j1r = j1.ScaleTo(SCR_W, SCR_H, userParam, userParam);
            
     
            if (!nearButton)
            {
                drawrec1.X = (int)j1r.Position.X;
                drawrec1.Y = (int)j1r.Position.Y;
            }
            else
            {
                  drawrec1.X = (int)center.X;
                  drawrec1.Y = (int)center.Y;

            }


            //스케일 없을떄는.,
            //spriteBatch.Draw(rightHandTextures[itemManager.getRightHandIndex()],new Vector2(drawrec1.X, drawrec1.Y),Color.White);

            Vector2 pointLocation = new Vector2(drawrec1.X, drawrec1.Y);
            if (itemManager.getRightHandIndex() == 5 || itemManager.getRightHandIndex() == 3)
            {
                pointLocation = new Vector2(drawrec1.X-40,drawrec1.Y-40);
            }



            spriteBatch.Draw(
             rightHandTextures[itemManager.getRightHandIndex()],
                    //위치: Center-> location 으로 바꿈 (마커와 노트 매칭 떄문에 )
            pointLocation,

             null,
             Color.White,
             0f,
                    //origin ->  new Vector2(frameWidth / 2, frameHeight / 2) ->  new Vector2(0,0) 으로 바꿈 (마커와 노트 매칭 떄문에 )
             new Vector2(0, 0),
                    //오른쪽 마크 크기 
             0.8f,
             SpriteEffects.None,
             0.0f);   

            j2r = j2.ScaleTo(SCR_W, SCR_H, userParam, userParam);

            //drawrec2.X = (int)j2r.Position.X - drawrec2.Width / 2;
            //drawrec2.Y = (int)j2r.Position.Y - drawrec2.Height / 2;
            drawrec2.X = (int)j2r.Position.X ;
            drawrec2.Y = (int)j2r.Position.Y ;

            Texture2D leftHandTexture = leftHandTextures[itemManager.getLeftHandIndex()];
            
            //스케이 ㄹ없을 때는
             //spriteBatch.Draw(leftHandTexture, new Vector2((float)drawrec2.X - (float)(leftHandTexture.Width * 0.5), (float)drawrec2.Y - (float)(leftHandTexture.Height * 0.5)), Color.White);
            //Trace.WriteLine(drawrec2);

            spriteBatch.Draw(
             leftHandTexture,
                //위치: Center-> location 으로 바꿈 (마커와 노트 매칭 떄문에 )
             new Vector2((float)drawrec2.X - (float)(leftHandTexture.Width * 0.25f), (float)drawrec2.Y - (float)(leftHandTexture.Height * 0.25f)),
                    //  new Vector2((float)drawrec2.X , (float)drawrec2.Y ),
             null,
             Color.White,
             0f,
                //origin ->  new Vector2(frameWidth / 2, frameHeight / 2) ->  new Vector2(0,0) 으로 바꿈 (마커와 노트 매칭 떄문에 )
              new Vector2(0, 0),
                //오른쪽 마크 크기 
             0.5f,
             SpriteEffects.None,
             0.0f);   

        }
        private void ScalePosition(FrameworkElement element, Joint joint, int slot)
        {
            //convert the value to X/Y
            //Joint scaledJoint = joint.ScaleTo(1280, 720);

            //convert & scale (.3 = means 1/3 of joint distance)
            Joint scaledJoint = joint.ScaleTo(380, 301, .9f, .5f);

            if (slot == 0)
            {
                Canvas.SetLeft(element, scaledJoint.Position.X);
                Canvas.SetTop(element, scaledJoint.Position.Y);
            }
            else
            {
                Canvas.SetLeft(element, scaledJoint.Position.X+380);
                Canvas.SetTop(element, scaledJoint.Position.Y);
            }
        }
Exemplo n.º 21
0
        public void SetPosition(Joint joint)
        {
            if (!menuOpened)
            {
                if (Global.initPos)
                {

                    //in Global check if z moving forward by some amount then increase 0.3 and 0.4 so hand moves less
                    Joint scaledJoint = joint.ScaleTo((int)Global.windowWidth, (int)Global.windowHeight, (float)0.25, (float)0.25);
                    cursorX = cursorX + 519;
                    cursorX = (double)Math.Max(0, Math.Min(scaledJoint.Position.X, Global.windowWidth - hand.Width));
                    cursorY = (double)Math.Max(0, Math.Min(scaledJoint.Position.Y, Global.windowHeight - hand.Height));
                    Canvas.SetLeft(this, cursorX);
                    Canvas.SetTop(this, cursorY);
                }
                else
                {

                    Canvas.SetLeft(this, Global.windowWidth - hand.Width);
                    Canvas.SetTop(this, Global.windowHeight - hand.Height);
                }
            }
            else
            {
                radialMenu.setCursorPosition(this, joint);
                Canvas.SetLeft(this, cursorX);
                Canvas.SetTop(this, cursorY);
            }
        }
Exemplo n.º 22
0
 private void ScalePosition(FrameworkElement element, Joint joint)
 {
     Joint scaledJoint = joint.ScaleTo(1280,800); // NOTE: probably need to adjust this better
     Canvas.SetLeft(element, scaledJoint.Position.X);
     Canvas.SetTop(element, scaledJoint.Position.Y);
 }
 private void ScaleEdges(Line line, Joint one, Joint two)
 {
     Joint scaledJoint1 = one.ScaleTo(320, 320, .5f, .5f);
     Joint scaledJoint2 = two.ScaleTo(320, 320, .5f, .5f);
     line.X1 = scaledJoint1.Position.X;
     line.X2 = scaledJoint2.Position.X;
     line.Y1 = scaledJoint1.Position.Y;
     line.Y2 = scaledJoint2.Position.Y;
 }
Exemplo n.º 24
0
        private void SetEllipsePosition(Ellipse ellipse, Joint joint)
        {
            var scaledJoint = joint.ScaleTo(1024, 1280, k_xMaxJointScale, k_yMaxJointScale);

            Canvas.SetLeft(ellipse, scaledJoint.Position.X - (double)ellipse.GetValue(Canvas.WidthProperty) / 2);
            Canvas.SetTop(ellipse, scaledJoint.Position.Y - (double)ellipse.GetValue(Canvas.WidthProperty) / 2);
            Canvas.SetZIndex(ellipse, (int)-Math.Floor(scaledJoint.Position.Z * 100));
            if (joint.JointType == JointType.HandLeft || joint.JointType == JointType.HandRight)
            {
                byte val = (byte)(Math.Floor((joint.Position.Z - 0.8) * 255 / 2));
                ellipse.Fill = new SolidColorBrush(Color.FromRgb(val, val, val));
            }
        }
        private void ScalePosition(FrameworkElement element, Joint joint)
        {
            //convert the value to X/Y
            //Joint scaledJoint = joint.ScaleTo(1280, 720); 

            //convert & scale (.3 = means 1/3 of joint distance)
            Joint scaledJoint = joint.ScaleTo(320, 320, .5f, .5f);

            Canvas.SetLeft(element, scaledJoint.Position.X);
            Canvas.SetTop(element, scaledJoint.Position.Y);
            SolidColorBrush mybrush = new SolidColorBrush();
            byte r, g, b;
            b = (byte)(100 * scaledJoint.Position.Z - 100);
            b = (byte)(b*1.3);
            g = r = 0;
            //Console.Write("Color b : ");
            //Console.WriteLine(b);
            mybrush.Color = Color.FromArgb(255, r, g, b);
            ((Ellipse)element).Fill = mybrush;
        }
Exemplo n.º 26
0
        private void ScalePosition(FrameworkElement element, Joint joint)
        {
            //convert the value to X/Y
            //Joint scaledJoint = joint.ScaleTo((int)canvas1.Width, (int)canvas1.Height);

            //convert & scale (.3 = means 1/3 of joint distance)
            Joint scaledJoint = joint.ScaleTo((int)canvas1.Width,(int) canvas1.Height, .2f, .2f);

            Canvas.SetLeft(element, scaledJoint.Position.X);
            Canvas.SetTop(element, scaledJoint.Position.Y);

            Canvas.SetLeft(capturedPlaneNumber, (Canvas.GetLeft(rightLander) + (rightLander.Width / 2)) - (capturedPlaneNumber.Width / 2));
            Canvas.SetTop(capturedPlaneNumber, (Canvas.GetTop(rightLander) + (rightLander.Height / 2)) - (capturedPlaneNumber.Height / 2));
        }
Exemplo n.º 27
0
 private void ScalePosition(FrameworkElement element, Joint joint)
 {
     //convert the value to X/Y
     //Joint scaledJoint = joint.ScaleTo(1280, 720); 
      
     //convert & scale (.3 = means 1/3 of joint distance)
     Joint scaledJoint = joint.ScaleTo(1280, 720, 0.3f, 0.3f);
     InkCanvas.SetLeft(element, scaledJoint.Position.X-element.Width/2);
     InkCanvas.SetTop(element, scaledJoint.Position.Y-element.Height/2);
     textBox.RightPos = (int)scaledJoint.Position.X + " " + (int)scaledJoint.Position.Y + "\n";
     RHPos[0] = scaledJoint.Position.X - element.Width/2;
     RHPos[1] = scaledJoint.Position.Y - element.Height/2;
 }