private void mainListBoxSelectedValueChanged(object sender, EventArgs e) { if (((XPListBox)sender).SelectedItem is XPListBoxGroup) { if (searchTextBox.Text == string.Empty) { int index = ((XPListBox)sender).SelectedIndex; (((XPListBox)sender).SelectedItem as XPListBoxGroup).Visible = !(((XPListBox)sender).SelectedItem as XPListBoxGroup).Visible; this.UpdateControl(); this.mainListBox.TopIndex = index; } } else if (((XPListBox)sender).SelectedItem is XPListBoxItem) { XPListBoxItem item = (((XPListBox)sender).SelectedItem as XPListBoxItem); for (int i = 0; i < this.listBoxGroups.Count; i++) { if (this.listBoxGroups[i].Items.Contains(item)) { this.SelectedToken = (this.listBoxGroups[i].Items[this.listBoxGroups[i].Items.IndexOf(item)].Tag as TokenInfo).Token; descriptionTextBox.Text = (this.listBoxGroups[i].Items[this.listBoxGroups[i].Items.IndexOf(item)].Tag as TokenInfo).Description; if (this.TokenSelected != null) { this.TokenSelected(); } } } } }
protected void InitializeToken(IToken Token) { TokenInfo tag = new TokenInfo(); tag.Token = Token; tag.Name = Token.Name; tag.Category = "Misc"; if (Token is ITokenTemplateEditorCompatible) { tag.Description = (Token as ITokenTemplateEditorCompatible).Description(LanguageType.English); tag.Category = (Token as ITokenTemplateEditorCompatible).Group; } XPListBoxItem token = new XPListBoxItem(tag.Name, !(Token is ISimpleToken) ? 0 : 1) { Tag = tag }; bool added = false; for (int k = 0; k < this.listBoxGroups.Count; k++) { if (this.listBoxGroups[k].Text == (token.Tag as TokenInfo).Category) { added = true; this.listBoxGroups[k].Items.Add(token); break; } } if (!added) { XPListBoxGroup group = new XPListBoxGroup((token.Tag as TokenInfo).Category, 2); group.Items.Add(token); this.listBoxGroups.Add(group); } }