예제 #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);
        }