Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        protected virtual void OnPlaybackStopped(WaveOutEvent sender, TimeSpan startTime, TimeSpan endTime)
        {
            sender.Dispose();

            if (_waveOut == sender)
            {
                SetCursor(_playbackStream.CurrentTime);
                _waveOut          = null;
                _scrollCalculator = null;

                if (PlaybackStopped != null)
                {
                    PlaybackStopped(this, startTime, endTime);
                }
            }
        }
Exemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        protected virtual bool OnInitiatiatingBoundaryMove(int mouseX, TimeSpan boundary)
        {
            if (CanBoundaryBeMoved != null && !CanBoundaryBeMoved(boundary, AllowMovingBoundariesWithAdjacetAnnotations))
            {
                return(false);
            }

            _scrollCalculator = new WaveControlScrollCalculator(this);

            // Figure out the limits within which the boundary may be moved. It's not allowed
            // to be moved to the left of the previous boundary or to the right of the next
            // boundary.
            _minXForBoundaryMove = Painter.ConvertTimeToXCoordinate(SegmentBoundaries.LastOrDefault(b => b < boundary));

            var  nextBoundary         = SegmentBoundaries.FirstOrDefault(b => b > boundary);
            bool limitedByEndOfStream = nextBoundary == default(TimeSpan);

            if (limitedByEndOfStream)
            {
                nextBoundary = WaveStream.TotalTime;
            }

            _maxXForBoundaryMove = Painter.ConvertTimeToXCoordinate(nextBoundary);

            if (_minXForBoundaryMove > 0)
            {
                _minXForBoundaryMove += WavePainterBasic.kBoundaryHotZoneHalfWidth;
            }

            if (_maxXForBoundaryMove == 0)
            {
                _maxXForBoundaryMove = ClientSize.Width - WavePainterBasic.kRightDisplayPadding + 1;
            }
            else if (!limitedByEndOfStream)
            {
                _maxXForBoundaryMove -= WavePainterBasic.kBoundaryHotZoneHalfWidth;
            }

            Painter.SetMovingAnchorTime(boundary);
            IsBoundaryMovingInProgress      = true;
            _mouseXAtBeginningOfSegmentMove = mouseX;

            return(true);
        }
Exemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>Returns true if the requested time is already visible. False if a scroll will be
        /// done (using the slide timer) to get there.</summary>
        /// ------------------------------------------------------------------------------------
        public bool EnsureTimeIsVisible(TimeSpan time, TimeRange timeRange, bool scrollToCenter,
                                        bool prepareForPlayback)
        {
            bool discardCalculator = false;

            if (_scrollCalculator == null || _scrollCalculator.TimeRange != timeRange)
            {
                KillSlideTimer();
                _scrollCalculator = new WaveControlScrollCalculator(this, timeRange, scrollToCenter);
                discardCalculator = !prepareForPlayback;
            }

            var retVal = EnsureTimeIsVisible(time);

            if (discardCalculator)
            {
                _scrollCalculator = null;
            }

            return(retVal);
        }
Exemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>Returns true if the requested horizontal pixel location is already visible. False
        /// if a scroll will be done (using the slide timer) to get there.</summary>
        /// ------------------------------------------------------------------------------------
        public bool EnsureXIsVisible(int x)
        {
            bool discardCalculator = false;

            if (_scrollCalculator == null)
            {
                KillSlideTimer();
                _scrollCalculator = new WaveControlScrollCalculator(this,
                                                                    new TimeRange(TimeSpan.Zero, _playbackStream.TotalTime), true);
                discardCalculator = true;
            }

            _slidingTargetScrollOffset = _scrollCalculator.ComputeTargetScrollOffset(x);

            if (discardCalculator)
            {
                _scrollCalculator = null;
            }

            if (_slidingTargetScrollOffset == -AutoScrollPosition.X)
            {
                return(true);
            }

            _endSlideTime = DateTime.Now.AddMilliseconds(250);
            if (_slideTimer == null || !_slideTimer.Enabled)
            {
                Invoke((Action)(() =>
                {
                    _slideTimer = new Timer();
                    _slideTimer.Interval = 1;
                    _slideTimer.Tick += HandleSlideTimerTick;
                    _slideTimer.Start();
                }));
            }
            return(false);
        }
Exemplo n.º 5
0
 /// ------------------------------------------------------------------------------------
 public void DiscardScrollCalculator()
 {
     _scrollCalculator = null;
 }