private bool RecalculateRowIndex(Event e) { if (e.Visibility == Visibility.Hidden) return false; bool bOccupationFound = false; for (; e.Row <= 2 && IsSpanOccupiedByOthers(e, e.Row); e.Row++) { bOccupationFound = true; } return bOccupationFound; }
private bool ResetRowIndex(Event e) { if (e.Visibility == Visibility.Hidden) return false; bool bOccupationFound = false; for (; (e.Row - 1) >= 0 && !IsSpanOccupiedByOthers(e, e.Row - 1); e.Row--) { bOccupationFound = true; } return bOccupationFound; }
private bool IsSpanOccupiedByOthers(Event me, int row) { var occupyingEvents = from e in Events where !ReferenceEquals(e, me) where (e.Visibility == Visibility.Visible) && (e.Row == row) && ((e.From >= me.From & e.From <= me.Till) | (e.Till >= me.From & e.Till <= me.Till)) select e; return (occupyingEvents.Count() > 0); }