示例#1
0
        internal void OpenFile(string fileName)
        {
            LogTabData tab = new LogTabData(fileName, _optionsTracker.Options);

            _tabs.Add(tab);
            logTabControl.SelectedIndex = logTabControl.Items.Count - 1;
        }
示例#2
0
 private void SelectPosition(long line)
 {
     if (!_isInSearch)
     {
         LogTabData tab = _tabs[logTabControl.SelectedIndex];
         tab.LastPosition = new SearchPosition(line, 0, null, 0);
     }
 }
示例#3
0
        void ScrollToIndex(LogTabData tab, int index)
        {
            var item = VisualSearch.FindVisualChild <ListView>(logTabControl, view => view.DataContext == tab);

            item.SelectedIndex = index;

            var    vsp          = VisualSearch.FindVisualChild <ScrollViewer>(item);
            double scrollHeight = vsp.ScrollableHeight;

            double offset = scrollHeight * index / item.Items.Count + vsp.ViewportHeight / 2;

            vsp.ScrollToVerticalOffset(offset);
        }
示例#4
0
        private void SetParser()
        {
            LogTabData tab = _tabs[logTabControl.SelectedIndex];

            LineParserOptionsWindow filterWindow = new LineParserOptionsWindow();

            filterWindow.Owner       = this;
            filterWindow.DataContext = tab.FileOptions.ParserOptions.Clone();
            if (filterWindow.ShowDialog() ?? false)
            {
                tab.Context.SetParser(filterWindow.Options.CreateParser());
                tab.FileOptions.ParserOptions = filterWindow.Options;
                var index = logTabControl.SelectedIndex;
                DataContext = null;
                DataContext = _tabs;
                logTabControl.SelectedIndex = index;
                if (filterWindow.Default)
                {
                    _optionsTracker.Options.DefaultParserOptions = filterWindow.Options;
                }
            }
        }
示例#5
0
 private void SearchClick(Func <Searcher, SearchFilter, SearchPosition?, SearchPosition?> method)
 {
     try
     {
         _isInSearch = true;
         LogTabData       tab             = _tabs[logTabControl.SelectedIndex];
         LogContext       context         = tab.Context;
         StringComparison isCaseSensitive = (caseSensitive.IsChecked == true)
             ? StringComparison.InvariantCulture
             : StringComparison.InvariantCultureIgnoreCase;
         SearchFilter   filter       = new SearchFilter(searchBox.Text, isCaseSensitive);
         SearchPosition?nextPosition = method(context.Searcher, filter, tab.LastPosition);
         if (nextPosition != null)
         {
             tab.LastPosition = nextPosition;
             ScrollToIndex(tab, (int)nextPosition.Value.Line);
         }
     }
     finally
     {
         _isInSearch = false;
     }
 }
示例#6
0
 void CloseFile(LogTabData tab)
 {
     _tabs.Remove(tab);
     tab.Dispose();
 }
示例#7
0
        void CloseFile()
        {
            LogTabData tab = _tabs[logTabControl.SelectedIndex];

            CloseFile(tab);
        }