void updateStartsAndEnds(ReleaseEntryViewModel changedObject) { // First scan for invalid scenarios int startIdx = -1; int endIdx = -1; int currentIdx = -1; for (int i=0; i < ReleasesList.Count; i++) { var current = ReleasesList[i]; if (changedObject == current) currentIdx = i; if (current.CurrentAction == ReleaseEntryActions.Start) { if (startIdx >= 0) { ReleasesList[startIdx].CurrentAction = ReleaseEntryActions.None; startIdx = i; } startIdx = i; continue; } if (current.CurrentAction == ReleaseEntryActions.End) { if (endIdx >= 0) { current.CurrentAction = ReleaseEntryActions.None; } else { endIdx = i; } endIdx = i; continue; } } if (endIdx < startIdx && endIdx >= 0) goto bogus; foreach (var v in ReleasesList) { v.Enabled = true; } if (startIdx >= 0) { for (int i=0; i < startIdx; i++) { ReleasesList[i].Enabled = false; } } if (endIdx >= 0) { for (int i=endIdx+1; i < ReleasesList.Count; i++) { ReleasesList[i].Enabled = false; } } if (startIdx >=0 || endIdx >= 0) { foreach (var v in ReleasesList) { if (!v.Enabled) continue; if (v.CurrentAction != ReleaseEntryActions.None) continue; v.CurrentAction = ReleaseEntryActions.Install; } } return; bogus: foreach (var v in ReleasesList) { v.Enabled = true; } }
void updateStartsAndEnds(ReleaseEntryViewModel changedObject) { // First scan for invalid scenarios int startIdx = -1; int endIdx = -1; int currentIdx = -1; for (int i = 0; i < ReleasesList.Count; i++) { var current = ReleasesList[i]; if (changedObject == current) { currentIdx = i; } if (current.CurrentAction == ReleaseEntryActions.Start) { if (startIdx >= 0) { ReleasesList[startIdx].CurrentAction = ReleaseEntryActions.None; startIdx = i; } startIdx = i; continue; } if (current.CurrentAction == ReleaseEntryActions.End) { if (endIdx >= 0) { current.CurrentAction = ReleaseEntryActions.None; } else { endIdx = i; } endIdx = i; continue; } } if (endIdx < startIdx && endIdx >= 0) { goto bogus; } foreach (var v in ReleasesList) { v.Enabled = true; } if (startIdx >= 0) { for (int i = 0; i < startIdx; i++) { ReleasesList[i].Enabled = false; } } if (endIdx >= 0) { for (int i = endIdx + 1; i < ReleasesList.Count; i++) { ReleasesList[i].Enabled = false; } } if (startIdx >= 0 || endIdx >= 0) { foreach (var v in ReleasesList) { if (!v.Enabled) { continue; } if (v.CurrentAction != ReleaseEntryActions.None) { continue; } v.CurrentAction = ReleaseEntryActions.Install; } } return; bogus: foreach (var v in ReleasesList) { v.Enabled = true; } }