/// <summary> /// Gets the range of events that intersect the rectangle that encloses 'begin' and 'end'</summary> /// <param name="begin">Beginning timeline path</param> /// <param name="end">Ending timeline path</param> /// <returns>Enumeration of timeline paths that intersect the rectangle. /// A timeline path is a sequence of objects in timelines, e.g., groups, tracks, events.</returns> protected virtual IEnumerable <TimelinePath> GetRangeOfEvents(TimelinePath begin, TimelinePath end) { // If the two paths are the same, then the rectangle is just a point. // This check fixes a bug where the 'rectangle' becomes the whole interval // and then falsely selects an adjacent zero-length object due to Overlaps(). if (begin.Equals(end)) { return new TimelinePath[] { begin } } ; // Get the range of tracks between these two events. bool searchMarkers = false; System.Collections.IEnumerable rangeOfTracks; if (begin.Last is IMarker || end.Last is IMarker) { rangeOfTracks = Owner.AllTracks; searchMarkers = true; } else { TimelinePath beginTrack = GetOwningTrack(begin); TimelinePath endTrack = GetOwningTrack(end); rangeOfTracks = GetRangeOfTracks(beginTrack, endTrack); } // Get the range of times to look for. float beginStart, beginEnd; D2dTimelineControl.CalculateRange(begin, out beginStart, out beginEnd); float endStart, endEnd; D2dTimelineControl.CalculateRange(end, out endStart, out endEnd); float beginTime = Math.Min(beginStart, endStart); float endTime = Math.Max(beginEnd, endEnd); // Look through all the IEvents of these tracks. List <TimelinePath> range = new List <TimelinePath>(); foreach (TimelinePath testPath in rangeOfTracks) { ITrack track = (ITrack)testPath.Last; foreach (IKey key in track.Keys) { testPath.Last = key; if (Overlaps(testPath, beginTime, endTime)) { range.Add(new TimelinePath(testPath)); } } foreach (IInterval interval in track.Intervals) { testPath.Last = interval; if (Overlaps(testPath, beginTime, endTime)) { range.Add(new TimelinePath(testPath)); } } } // Look for markers? if (searchMarkers) { foreach (TimelinePath testPath in Owner.AllMarkers) { if (Overlaps(testPath, beginTime, endTime)) { range.Add(testPath); } } } return(range); }
/// <summary> /// Gets the range of events that intersect the rectangle that encloses 'begin' and 'end'</summary> /// <param name="begin">Beginning timeline path</param> /// <param name="end">Ending timeline path</param> /// <returns>Enumeration of timeline paths that intersect the rectangle. /// A timeline path is a sequence of objects in timelines, e.g., groups, tracks, events.</returns> protected virtual IEnumerable<TimelinePath> GetRangeOfEvents(TimelinePath begin, TimelinePath end) { // If the two paths are the same, then the rectangle is just a point. // This check fixes a bug where the 'rectangle' becomes the whole interval // and then falsely selects an adjacent zero-length object due to Overlaps(). if (begin.Equals(end)) return new TimelinePath[] { begin }; // Get the range of tracks between these two events. bool searchMarkers = false; System.Collections.IEnumerable rangeOfTracks; if (begin.Last is IMarker || end.Last is IMarker) { rangeOfTracks = Owner.AllTracks; searchMarkers = true; } else { TimelinePath beginTrack = GetOwningTrack(begin); TimelinePath endTrack = GetOwningTrack(end); rangeOfTracks = GetRangeOfTracks(beginTrack, endTrack); } // Get the range of times to look for. float beginStart, beginEnd; D2dTimelineControl.CalculateRange(begin, out beginStart, out beginEnd); float endStart, endEnd; D2dTimelineControl.CalculateRange(end, out endStart, out endEnd); float beginTime = Math.Min(beginStart, endStart); float endTime = Math.Max(beginEnd, endEnd); // Look through all the IEvents of these tracks. List<TimelinePath> range = new List<TimelinePath>(); foreach (TimelinePath testPath in rangeOfTracks) { ITrack track = (ITrack)testPath.Last; foreach (IKey key in track.Keys) { testPath.Last = key; if (Overlaps(testPath, beginTime, endTime)) range.Add(new TimelinePath(testPath)); } foreach (IInterval interval in track.Intervals) { testPath.Last = interval; if (Overlaps(testPath, beginTime, endTime)) range.Add(new TimelinePath(testPath)); } } // Look for markers? if (searchMarkers) { foreach (TimelinePath testPath in Owner.AllMarkers) { if (Overlaps(testPath, beginTime, endTime)) range.Add(testPath); } } return range; }