/// <summary> /// Adds the given <paramref name="element"/> to the <paramref name="layer">track</paramref>. /// </summary> /// <param name="element">The element being added.</param> /// <param name="layer">The track where the element is going to be added.</param> public void AddElement(TimelineElement element, Track layer) { if (element == null) { throw new ArgumentNullException("element"); } if (element.Id == Guid.Empty) { throw new ArgumentException("The element Id cannot be empty.", "element"); } TimelineElement prevElement = null; foreach (var entry in layer.Shots.Where(entry => entry.Position < element.Position)) { prevElement = entry; } if (prevElement == null) { layer.Shots.Insert(0, element); } else { layer.Shots.Insert(layer.Shots.IndexOf(prevElement) + 1, element); } this.OnElementAdded(element); var videoInOut = element.Asset as VideoAssetInOut; if (videoInOut != null && videoInOut.AddMarkersToSequence) { this.AddPlayByPlayMarkersToTimeline(element.Position.TotalSeconds, videoInOut); } }
/// <summary> /// Compares the position of the given elements. /// </summary> /// <param name="element1">The first element.</param> /// <param name="element2">The second element.</param> /// <returns>Returns a value indicating which element should be first.</returns> private static int CompareElements(TimelineElement element1, TimelineElement element2) { return(element1.Position.CompareTo(element2.Position)); }
/// <summary> /// Tries to link the given <paramref name="element"/> to a previous element in the timeline. /// </summary> /// <param name="element">The element being linked.</param> /// <param name="previousElement">The previous element being linked to the element.</param> /// <returns>True if the link is effective;otherwise false.</returns> public bool LinkPreviousElement(TimelineElement element, TimelineElement previousElement) { return(this.LinkNextElement(previousElement, element)); }
/// <summary> /// Get the element within the specific range. /// </summary> /// <param name="startTimeCode">The start time to look to the element.</param> /// <param name="endTimeCode">The end time to look to the element.</param> /// <param name="layer">The track where the element should be searched.</param> /// <param name="elementToIgnore">The element being ignored in the search.</param> /// <returns>The element within the range or null.</returns> public TimelineElement GetElementWithinRange(TimeCode startTimeCode, TimeCode endTimeCode, Track layer, TimelineElement elementToIgnore) { foreach (var entry in layer.Shots) { var entryStart = entry.Position; var entryEnd = entry.Position + entry.Duration; if (entry == elementToIgnore) { continue; } if (startTimeCode == entryStart || endTimeCode == entryEnd) { return(entry); } if (startTimeCode > entryStart && startTimeCode < entryEnd) { return(entry); } if (endTimeCode > entryStart && endTimeCode < entryEnd) { return(entry); } if (startTimeCode < entryStart && endTimeCode > entryEnd) { return(entry); } if (startTimeCode > entryStart && startTimeCode < entryEnd) { return(entry); } } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="TimelineElementEventArgs"/> class. /// </summary> /// <param name="timelineElement">The timeline element.</param> public TimelineElementEventArgs(TimelineElement timelineElement) { this.Element = timelineElement; }
/// <summary> /// Sets the memento. /// </summary> /// <param name="element">The <see cref="TimelineElement"/>.</param> public void SetMemento(TimelineElement element) { this.InPosition = element.inPosition; this.OutPosition = element.OutPosition; this.Position = element.Position; }
private bool ShouldRemovePlayByPlayMarkers(TimelineElement timelineElement) { var videoInOut = timelineElement.Asset as VideoAssetInOut; return(videoInOut != null && videoInOut.AddMarkersToSequence); }
/// <summary> /// Get the element that is within the range of the given <paramref name="position"/>. /// </summary> /// <param name="position">The position used to find the elements.</param> /// <param name="layer">The track where the element is going to be searched.</param> /// <param name="elementToIgnore">The element being ingnored in the search.</param> /// <returns>The element within the position or null.</returns> public TimelineElement GetElementAtPosition(TimeCode position, Track layer, TimelineElement elementToIgnore) { return(layer.Shots.Where(entry => entry != elementToIgnore).FirstOrDefault(entry => entry.Position <= position && (entry.Position + entry.Duration) >= position)); }
public TimelineElementEventArgs(TimelineElement timelineElement, RefreshSource source) { this.Element = timelineElement; this.RefreshSource = source; }
/// <summary> /// Initializes a new instance of the <see cref="TimelineElementEventArgs"/> class. /// </summary> /// <param name="timelineElement">The timeline element.</param> public TimelineElementEventArgs(TimelineElement timelineElement) : this(timelineElement, RefreshSource.Any) { }