/// <summary> /// Draws the timeline to the display</summary> /// <param name="timeline">Timeline</param> /// <param name="selection">Selected timeline objects</param> /// <param name="activeGroup">Currently active group, or null</param> /// <param name="activeTrack">Currently active track, or null</param> /// <param name="transform">Transform taking timeline objects to display coordinates</param> /// <param name="clientRectangle">Bounds of displayed area of timeline, in screen space</param> /// <returns>Bounding rectangles for all timeline objects, organized in a dictionary of TimelinePath/RectangleF pairs</returns> public virtual TimelineLayout Draw( ITimeline timeline, ISelectionContext selection, TimelinePath activeGroup, TimelinePath activeTrack, Matrix transform, RectangleF clientRectangle) { Context c = new Context(this, transform, clientRectangle, m_graphics); TimelineLayout layout = Layout(timeline, c); c.ClearRecursionData(); try { if (m_printing) { transform.Translate(m_marginBounds.Left, m_marginBounds.Top, MatrixOrder.Append); m_graphics.PushAxisAlignedClip(m_marginBounds); } // Clear the header column. m_graphics.FillRectangle(new RectangleF(0, 0, HeaderWidth, c.ClientRectangle.Height), m_headerBrush); // Draw the main timeline and then any sub-timelines. DrawSubTimeline(null, timeline, false, true, selection, activeGroup, activeTrack, layout, c); foreach (TimelinePath path in D2dTimelineControl.GetHierarchy(timeline)) DrawSubTimeline(path, selection, activeGroup, activeTrack, layout, c); // Draw the dark vertical line on the header that separates the groups and tracks. m_graphics.DrawLine(new PointF(TrackIndent, m_timeScaleHeight), new PointF(TrackIndent, c.ClientRectangle.Height), m_headerLineBrush); // Draw the dark vertical line on the right-side of the header, separating it from the canvas. m_graphics.DrawLine(new PointF(HeaderWidth, m_timeScaleHeight), new PointF(HeaderWidth, c.ClientRectangle.Height), m_headerLineBrush); // draw scales, etc. if (m_printing) c.Graphics.TranslateTransform(0, m_marginBounds.Top); DrawEventOverlay(c); // Draw the dark horizontal line underneath the scale. m_graphics.DrawLine(new PointF(0, m_timeScaleHeight), new PointF(HeaderWidth, m_timeScaleHeight), m_scaleLineBrush); } finally { if (m_printing) m_graphics.PopAxisAlignedClip(); } // Give the Markers in the main timeline precedence over the scale and canvas RectangleF clipBounds = m_graphics.ClipBounds; clipBounds.X = HeaderWidth; //var clipBounds = new RectangleF(HeaderWidth, 0, m_graphics.Size.Width, m_graphics.Size.Height); DrawMarkers(null, timeline, selection, c, layout, clipBounds); return layout; }
/// <summary> /// Draws the timeline to the display</summary> /// <param name="timeline">Timeline</param> /// <param name="selection">Selected timeline objects</param> /// <param name="activeGroup">Currently active group, or null</param> /// <param name="activeTrack">Currently active track, or null</param> /// <param name="transform">Transform taking timeline objects to display coordinates</param> /// <param name="clientRectangle">Display coordinate bounding rectangle</param> /// <param name="g">Graphics object</param> /// <returns>Bounding rectangles for all timeline objects, organized in a dictionary of TimelinePath/RectangleF pairs</returns> public virtual TimelineLayout Draw( ITimeline timeline, ISelectionContext selection, TimelinePath activeGroup, TimelinePath activeTrack, Matrix transform, RectangleF clientRectangle, Graphics g) { if (m_printing) { transform.Translate(m_marginBounds.Left, m_marginBounds.Top, MatrixOrder.Append); g.SetClip(m_marginBounds); } Context c = new Context(this, transform, clientRectangle, g); TimelineLayout layout = Layout(timeline, c); c.ClearRecursionData(); // Clear the header column. g.FillRectangle(SystemBrushes.Control, 0, 0, m_headerWidth, c.ClientRectangle.Height); // Draw the main timeline and then any sub-timelines. DrawSubTimeline(null, timeline, false, true, selection, activeGroup, activeTrack, layout, c); foreach (TimelinePath path in TimelineControl.GetHierarchy(timeline)) DrawSubTimeline(path, selection, activeGroup, activeTrack, layout, c); // Draw the dark vertical line on the header that separates the groups and tracks. g.DrawLine(SystemPens.ControlDark, TrackIndent, m_timeScaleHeight, TrackIndent, c.ClientRectangle.Height); // Draw the dark vertical line on the right-side of the header, separating it from the canvas. g.DrawLine(SystemPens.ControlDark, m_headerWidth, m_timeScaleHeight, m_headerWidth, c.ClientRectangle.Height); // draw scales, etc. if (m_printing) c.Graphics.TranslateTransform(0, m_marginBounds.Top); DrawEventOverlay(c); // Draw the dark horizontal line underneath the scale. g.DrawLine(SystemPens.ControlDark, 0, m_timeScaleHeight, m_headerWidth, m_timeScaleHeight); // Give the Markers in the main timeline precedence over the scale and canvas RectangleF clipBounds = g.ClipBounds; clipBounds.X = m_headerWidth; DrawMarkers(null, timeline, selection, c, layout, clipBounds); return layout; }