Пример #1
0
 private void SysTrayAddCommand(object sender, EventArgs e)
 {
     if (!AssistantHelper.IsWindowOpen <AddNewCommand>())
     {
         var addNewCommand = new AddNewCommand(_assistantService);
         addNewCommand.Show();
     }
     else
     {
         MessageBox.Show(Properties.Resources.FormIsAlreadyOpen, Properties.Resources.Information, MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
Пример #2
0
 public void DefaultSpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     recognizedCommand = AssistantHelper.GetRecognizedCommand(commands.Command, e.Result.Text);
     if (recognizedCommand.CommandText == Properties.Resources.AddNewCommand)
     {
         if (!AssistantHelper.IsWindowOpen <AddNewCommand>())
         {
             var addNewCommand = new AddNewCommand(_assistantService);
             addNewCommand.Show();
             Sara.SpeakAsync(recognizedCommand.Answer);
         }
         else
         {
             Sara.SpeakAsync(Properties.Resources.FormIsAlreadyOpen);
         }
     }
     else if (recognizedCommand.CommandText == Properties.Resources.ShowCommands)
     {
         if (!AssistantHelper.IsWindowOpen <CommandManagement>())
         {
             var commandManagement = new CommandManagement();
             commandManagement.Show();
             Sara.SpeakAsync(recognizedCommand.Answer);
         }
         else
         {
             Sara.SpeakAsync(Properties.Resources.FormIsAlreadyOpen);
         }
     }
     else if (recognizedCommand.CommandText == Properties.Resources.TimeForBreak)
     {
         Sara.SpeakAsync(recognizedCommand.Answer);
         CancelRecognize();
         contextMenu.MenuItems[0].Enabled = true;
         contextMenu.MenuItems[1].Enabled = false;
     }
     else if (recognizedCommand.NeedsConfirmation)
     {
         Sara.SpeakAsync(Properties.Resources.ConfirmOperation);
         StopRecognize();
         recognizer = new SpeechRecognitionEngine();
         _speechRecognizerService.CreateNewSynthesizer(commands.Command.Where(x => x.IsConfimation).Select(x => x.CommandText).ToArray(), recognizer, Sara, listener, ConfirmationSpeechRecognized, RecognizerSpeechRecognized, ListenerSpeechRecognize);
     }
     else
     {
         _speechRecognizerService.ExecuteRecognizedAction(Sara, recognizedCommand);
     }
 }