Exemplo n.º 1
0
        /// <summary>
        /// Exits AISA after greeting the user
        /// </summary>
        private void ExitAISA()
        {
            //Stop the AISA Recognition


            //Say the end greeting
            OpenSpeak.Speak(Greetings.End());

            AISAHandler.Pause();

            //Disappear the program
            var da = new DoubleAnimation(SystemParameters.PrimaryScreenHeight, TimeSpan.FromSeconds(1));

            da.EasingFunction = new QuinticEase();
            BeginAnimation(TopProperty, da);

            //Close the program in 2 seconds
            var dt = new DispatcherTimer();

            dt.Interval = TimeSpan.FromSeconds(2);
            dt.Tick    += (a, b) =>
            {
                Application.Current.Shutdown();
            };
            dt.Start();
        }
Exemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //Start AISA Command Recognition
            try
            {
                AISAHandler.Initialize(() =>
                {
                    Speech.Activate();
                    AskSheet.Visibility   = Visibility.Hidden;
                    Spinner.Visibility    = Visibility.Visible;
                    Hypothesis.Visibility = Visibility.Visible;
                },
                                       () =>
                {
                    Speech.Deactivate();
                }, HandleResult);
            }
            catch (Exception) { }

            AISAHandler.Start();

            //Set advanced result controllers
            ViewControllerConnector.Connect          += ConnectionHandler;
            ViewControllerConnector.None             += NoneHandler;
            ViewControllerConnector.ChangeHypothesis += ChangeHypothesisHandler;
        }
Exemplo n.º 3
0
        public MCQ(string _class, string paper_index)
        {
            InitializeComponent();

            //Set the private fields
            classIndex = _class;
            Paper      = paper_index;

            //Set the paper name
            PaperName.Content = Context.currentPaper.name;

            //Show the first question
            UpdateQuestion(true);

            //Pause the AISA Handler for concurrent recognitions
            AISAHandler.Pause();

            //Setup the Speech Recognizer
            _recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(new string[]
            {
                "A", "B", "C", "D", "One", "Two", "Three", "Four", "I don't know", "Skip", "No", "Next", "Previous", "Continue"
            }))));

            _recognizer.SpeechRecognized += _recognizer_SpeechRecognized;

            _recognizer.SetInputToDefaultAudioDevice();

            //Start the speech recognition process
            _recognizer.RecognizeAsync(RecognizeMode.Multiple);
        }
Exemplo n.º 4
0
        public void HideWindow()
        {
            //Disappear the program
            var da = new DoubleAnimation(SystemParameters.PrimaryScreenHeight, TimeSpan.FromMilliseconds(500));

            da.EasingFunction = new QuinticEase();
            BeginAnimation(TopProperty, da);

            AISAHandler.Pause();

            ViewControllerConnector.MainWindowHide();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Fades the GetHelp object out
        /// </summary>
        private void CloseHelp()
        {
            //Start the AISA recognition
            AISAHandler.Start();

            //Animate the fading out of the object
            var da = new DoubleAnimation(0, TimeSpan.FromMilliseconds(500));

            da.EasingFunction = new QuinticEase();
            da.Completed     += (a, b) =>
            {
                //Actually inactivate GetHelp object from the view
                GetHelp.Visibility = Visibility.Hidden;
            };

            GetHelp.BeginAnimation(OpacityProperty, da);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Fades the GetHelp object in
        /// </summary>
        private void Help()
        {
            if (!ViewControllerConnector.StartedCommandRecognition)
            {
                //Stop AISA recognition
                AISAHandler.Pause();

                //Set the visibility to true
                GetHelp.Visibility = Visibility.Visible;
                GetHelp.Opacity    = 0;

                //Animate the fading in of the object
                var da = new DoubleAnimation(1, TimeSpan.FromMilliseconds(500));
                da.EasingFunction = new QuinticEase();
                GetHelp.BeginAnimation(OpacityProperty, da);
            }
        }
Exemplo n.º 7
0
        public void ShowWindow()
        {
            AISAHandler.Start();

            //Disappear the program
            var da = new DoubleAnimation(SystemParameters.WorkArea.Height - Height, TimeSpan.FromSeconds(1));

            da.EasingFunction = new QuinticEase();
            BeginAnimation(TopProperty, da);

            ResultSheet.Visibility = Visibility.Hidden;
            AskSheet.Visibility    = Visibility.Visible;

            //Start that thingy animation
            var sa = FindResource("AskSheetToUp") as Storyboard;

            sa.Begin();
        }
Exemplo n.º 8
0
        public void StartPaper(string _class, string paper_index)
        {
            //Pause the AISA Handler
            AISAHandler.Pause();
            ViewControllerConnector.PaperStarted = true;

            var da = new DoubleAnimation(0.5, TimeSpan.FromSeconds(1));

            da.EasingFunction = new QuinticEase();

            //Set the opacity of the MainWindows to 0.5 in 1 second
            BeginAnimation(OpacityProperty, da);

            //Start a new MCQ
            var mcq = new MCQ(_class, paper_index);

            mcq.Show();
        }
Exemplo n.º 9
0
        private void CompletePaper()
        {
            UploadingPanel.Visibility = Visibility.Visible;

            //Animate the uploading panel to preview the spinner
            var da = new DoubleAnimation(1, TimeSpan.FromMilliseconds(500));

            da.EasingFunction = new QuinticEase();
            UploadingPanel.BeginAnimation(OpacityProperty, da);

            _recognizer.RecognizeAsyncCancel();
            _recognizer.Dispose(); // Dispose the recognizer object

            //Start the uploading functionality
            var threadstart = new ThreadStart(() =>
            {
                var result = Scholar.Class.PostMCQPaper(Context.previousPaper[0], Context.previousPaper[1], _answers, Properties.Settings.Default.scholarUsername, Properties.Settings.Default.scholarPassword);

                Application.Current.Dispatcher.Invoke(() =>
                {
                    //Do this in the user interface thread
                    var da2            = new DoubleAnimation(0, TimeSpan.FromMilliseconds(500));
                    da2.EasingFunction = new QuinticEase();

                    da2.Completed += (a, b) =>
                    {
                        //Show the results
                        ResultSheet.Visibility = Visibility.Visible;
                        ResultSheet.BeginAnimation(OpacityProperty, da);

                        PaperNameResults.Content = Context.currentPaper.name;

                        var correct   = 0;
                        var incorrect = 0;
                        var skipped   = 0;

                        for (int i = 0; i < _answers.Length; i++)
                        {
                            var given_answer   = _answers[i];
                            var correct_answer = Context.currentPaper.questions[i].correct;

                            if (given_answer == 0)
                            {
                                skipped++;
                            }
                            else
                            {
                                if (given_answer == correct_answer)
                                {
                                    //Answer is correct
                                    correct++;
                                }
                                else
                                {
                                    incorrect++;
                                }
                            }
                        }

                        //Set the numbers
                        correct_count.Content    = correct.ToString();
                        incorrect_count.Content  = incorrect.ToString();
                        unanswered_count.Content = skipped.ToString();


                        //Set the event handlers
                        OkayButton.Clicked = () =>
                        {
                            _recognizer.RecognizeAsyncCancel();
                            _recognizer = null;

                            ViewControllerConnector.PaperStarted = false;
                            AISAHandler.Start();
                            ViewControllerConnector.Opaque();

                            Close();
                        };

                        _recognizer = new SpeechRecognitionEngine();
                        _recognizer.SetInputToDefaultAudioDevice();
                        _recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(
                                                                                   new string[] { "Okay", "OK", "Close", "Exit" }
                                                                                   ))));

                        _recognizer.SpeechRecognized += (x, y) =>
                        {
                            _recognizer.RecognizeAsyncCancel();
                            _recognizer = null;

                            ViewControllerConnector.PaperStarted = false;
                            AISAHandler.Start();
                            ViewControllerConnector.Opaque();

                            Close();
                        };

                        _recognizer.RecognizeAsync();
                    };

                    //Fade the uploading panel out
                    UploadingPanel.BeginAnimation(OpacityProperty, da2);
                });
            });

            var thread = new Thread(threadstart);

            thread.Start();
        }