/// ------------------------------------------------------------------------------------
        private void DrawBackground(PaintEventArgs e, Rectangle rc)
        {
            var rcSegmentedArea = GetFullRectangleForTimeRange(new TimeRange(TimeSpan.Zero,
                                                                             SegmentBoundaries.LastOrDefault()));

            rcSegmentedArea.Intersect(rc);
            if (rcSegmentedArea.Width > 0)
            {
                using (var brush = new SolidBrush(SegmentedBackgroundColor))
                    e.Graphics.FillRectangle(brush, rcSegmentedArea);
            }

            FillIgnoredSegments(e, Color.White);

            var x = (!SegmentBoundaries.Any()) ? 0 : ConvertTimeToXCoordinate(SegmentBoundaries.Last()) + 1;

            if (x > rc.Right)
            {
                return;
            }

            if (x > rc.X)
            {
                rc.Width -= (x - rc.X);
                rc.X      = x;
            }
            using (var brush = new SolidBrush(UnsegmentedBackgroundColor))
                e.Graphics.FillRectangle(brush, rc);
        }
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);
        }