private void UpdateHelpKeyword(bool tryLater)
{
IHelpService service = this.GetService(typeof(IHelpService)) as IHelpService;
if (service == null)
{
if (tryLater)
{
Application.Idle += new EventHandler(this.ApplicationIdle);
}
}
else
{
if (this._contextAttributes != null)
{
foreach (string str in this._contextAttributes)
{
service.RemoveContextAttribute("Keyword", str);
}
this._contextAttributes = null;
}
service.RemoveContextAttribute("Selection", SelectionKeywords[this._contextKeyword]);
bool flag = false;
if (this._selection.Count == 0)
{
flag = true;
}
else if (this._selection.Count == 1)
{
IDesignerHost host = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
if ((host != null) && this._selection.Contains(host.RootComponent))
{
flag = true;
}
}
this._contextAttributes = new string[this._selection.Count];
for (int i = 0; i < this._selection.Count; i++)
{
object component = this._selection[i];
string className = TypeDescriptor.GetClassName(component);
HelpKeywordAttribute attribute = (HelpKeywordAttribute)TypeDescriptor.GetAttributes(component)[typeof(HelpKeywordAttribute)];
if ((attribute != null) && !attribute.IsDefaultAttribute())
{
className = attribute.HelpKeyword;
}
this._contextAttributes[i] = className;
}
HelpKeywordType keywordType = flag ? HelpKeywordType.GeneralKeyword : HelpKeywordType.F1Keyword;
foreach (string str3 in this._contextAttributes)
{
service.AddContextAttribute("Keyword", str3, keywordType);
}
int count = this._selection.Count;
if ((count == 1) && flag)
{
count--;
}
this._contextKeyword = (short)Math.Min(count, SelectionKeywords.Length - 1);
service.AddContextAttribute("Selection", SelectionKeywords[this._contextKeyword], HelpKeywordType.FilterKeyword);
}
}