The keywords page demonstrates how to load a list of visible keywords from a catalog, as well as how to search the list (perform an index word-wheel).
Hit the "Get Keywords" button and the results list will fill with a list of keywords. Data for the selected keyword result object is displayed at the bottom. Here I've typed "lock method" into the search box, and the code has found an item and scrolled down to that item (a typical index word-wheel).
To the right we list the Topic results associated with the selected Index item. And to the right of that we show the rendered topic and topic object data.
Index Again this is very simple to code. The VS catalog can contain over a million keywords so we are using a ListView control in Virtual mode.
We get a collection of Keywords by passing the _catalog object into GetKeywords() method.
IKeywordCollection keywords = _catalogRead.GetKeywords(_catalog, true);
The true parameter enables some caching to speed up loading.
Keyword ClassWe can access each Keyword object by iterating through the collection.
for (int i = 0; i < keywords.Count; i++)
{
keywords.MoveTo(i);
keyword keyword = (Keyword)keywords.Current;
....
}
There is also keywords.MoveNext(); that can be used if you are iterating with a foreach(...) { } loop.
The keyword object has these handy members:
keyword.DisplayValue | holds the keyword display string. | keyword.IsSubkey | tells us if we need to indent the keyword. | keyword.Topics | gives access to the list of result topics associated with the keyword. |
Word WheelWe want to type in the edit box (above the keyword list) and select the closest match in the list (the keyword starting with that text).
The MoveToKeyword() method returns the index of the List item we want to select and scroll into view
int i = _helpKeywords.MoveToKeyword(text); //where text is the text typed if (i >= 0 && i <= _helpKeywords.Count) { ...
|