private bool TryToMoveToSnapPoint(SnapPoint snapPoint) { if (snapPoint != null) { MoveToTime((MetricTimeSpan)snapPoint.Time); } return(snapPoint != null); }
/// <summary> /// Adds a snap point with the specified data at given time. /// </summary> /// <typeparam name="TData">Type of data that will be attached to a snap point.</typeparam> /// <param name="time">Time to add snap point at.</param> /// <param name="data">Data to attach to snap point.</param> /// <returns>An instance of the <see cref="SnapPoint{TData}"/> representing a snap point /// with <paramref name="data"/> at <paramref name="time"/>.</returns> /// <exception cref="ArgumentNullException"><paramref name="time"/> is <c>null</c>.</exception> public SnapPoint <TData> AddSnapPoint <TData>(ITimeSpan time, TData data) { ThrowIfArgument.IsNull(nameof(time), time); var metricTime = TimeConverter.ConvertTo <MetricTimeSpan>(time, _tempoMap); var snapPoint = new SnapPoint <TData>(metricTime, data); _snapPoints.Add(snapPoint); return(snapPoint); }
/// <summary> /// Sets playback position to the time of the specified snap point. /// </summary> /// <param name="snapPoint">Snap point to move to.</param> /// <exception cref="ArgumentNullException"><paramref name="snapPoint"/> is null.</exception> /// <exception cref="ObjectDisposedException">The current <see cref="Playback"/> is disposed.</exception> /// <exception cref="MidiDeviceException">An error occurred on device.</exception> public void MoveToSnapPoint(SnapPoint snapPoint) { ThrowIfArgument.IsNull(nameof(snapPoint), snapPoint); EnsureIsNotDisposed(); if (!snapPoint.IsEnabled) { return; } MoveToTime((MetricTimeSpan)snapPoint.Time); }
/// <summary> /// Sets playback position to the time of the specified snap point. /// </summary> /// <param name="snapPoint">Snap point to move to.</param> /// <returns><c>true</c> if playback position successfully changed to the time of <paramref name="snapPoint"/>; /// otherwise, <c>false</c>.</returns> /// <exception cref="ArgumentNullException"><paramref name="snapPoint"/> is <c>null</c>.</exception> /// <exception cref="ObjectDisposedException">The current <see cref="Playback"/> is disposed.</exception> /// <exception cref="MidiDeviceException">An error occurred on device.</exception> public bool MoveToSnapPoint(SnapPoint snapPoint) { ThrowIfArgument.IsNull(nameof(snapPoint), snapPoint); EnsureIsNotDisposed(); if (!snapPoint.IsEnabled) { return(false); } return(TryToMoveToSnapPoint(snapPoint)); }
/// <summary> /// Removes a snap point. /// </summary> /// <typeparam name="TData">Type of data attached to <paramref name="snapPoint"/>.</typeparam> /// <param name="snapPoint">Snap point to remove.</param> /// <exception cref="ArgumentNullException"><paramref name="snapPoint"/> is <c>null</c>.</exception> public void RemoveSnapPoint <TData>(SnapPoint <TData> snapPoint) { ThrowIfArgument.IsNull(nameof(snapPoint), snapPoint); _snapPoints.Remove(snapPoint); }
private bool IsSnapPointWithData <TData>(SnapPoint snapPoint, TData data) { var snapPointWithData = snapPoint as SnapPoint <TData>; return(snapPointWithData != null && snapPointWithData.Data.Equals(data)); }