internal void OpenFile(string fileName) { LogTabData tab = new LogTabData(fileName, _optionsTracker.Options); _tabs.Add(tab); logTabControl.SelectedIndex = logTabControl.Items.Count - 1; }
private void SelectPosition(long line) { if (!_isInSearch) { LogTabData tab = _tabs[logTabControl.SelectedIndex]; tab.LastPosition = new SearchPosition(line, 0, null, 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); }
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; } } }
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; } }
void CloseFile(LogTabData tab) { _tabs.Remove(tab); tab.Dispose(); }
void CloseFile() { LogTabData tab = _tabs[logTabControl.SelectedIndex]; CloseFile(tab); }