private void UpdateVerticalScrollbar() { var count = LogSource?.GetProperty(Properties.LogEntryCount) ?? 0; var totalHeight = count * _textSettings.LineHeight; var usableHeight = PartTextCanvas.ActualHeight; if (totalHeight > usableHeight) { _verticalScrollBar.Minimum = 0; _verticalScrollBar.Maximum = Math.Ceiling((totalHeight - usableHeight) / _textSettings.LineHeight) * _textSettings.LineHeight; _verticalScrollBar.ViewportSize = usableHeight; _verticalScrollBar.Visibility = Visibility.Visible; } else { _verticalScrollBar.Minimum = 0; _verticalScrollBar.Maximum = 0; _verticalScrollBar.ViewportSize = usableHeight; _verticalScrollBar.Visibility = Visibility.Collapsed; } }
public LogSourceSection CalculateVisibleSection() { if (_logSource == null) { return(new LogSourceSection(0, 0)); } double maxLinesInViewport = (ActualHeight - _yOffset) / _textSettings.LineHeight; var maxCount = (int)Math.Ceiling(maxLinesInViewport); var logLineCount = LogSource.GetProperty(Properties.LogEntryCount); // Somebody may have specified that he wants to view line X, but if the source // doesn't offer this line (yet), then we must show something else... var actualCurrentLine = _currentLine >= logLineCount?Math.Max(0, logLineCount - maxCount) : _currentLine; int linesLeft = logLineCount - actualCurrentLine; int count = Math.Min(linesLeft, maxCount); if (count < 0) { return(new LogSourceSection()); } return(new LogSourceSection(actualCurrentLine, count)); }