/// <summary> /// 使用在导航过程中传递的内容填充页。 在从以前的会话 /// 重新创建页时,也会提供任何已保存状态。 /// </summary> /// <param name="sender"> /// 事件的来源; 通常为 <see cref="NavigationHelper"/> /// </param> /// <param name="e">事件数据,其中既提供在最初请求此页时传递给 /// <see cref="Frame.Navigate(Type, Object)"/> 的导航参数,又提供 /// 此页在以前会话期间保留的状态的 /// 字典。 首次访问页面时,该状态将为 null。</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter == null) { return; } if (e.NavigationParameter.GetType().Equals(typeof(string))) { string CS = e.NavigationParameter.ToString(); this.DefaultViewModel["CS"] = CS; //处理浏览器 _htmltianqiV.Source = new Uri("http://m.8684.cn/bus"); } if (e.NavigationParameter.GetType().Equals(typeof(VoiceCommandActivatedEventArgs))) { VoiceCommandActivatedEventArgs commandArgs_thisone = e.NavigationParameter as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs_thisone.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; string navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties["NavigationTarget"][0]; PublicS.GetInitGongJiao(); string gongjiao = ""; PublicS.GongJiaoDic.TryGetValue(textSpoken.Replace("公交", "").Replace("信息", "").Replace("线路", "").Replace("路线", "").Trim(), out gongjiao); PublicS.GongJiaoDic.Clear(); _htmltianqiV.Source = new Uri(gongjiao); } }
/// <summary> /// 使用在导航过程中传递的内容填充页。 在从以前的会话 /// 重新创建页时,也会提供任何已保存状态。 /// </summary> /// <param name="sender"> /// 事件的来源; 通常为 <see cref="NavigationHelper"/> /// </param> /// <param name="e">事件数据,其中既提供在最初请求此页时传递给 /// <see cref="Frame.Navigate(Type, Object)"/> 的导航参数,又提供 /// 此页在以前会话期间保留的状态的 /// 字典。 首次访问页面时,该状态将为 null。</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter == null) { return; } if (e.NavigationParameter.GetType().Equals(typeof(string))) { string CS = e.NavigationParameter.ToString(); this.DefaultViewModel["CS"] = CS; //处理浏览器 _sip.Text = ""; _htmltianqiV.Source = new Uri("http://news.hatohalo.com:801/bwc_zz_md5.aspx"); } if (e.NavigationParameter.GetType().Equals(typeof(VoiceCommandActivatedEventArgs))) { VoiceCommandActivatedEventArgs commandArgs_thisone = e.NavigationParameter as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs_thisone.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; string navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties["NavigationTarget"][0]; _sip.Text = ""; _htmltianqiV.Source = new Uri("http://news.hatohalo.com:801/bwc_zz_md5.aspx"); } }
/// <summary> /// Handles voice commands from Cortana integration /// </summary> /// <param name="e"></param> /// <returns></returns> protected override bool OnActivation(VoiceCommandActivatedEventArgs e) { var info = new VoiceCommandInfo(e.Result); switch (info.VoiceCommandName) { case "showTitleDetails": { // Access the value of the {destination} phrase in the voice command string spokenTitle = info.GetSemanticInterpretation("Titles"); this.Details(spokenTitle); return true; } case "playTitle": { // Access the value of the {destination} phrase in the voice command string spokenTitle = info.GetSemanticInterpretation("Titles"); this.Media(spokenTitle); return true; } default: // If we can't determine what page to launch, go to the default entry point. return false; } }
protected override async void OnActivated(IActivatedEventArgs args) { SetupShell(args); // we need to wait for the shell to load while (AppShell.Current == null) { await Task.Delay(200); } switch (args.Kind) { case ActivationKind.Protocol: ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs; Windows.Foundation.WwwFormUrlDecoder decoder = new Windows.Foundation.WwwFormUrlDecoder(protocolArgs.Uri.Query); var siteId = decoder.GetFirstValueByName("LaunchContext"); var parameter = new TripNavigationParameter { TripId = AppSettings.LastTripId, SightId = Guid.ParseExact(siteId, "D") }.GetJson(); AppShell.Current.NavigateToPage(typeof(TripDetailPage), parameter); break; // Insert the M2_VoiceActivation snippet here case ActivationKind.VoiceCommand: VoiceCommandActivatedEventArgs voiceArgs = args as VoiceCommandActivatedEventArgs; HandleVoiceCommand(args); break; // Insert the M2_ToastActivation snippet here case ActivationKind.ToastNotification: var toast = args as ToastNotificationActivatedEventArgs; var props = toast.Argument.Split(':'); if (props[0] == "View") { var tripParam = new TripNavigationParameter { TripId = AppSettings.LastTripId, SightId = Guid.ParseExact(props[1], "D") }.GetJson(); AppShell.Current.NavigateToPage(typeof(TripDetailPage), tripParam); } else if (props[0] == "Remove") { var tripParam = new TripNavigationParameter { TripId = AppSettings.LastTripId, SightId = Guid.ParseExact(props[1], "D"), DeleteSight = true }.GetJson(); AppShell.Current.NavigateToPage(typeof(TripDetailPage), tripParam); } break; default: break; } // Ensure the current window is active Window.Current.Activate(); }
protected async override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs commandArgs = args as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; MessageDialog messageDialog = new MessageDialog(""); switch (voiceCommandName) { case "OpenVim": try { Windows.Web.Http.HttpClient client = new Windows.Web.Http.HttpClient(); await client.GetAsync(new Uri("http://localhost:8888/vim")); } catch (Exception) { messageDialog.Content = "Failed to launch vim"; await messageDialog.ShowAsync(); } break; default: messageDialog.Content = "Unknown command"; await messageDialog.ShowAsync(); break; } } }
public static string GetRequestedContact(VoiceCommandActivatedEventArgs args) { // Voice command activation. if (args.Kind == ActivationKind.VoiceCommand) { SpeechRecognitionResult speechRecognitionResult = args.Result; // Get the name of the voice command and the text spoken. // See VoiceCommands.xml for supported voice commands. string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; // commandMode indicates whether the command was entered using speech or text. // Apps should respect text mode by providing silent (text) feedback. string commandMode = SemanticInterpretation("commandMode", speechRecognitionResult); string user = string.Empty; switch (voiceCommandName) { case "zeige": // Access the value of {destination} in the voice command. user = SemanticInterpretation("nutzer", speechRecognitionResult); break; default: break; } return(user); } return(null); }
public void HandleVoiceRequest(VoiceCommandActivatedEventArgs commandArgs) { Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = commandArgs.Result; // Get the name of the voice command and the text spoken. See AdventureWorksCommands.xml for // the <Command> tags this can be filled with. string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; // The commandMode is either "voice" or "text", and it indictes how the voice command // was entered by the user. // Apps should respect "text" mode by providing feedback in silent form. string commandMode = this.SemanticInterpretation("commandMode", speechRecognitionResult); switch (voiceCommandName) { case "openBookmarks": var bookmarkCommand = new NavigateToBookmarksCommand(); bookmarkCommand.Execute(null); break; case "openPrivateMessages": var pmCommand = new NavigateToPrivateMessageListPageCommand(); pmCommand.Execute(null); break; case "lowtaxIsAJerk": var lowtaxCommand = new NavigateToNewPrivateMessagePageLowtaxCommand(); lowtaxCommand.Execute(null); break; default: break; } }
/// <summary> /// 使用在导航过程中传递的内容填充页。 在从以前的会话 /// 重新创建页时,也会提供任何已保存状态。 /// </summary> /// <param name="sender"> /// 事件的来源; 通常为 <see cref="NavigationHelper"/> /// </param> /// <param name="e">事件数据,其中既提供在最初请求此页时传递给 /// <see cref="Frame.Navigate(Type, Object)"/> 的导航参数,又提供 /// 此页在以前会话期间保留的状态的 /// 字典。 首次访问页面时,该状态将为 null。</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter == null) { return; } if (e.NavigationParameter.GetType().Equals(typeof(string))) { string CS = e.NavigationParameter.ToString(); this.DefaultViewModel["CS"] = CS; //处理浏览器 _htmltianqiV.Source = new Uri("http://waptianqi.2345.com"); } if (e.NavigationParameter.GetType().Equals(typeof(VoiceCommandActivatedEventArgs))) { VoiceCommandActivatedEventArgs commandArgs_thisone = e.NavigationParameter as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs_thisone.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; string navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties["NavigationTarget"][0]; //await new MessageDialog(textSpoken.Replace("的天气", "").Replace("天气", "").Trim()).ShowAsync(); PublicS.GetInitCityDM(); string cityDM = "http://waptianqi.2345.com"; PublicS.CityDicDM.TryGetValue(textSpoken.Replace("预报", "").Replace("的天气", "").Replace("天气", "").Trim(), out cityDM); PublicS.CityDicDM.Clear(); _htmltianqiV.Source = new Uri(cityDM); } }
protected async override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.VoiceCommand) { Frame rootFrame = Window.Current.Content as Frame; VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args; //check for the command name that launched the app string voiceCommandName = vcArgs.Result.RulePath.FirstOrDefault(); switch (voiceCommandName) { case "ViewEntry": rootFrame.Navigate(typeof(ViewDiaryEntry), vcArgs.Result.Text); break; case "AddEntry": case "EagerEntry": rootFrame.Navigate(typeof(AddDiaryEntry), vcArgs.Result.Text); break; default: await DisplayMessage("Didn't understand that. Try again."); break; } } }
/// <summary> /// 使用在导航过程中传递的内容填充页。 在从以前的会话 /// 重新创建页时,也会提供任何已保存状态。 /// </summary> /// <param name="sender"> /// 事件的来源; 通常为 <see cref="NavigationHelper"/> /// </param> /// <param name="e">事件数据,其中既提供在最初请求此页时传递给 /// <see cref="Frame.Navigate(Type, Object)"/> 的导航参数,又提供 /// 此页在以前会话期间保留的状态的 /// 字典。 首次访问页面时,该状态将为 null。</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter == null) { return; } if (e.NavigationParameter.GetType().Equals(typeof(string))) { string CS = e.NavigationParameter.ToString(); this.DefaultViewModel["CS"] = CS; //处理浏览器 _sip.Text = ""; _htmltianqiV.Source = new Uri("http://news.hatohalo.com:801/bwc_zz_ip.aspx"); } if (e.NavigationParameter.GetType().Equals(typeof(VoiceCommandActivatedEventArgs))) { VoiceCommandActivatedEventArgs commandArgs_thisone = e.NavigationParameter as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs_thisone.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; string navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties["NavigationTarget"][0]; //await new MessageDialog(textSpoken.Replace("的天气", "").Replace("天气", "").Trim()).ShowAsync(); string ip = textSpoken.Replace("i", "").Replace("I", "").Replace("p", "").Replace("P", "").Replace("地址", "").Replace("零", "0").Replace("点", ".").Replace("一", "1").Replace("二", "2").Replace("三", "3").Replace("四", "4").Replace("五", "5").Replace("六", "6").Replace("七", "7").Replace("八", "8.").Replace("九", "9").Trim(); _sip.Text = ip; _htmltianqiV.Source = new Uri("http://news.hatohalo.com:801/bwc_zz_ip.aspx?ip=" + ip); } }
/// <summary> /// Handles voice commands from Cortana integration /// </summary> /// <param name="e"></param> /// <returns></returns> protected override bool OnActivation(VoiceCommandActivatedEventArgs e) { var info = new VoiceCommandInfo(e.Result); switch (info.VoiceCommandName) { case "showTitleDetails": { // Access the value of the {destination} phrase in the voice command string spokenTitle = info.GetSemanticInterpretation("Titles"); this.Details(spokenTitle); return(true); } case "playTitle": { // Access the value of the {destination} phrase in the voice command string spokenTitle = info.GetSemanticInterpretation("Titles"); this.Media(spokenTitle); return(true); } default: // If we can't determine what page to launch, go to the default entry point. return(false); } }
protected async override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs cmd = args as VoiceCommandActivatedEventArgs; SpeechRecognitionResult result = cmd.Result; MessageDialog dialog = new MessageDialog(""); string commandName = result.RulePath[0]; switch (commandName) { case "ST_CheckCode": dialog.Content = "Check code"; break; default: Debug.Write("Coldnt find command"); break; } await dialog.ShowAsync(); } }
/// <summary> /// 使用在导航过程中传递的内容填充页。 在从以前的会话 /// 重新创建页时,也会提供任何已保存状态。 /// </summary> /// <param name="sender"> /// 事件的来源; 通常为 <see cref="NavigationHelper"/> /// </param> /// <param name="e">事件数据,其中既提供在最初请求此页时传递给 /// <see cref="Frame.Navigate(Type, Object)"/> 的导航参数,又提供 /// 此页在以前会话期间保留的状态的 /// 字典。 首次访问页面时,该状态将为 null。</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter == null) { return; } if (e.NavigationParameter.GetType().Equals(typeof(string))) { string CS = e.NavigationParameter.ToString(); this.DefaultViewModel["CS"] = CS; //处理浏览器 _htmltianqiV.Source = new Uri("http://tools.2345.com/m/shenfenzheng.htm"); } if (e.NavigationParameter.GetType().Equals(typeof(VoiceCommandActivatedEventArgs))) { VoiceCommandActivatedEventArgs commandArgs_thisone = e.NavigationParameter as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs_thisone.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; string navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties["NavigationTarget"][0]; //await new MessageDialog(textSpoken.Replace("的天气", "").Replace("天气", "").Trim()).ShowAsync(); string sfz = textSpoken.Replace("身份证号码", "").Replace("身份证号", "").Replace("身份证", "").Trim(); _htmltianqiV.Source = new Uri("http://tools.2345.com/m/shenfenzheng.htm"); _htmltianqiV.Tag = "CS:" + sfz; } }
/* * Look up the spoken command and execute its corresponding action */ public static void RunCommand(VoiceCommandActivatedEventArgs cmd) { SpeechRecognitionResult result = cmd.Result; string commandName = result.RulePath[0]; vcdLookup[commandName].DynamicInvoke(); }
protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs cmd = args as VoiceCommandActivatedEventArgs; SpeechRecognitionResult result = cmd.Result; string commandName = result.RulePath[0]; MessageDialog dialog = new MessageDialog(""); switch (commandName) { case "TurnOnDeskLight": test.turningOnLightMqtt(); break; case "TurnOffDeskLight": test.turningOffLightMqtt(); break; default: Debug.WriteLine("Couldn't find command name"); break; } } CoreApplication.Exit(); }
protected async override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs cmd = args as VoiceCommandActivatedEventArgs; SpeechRecognitionResult result = cmd.Result; string commandName = result.RulePath[0]; MessageDialog dialog = new MessageDialog(""); switch (commandName) { case "OpenApp": // this is the code to open the app dialog.Content = "This is when the app opens."; break; case "WhoIsIt": // this is the code to open the app and show who is at the door dialog.Content = "This is when the app opens and shows who is at the door."; break; default: Debug.WriteLine("Couldn't find command name."); break; } await dialog.ShowAsync(); } }
/// <summary> /// 使用在导航过程中传递的内容填充页。 在从以前的会话 /// 重新创建页时,也会提供任何已保存状态。 /// </summary> /// <param name="sender"> /// 事件的来源; 通常为 <see cref="NavigationHelper"/> /// </param> /// <param name="e">事件数据,其中既提供在最初请求此页时传递给 /// <see cref="Frame.Navigate(Type, Object)"/> 的导航参数,又提供 /// 此页在以前会话期间保留的状态的 /// 字典。 首次访问页面时,该状态将为 null。</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter == null) { return; } if (e.NavigationParameter.GetType().Equals(typeof(string))) { string CS = e.NavigationParameter.ToString(); this.DefaultViewModel["CS"] = CS; //处理浏览器 _htmltianqiV.Source = new Uri("http://3g.ruyicai.com/w3g/winInfo/selectWinInfoCenter"); } if (e.NavigationParameter.GetType().Equals(typeof(VoiceCommandActivatedEventArgs))) { VoiceCommandActivatedEventArgs commandArgs_thisone = e.NavigationParameter as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs_thisone.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; string navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties["NavigationTarget"][0]; //await new MessageDialog(textSpoken.Replace("的天气", "").Replace("天气", "").Trim()).ShowAsync(); //string gupiao = textSpoken.Replace("股票代码", "").Replace("股票", "").Trim(); _htmltianqiV.Source = new Uri("http://3g.ruyicai.com/w3g/winInfo/selectWinInfoCenter"); } }
/// <summary> /// 使用在导航过程中传递的内容填充页。 在从以前的会话 /// 重新创建页时,也会提供任何已保存状态。 /// </summary> /// <param name="sender"> /// 事件的来源; 通常为 <see cref="NavigationHelper"/> /// </param> /// <param name="e">事件数据,其中既提供在最初请求此页时传递给 /// <see cref="Frame.Navigate(Type, Object)"/> 的导航参数,又提供 /// 此页在以前会话期间保留的状态的 /// 字典。 首次访问页面时,该状态将为 null。</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter == null) { return; } if (e.NavigationParameter.GetType().Equals(typeof(string))) { string CS = e.NavigationParameter.ToString(); this.DefaultViewModel["CS"] = CS; //处理浏览器 _sip.Text = ""; _htmltianqiV.Source = new Uri("http://news.hatohalo.com:801/bwc_zz_yuming.aspx"); } if (e.NavigationParameter.GetType().Equals(typeof(VoiceCommandActivatedEventArgs))) { VoiceCommandActivatedEventArgs commandArgs_thisone = e.NavigationParameter as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs_thisone.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; string navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties["NavigationTarget"][0]; //await new MessageDialog(textSpoken.Replace("的天气", "").Replace("天气", "").Trim()).ShowAsync(); string yuming = textSpoken.Replace("域名", "").Replace(" ", "").Replace("三w", "www").Replace("三W", "www").Replace("点", ".").Trim(); _sip.Text = yuming; _htmltianqiV.Source = new Uri("http://news.hatohalo.com:801/bwc_zz_yuming.aspx?yuming=" + yuming); } }
protected CortanaCommand(string name, string argument, VoiceCommandActivatedEventArgs commandArgs=null) { Name = name; Argument = argument; OrganizeFeedback(commandArgs); }
public async void HandleActivation(VoiceCommandActivatedEventArgs args) { var speechRecognitionResult = args.Result; var voiceCommandName = speechRecognitionResult.RulePath[0]; _tracking.TrackVoiceCommandEvent(voiceCommandName); if (voiceCommandName == "SelectCity") { var cityName = speechRecognitionResult.SemanticInterpretation.Properties["city"][0]; var cityId = _phrases.FindCityIdByName(cityName); if (cityId != null) { await ServiceLocator.Current.GetInstance <MainViewModel>().TrySelectCityById(cityId); } } else if (voiceCommandName == "SelectParkingLot") { var cityName = speechRecognitionResult.SemanticInterpretation.Properties["city"][0]; var cityId = _phrases.FindCityIdByName(cityName); if (cityId != null) { var parkingLotName = speechRecognitionResult.SemanticInterpretation.Properties["parking_lot"][0]; var parkingLotId = _phrases.FindParkingLotIdByNameAndCityId(cityId, parkingLotName); await ServiceLocator.Current.GetInstance <MainViewModel>().TrySelectParkingLotById(cityId, parkingLotId); } } }
protected async override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs cmd = args as VoiceCommandActivatedEventArgs; SpeechRecognitionResult result = cmd.Result; string commandName = result.RulePath[0]; MessageDialog dialog = new MessageDialog(""); switch (commandName) { case "ShutDownComputer": dialog.Content = "shut down time"; break; default: Debug.WriteLine("Couldn't find command name"); break; } await dialog.ShowAsync(); } }
/// <summary> /// 使用在导航过程中传递的内容填充页。 在从以前的会话 /// 重新创建页时,也会提供任何已保存状态。 /// </summary> /// <param name="sender"> /// 事件的来源; 通常为 <see cref="NavigationHelper"/> /// </param> /// <param name="e">事件数据,其中既提供在最初请求此页时传递给 /// <see cref="Frame.Navigate(Type, Object)"/> 的导航参数,又提供 /// 此页在以前会话期间保留的状态的 /// 字典。 首次访问页面时,该状态将为 null。</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter == null) { return; } if (e.NavigationParameter.GetType().Equals(typeof(string))) { string CS = e.NavigationParameter.ToString(); this.DefaultViewModel["CS"] = CS; //处理浏览器 _htmltianqiV.Source = new Uri("http://m.kuaidi100.com/"); } if (e.NavigationParameter.GetType().Equals(typeof(VoiceCommandActivatedEventArgs))) { VoiceCommandActivatedEventArgs commandArgs_thisone = e.NavigationParameter as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs_thisone.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; string navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties["NavigationTarget"][0]; //await new MessageDialog(textSpoken.Replace("快递单号", "").Replace("快递单", "").Trim()).ShowAsync(); string kuaidiNumber = textSpoken.Replace("快递单号", "").Replace("快递单", "").Replace("快递", "").Replace(" ", ""); _htmltianqiV.Source = new Uri("http://m.kuaidi100.com/result.jsp?nu=" + kuaidiNumber); } //加载历史记录 bangding(); }
/// <summary> /// Converts VoiceCommandActivatedEvent into specific CortanaCommand. 2 purposes: /// 1) Parse the "argument" of the command (ex. filename "My Cool Script", notepad note "feed the cat", etc.) into usable format. /// 2) Separate the details of "capturing" a voice command (here) from the command's business logic (in it's subclass of CortanaCommand) /// </summary> public static CortanaCommand ProcessCommand(VoiceCommandActivatedEventArgs commandArgs) { SpeechRecognitionResult speechRecognitionResult = commandArgs.Result; CommandDiagnostics diagnostics = new CommandDiagnostics(commandArgs); return(ProcessCommand(speechRecognitionResult, diagnostics)); }
/// <summary> /// 使用在导航过程中传递的内容填充页。 在从以前的会话 /// 重新创建页时,也会提供任何已保存状态。 /// </summary> /// <param name="sender"> /// 事件的来源; 通常为 <see cref="NavigationHelper"/> /// </param> /// <param name="e">事件数据,其中既提供在最初请求此页时传递给 /// <see cref="Frame.Navigate(Type, Object)"/> 的导航参数,又提供 /// 此页在以前会话期间保留的状态的 /// 字典。 首次访问页面时,该状态将为 null。</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter == null) { return; } if (e.NavigationParameter.GetType().Equals(typeof(string))) { string CS = e.NavigationParameter.ToString(); this.DefaultViewModel["CS"] = CS; //处理浏览器 _htmltianqiV.Source = new Uri("http://dp.sina.cn/dpool/tools/money/index.php?pos=63&vt=4"); } if (e.NavigationParameter.GetType().Equals(typeof(VoiceCommandActivatedEventArgs))) { VoiceCommandActivatedEventArgs commandArgs_thisone = e.NavigationParameter as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs_thisone.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; string navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties["NavigationTarget"][0]; _htmltianqiV.Source = new Uri("http://dp.sina.cn/dpool/tools/money/index.php?pos=63&vt=4"); } }
// Cortana를 통해 ActivationKind.VoiceCommand로 앱이 활성화가 될 때 트리거된다. // Library 클래스의 Command 프로퍼티는 VCD.xml에 기반한 음성 입력의 결과로 설정된다. protected override void OnActivated(IActivatedEventArgs e) { base.OnActivated(e); try { if (e.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs args = (VoiceCommandActivatedEventArgs)e; Library.Command = args.Result.SemanticInterpretation.Properties["colour"].FirstOrDefault(); } } catch { } Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), e); } Window.Current.Activate(); }
protected override async void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs cmd = args as VoiceCommandActivatedEventArgs; SpeechRecognitionResult result = cmd.Result; string commandName = result.RulePath[0]; MessageDialog popup = new MessageDialog(""); switch (commandName) { case "Rolladen": var properties = result.SemanticInterpretation.Properties; string room = properties["Zimmer"][0]; string action = properties["RolladenAktion"][0]; string label = string.Format("Zimmer: {0}| Aktion: {1}", room, action); popup.Content = label; break; default: Debug.WriteLine("Unknown command: " + commandName); break; } await popup.ShowAsync(); } }
protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs voiceCommandArgs = args as VoiceCommandActivatedEventArgs; Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = voiceCommandArgs.Result; String text = speechRecognitionResult.Text; string voiceCommandName = speechRecognitionResult.RulePath[0]; switch (voiceCommandName) { case "voicecommand": string newtxt = this.SemanticInterpretation("name", speechRecognitionResult); if (newtxt != null) { text = newtxt; } ReadText(new MediaElement(), text); Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; rootFrame.Navigate(typeof(MainPage), speechRecognitionResult); // Place the frame in the current Window Window.Current.Content = rootFrame; } else { Window.Current.Content = rootFrame; } // Since we're expecting to always show a details page, navigate even if // a content frame is in place (unlike OnLaunched). // Navigate to either the main trip list page, or if a valid voice command // was provided, to the details page for that trip. // Ensure the current window is active Window.Current.Activate(); break; default: ReadText(new MediaElement(), text); break; } } else if (args.Kind == ActivationKind.Protocol) { } }
public static void HandleCommand(IActivatedEventArgs args, Frame rootFrame) { if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs voiceArgs = (VoiceCommandActivatedEventArgs)args; if (!((Frame)Window.Current.Content).Navigate(typeof(NordicUART), ToolboxIdentifications.PageId.NORDIC_UART)) { } } }
public NavigationParameterModel(IDatabaseService databaseService, LicenseInformation licenseInformation, IStringResourceService stringResourceService, VoiceCommandActivatedEventArgs voiceCommandArgs) { DatabaseService = databaseService; LicenseInformation = licenseInformation; StringResourceService = stringResourceService; VoiceCommandActivatedEventArgs = voiceCommandArgs; }
/// <summary> /// Invoked when the application is activated by some means other than normal launching. /// </summary> /// <param name="e">Event data for the event.</param> protected async override void OnActivated(IActivatedEventArgs e) { // Handle when app is launched by Cortana if (e.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs commandArgs = e as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; IReadOnlyList<string> recognizedVoiceCommandPhrases; System.Diagnostics.Debug.WriteLine("voiceCommandName: " + voiceCommandName); System.Diagnostics.Debug.WriteLine("textSpoken: " + textSpoken); MessageDialog messageDialog = new MessageDialog(""); switch (voiceCommandName) { case "Activate_Alarm": System.Diagnostics.Debug.WriteLine("Activate_Alarm command"); messageDialog.Content = "Activate Alarm command"; break; case "Change_Temperature": string temperature = ""; if (speechRecognitionResult.SemanticInterpretation.Properties.TryGetValue("temperature", out recognizedVoiceCommandPhrases)) { temperature = recognizedVoiceCommandPhrases.First(); } messageDialog.Content = "Change_Temperature command. The passed PhraseTopic value is " + temperature; break; case "Change_Light_Color": string color = ""; if (speechRecognitionResult.SemanticInterpretation.Properties.TryGetValue("colors", out recognizedVoiceCommandPhrases)) { color = recognizedVoiceCommandPhrases.First(); } messageDialog.Content = "Change_Light_Color command. The passed PhraseList value is " + color; break; default: messageDialog.Content = "Unknown command"; break; } await messageDialog.ShowAsync(); } }
public async void HandleCommand(VoiceCommandActivatedEventArgs args) { var speechRecogResult = args.Result; var cmdName = speechRecogResult.RulePath[0]; var textSpoken = speechRecogResult.Text; string commandMode = speechRecogResult.SemanticInterpretation.Properties["commandMode"].ToString(); var cmd = Commands.FirstOrDefault(t => t.CommandName.ToLower().Equals(cmdName.ToLower())); cmd?.Execute(speechRecogResult.SemanticInterpretation); }
public async void HandleCommand(VoiceCommandActivatedEventArgs args) { var speechRecogResult = args.Result; var cmdName = speechRecogResult.RulePath[0]; var textSpoken = speechRecogResult.Text; string commandMode = speechRecogResult.SemanticInterpretation.Properties["commandMode"].ToString(); var cmd = Commands.FirstOrDefault(t => t.CommandName.ToLower().Equals(cmdName.ToLower())); cmd?.Execute(speechRecogResult.SemanticInterpretation); }
protected override void OnActivated(IActivatedEventArgs args) { if (args is FileOpenPickerContinuationEventArgs) { Frame rootFrame = Window.Current.Content as Frame; if (Config.pictrueType == 1) { var p = rootFrame.Content as Dreaming; p.FilePickerEvent = (FileOpenPickerContinuationEventArgs)args; rootFrame.Navigate(typeof(Dreaming)); } else if (Config.pictrueType == 2) { var p = rootFrame.Content as Chat; p.FilePickerEvent = (FileOpenPickerContinuationEventArgs)args; rootFrame.Navigate(typeof(Chat)); } else { var p = rootFrame.Content as UserData; p.FilePickerEvent = (FileOpenPickerContinuationEventArgs)args; rootFrame.Navigate(typeof(UserData)); } Window.Current.Activate(); } if (args is VoiceCommandActivatedEventArgs) { VoiceCommandActivatedEventArgs voice = (VoiceCommandActivatedEventArgs)args; string result = voice.Result.Text; string path = voice.Result.RulePath[0]; string navigation = voice.Result.SemanticInterpretation.Properties["NavigationTarget"][0]; Debug.WriteLine(result); Debug.WriteLine(navigation); Frame rootFrame = new Frame(); if (path == "dreamingStart") { rootFrame.Navigate(typeof(AllDreaming), voice); } else if (result.Contains("发布")) { rootFrame.Navigate(typeof(Dreaming), voice); } Window.Current.Content = rootFrame; Window.Current.Activate(); } }
public static void OnActivated(VoiceCommandActivatedEventArgs args) { var commands = args as VoiceCommandActivatedEventArgs; SpeechRecognitionResult result = commands.Result; string voiceCommandName = result.RulePath[0]; CortanaCommand command; if (Commands.ContainsKey(voiceCommandName)) { command = Commands[voiceCommandName]; } else { // get default command command = new DefaultCommand(); } command.OnHandleCommand(args); }
private void OrganizeFeedback(VoiceCommandActivatedEventArgs commandArgs) { if (commandArgs != null) { SpeechRecognitionResult speech = commandArgs.Result; RawText = speech.Text; Mode = SemanticInterpretation("commandMode", speech); SpeechRecognitionConfidence confidence = speech.Confidence; double rawConfidence = speech.RawConfidence; TimeSpan duration = speech.PhraseDuration; DateTimeOffset start = speech.PhraseStartTime; SpeechRecognitionResultStatus status = speech.Status; } else { RawText = Mode = null; } }
/// <summary> /// Converts VoiceCommandActivatedEvent into specific CortanaCommand. 2 purposes: /// 1) Parse the "argument" of the command (ex. filename "My Cool Script", notepad note "feed the cat", etc.) into usable format. /// 2) Separate the details of "capturing" a voice command (here) from the command's business logic (in it's subclass of CortanaCommand) /// </summary> public static CortanaCommand ProcessCommand(VoiceCommandActivatedEventArgs commandArgs) { SpeechRecognitionResult speechRecognitionResult = commandArgs.Result; // Get the name of the voice command and the text spoken string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; string argument = null; CortanaCommand processedCommand = null; switch (voiceCommandName) { case CortanaCommand.Execute: argument = GetPhraseArg(speechRecognitionResult, "filename"); // filename processedCommand = new ExecuteCortanaCommand(argument, commandArgs); break; case CortanaCommand.YouTube: const string youtube = "YouTube"; argument = StripOffCommand(youtube, textSpoken); // search text processedCommand = new YoutubeCortanaCommand(argument, commandArgs); break; case CortanaCommand.Notepad: const string notepad = "Notepad"; argument = StripOffCommand(notepad, textSpoken); // text processedCommand = new NotepadCortanaCommand(argument, commandArgs); break; case CortanaCommand.ToggleListening: processedCommand = new ToggleListeningCortanaCommand(null, commandArgs); // no argument needed break; default: Debug.WriteLine("Command Name Not Found: " + voiceCommandName); break; } return processedCommand; }
/// <summary> /// Handles voice command defined by given voice command arguments /// </summary> /// <param name="args">Arguments that define voice command</param> /// <returns>Awaitable <see cref="Task"/></returns> public async Task HandleVoiceCommnadAsync(VoiceCommandActivatedEventArgs args) { string commandName = args?.Result.RulePath.FirstOrDefault(); logger.LogMessage($"Voice commands handler: Processing {commandName} command..."); switch (commandName) { case "playTheLastEpisode": await episodeListManager.PlayLastDownloadedEpisodeAsync(); playbackManager.Play(); break; case "playEpisodeByNumber": if (isVoiceCommand(args.Result)) { int episodeNumber = -1; var spokenNumber = args.Result.SemanticInterpretation.Properties["number"].FirstOrDefault(); int.TryParse(spokenNumber, out episodeNumber); var episodeToPlay = episodeListManager.GetEpisodeByNumber(episodeNumber); if (episodeToPlay == null) { // TODO: Speak error logger.LogMessage($"VoiceCommandHandler: Cannot play episode with number {episodeNumber}.", LoggingLevel.Warning); return; } if (!episodeToPlay.CanBePlayed) { // TODO: Speak error logger.LogMessage($"VoiceCommandHandler: Found episode with number {episodeNumber}, but cannot play it", LoggingLevel.Warning); return; } playlist.Clear(); await episodeListManager.PlayEpisodeAsync(episodeToPlay); playbackManager.Play(); await episodeListManager.UpdateEpisodeStatesAsync(); } break; case "startPlayback": if (playlist.CurrentTrack != null) { playbackManager.Play(); } break; case "pausePlayback": playbackManager.SchedulePause(); break; case "goForward": changePosition(args?.Result.SemanticInterpretation.Properties, Direction.Forward); break; case "goBack": changePosition(args?.Result.SemanticInterpretation.Properties, Direction.Backward); break; case "nextTrack": case "nextEpisode": playbackManager.GoToNextTrack(); break; case "previousTrack": case "previousEpisode": playbackManager.GoToPreviousTrack(); break; case "checkForUpdates": int newEpisodesCount = await episodeListManager.LoadEpisodeListFromServerAsync(); string message = "Update complete. "; if (newEpisodesCount == 1) { message += "There is one new episode."; } else if (newEpisodesCount > 1) { message += $"There are {newEpisodesCount} new episodes."; } else { message += "There are no new episodes yet!"; } // TODO: Speak result // await textSpeaker.SpeakText(message); break; } }
private void RespondToVoiceCommand(VoiceCommandActivatedEventArgs e, IAppPage page) { CortanaCommand command = Cortana.ProcessCommand(e); page.RespondToVoice(command); // see MainPage for example }
public YoutubeCortanaCommand(string argument, VoiceCommandActivatedEventArgs commandArgs = null) : base(YouTube, argument, commandArgs) { /*Super constructor does everything*/ }
public NotepadCortanaCommand(string argument, VoiceCommandActivatedEventArgs commandArgs = null) : base(Notepad, argument, commandArgs) { /*Super constructor does everything*/ }
public abstract void OnHandleCommand(VoiceCommandActivatedEventArgs args);
protected virtual Task OnVoiceCommandStartAsync(VoiceCommandActivatedEventArgs voiceCommandArgs, object e) { return Task.FromResult<object>(null); }
protected abstract bool OnActivation(VoiceCommandActivatedEventArgs e);
public CommandDiagnostics(VoiceCommandActivatedEventArgs commandArgs) { OrganizeFeedback(commandArgs); }
/// <summary> /// Converts VoiceCommandActivatedEvent into specific CortanaCommand. 2 purposes: /// 1) Parse the "argument" of the command (ex. filename "My Cool Script", notepad note "feed the cat", etc.) into usable format. /// 2) Separate the details of "capturing" a voice command (here) from the command's business logic (in it's subclass of CortanaCommand) /// </summary> public static CortanaCommand ProcessCommand(VoiceCommandActivatedEventArgs commandArgs) { SpeechRecognitionResult speechRecognitionResult = commandArgs.Result; CommandDiagnostics diagnostics = new CommandDiagnostics(commandArgs); return ProcessCommand(speechRecognitionResult, diagnostics); }
private void HandleVoiceCommands(VoiceCommandActivatedEventArgs args) { Navigate(args); }
public ToggleListeningCortanaCommand(string argument, VoiceCommandActivatedEventArgs commandArgs = null) : base(ToggleListening, argument, commandArgs) { /*Super constructor does everything*/ }
/* Look up the spoken command and execute its corresponding action */ public static void RunCommand(VoiceCommandActivatedEventArgs cmd) { SpeechRecognitionResult result = cmd.Result; string commandName = result.RulePath[0]; vcdLookup[commandName].DynamicInvoke(); }
public override void OnHandleCommand(VoiceCommandActivatedEventArgs args) { initWindow(); App.Instance.ShowMainPage(args); Window.Current.Activate(); }
public void HandleVoiceRequest(VoiceCommandActivatedEventArgs commandArgs) { Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = commandArgs.Result; // Get the name of the voice command and the text spoken. See AdventureWorksCommands.xml for // the <Command> tags this can be filled with. string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; // The commandMode is either "voice" or "text", and it indictes how the voice command // was entered by the user. // Apps should respect "text" mode by providing feedback in silent form. string commandMode = this.SemanticInterpretation("commandMode", speechRecognitionResult); switch (voiceCommandName) { case "openBookmarks": var bookmarkCommand = new NavigateToBookmarksCommand(); bookmarkCommand.Execute(null); break; case "openPrivateMessages": var pmCommand = new NavigateToPrivateMessageListPageCommand(); pmCommand.Execute(null); break; case "lowtaxIsAJerk": var lowtaxCommand = new NavigateToNewPrivateMessagePageLowtaxCommand(); lowtaxCommand.Execute(null); break; default: break; } }
public static void HandleCommands(VoiceCommandActivatedEventArgs argus) { SpeechRecognitionResult speechRecognitionResult = argus.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; Type NavigationPageType = null; VoiceCommand voiceCommand = new VoiceCommand(); switch (voiceCommandName.ToLower()) { case "closeapp": Application.Current.Exit(); break; case "openapp": if(App.Instance.Frame.Content == null) { NavigationPageType = typeof(MainPage); App.Instance.Frame.Navigate(NavigationPageType, voiceCommand); } Window.Current.Activate(); break; case "continuevideo": var settings = ApplicationData.Current.LocalSettings.Values; object videoInfo = string.Empty; if(settings.TryGetValue(Constants.CurrentPlayingVideoInfo, out videoInfo)) { string[] temp = videoInfo.ToString().Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); if(temp.Length == 2) { VideoPlayPage.PageParams paras = new VideoPlayPage.PageParams(); paras.VideoId = Int32.Parse(temp[0]); paras.StartPosition = TimeSpan.Parse(temp[1]); paras.IsLanuchFromSerivice = true; App.Instance.Frame.Navigate(typeof(VideoPlayPage), paras); Window.Current.Activate(); } } break; case "playvideo": if(IsInVideoPlayerPage()) { var videoPlayer = App.Instance.Frame.Content as VideoPlayPage; videoPlayer.Play(); } break; case "pausevideo": if(IsInVideoPlayerPage()) { var videoPlayer = App.Instance.Frame.Content as VideoPlayPage; videoPlayer.Pause(); } break; case "stopvideo": if(IsInVideoPlayerPage()) { var videoPlayer = App.Instance.Frame.Content as VideoPlayPage; videoPlayer.Stop(); } break; default: App.Instance.Frame.Navigate(typeof(MainPage), voiceCommand); Window.Current.Activate(); break; } }