Example #1
0
        //Method to handle help page button presses
        public void helpEvents(Button btn)
        {
            //Get the button name that was pressed
            switch (btn.Content.ToString())
            {
            case "Tutorial":     //Open the tutorial grid and hide the others
                kinect.help.commandGrid.Visibility    = System.Windows.Visibility.Collapsed;
                kinect.help.gestureGrid.Visibility    = System.Windows.Visibility.Collapsed;
                kinect.help.btn_goLeft.Visibility     = System.Windows.Visibility.Visible;
                kinect.help.btn_goRight.Visibility    = System.Windows.Visibility.Visible;
                kinect.help.tutorialGif.Visibility    = System.Windows.Visibility.Visible;
                kinect.help.lbl_gifHeading.Visibility = System.Windows.Visibility.Visible;
                break;

            case "Gestures":     //Open the gesture grid and hide the others
                kinect.help.commandGrid.Visibility    = System.Windows.Visibility.Collapsed;
                kinect.help.gestureGrid.Visibility    = System.Windows.Visibility.Visible;
                kinect.help.btn_goLeft.Visibility     = System.Windows.Visibility.Collapsed;
                kinect.help.btn_goRight.Visibility    = System.Windows.Visibility.Collapsed;
                kinect.help.tutorialGif.Visibility    = System.Windows.Visibility.Collapsed;
                kinect.help.lbl_gifHeading.Visibility = System.Windows.Visibility.Collapsed;
                break;

            case "Voice Commands":     //Open the voice command grid and hide the others
                kinect.help.commandGrid.Visibility    = System.Windows.Visibility.Visible;
                kinect.help.gestureGrid.Visibility    = System.Windows.Visibility.Collapsed;
                kinect.help.btn_goLeft.Visibility     = System.Windows.Visibility.Collapsed;
                kinect.help.btn_goRight.Visibility    = System.Windows.Visibility.Collapsed;
                kinect.help.tutorialGif.Visibility    = System.Windows.Visibility.Collapsed;
                kinect.help.lbl_gifHeading.Visibility = System.Windows.Visibility.Collapsed;
                break;

            case "<":     //Navigate to the previous gif in the tuorial grid
                kinect.help.previousGif();
                break;

            case ">":     //Navigate to the next gif in the tutorial grid
                kinect.help.nextGif();
                break;

            case "Back":     //Go back to the main menu
                kinect.openMenu();
                break;
            }
        }
Example #2
0
        //Method to position UI elements of the page relative to the screen size
        public void init()
        {
            //Initialise the default program settings on first load
            Settings.fontScale        = 1.0;
            Settings.rightHandTracked = true;
            Settings.windowWidth      = 640;
            Settings.windowHeight     = 480;
            Settings.ttsVolume        = 100;
            String dir = Directory.GetParent(Directory.GetParent(Environment.CurrentDirectory).ToString()).ToString() + "\\resources\\";

            Settings.resourcePath = dir;

            //Initialise the Kinect, passing an instance of this class to allow the program to return
            mainLogic = new Kinect(this);
            //Start up the Kinect features
            mainLogic.initiate_kinect();
            //Tell the kinect to set this page as the content of the window
            mainLogic.openMenu();
            //Audibly tell the user that the program is ready
            textToSpeech("program loaded");
        }
Example #3
0
        private void speechRecognised(object sender, SpeechRecognizedEventArgs e)
        {
            //Handles all of the commands when they are recognised in people's speech
            //Used in speech to text confirmation
            Boolean confirm = false;
            //Converts the speech detection result to lower case for cosnsitency
            String result = e.Result.Text.ToLower();
            //Stores the confidence of the result of the current speech detection as a double
            double conf = e.Result.Confidence;

            //Ensures that the confidence for the result is high enough and that the result is not null to prevent null exception errors
            if (conf >= 0.75 && result != null)
            {
                Console.WriteLine("Speech detection result: " + result);
                switch (result)
                {
                case "save":
                    //Allows for saving the current program, but only whilst in the code window
                    if (kinect.currentWindow == "main")
                    {
                        events.savePress();
                    }
                    break;

                case "run":
                    //Allows for running of the code whilst in the code window
                    if (kinect.currentWindow == "main")
                    {
                        events.runPress();
                    }
                    break;

                case "switch":
                    //If the right hand is currently being tracked...
                    if (Settings.rightHandTracked)
                    {
                        //... sets the left hand to be tracked
                        Settings.rightHandTracked = false;
                        //Removes the previously drawn cursor from the screen
                        kinect.removePerson(kinect.People[0]);
                        kinect.removePerson(kinect.People[1]);
                        //And then re-initialises the hand skeleton
                        kinect.initialisePeople();
                    }
                    //Else if the right hand is not being tracked...
                    else if (!Settings.rightHandTracked)
                    {
                        //... sets the right hand to be tracked
                        Settings.rightHandTracked = true;
                        //And performs the same function as switching to the left hand
                        kinect.removePerson(kinect.People[0]);
                        kinect.removePerson(kinect.People[1]);
                        kinect.initialisePeople();
                    }
                    break;

                case "mute":
                case "quiet":
                    //Stops the text to speech from making any noise
                    Settings.ttsVolume = 0;
                    break;

                case "unmute":
                    Settings.ttsVolume = 100;
                    break;

                case "select":
                    //Runs the method for selecting the currently hovered icon with speech rather than a push gesture
                    speechSelect();
                    break;

                case "undo":
                    //Undoes the previous entry into the code window, checking if the current window is the code window
                    if (kinect.currentWindow == "main")
                    {
                        events.removeLastStatement();
                    }
                    break;

                case "start text":
                    //Checks to see if the user is in the input window
                    if (kinect.currentWindow == "input")
                    {
                        //Runs the speech to text method using the current commands result and the current confirm boolean
                        speechToText(result, confirm);
                    }
                    break;

                case "back":
                    //Checks the current window to know where to navigate back to
                    //Potential for improvement - acquire previous window and set window content back to previous window when back is said
                    switch (kinect.currentWindow)
                    {
                    case "input":
                        kinect.openCode();
                        events.removeLastStatement();
                        break;

                    case "menu":
                        //Used to prevent the users from going back in the menu
                        kinect.frame.textToSpeech("You are already in the main window");
                        break;

                    default:
                        kinect.openMenu();
                        break;
                    }
                    break;

                case "confirm":
                    //If the current window is input, allows for confirming of the current statement using speech
                    if (kinect.currentWindow == "input")
                    {
                        events.addStatement();
                    }
                    break;

                case "decline":
                    //Or if the user wishes to decline the current input, that can be done using speech
                    if (kinect.currentWindow == "input")
                    {
                        //Removing the previous empty statement and opening the code window again
                        events.removeLastStatement();
                        kinect.openCode();
                    }
                    break;

                case "set":
                case "value":
                    //Allows the user to use speech to text to enter values for variable names and values
                    if (kinect.currentWindow == "input")
                    {
                        //varResult is used in checking which part of the variable is being set
                        //...as well as which speech to text command is being run in the relevant method
                        varResult = result;
                        speechToText(result, confirm);
                    }
                    break;

                case "change title":
                    //Changes the title of the current project using speech to text
                    if (kinect.currentWindow == "main")
                    {
                        //Sets varResult to be used as a check when running the speech to text commands
                        varResult = result;
                        speechToText(result, confirm);
                    }
                    break;

                case "close":
                    //If the current window is either the menu or the main window...
                    if (kinect.currentWindow == "main" || kinect.currentWindow == "menu")
                    {
                        try
                        {
                            //Saying close closes the current running Python window
                            //Both pages allow for closing due to the open function in the menu allowing for opening of projects from the menu
                            events.cmd.Kill();
                        }
                        catch (InvalidOperationException e2)
                        {
                            //Prints the invalid operation exception if thrown, caused by the command trying to be killed if it isn't open
                            Console.WriteLine("InvalidOperationException in speech: " + e2.Message + e2.Source);
                        }
                    }
                    break;

                //Opens either settings or help depending on which command is used, allowing for navigation using speech
                case "help":
                    kinect.openHelp();
                    break;

                case "settings":
                    kinect.openSettings();
                    break;

                default:
                    //Otherwise, if no command is recognised the user is informed about this
                    kinect.frame.textToSpeech("Difficulty understanding command, please repeat");
                    Console.WriteLine("Difficulty understanding command, please repeat");
                    break;
                }
            }
        }