c# - Opening a hyperlink generated dynamically with a string command -


Bastostory,

So I'm working on a personal assistant program and all my voice commands Translated to the wire

I have found the ability to search Google and display results as a hyperlinks in the text block.

Now I want to be able to set up these links to open the speech (string command) so far I have the following.

This bit allows me to search for using a custom GoogleSearch class Google Custom Search API.

  public zero search_google (string query) // Google search {#region link string string result_1 = ""; String result_2 = ""; String result_3 = ""; String result_4 = ""; String result_5 = ""; String result_6 = ""; String result_7 = ""; String result_8 = ""; String result_9 = ""; String result_10 = ""; #endregion Google Search Search = New Google Search () {key = "{APK}", cx = "{cxkey}"}; search.SearchCompleted + = (a, b) = & gt; {tab_control.SelectedIndex = 2; Int p = 1; search_results.txt = string Empty; Foreign items (items B. in response to items i.e.) {hyperlink hyperlink = new hyperlink () {navigatry = new uri (i. Link)}; hyperLink.Inlines.Add (i.Title); Hyperlink Navigate the request + = hyperlink_aruyesest; Hyperlink Name = "results_" + p; //search_results.Inlines.Add(hyperLinkName); search_results.Inlines.Add (Environment.NewLine); Search_results.Inlines.Add (hyperlink); Search_results.Inlines.Add (Environment.NewLine); Search_results.Inlines.Add (i.Snippet); Search_results.Inlines.Add (Environment.NewLine); Search_results.Inlines.Add (Environment.NewLine); P ++; }; }; Search.Search (query); }   

This shows my results in a text block in the series of hyperlinks and text snippets that I set on the main window. The search process has been started by my input analyst, which looks for the keyword "Search" or "Google".

The next step is to check the input parser for the keyword "result" so that it can open the hyperlink. There is an incomplete code for here.

  if ((input .contount ("result") || input. ("Result")) and amp; tab_control.TabIndex == 2) {int result_number = 0; Switch (result_number) {case 1: if (Input.Contains ("first") || input.Contains ("1st")} {// open hyperlink with name property result}} break; Case 2: // Added up to 10 with the same syntax for parsing in additional cases. }}    

You can open a hyperlink in the default browser:

  Process.Start (myHyperlink); Based on your comments, it looks like you're having trouble accessing  result_1  (etc.).   

Edit

.

public void search_google (string)

query) // Google search {#region Link string string result_1 = "";

This means that result_1 is visible only within that method.

If your if and switches statements are not part of search_google () , they should never result_1 < / code> can not be viewed. If these statements are in a different method, then you can work by moving the issue from result_1 to class level ( search_google () ).

On the site note instead of defining ten personal results string, you might want to use an array of stars or a list of stars.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -