public void RefreshPredictions(Prediction[] predictionsToSelect) { if (InvokeRequired) { Invoke(new Action<Prediction[]>(RefreshPredictions), new object[] { predictionsToSelect }); return; } predictions.BeginUpdate(); predictions.Nodes.Clear(); toolTip.SetToolTip(predictions, null); List<Prediction> allPredictions = Prediction.GetAll(true); allPredictions.Sort(new Comparison<Prediction>((p1, p2) => p1.Id.CompareTo(p2.Id))); foreach (PredictionGroup group in Group(allPredictions, _groups, 0)) AddToTree(predictions.Nodes, group); predictions.EndUpdate(); if (predictionsToSelect != null && predictionsToSelect.Length > 0) { _setPredictionsToolTip = predictionsToSelect.Count() == 1; TraversePredictionTree().Where(n => n.Tag is Prediction && predictionsToSelect.Select(p => p.Id).Contains((n.Tag as Prediction).Id)).Select(n => n.Checked = true).ToArray(); } _setPredictionsToolTip = true; }