Exemplo n.º 1
0
        public LogEntryListView()
        {
            var textSettings = TextSettings.Default;

            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);

            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;
        }
Exemplo n.º 2
0
        public LogEntryListView()
        {
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(value: 1, type: GridUnitType.Auto)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(value: 1, type: GridUnitType.Auto)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(value: 1, type: GridUnitType.Auto)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(value: 1, type: GridUnitType.Auto)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(value: 1, type: GridUnitType.Auto)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(value: 1, type: GridUnitType.Star)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(value: 1, type: GridUnitType.Auto)
            });
            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);
            _verticalScrollBar.SetValue(RangeBase.SmallChangeProperty, TextHelper.LineHeight);
            _verticalScrollBar.SetValue(RangeBase.LargeChangeProperty, 10 * TextHelper.LineHeight);

            _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);
            _horizontalScrollBar.SetValue(RangeBase.SmallChangeProperty, TextHelper.LineHeight);
            _horizontalScrollBar.SetValue(RangeBase.LargeChangeProperty, 10 * TextHelper.LineHeight);

            _lineNumberColumn = new OriginalLineNumberColumnPresenter();
            _lineNumberColumn.SetValue(RowProperty, value: 0);
            _lineNumberColumn.SetValue(ColumnProperty, value: 0);
            _lineNumberColumn.SetValue(MarginProperty, new Thickness(left: 5, top: 0, right: 5, bottom: 0));

            _dataSourceCanvas = new DataSourceCanvas();
            _dataSourceCanvas.SetValue(RowProperty, value: 0);
            _dataSourceCanvas.SetValue(ColumnProperty, value: 1);
            _dataSourceCanvas.SetValue(MarginProperty, new Thickness(left: 0, top: 0, right: 5, bottom: 0));

            _deltaTimesColumn            = new DeltaTimeColumnPresenter();
            _deltaTimesColumn.Visibility = Visibility.Collapsed;
            _deltaTimesColumn.SetValue(RowProperty, value: 0);
            _deltaTimesColumn.SetValue(ColumnProperty, value: 2);
            _dataSourceCanvas.SetValue(MarginProperty, new Thickness(left: 0, top: 0, right: 5, bottom: 0));

            _elapsedTimeColumn            = new ElapsedTimeColumnPresenter();
            _elapsedTimeColumn.Visibility = Visibility.Collapsed;
            _elapsedTimeColumn.SetValue(RowProperty, value: 0);
            _elapsedTimeColumn.SetValue(ColumnProperty, value: 3);
            _dataSourceCanvas.SetValue(MarginProperty, new Thickness(left: 0, top: 0, right: 5, bottom: 0));

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

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

            separator.SetValue(RowProperty, value: 0);
            separator.SetValue(ColumnProperty, value: 4);
            separator.SetValue(MarginProperty, new Thickness(left: 0, top: 0, right: 5, bottom: 0));

            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;
        }
Exemplo n.º 3
0
        public LogEntryListView()
        {
            _verticalScrollBar = new FlatScrollBar
                {
                    Name = "PART_VerticalScrollBar",
                    Thickness = 10
                };
            _verticalScrollBar.ValueChanged += VerticalScrollBarOnValueChanged;
            _verticalScrollBar.Scroll += VerticalScrollBarOnScroll;
            _verticalScrollBar.SetValue(RowProperty, 0);
            _verticalScrollBar.SetValue(ColumnProperty, 2);

            _horizontalScrollBar = new FlatScrollBar
                {
                    Name = "PART_HorizontalScrollBar",
                    Orientation = Orientation.Horizontal,
                    Thickness = 10
                };
            _horizontalScrollBar.SetValue(RowProperty, 1);
            _horizontalScrollBar.SetValue(ColumnProperty, 0);
            _horizontalScrollBar.SetValue(ColumnSpanProperty, 2);

            ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(1, GridUnitType.Auto)});
            ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)});
            ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(1, GridUnitType.Auto)});
            RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Star)});
            RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)});

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

            _lineNumberCanvas = new LineNumberCanvas();
            _lineNumberCanvas.SetValue(RowProperty, 0);
            _lineNumberCanvas.SetValue(ColumnProperty, 0);

            Children.Add(_lineNumberCanvas);
            Children.Add(_textCanvas);
            Children.Add(_verticalScrollBar);
            Children.Add(_horizontalScrollBar);

            _timer = new DispatcherTimer(MaximumRefreshInterval, DispatcherPriority.Normal, OnTimer, Dispatcher);
            _timer.Start();
        }