Ejemplo n.º 1
0
 private void Source_SourcePropertyChangedEvent(object sender, SourcePropertyChangedEventArgs e)
 {
     if (e.Property == ESourceProperty.FftData)
     {
         UpdateSpectrum(_spectrumResolution, _source.FftData);
     }
     else if (e.Property == ESourceProperty.PlaybackState && (PlaybackState)e.Value == PlaybackState.Playing)
     {
         CreateBars();
     }
     else if (e.Property == ESourceProperty.RecordingState && (RecordingState)e.Value == RecordingState.Recording)
     {
         CreateBars();
     }
     else if (e.Property == ESourceProperty.PlaybackState && (PlaybackState)e.Value != PlaybackState.Playing)
     {
         SilenceBars();
     }
     else if (e.Property == ESourceProperty.RecordingState && (RecordingState)e.Value == RecordingState.Stopped)
     {
         SilenceBars();
     }
 }
Ejemplo n.º 2
0
        private void Source_SourcePropertyChangedEvent(object sender, SourcePropertyChangedEventArgs e)
        {
            if (e.Property == ESourceProperty.Position)
            {
                TimeSpan position = (TimeSpan)e.Value;
                Dispatcher.BeginInvoke((Action) delegate
                {
                    Position = position;

                    if (lengthGrid != null && progressLine != null)
                    {
                        var x = 0d;

                        if (_source.Length.TotalMilliseconds != 0)
                        {
                            double progressPercent = position.TotalMilliseconds / _source.Length.TotalMilliseconds;
                            x = progressPercent * lengthGrid.RenderSize.Width;
                        }

                        progressLine.Width = x;
                    }
                });
            }
        }
Ejemplo n.º 3
0
        private void Source_SourcePropertyChangedEvent(object sender, SourcePropertyChangedEventArgs e)
        {
            if (timeText != null)
            {
                if (e.Property == ESourceProperty.PlaybackState)
                {
                    _activeSource = sender as ISource;

                    /*if ((CSCore.SoundOut.PlaybackState)e.Value == CSCore.SoundOut.PlaybackState.Playing)
                     * {
                     *  _activeSource = sender as ISource;
                     * }
                     * else if ((CSCore.SoundOut.PlaybackState)e.Value == CSCore.SoundOut.PlaybackState.Paused)
                     * {
                     *  _activeSource = sender as ISource;
                     * }
                     * else if ((CSCore.SoundOut.PlaybackState)e.Value == CSCore.SoundOut.PlaybackState.Stopped)
                     * {
                     *  _activeSource = null;
                     * }*/

                    // Calculate the time elapsed and remaining time of the queue.
                    var index = SourceCollection.IndexOf(_activeSource);

                    _elapsedTotal   = TimeSpan.Zero;
                    _remainingTotal = TimeSpan.Zero;

                    if (index == -1)
                    {
                        // There is no active source, so the elapsed time will be 0 and the remaining
                        // will be the length of the entire queue.
                        _remainingTotal = TimeSpan.FromTicks(SourceCollection.Sum(x => x.Length.Ticks));
                    }
                    else
                    {
                        // There is an active source, so we need to sum all of the sources before
                        // and after the active source to get the elapsed and remaining times.
                        for (var i = 0; i < SourceCollection.Count; i++)
                        {
                            var source = SourceCollection[i];

                            if (i < index)
                            {
                                // add to elapsed time.
                                _elapsedTotal += source.Length;
                            }
                            else if (i > index)
                            {
                                // add to remaining time.
                                _remainingTotal += source.Length;
                            }
                        }
                    }
                }

                if (e.Property == ESourceProperty.Position)
                {
                    CalculateTime();
                }
            }
        }