Пример #1
0
        void tmr_Tick(object sender, EventArgs e)
        {
            Frame frame = Controller.Frame();

            var hands = frame.Hands;
            var hand = hands[0];
            var fingers = hand.Fingers;

            if (controller == null || !controller.IsConnected)
            {
                StopDrawing(this, EventArgs.Empty);
            }
            else
            {

                if ((hands[0].IsRight) && (fingers[FINGER_ID] != Finger.Invalid) && (fingers[FINGER_ID].IsExtended))
                {
                    var normailizedPos = frame.InteractionBox.NormalizePoint(fingers[FINGER_ID].StabilizedTipPosition, false);
                    CurrentNormalizedPosition = new Point3DNormalized(normailizedPos.x, 1 - normailizedPos.y, 1 - normailizedPos.z);

                    StartDrawing(this, EventArgs.Empty);
                }
                if (!this.controller.HasFocus)
                {
                    StopDrawing(this, EventArgs.Empty);
                }
            }
        }
Пример #2
0
        void tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            float normalizedX = this.X / (float)controlHeight;
            float normalizedY = this.Y / (float)controlWidth;

            CurrentNormalizedPosition = new Point3DNormalized(normalizedX,normalizedY,0);
        }
Пример #3
0
        /// <summary>
        /// Add a normalized point
        /// </summary>
        /// <param name="p3n">The new point 3D normalized</param>
        public void AddNormalizedPoint(Point3DNormalized p3n, long timestamp, TypeDrawZone t)
        {
            this.Path.Add(new PathStep(p3n, timestamp - Path.Timestamp));

            if (this.Path.Count % 10 == 0 && t != TypeDrawZone.Player)
            {
                this.Path.DeleteUselessPoint();
            }
        }
Пример #4
0
 /// <summary>
 /// Normalize a point
 /// </summary>
 private Point UnnormalizePoint(Point3DNormalized p3n)
 {
     return new Point((int)(p3n.X * this.Size.Width), (int)(p3n.Y * this.Size.Height));
 }
Пример #5
0
        /// <summary>
        /// Add a normalized point
        /// </summary>
        /// <param name="p3n">The new point 3D normalized</param>
        public void AddNormalizedPoint(Point3DNormalized p3n, long timestamp, TypeDrawZone t)
        {
            this.Path.Add(new PathStep(p3n, timestamp - Path.Timestamp));

            if (this.Path.Count % 10 == 0 && t != TypeDrawZone.Player)
                this.Path.DeleteUselessPoint();
        }
Пример #6
0
        void tmr_Tick(object sender, EventArgs e)
        {
            Frame frame = Controller.Frame();

            if (controller == null || !controller.IsConnected)
            {
                StopDrawing(this, EventArgs.Empty);
            }
            else
            {
                var hands = frame.Hands;
                var hand = hands[0];
                var fingers = hand.Fingers;

                if ((fingers[FINGER_ID] != Finger.Invalid) && (fingers[FINGER_ID].IsExtended))
                {
                    var normailizedPos = frame.InteractionBox.NormalizePoint(fingers[FINGER_ID].StabilizedTipPosition, false);
                    CurrentNormalizedPosition = new Point3DNormalized(normailizedPos.x, 1 - normailizedPos.y, 1 - normailizedPos.z);
                   /* try{*/
                    StartDrawing(this, EventArgs.Empty);
                   /* }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.Message);
                    }*/
                }
                if (fingers.IsEmpty)
                {
                    try
                    {
                        StopDrawing(this, EventArgs.Empty);
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.Message);
                    }
                }
            }
        }
Пример #7
0
 public PathStep(Point3DNormalized fromPoint, long timestamp)
 {
     NormalizedPosition = fromPoint;
     Timestamp          = timestamp;
 }
Пример #8
0
        void tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            float normalizedX = this.X / (float)controlWidth;
            float normalizedY = this.Y / (float)controlHeight;
            if (oldx == X && oldy == Y)
            {
                if (watch.IsRunning)
                {
                    if (watch.ElapsedMilliseconds == WAITITME)
                    {
                        StopDrawing(this, EventArgs.Empty);
                        watch.Stop();
                        watch.Reset();
                    }

                }
                else
                {
                    watch.Start();
                }
            }
            else
            {
                if (watch.IsRunning)
                {
                    watch.Stop();
                    watch.Reset();
                }
            }

            oldx = X;
            oldy = Y;
            CurrentNormalizedPosition = new Point3DNormalized(normalizedX, normalizedY, 0);
        }
Пример #9
0
 public PathStep(Point3DNormalized fromPoint, long timestamp)
 {
     NormalizedPosition = fromPoint;
     Timestamp = timestamp;
 }
Пример #10
0
 /// <summary>
 /// Add a normalized point
 /// </summary>
 /// <param name="normalizedPoint">Point3DNormalized</param>
 public void AddPointDrawing(Point3DNormalized normalizedPoint)
 {
     CurrentLine.AddNormalizedPoint(normalizedPoint, Stopwatch.ElapsedMilliseconds, this.TypeDrawZone);
 }
Пример #11
0
 /// <summary>
 /// Normalize a point
 /// </summary>
 private Point UnnormalizePoint(Point3DNormalized p3n)
 {
     return(new Point((int)(p3n.X * this.Size.Width), (int)(p3n.Y * this.Size.Height)));
 }
Пример #12
0
 /// <summary>
 /// Add a normalized point
 /// </summary>
 /// <param name="normalizedPoint">Point3DNormalized</param>
 public void AddPointDrawing(Point3DNormalized normalizedPoint)
 {
     CurrentLine.AddNormalizedPoint(normalizedPoint, Stopwatch.ElapsedMilliseconds, this.TypeDrawZone);
 }
Пример #13
0
        void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Vector3d pos = Device.Position;

            CurrentNormalizedPosition = new Point3DNormalized(
                (pos.X - MIN_X) / (MAX_X - MIN_X),
                (pos.Y - MIN_Y) / (MAX_Y - MIN_Y),
                (pos.Z - MIN_Z) / (MAX_Z - MIN_Z)
            );

            Debug.WriteLine("X {0}  Y {1}   Z  {2}", pos.X, pos.Y, pos.Z);

            var buttonIsPressed = Device.IsButtonPressed;

            if (!WasDrawing && buttonIsPressed)
            {
                StartDrawing(this, EventArgs.Empty);
            }
            if (WasDrawing && !buttonIsPressed)
            {
                StopDrawing(this, EventArgs.Empty);
            }

            WasDrawing = buttonIsPressed;
        }