Exemplo n.º 1
0
        public void OnTimer(object sender, EventArgs args)
        {
            if (Interlocked.Exchange(ref _pendingModificationsCount, value: 0) > 0)
            {
                try
                {
                    PartTextCanvas.DetermineVerticalOffset();
                    PartTextCanvas.CurrentlyVisibleSection = CalculateVisibleSection();

                    UpdateScrollViewerRegions();
                    ScrollToBottomIfRequired();

                    PartTextCanvas.UpdateVisibleLines();
                    PartTextCanvas.OnMouseMove();
                }
                catch (Exception e)
                {
                    Log.ErrorFormat("Caught unexpected exception while updating: {0}", e);

                    // Common sense says that functions which fail once work when tried again.
                    // The same goes for this control: If drawing fails then it's conceivable
                    // that it will work when we try again in a few milliseconds...
                    Interlocked.Increment(ref _pendingModificationsCount);
                }
            }
        }
Exemplo n.º 2
0
        private void OnLogFileChanged(ILogSource oldValue, ILogSource newValue)
        {
            oldValue?.RemoveListener(this);

            PartTextCanvas.LogSource = newValue;

            if (newValue != null)
            {
                newValue.AddListener(this, TimeSpan.FromMilliseconds(value: 100), maximumLineCount: 10000);

                _maxLineWidth = (int)Math.Ceiling(_textSettings.EstimateWidthUpperLimit(newValue.GetProperty(TextProperties.MaxCharactersInLine)));
                UpdateScrollViewerRegions();
                PartTextCanvas.DetermineVerticalOffset();
                PartTextCanvas.UpdateVisibleSection();
                PartTextCanvas.UpdateVisibleLines();
            }
            else
            {
                _maxLineWidth = 0;
                TextCanvasOnVisibleLinesChanged();
                UpdateScrollViewerRegions();
            }

            MatchScrollbarValueToCurrentLine();
        }