Example #1
0
        private void Update()
        {
            var hashSet = new HashSet <object>();

            foreach (var textViewLine in _textView.TextViewLines.Where(textViewLine => textViewLine.IsFirstTextViewLineForSnapshotLine))
            {
                hashSet.Add(textViewLine.IdentityTag);
            }

            var dictionary = new Dictionary <object, TimeStampVisual>();
            var list1      = new List <int>();

            for (var index = _translatedCanvas.Children.Count - 1; index >= 0; --index)
            {
                var timeStampVisual = _translatedCanvas.Children[index] as TimeStampVisual;
                if (timeStampVisual != null)
                {
                    if (hashSet.Contains(timeStampVisual.LineTag))
                    {
                        dictionary.Add(timeStampVisual.LineTag, timeStampVisual);
                    }
                    else
                    {
                        list1.Add(index);
                    }
                }
            }

            var list2 = new List <TimeStampVisual>();

            foreach (var line in _textView.TextViewLines)
            {
                if (line.IsFirstTextViewLineForSnapshotLine)
                {
                    var lineNumber = line.Start.GetContainingLine().LineNumber;
                    if (lineNumber < _lineTimeStamps.Count)
                    {
                        var             timeStamp         = _lineTimeStamps[lineNumber];
                        var             previousTimeStamp = _lineTimeStamps[Math.Max(lineNumber - 1, 0)];
                        TimeStampVisual timeStampVisual;
                        if (!dictionary.TryGetValue(line.IdentityTag, out timeStampVisual))
                        {
                            var index = list1.Count - 1;
                            if (index < 0)
                            {
                                timeStampVisual = new TimeStampVisual();
                                list2.Add(timeStampVisual);
                            }
                            else
                            {
                                timeStampVisual = _translatedCanvas.Children[list1[index]] as TimeStampVisual;
                                list1.RemoveAt(index);
                            }
                        }

                        if (timeStampVisual != null)
                        {
                            var startDiff = timeStamp - BuildEventsProvider.BuildEvents.DebugStartTime;
                            var lastDiff  = timeStamp - previousTimeStamp;

                            var text = lineNumber == 0 || lastDiff != TimeSpan.Zero
                                ? $"{startDiff.Minutes:D2}:{startDiff.Seconds:D2}.{startDiff.Milliseconds:D3} " +
                                       $"({lastDiff.Minutes:D2}:{lastDiff.Seconds:D2}.{lastDiff.Milliseconds:D3})"
                                : "";

                            timeStampVisual.Update(text, line, _textView, _textRunProperties, MinWidth, _oldViewportTop);
                        }
                    }
                }
            }

            foreach (var index in list1)
            {
                _translatedCanvas.Children.RemoveAt(index);
            }
            foreach (var element in list2)
            {
                _translatedCanvas.Children.Add(element);
            }
        }
Example #2
0
        private void Update()
        {
            var hashSet = new HashSet<object>();
            foreach (var textViewLine in _textView.TextViewLines.Where(textViewLine => textViewLine.IsFirstTextViewLineForSnapshotLine))
            {
                hashSet.Add(textViewLine.IdentityTag);
            }

            var dictionary = new Dictionary<object, TimeStampVisual>();
            var list1 = new List<int>();
            for (var index = _translatedCanvas.Children.Count - 1; index >= 0; --index)
            {
                var timeStampVisual = _translatedCanvas.Children[index] as TimeStampVisual;
                if (timeStampVisual != null)
                {
                    if (hashSet.Contains(timeStampVisual.LineTag)) dictionary.Add(timeStampVisual.LineTag, timeStampVisual);
                    else list1.Add(index);
                }
            }

            var list2 = new List<TimeStampVisual>();
            foreach (var line in _textView.TextViewLines)
            {
                if (line.IsFirstTextViewLineForSnapshotLine)
                {
                    var lineNumber = line.Start.GetContainingLine().LineNumber;
                    if (lineNumber < _lineTimeStamps.Count)
                    {
                        var timeStamp = _lineTimeStamps[lineNumber];
                        var previousTimeStamp = _lineTimeStamps[Math.Max(lineNumber - 1, 0)];
                        TimeStampVisual timeStampVisual;
                        if (!dictionary.TryGetValue(line.IdentityTag, out timeStampVisual))
                        {
                            var index = list1.Count - 1;
                            if (index < 0)
                            {
                                timeStampVisual = new TimeStampVisual();
                                list2.Add(timeStampVisual);
                            }
                            else
                            {
                                timeStampVisual = _translatedCanvas.Children[list1[index]] as TimeStampVisual;
                                list1.RemoveAt(index);
                            }
                        }

                        if (timeStampVisual != null)
                        {
                            var startDiff = timeStamp - BuildEventsProvider.BuildEvents.DebugStartTime;
                            var lastDiff = timeStamp - previousTimeStamp;

                            var text = lineNumber == 0 || lastDiff != TimeSpan.Zero
                                ? $"{startDiff.Minutes:D2}:{startDiff.Seconds:D2}.{startDiff.Milliseconds:D3} " +
                                    $"({lastDiff.Minutes:D2}:{lastDiff.Seconds:D2}.{lastDiff.Milliseconds:D3})"
                                : "";

                            timeStampVisual.Update(text, line, _textView, _textRunProperties, MinWidth, _oldViewportTop);
                        }
                    }
                }
            }

            foreach (var index in list1) _translatedCanvas.Children.RemoveAt(index);
            foreach (var element in list2) _translatedCanvas.Children.Add(element);
        }