public void Build(object root) { this.root = root; //create set of selected and checked nodes var selected = new HashSet <object>(); var check = new HashSet <object>(); foreach (var i in SelectedItemIndex) { selected.Add(nodes[i]); } foreach (var i in CheckedItemIndex) { check.Add(nodes[i]); } // nodes.Clear(); levels.Clear(); SelectedItemIndex.Clear(); CheckedItemIndex.Clear(); //build list of expanded nodes if (ShowRootNode) { AddNode(root, 0); } else { AddNodeChildren(root, 0); } //restore indexes of selected and checked nodes var newExpanded = new HashSet <object>(); hasChildren = new BitArray(nodes.Count); for (int i = 0; i < nodes.Count; i++) { var node = nodes[i]; if (selected.Contains(node)) { SelectedItemIndex.Add(i); } if (check.Contains(node)) { CheckedItemIndex.Add(i); } if (expandedNodes.Contains(node)) { newExpanded.Add(node); } hasChildren[i] = GetNodeChildren(nodes[i]).Cast <object>().Any(); } expandedNodes = newExpanded; ItemCount = nodes.Count; base.Build(); }
public FastList() { if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) { ItemCount = 100; ItemTextNeeded += (o, a) => a.Result = "Item " + a.ItemIndex; SelectedItemIndex.Add(0); } }
public FastTree() { AutoCollapse = true; ShowRootNode = false; ShowExpandBoxes = true; ItemIndentDefault = 16; if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) { Build(new object[] { "Node 1", "Node 2", "Node 3" }); SelectedItemIndex.Add(0); } }