Beispiel #1
0
        private bool TryToMoveToSnapPoint(SnapPoint snapPoint)
        {
            if (snapPoint != null)
            {
                MoveToTime((MetricTimeSpan)snapPoint.Time);
            }

            return(snapPoint != null);
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        /// <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);
        }
Beispiel #4
0
        /// <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));
        }
Beispiel #5
0
        /// <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);
        }
Beispiel #6
0
        private bool IsSnapPointWithData <TData>(SnapPoint snapPoint, TData data)
        {
            var snapPointWithData = snapPoint as SnapPoint <TData>;

            return(snapPointWithData != null && snapPointWithData.Data.Equals(data));
        }