Ejemplo n.º 1
0
        public TextLine(LogLine logLine,
                        HashSet <LogLineIndex> hoveredIndices,
                        HashSet <LogLineIndex> selectedIndices,
                        bool colorByLevel,
                        TextSettings textSettings,
                        TextBrushes textBrushes)
        {
            if (logLine == null)
            {
                throw new ArgumentNullException(nameof(logLine));
            }
            if (hoveredIndices == null)
            {
                throw new ArgumentNullException(nameof(hoveredIndices));
            }
            if (selectedIndices == null)
            {
                throw new ArgumentNullException(nameof(selectedIndices));
            }
            if (textBrushes == null)
            {
                throw new ArgumentNullException(nameof(textBrushes));
            }

            _logLine         = logLine;
            _hoveredIndices  = hoveredIndices;
            _selectedIndices = selectedIndices;
            _segments        = new List <TextSegment>();
            _colorByLevel    = colorByLevel;
            _textSettings    = textSettings;
            _textBrushes     = textBrushes;
            _isFocused       = true;
        }
Ejemplo n.º 2
0
        private void OnSettingsChanged(ILogViewerSettings settings)
        {
            var textSettings = settings != null
                                ? new TextSettings(settings.FontSize, settings.TabWidth)
                                : TextSettings.Default;
            var textBrushes = new TextBrushes(settings);

            ChangeTextSettings(textSettings, textBrushes);
        }
Ejemplo n.º 3
0
        private void ChangeTextSettings(TextSettings textSettings, TextBrushes textBrushes)
        {
            _textSettings = textSettings;
            _textBrushes  = textBrushes;

            _verticalScrollBar.SetValue(RangeBase.SmallChangeProperty, _textSettings.LineHeight);
            _verticalScrollBar.SetValue(RangeBase.LargeChangeProperty, 10 * _textSettings.LineHeight);

            _horizontalScrollBar.SetValue(RangeBase.SmallChangeProperty, _textSettings.LineHeight);
            _horizontalScrollBar.SetValue(RangeBase.LargeChangeProperty, 10 * _textSettings.LineHeight);

            foreach (var columnPresenter in _columnPresenters.Values)
            {
                columnPresenter.TextSettings = _textSettings;
            }
            PartTextCanvas.ChangeTextSettings(_textSettings, _textBrushes);

            if (LogFile != null)
            {
                TextCanvasOnVisibleLinesChanged();
            }
        }
Ejemplo n.º 4
0
        public LogEntryListView()
        {
            var textSettings = new TextSettings();
            var textBrushes  = new TextBrushes(null);

            RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(value: 1, type: GridUnitType.Star)
            });
            RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(value: 1, type: GridUnitType.Auto)
            });

            _verticalScrollBar = new FlatScrollBar
            {
                Name      = "PART_VerticalScrollBar",
                Thickness = 18
            };
            _verticalScrollBar.ValueChanged += VerticalScrollBarOnValueChanged;
            _verticalScrollBar.Scroll       += VerticalScrollBarOnScroll;
            _verticalScrollBar.SetValue(RowProperty, value: 0);
            _verticalScrollBar.SetValue(ColumnProperty, value: 6);

            _horizontalScrollBar = new FlatScrollBar
            {
                Name        = "PART_HorizontalScrollBar",
                Orientation = Orientation.Horizontal,
                Thickness   = 18
            };
            _horizontalScrollBar.SetValue(RowProperty, value: 1);
            _horizontalScrollBar.SetValue(ColumnProperty, value: 0);
            _horizontalScrollBar.SetValue(ColumnSpanProperty, value: 6);

            _columnPresenterFactories = new Dictionary <ILogFileColumn, Func <TextSettings, AbstractLogColumnPresenter> >
            {
                { LogFileColumns.DeltaTime, settings => new DeltaTimeColumnPresenter(settings) },
                { LogFileColumns.ElapsedTime, settings => new ElapsedTimeColumnPresenter(settings) },
                { LogFileColumns.OriginalLineNumber, settings => new OriginalLineNumberColumnPresenter(settings) },
                { LogFileColumns.LogLevel, settings => new  LogLevelColumnPresenter(settings) },
                { LogFileColumns.Message, settings => new MessageColumnPresenter(settings) },
                { LogFileColumns.Timestamp, settings => new TimestampColumnPresenter(settings) }
            };
            _columnPresenters          = new Dictionary <ILogFileColumn, AbstractLogColumnPresenter>();
            _columnDefinitionsByColumn = new Dictionary <ILogFileColumn, ColumnDefinition>();
            _columnsByColumnDefinition = new Dictionary <ColumnDefinition, ILogFileColumn>();

            _lineNumberColumn = (OriginalLineNumberColumnPresenter)AddColumn(LogFileColumns.OriginalLineNumber);
            _lineNumberColumn.SetValue(MarginProperty, new Thickness(left: 5, top: 0, right: 5, bottom: 0));

            _dataSourceCanvas = new DataSourceCanvas(textSettings);
            _dataSourceCanvas.SetValue(RowProperty, value: 0);
            _dataSourceCanvas.SetValue(ColumnProperty, value: 1);
            _dataSourceCanvas.SetValue(MarginProperty, new Thickness(left: 0, top: 0, right: 5, bottom: 0));
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(value: 1, type: GridUnitType.Auto)
            });

            _deltaTimesColumn            = (DeltaTimeColumnPresenter)AddColumn(LogFileColumns.DeltaTime);
            _deltaTimesColumn.Visibility = Visibility.Collapsed;
            _deltaTimesColumn.SetValue(MarginProperty, new Thickness(left: 0, top: 0, right: 5, bottom: 0));

            _elapsedTimeColumn            = (ElapsedTimeColumnPresenter)AddColumn(LogFileColumns.ElapsedTime);
            _elapsedTimeColumn.Visibility = Visibility.Collapsed;
            _elapsedTimeColumn.SetValue(MarginProperty, new Thickness(left: 0, top: 0, right: 5, bottom: 0));

            _fixedColumns = _columnPresenters.Keys.ToList();

            _messageColumnDefinition = new ColumnDefinition {
                Width = new GridLength(value: 1, type: GridUnitType.Star)
            };
            ColumnDefinitions.Add(_messageColumnDefinition);
            var messageColumnIndex = ColumnDefinitions.IndexOf(_messageColumnDefinition);

            PartTextCanvas = new TextCanvas(_horizontalScrollBar, _verticalScrollBar, textSettings);
            PartTextCanvas.SetValue(RowProperty, value: 0);
            PartTextCanvas.SetValue(ColumnProperty, value: messageColumnIndex);
            PartTextCanvas.MouseWheelDown        += TextCanvasOnMouseWheelDown;
            PartTextCanvas.MouseWheelUp          += TextCanvasOnMouseWheelUp;
            PartTextCanvas.SizeChanged           += TextCanvasOnSizeChanged;
            PartTextCanvas.VisibleLinesChanged   += TextCanvasOnVisibleLinesChanged;
            PartTextCanvas.RequestBringIntoView  += TextCanvasOnRequestBringIntoView;
            PartTextCanvas.VisibleSectionChanged += TextCanvasOnVisibleSectionChanged;
            PartTextCanvas.OnSelectionChanged    += TextCanvasOnOnSelectionChanged;

            ChangeTextSettings(textSettings, textBrushes);

            var separator = new Rectangle
            {
                Fill  = new SolidColorBrush(Color.FromRgb(225, 228, 232)),
                Width = 2
            };

            separator.SetValue(RowProperty, value: 0);
            separator.SetValue(ColumnProperty, value: messageColumnIndex);
            separator.SetValue(MarginProperty, new Thickness(left: 0, top: 0, right: 5, bottom: 0));
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(value: 1, type: GridUnitType.Auto)
            });

            Children.Add(_lineNumberColumn);
            Children.Add(_dataSourceCanvas);
            Children.Add(_deltaTimesColumn);
            Children.Add(_elapsedTimeColumn);
            Children.Add(separator);
            Children.Add(PartTextCanvas);
            Children.Add(_verticalScrollBar);
            Children.Add(_horizontalScrollBar);

            _timer = new DispatcherTimer(DispatcherPriority.Normal)
            {
                Interval = MaximumRefreshInterval,
            };
            _timer.Tick += OnTimer;
            Loaded      += OnLoaded;
            Unloaded    += OnUnloaded;
        }
Ejemplo n.º 5
0
 public void ChangeTextSettings(TextSettings textSettings, TextBrushes textBrushes)
 {
     _textSettings = textSettings;
     _textBrushes  = textBrushes;
 }