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; }
/// <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); }
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(); }
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(); }