private void owner_DrawingD2d(object sender, EventArgs e)
        {
            // Test if anything is visible.
            m_visibleManipulator =
                D2dTimelineControl.CalculateRange(Owner.EditableSelection, out m_worldMin, out m_worldMax);
            if (!m_visibleManipulator)
            {
                return;
            }

            D2dGraphics g           = Owner.D2dGraphics;
            Matrix      worldToView = Owner.Transform;

            // Make the TimelineRenderer draw the ghosts, if necessary. Must happen before
            //  the manipulator is drawn so that snap-to info is created.
            if (IsScaling)
            {
                TimelineLayout layout = Owner.GetLayout();

                GhostInfo[] ghosts = m_resizer.CreateGhostInfo(
                    layout,
                    Owner.GetDragOffset().X,
                    worldToView);

                Owner.Renderer.DrawGhosts(
                    ghosts,
                    DraggedSide,
                    worldToView,
                    Owner.ClientRectangle);
            }

            // Tighten clipping region. Has to occur after DrawGhosts because the TimelineRenderer
            //  assumes that it has to shrink the current Graphics.Clip region by the header width.
            try
            {
                g.PushAxisAlignedClip(Owner.VisibleClientRectangle);

                // Draw the manipulator, giving client code a customization point.
                DrawManipulator(g, out m_leftHandle, out m_rightHandle);
            }
            finally
            {
                g.PopAxisAlignedClip();
            }
        }
Ejemplo n.º 2
0
        /// <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);
        }