Exemplo n.º 1
0
        public LogViewMainPanelViewModel(IActionCenter actionCenter,
                                         IDataSources dataSources,
                                         IQuickFilters quickFilters,
                                         IApplicationSettings applicationSettings)
            : base(applicationSettings)
        {
            if (actionCenter == null)
            {
                throw new ArgumentNullException(nameof(actionCenter));
            }

            _applicationSettings = applicationSettings;
            _actionCenter        = actionCenter;

            _dataSources = new DataSourcesViewModel(applicationSettings, dataSources, _actionCenter);
            _dataSources.PropertyChanged += DataSourcesOnPropertyChanged;
            _quickFilters = new QuickFiltersSidePanelViewModel(applicationSettings, quickFilters);
            _quickFilters.OnFiltersChanged += OnFiltersChanged;

            _goToLine = new GoToLineViewModel();
            _goToLine.LineNumberChosen += GoToLineOnLineNumberChosen;

            _quickNavigation = new QuickNavigationViewModel(dataSources);
            _quickNavigation.DataSourceChosen += QuickNavigationOnDataSourceChosen;

            _bookmarks = new BookmarksViewModel(dataSources, OnNavigateToBookmark);

            _sidePanels = new ISidePanelViewModel[]
            {
                _dataSources,
                _quickFilters,
                _bookmarks
            };

            SelectedSidePanel = _sidePanels.FirstOrDefault(x => x.Id == _applicationSettings.MainWindow?.SelectedSidePanel);

            PropertyChanged += OnPropertyChanged;
            ChangeDataSource(CurrentDataSource);
        }
Exemplo n.º 2
0
        public void TestAddEmptyFilterWhenSelected2()
        {
            _quickFilters.AddQuickFilter().Value = "stuff";

            var model = new QuickFiltersSidePanelViewModel(_settings, _quickFilters);

            model.IsSelected.Should().BeFalse();

            _settings.QuickFilters.Should().HaveCount(1);
            _quickFilters.Filters.Should().HaveCount(1);

            model.IsSelected = true;

            const string reason = "because there doesn't exist any empty quick filter and thus a 2nd (empty) filter should've been added";

            _settings.QuickFilters.Should().HaveCount(2, reason);
            _quickFilters.Filters.Should().HaveCount(2, reason);
            var filter = _quickFilters.Filters.Last();

            filter.Id.Should().NotBe(QuickFilterId.Empty);
            filter.Value.Should().BeNullOrEmpty();
        }
Exemplo n.º 3
0
        public void TestChangeFilterType1()
        {
            var model = new QuickFiltersSidePanelViewModel(_settings, _quickFilters)
            {
                CurrentDataSource = new SingleDataSourceViewModel(new SingleDataSource(_logFileFactory, _scheduler,
                                                                                       new DataSource("adw")
                {
                    Id = DataSourceId.CreateNew()
                }), _actionCenter.Object)
            };

            var numFilterChanges = 0;
            var filter           = model.AddQuickFilter();

            filter.MatchType.Should().Be(FilterMatchType.SubstringFilter);
            filter.Value    = "Foobar";
            filter.IsActive = true;

            model.OnFiltersChanged += () => ++ numFilterChanges;
            filter.MatchType        = FilterMatchType.WildcardFilter;
            numFilterChanges.Should().Be(1);
        }
Exemplo n.º 4
0
        public void TestCreateFilterChain()
        {
            var model = new QuickFiltersSidePanelViewModel(_settings, _quickFilters);

            model.CreateFilterChain().Should().BeNull();
        }