Exemple #1
0
        private bool SetSelected(LogLineIndex from, LogLineIndex to, SelectMode selectMode)
        {
            bool changed = false;

            if (selectMode == SelectMode.Replace)
            {
                if (_hoveredIndices.Count > 0)
                {
                    changed = true;
                }

                _hoveredIndices.Clear();
            }

            LogLineIndex min   = LogLineIndex.Min(from, to);
            LogLineIndex max   = LogLineIndex.Max(from, to);
            int          count = max - min;

            for (int i = 0; i <= count /* we want to select everything including 'to' */; ++i)
            {
                changed |= _selectedIndices.Add(min + i);
            }

            if (changed)
            {
                var fn = OnSelectionChanged;
                fn?.Invoke(_selectedIndices);
            }

            return(changed);
        }
Exemple #2
0
        /// <summary>
        ///     Creates a new section which spawns from the lowest <see cref="Index" />
        ///     of the given two sections to the greatest <see cref="LastIndex" />.
        /// </summary>
        /// <param name="lhs"></param>
        /// <param name="rhs"></param>
        /// <returns></returns>
        public static LogFileSection MinimumBoundingLine(LogFileSection lhs, LogFileSection rhs)
        {
            LogLineIndex minIndex = LogLineIndex.Min(lhs.Index, rhs.Index);
            LogLineIndex maxIndex = LogLineIndex.Max(lhs.Index + lhs.Count, rhs.Index + rhs.Count);
            int          count    = maxIndex - minIndex;

            return(new LogFileSection(minIndex, count));
        }
Exemple #3
0
        private void Invalidate(LogFileSection sectionToInvalidate)
        {
            var firstInvalidIndex   = LogLineIndex.Min(_fullSourceSection.LastIndex, sectionToInvalidate.Index);
            var lastInvalidIndex    = LogLineIndex.Min(_fullSourceSection.LastIndex, sectionToInvalidate.LastIndex);
            var invalidateCount     = lastInvalidIndex - firstInvalidIndex + 1;
            var previousSourceIndex = _currentSourceIndex;

            _fullSourceSection = new LogFileSection(0, (int)firstInvalidIndex);
            if (_fullSourceSection.Count > 0)
            {
                // It's possible (likely) that we've received an invalidation for a region of the source
                // that we've already processed (i.e. created indices for). If that's the case, then we need
                // to rewind the index. Otherwise nothing needs to be done...
                var newIndex = _fullSourceSection.LastIndex + 1;
                if (newIndex < _currentSourceIndex)
                {
                    _currentSourceIndex = newIndex;
                }
            }
            else
            {
                _currentSourceIndex = 0;
            }

            lock (_syncRoot)
            {
                var toRemove = _indices.Count - lastInvalidIndex;
                if (toRemove > 0)
                {
                    _indices.RemoveRange((int)firstInvalidIndex, toRemove);
                    _currentLogEntry = new LogEntryInfo(firstInvalidIndex - 1, 0);
                }
                if (previousSourceIndex != _currentSourceIndex)
                {
                    _indices.RemoveRange((int)_currentSourceIndex, _indices.Count - _currentSourceIndex);
                }
            }

            if (_indices.Count != _currentSourceIndex)
            {
                Log.ErrorFormat("Inconsistency detected: We have {0} indices for {1} lines", _indices.Count,
                                _currentSourceIndex);
            }

            Listeners.Invalidate((int)firstInvalidIndex, invalidateCount);

            if (_fullSourceSection.Count > firstInvalidIndex)
            {
                _fullSourceSection = new LogFileSection(0, firstInvalidIndex.Value);
            }
        }