/// <summary> /// Construct a new surrogate for another <see cref="ITimelineTrack" />. /// </summary> /// <param name="substituteFor">The ITimelineTrack we're substituting for.</param> public TrackSurrogate(ITimelineTrack substituteFor) { SubstituteFor = substituteFor; Start = substituteFor.Start; End = substituteFor.End; Name = substituteFor.Name; }
/// <summary> /// Construct a new surrogate for another <see cref="ITimelineTrack" />. /// </summary> /// <param name="substituteFor">The ITimelineTrack we're substituting for.</param> public TrackSurrogate( ITimelineTrack substituteFor ) { SubstituteFor = substituteFor; Start = substituteFor.Start; End = substituteFor.End; Name = substituteFor.Name; }
/// <summary> /// Construct a new surrogate for another <see cref="ITimelineTrack" />. /// </summary> /// <param name="substituteFor">The ITimelineTrack we're substituting for.</param> public TrackSurrogate(ITimelineTrack substituteFor) { SubstituteFor = substituteFor; Start = substituteFor.Start; End = substituteFor.End; ID = substituteFor.ID; }
/// <summary> /// Calculate the bounding rectangle for a track in screen-space. /// </summary> /// <param name="track"> /// The track for which to calculate the bounding rectangle. /// </param> /// <param name="timeline">The timeline the track lives on.</param> /// <returns>The bounding rectangle for the given track.</returns> internal static RectangleF GetTrackExtents(ITimelineTrack track, TimelineControl timeline) { int trackIndex = timeline.TrackIndexForTrack(track); IKeyFrame firstKF = track.KeyFrames.First(); IKeyFrame lastKF = track.KeyFrames.Last(); return(RectangleToTrackExtents(new RectangleF(firstKF.T, 0, lastKF.T - firstKF.T, 0), timeline, trackIndex)); }
/// <summary> /// Construct a new surrogate for another <see cref="ITimelineTrack" />. /// </summary> /// <param name="substituteFor">The ITimelineTrack we're substituting for.</param> public TrackSurrogate(ITimelineTrack substituteFor) { SubstituteFor = substituteFor; //create surrogates of the keyframes that the original track has KeyFrames = new List <IKeyFrame>(); foreach (IKeyFrame kf in substituteFor.KeyFrames) { KeyFrames.Add(new KeyFrameSurrogate(kf)); } Name = substituteFor.Name; }
/// <summary> /// Calculate the bounding rectangle for a KeyFrame in screen-space. /// </summary> /// <param name="track"> /// The track which the keyframe is a part of /// </param> /// <param name="kf"> /// The keyframe in question /// </param> /// <param name="timeline">The timeline the track lives on.</param> /// <returns>The bounding rectangle for the given keyframe.</returns> internal static RectangleF GetKeyFrameExtents(ITimelineTrack track, IKeyFrame kf, TimelineControl timeline) { Rectangle trackAreaBounds = timeline.GetTrackAreaBounds(); int trackIndex = timeline.TrackIndexForTrack(track); RectangleF kfRectangle = new RectangleF(); kfRectangle.X = trackAreaBounds.X + (kf.T * timeline.RenderingScale.X) - timeline.KeyFrameWidth / 2 + timeline.RenderingOffset.X; kfRectangle.Width = timeline.KeyFrameWidth; kfRectangle.Height = (timeline.TrackHeight) * timeline.RenderingScale.Y; kfRectangle.Y = trackAreaBounds.Y + ((kfRectangle.Height + timeline.TrackSpacing) * trackIndex) + timeline.RenderingOffset.Y; return(kfRectangle); }
private void tlDesignView_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { if (tlDesignView.SelectedTracks.Count() > 0) { if (MessageBox.Show("真的要进行吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { ClearPropertyPanel(); foreach (ITimelineTrack tt in tlDesignView.SelectedTracks) { if (tt is StartTrack) { continue; } defaultParts.TrackElementList.Remove(tt); } tlDesignView.Invalidate(); } } } else if (e.KeyCode == Keys.D || e.KeyCode == Keys.S) { if (tlDesignView.SelectedTracks.Count() > 0) { ITimelineTrack first = tlDesignView.SelectedTracks.First(); int indexx = defaultParts.TrackElementList.IndexOf(first); if (indexx >= 0 && defaultParts.TrackElementList.Count - 1 > indexx) { tlDesignView.SelectTrack(defaultParts.TrackElementList[indexx + 1]); } } } else if (e.KeyCode == Keys.A || e.KeyCode == Keys.W) { if (tlDesignView.SelectedTracks.Count() > 0) { ITimelineTrack first = tlDesignView.SelectedTracks.First(); int indexx = defaultParts.TrackElementList.IndexOf(first); if (indexx >= 1) { tlDesignView.SelectTrack(defaultParts.TrackElementList[indexx - 1]); } } } }
/// <summary> /// Calculate the bounding rectangle for the lifetime of a track in screen-space. /// </summary> /// <param name="track"> /// The track which the keyframe is a part of /// </param> /// <param name="timeline">The timeline the track lives on.</param> /// <returns>The bounding rectangle for the given keyframe.</returns> internal static RectangleF GetTrackLifetimeExtents(ITimelineTrack track, TimelineControl timeline) { Rectangle trackAreaBounds = timeline.GetTrackAreaBounds(); int trackIndex = timeline.TrackIndexForTrack(track); RectangleF firstKFExtent = GetKeyFrameExtents(track, track.KeyFrames.First(), timeline); RectangleF lastKFExtent = GetKeyFrameExtents(track, track.KeyFrames.Last(), timeline); RectangleF lifetime = new RectangleF(); lifetime.X = firstKFExtent.X; lifetime.Width = lastKFExtent.X + lastKFExtent.Width - firstKFExtent.X; lifetime.Height = firstKFExtent.Height; lifetime.Y = firstKFExtent.Y; return(lifetime); }
/// <summary> /// Calculate the bounding rectangle for a track in screen-space. /// </summary> /// <param name="track"> /// The track for which to calculate the bounding rectangle. /// </param> /// <param name="timeline">The timeline the track lives on.</param> /// <returns>The bounding rectangle for the given track.</returns> internal static RectangleF GetTrackExtents(ITimelineTrack track, Timeline timeline) { int trackIndex = timeline.TrackIndexForTrack(track); return(RectangleToTrackExtents(new RectangleF(track.Start, 0, track.End.GetValueOrDefault() - track.Start, 0), timeline, trackIndex)); }
/// <summary> /// Copies all properties of the surrogate to another <see cref="ITimelineTrack" />. /// </summary> /// <param name="target">The target timeline track to copy the properties to.</param> public void CopyTo( ITimelineTrack target ) { target.Start = Start; target.End = End; }
/// <summary> /// Copies all properties of the surrogate to another <see cref="ITimelineTrack" />. /// </summary> /// <param name="target">The target timeline track to copy the properties to.</param> public void CopyTo(ITimelineTrack target) { target.Start = Start; target.End = End; }
/// <summary> /// Retrieve the index of a given track. /// If the track is a surrogate, returns the index of the track it's a substitute for. /// </summary> /// <param name="track">The track for which to retrieve the index.</param> /// <returns>The index of the track or the index the track is a substitute for.</returns> internal int TrackIndexForTrack( ITimelineTrack track ) { ITimelineTrack trackToLookFor = track; if( track is TrackSurrogate ) { trackToLookFor = ( (TrackSurrogate)track ).SubstituteFor; } return _tracks.FindIndex( t => t.TrackElements.Contains( trackToLookFor ) ); }
/// <summary> /// Add a track to the timeline. /// </summary> /// <param name="track">The track to add.</param> public void AddTrack( ITimelineTrack track ) { _tracks.Add( new SingleTrackToMultiTrackWrapper( track ) ); RecalculateScrollbarBounds(); Invalidate(); }
/// <summary> /// Construct a new SingleTrackToMultiTrackWrapper. /// </summary> /// <param name="track">The timeline track that should be wrapped.</param> public SingleTrackToMultiTrackWrapper(ITimelineTrack track) { _wrappedTrack = track; DisplayText = _wrappedTrack.DisplayText; ID = "DeviceParts_" + Guid.NewGuid().ToString(); }
/// <summary> /// Construct a new SelectionChangedEventArgs instance. /// </summary> /// <param name="selected">The track elements that were deselected in the operation.</param> /// <param name="deselected">The tracks that were selected in the operation.</param> public SelectionChangedEventArgs(ITimelineTrack selected, ITimelineTrack deselected) { Selected = selected; Deselected = deselected; }
/// <summary> /// Calculate the bounding rectangle for a track in screen-space. /// </summary> /// <param name="track"> /// The track for which to calculate the bounding rectangle. /// </param> /// <param name="timeline">The timeline the track lives on.</param> /// <returns>The bounding rectangle for the given track.</returns> internal static RectangleF GetTrackExtents( ITimelineTrack track, Timeline timeline ) { int trackIndex = timeline.TrackIndexForTrack( track ); return RectangleToTrackExtents( new RectangleF( track.Start, 0, track.End - track.Start, 0 ), timeline, trackIndex ); }
/// <summary> /// Construct a new TrackSelectionEventsArgs instance /// </summary> /// <param name="track">The track that was selected</param> public TrackSelectionEventsArgs(ITimelineTrack track) { SelectedTrack = track; }
/// <summary> /// Construct a new SingleTrackToMultiTrackWrapper. /// </summary> /// <param name="track">The timeline track that should be wrapped.</param> public SingleTrackToMultiTrackWrapper(ITimelineTrack track) { _wrappedTrack = track; }
/// <summary> /// Copies all properties of the surrogate to another <see cref="ITimelineTrack" />. /// </summary> /// <param name="target">The target timeline track to copy the properties to.</param> public void CopyTo(ITimelineTrack target) { target.KeyFrames = Extensions.Clone <IKeyFrame>(KeyFrames); target.Name = Name; }
/// <summary> /// Construct a new SingleTrackToMultiTrackWrapper. /// </summary> /// <param name="track">The timeline track that should be wrapped.</param> public SingleTrackToMultiTrackWrapper( ITimelineTrack track ) { _wrappedTrack = track; }