private void RefreshList() { var previousIndex = listConstraints.SelectedIndex; if (previousIndex == -1) { previousIndex = 0; } CallRefresh(); listConstraints.BeginUpdate(); listConstraints.Items.Clear(); //if (_builder.LastExecute == false) //{ // listConstraints.EndUpdate(); // return; //} var constraints = (from child in _document.Root.Children where NodeUtils.NodeIsConstraint(child.Key, _document) select child.Value).ToList(); if (_builder.Node == null) { foreach (var constraint in constraints) { var nb = new NodeBuilder(constraint); var listItem = new ConstraintListItem(_document, nb, nb.FunctionName, nb.FunctionName + ": " + NodeUtils.GetConstraintDependencies(constraint)); listConstraints.Items.Add(listItem); } } else { foreach (var constraint in constraints) { if (Document.NodeReferences(constraint, _builder.Node) || NodeUtils.LineHasLengthConstraint(_builder.Node, constraint)) { var nb = new NodeBuilder(constraint); var listItem = new ConstraintListItem(_document, nb, nb.FunctionName, nb.FunctionName + ": " + NodeUtils.GetConstraintDependencies(constraint, _builder.ShapeName)); listConstraints.Items.Add(listItem); } } } listConstraints.EndUpdate(); if (listConstraints.Items.Count > 0) { listConstraints.SelectedIndex = previousIndex < listConstraints.Items.Count ? previousIndex : 0; } }