public void ChangeFpErrorCodeOwner(RouteStationFailure failure) { var currentFpHolder = AllProcessFailures.FirstOrDefault(f => f.IsFpErrorCode); if (currentFpHolder == null) { currentFpHolder = Failures.FirstOrDefault(f => f.IsFpErrorCode); } if (currentFpHolder != null) { currentFpHolder.IsFpErrorCode = false; } failure.IsFpErrorCode = true; }
private void Failures_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemDeleted) { if (AllProcessFailures.FirstOrDefault(f => f.IsFpErrorCode) == null) { ChangeFpErrorCodeOwner(AllProcessFailures.Take(1).ToArray()[0]); return; } } if (e.ListChangedType == ListChangedType.ItemAdded) { if (AllProcessFailures.Count == 0 && Failures.Count == 1) { Failures[0].IsFpErrorCode = true; } } }