예제 #1
0
        public void stopRecognized()
        {
            SkeletonUtils.modifyUI(
                new ThreadStart(() =>
            {
                try
                {
                    voiceControl.Fill = new SolidColorBrush(Colors.Red);
                }
                catch (Exception) { }
            }));

            if (skeletonClient != null)
            {
                if (leftArmAnalyzer != null)
                {
                    skeletonClient.unsubscribe(leftArmAnalyzer);
                }
                if (rightArmAnalyzer != null)
                {
                    skeletonClient.unsubscribe(rightArmAnalyzer);
                }
                for (int i = 0; i < movements.Length; i++)
                {
                    if (movements[i] != null)
                    {
                        skeletonClient.unsubscribe(movements[i]);
                    }
                }
            }
        }
예제 #2
0
 private void UnselectBucket(BucketPosition pos)
 {
     SkeletonUtils.modifyUI(
         new ThreadStart(() =>
     {
         try
         {
             boxes[(int)pos].Fill         = new SolidColorBrush((getController(pos).getVolume() > 100) ? Colors.Green : Colors.White);
             progressBars[(int)pos].Value = getController(pos).getVolume();
         }
         catch (Exception) { }
     }));
 }
예제 #3
0
        public void setUpRecognized()
        {
            SkeletonUtils.modifyUI(
                new ThreadStart(() =>
            {
                try
                {
                    voiceControl.Fill = new SolidColorBrush(Colors.Green);
                }
                catch (Exception) { }
            }));

            if (skeletonClient != null)
            {
                skeletonClient.unsubscribeAll();
                skeletonClient.subscribe(new SkeletonListener(skeletonCanvas));
                recordingStream = new CurrentRecording();
                skeletonClient.subscribe(recordingStream);
            }

            foreach (BucketPosition pos in Enum.GetValues(typeof(BucketPosition)))
            {
                if (getController(pos) != null)
                {
                    SkeletonUtils.modifyUI(
                        new ThreadStart(() =>
                    {
                        try
                        {
                            progressBars[(int)pos].Value = getController(pos).getVolume();
                        }
                        catch (Exception) { }
                    }));

                    SkeletonUtils.modifyUI(
                        new ThreadStart(() =>
                    {
                        try
                        {
                            boxes[(int)pos].Fill = new SolidColorBrush((getController(pos).getVolume() > 100) ? Colors.Green : Colors.White);
                        }
                        catch (Exception) { }
                    }));
                }
            }
            playing = false;
        }
예제 #4
0
        public void selectBucket(BucketPosition pos)
        {
            SkeletonUtils.modifyUI(
                new ThreadStart(() =>
            {
                try
                {
                    boxes[(int)pos].Fill = new SolidColorBrush(Colors.Cyan);
                }
                catch (Exception) { }
            }));

            System.Timers.Timer myTimer = new System.Timers.Timer();
            myTimer.Elapsed += delegate { UnselectBucket(pos); };
            myTimer.Interval = 1000; // 1s
            myTimer.Start();
        }
예제 #5
0
        public void toggleBuckets()
        {
            if (bucketsEnabled)
            {
                // Deactivate them
                foreach (BucketPosition pos in Enum.GetValues(typeof(BucketPosition)))
                {
                    if (allControllers[(int)pos] != null)
                    {
                        SkeletonUtils.modifyUI(
                            new ThreadStart(() =>
                        {
                            try
                            {
                                enablers[(int)pos].IsEnabled = false;
                            }
                            catch (Exception) { }
                        }));
                    }
                }
                if (leftArmAnalyzer != null)
                {
                    skeletonClient.unsubscribe(leftArmAnalyzer);
                }
                if (rightArmAnalyzer != null)
                {
                    skeletonClient.unsubscribe(rightArmAnalyzer);
                }

                SkeletonUtils.modifyUI(
                    new ThreadStart(() =>
                {
                    try
                    {
                        voiceControl.Fill = new SolidColorBrush(Colors.Orange);
                    }
                    catch (Exception) { }
                }));
                bucketsEnabled = false;
            }
            else
            {
                // Activate them
                foreach (BucketPosition pos in Enum.GetValues(typeof(BucketPosition)))
                {
                    if (allControllers[(int)pos] != null)
                    {
                        SkeletonUtils.modifyUI(
                            new ThreadStart(() =>
                        {
                            try
                            {
                                enablers[(int)pos].IsEnabled = true;
                            }
                            catch (Exception) { }
                        }));
                    }
                }
                if (leftArmAnalyzer != null)
                {
                    skeletonClient.subscribe(leftArmAnalyzer);
                }
                if (rightArmAnalyzer != null)
                {
                    skeletonClient.subscribe(rightArmAnalyzer);
                }

                SkeletonUtils.modifyUI(
                    new ThreadStart(() =>
                {
                    try
                    {
                        voiceControl.Fill = new SolidColorBrush(Colors.Cyan);
                    }
                    catch (Exception) { }
                }));
                bucketsEnabled = true;
            }
        }
예제 #6
0
        public void startRecognized()
        {
            if (playing)
            {
                // Will stop playing now
                playing = false;
                if (leftArmAnalyzer != null)
                {
                    skeletonClient.unsubscribe(leftArmAnalyzer);
                }
                if (rightArmAnalyzer != null)
                {
                    skeletonClient.unsubscribe(rightArmAnalyzer);
                }
                for (int i = 0; i < movements.Length; i++)
                {
                    if (movements[i] != null)
                    {
                        skeletonClient.unsubscribe(movements[i]);
                    }
                }
            }
            else
            {
                // Will start playing now
                playing = true;

                if (bucketsEnabled)
                {
                    if (leftArmAnalyzer != null)
                    {
                        skeletonClient.subscribe(leftArmAnalyzer);
                    }
                    if (rightArmAnalyzer != null)
                    {
                        skeletonClient.subscribe(rightArmAnalyzer);
                    }
                    SkeletonUtils.modifyUI(
                        new ThreadStart(() =>
                    {
                        try
                        {
                            voiceControl.Fill = new SolidColorBrush(Colors.Cyan);
                        }
                        catch (Exception) { }
                    }));
                }
                else
                {
                    SkeletonUtils.modifyUI(
                        new ThreadStart(() =>
                    {
                        try
                        {
                            voiceControl.Fill = new SolidColorBrush(Colors.Orange);
                        }
                        catch (Exception) { }
                    }));
                }
                for (int i = 0; i < movements.Length; i++)
                {
                    if (movements[i] != null)
                    {
                        skeletonClient.subscribe(movements[i]);
                    }
                }
            }
        }
예제 #7
0
        public void setMovementValue(Movement mov, double val)
        {
            // Exact movement is 250
            // Close movement is 350
            if (val > 1000)
            {
                val = 1000;
            }
            lastMovementValues[(int)mov] = val;
            double min = val;

            foreach (Movement pos in Enum.GetValues(typeof(Movement)))
            {
                double actual = lastMovementValues[(int)pos];
                if (actual < min && actual > 0)
                {
                    min = actual;
                }
            }
            SkeletonUtils.modifyUI(
                new ThreadStart(() =>
            {
                try
                {
                    MovementDiff.Value = min;
                }
                catch (Exception) { }
            }));

            if (min < gesturePrecision + progressBarDelta)
            {
                SkeletonUtils.modifyUI(
                    new ThreadStart(() =>
                {
                    try
                    {
                        MovementDiffClose.Value = min;
                    }
                    catch (Exception) { }
                }));
            }
            else
            {
                SkeletonUtils.modifyUI(
                    new ThreadStart(() =>
                {
                    try
                    {
                        MovementDiffClose.Value = gesturePrecision + progressBarDelta;
                    }
                    catch (Exception) { }
                }));
            }
            if (min < gesturePrecision)
            {
                SkeletonUtils.modifyUI(
                    new ThreadStart(() =>
                {
                    try
                    {
                        MovementPrecision.Value = min;
                    }
                    catch (Exception) { }
                }));
            }
            else
            {
                SkeletonUtils.modifyUI(
                    new ThreadStart(() =>
                {
                    try
                    {
                        MovementPrecision.Value = gesturePrecision;
                    }
                    catch (Exception) { }
                }));
            }
        }