private bool SetSelected(LogLineIndex from, LogLineIndex to, SelectMode selectMode) { bool changed = false; if (selectMode == SelectMode.Replace) { if (_hoveredIndices.Count > 0) { changed = true; } _hoveredIndices.Clear(); } LogLineIndex min = LogLineIndex.Min(from, to); LogLineIndex max = LogLineIndex.Max(from, to); int count = max - min; for (int i = 0; i <= count /* we want to select everything including 'to' */; ++i) { changed |= _selectedIndices.Add(min + i); } if (changed) { var fn = OnSelectionChanged; fn?.Invoke(_selectedIndices); } return(changed); }
/// <summary> /// Creates a new section which spawns from the lowest <see cref="Index" /> /// of the given two sections to the greatest <see cref="LastIndex" />. /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> /// <returns></returns> public static LogFileSection MinimumBoundingLine(LogFileSection lhs, LogFileSection rhs) { LogLineIndex minIndex = LogLineIndex.Min(lhs.Index, rhs.Index); LogLineIndex maxIndex = LogLineIndex.Max(lhs.Index + lhs.Count, rhs.Index + rhs.Count); int count = maxIndex - minIndex; return(new LogFileSection(minIndex, count)); }