public void chkAutoClear_Click(object sender, RoutedEventArgs e) { if (GTaskSettings.IsFree) { GTaskSettings.Upsell(); chkAutoClear.IsChecked = false; } }
private async void speech_Click(object sender, EventArgs eventArgs) { string message = "Excuse me, what did you say?!"; string txtbxType = string.Empty; if (GTaskSettings.IsFree) { GTaskSettings.Upsell(); } else { try { //If no textbox is selected, there is no where to put the text if (focusedTextbox == null) { MessageBoxResult o = MessageBox.Show("Please select the text box you want to use and try again.", "Which Text Box?", MessageBoxButton.OK); return; } // Create an instance of SpeechRecognizerUI. this.recoWithUI = new SpeechRecognizerUI(); recoWithUI.Settings.ReadoutEnabled = false; recoWithUI.Settings.ShowConfirmation = false; if (focusedTextbox.Name == "txtbxTitle") { recoWithUI.Settings.ListenText = "Listening for Task Title..."; recoWithUI.Settings.ExampleText = "Ex. 'Mow the lawn'"; txtbxType = "Title"; } else { recoWithUI.Settings.ListenText = "Listening for Tasks Notes..."; recoWithUI.Settings.ExampleText = "Ex. 'This needs to be done by Tuesday.'"; txtbxType = "Notes"; } // Start recognition (load the dictation grammar by default). SpeechRecognitionUIResult recoResult = await recoWithUI.RecognizeWithUIAsync(); // Do something with the recognition result. string txtbxText = focusedTextbox.Text; string SpeakResult = (recoResult.RecognitionResult == null) ? string.Empty : recoResult.RecognitionResult.Text; string FinalText = string.Empty; int SelectionStart = focusedTextbox.SelectionStart; int SelectionLength = focusedTextbox.SelectionLength; int SelectionEnd = SelectionStart + SelectionLength; if (SpeakResult == string.Empty) //If nothing in speech result, don't do anything { return; } FinalText = SpeechHelper.FormatSpeech(SelectionStart, txtbxText, SelectionEnd, SpeakResult, txtbxType); if (FinalText != String.Empty) //Results are returned { if (SelectionLength == 0) //0 means it is an insert { focusedTextbox.Text = focusedTextbox.Text.Insert(SelectionStart, FinalText); focusedTextbox.Select(SelectionStart + FinalText.Length, 0); //Set the cursor location to where the start was previously } else //greater than 0 means it is a replace { focusedTextbox.SelectedText = FinalText; focusedTextbox.Select(SelectionStart + FinalText.Length, 0); //Set the cursor location to where the start was previously } } } catch { if (GTaskSettings.MsgError) { MessageBox.Show(message); } } } }
//Speech private async void speech_Click(object sender, EventArgs eventArgs) { string message = "Excuse me, what did you say?!"; string txtbxType = "Title"; if (GTaskSettings.IsFree) { GTaskSettings.Upsell(); } else { try { // Create an instance of SpeechRecognizerUI. this.recoWithUI = new SpeechRecognizerUI(); recoWithUI.Settings.ReadoutEnabled = false; recoWithUI.Settings.ShowConfirmation = false; recoWithUI.Settings.ListenText = "Listening for Task List Title..."; recoWithUI.Settings.ExampleText = "Ex. 'Grocery List'"; // Start recognition (load the dictation grammar by default). SpeechRecognitionUIResult recoResult = await recoWithUI.RecognizeWithUIAsync(); // Do something with the recognition result. string txtbxText = txtbxTitle.Text; string FinalText = string.Empty; int SelectionStart = txtbxTitle.SelectionStart; int SelectionLength = txtbxTitle.SelectionLength; int SelectionEnd = SelectionStart + SelectionLength; string SpeakResult = (recoResult.RecognitionResult == null) ? string.Empty : recoResult.RecognitionResult.Text; if (SpeakResult == string.Empty) //If nothing in speech result, don't do anything { return; } FinalText = SpeechHelper.FormatSpeech(SelectionStart, txtbxText, SelectionEnd, SpeakResult, txtbxType); if (FinalText != String.Empty) //Results are returned { if (SelectionLength == 0) //0 means it is an insert { txtbxTitle.Text = txtbxTitle.Text.Insert(SelectionStart, FinalText); txtbxTitle.Select(SelectionStart + FinalText.Length, 0); //Set the cursor location to where the start was previously } else //greater than 0 means it is a replace { txtbxTitle.SelectedText = FinalText; txtbxTitle.Select(SelectionStart + FinalText.Length, 0); //Set the cursor location to where the start was previously } } } catch { if (GTaskSettings.MsgError) { MessageBox.Show(message); } } } }