コード例 #1
0
        public void AddTrace(TraceEvent evt)
        {
            if (evt == null || evt.ProcessName == null)
            {
                return;
            }

            if (App.Current.Settings.ExcludeLine(evt.Text, evt.ProcessName))
            {
                return;
            }

            var last = _dataSource.LastOrDefault();

            evt.PreviousTicks = last != null ? last.Ticks : evt.Ticks;
            _dataSource.Add(evt);

            if (_state.AutoScroll)
            {
                // only ask to scroll if nothing is scrolling
                _scrollTo = evt;
                if (Interlocked.CompareExchange(ref _scrollingTo, 1, 0) == 0)
                {
                    Dispatcher.BeginInvoke(() =>
                    {
                        var st = _scrollTo;
                        if (st != null)
                        {
                            LV.ScrollIntoView(st);
                        }
                        Interlocked.Exchange(ref _scrollingTo, 0);
                    }, DispatcherPriority.SystemIdle);
                }
            }
        }
コード例 #2
0
        private void DoFind(bool next)
        {
            if (_findWindow == null)
            {
                return;
            }

            var search = _findWindow.Searches.Text;

            if (string.IsNullOrWhiteSpace(search))
            {
                return;
            }

            var focused = FocusManager.GetFocusedElement(_findWindow) is System.Windows.Controls.TextBox;

            int start = Math.Max(0, LV.SelectedIndex);
            var sc    = _findWindow.CaseMatch ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;

            foreach (int i in EnumerateItems(start, next))
            {
                var evt = (TraceEvent)LV.Items[i];
                if (evt.Text == null)
                {
                    continue;
                }

                if (evt.Text.IndexOf(search, sc) > 0)
                {
                    LV.SelectedItem = evt;
                    ((System.Windows.Controls.ListViewItem)LV.ItemContainerGenerator.ContainerFromItem(evt))?.Focus();
                    LV.ScrollIntoView(evt);
                    if (focused)
                    {
                        if (next)
                        {
                            _findWindow.FindNext.Focus();
                        }
                        else
                        {
                            _findWindow.FindPrev.Focus();
                        }
                    }
                    _findWindow.Searches.SelectedItem = search;
                    return;
                }
            }

            _findWindow.ShowMessage("Cannot find '" + search + "'.", MessageBoxImage.Information);
        }