コード例 #1
0
        public MainWindowViewModel(IApplicationSettings settings,
                                   DataSources dataSources,
                                   QuickFilters quickFilters,
                                   IActionCenter actionCenter,
                                   IAutoUpdater updater,
                                   ITaskScheduler taskScheduler,
                                   IAnalysisStorage analysisStorage,
                                   IDispatcher dispatcher,
                                   IPluginLoader pluginLoader)
        {
            if (dataSources == null)
            {
                throw new ArgumentNullException(nameof(dataSources));
            }
            if (quickFilters == null)
            {
                throw new ArgumentNullException(nameof(quickFilters));
            }
            if (updater == null)
            {
                throw new ArgumentNullException(nameof(updater));
            }
            if (dispatcher == null)
            {
                throw new ArgumentNullException(nameof(dispatcher));
            }

            _applicationSettings = settings;

            _plugins  = pluginLoader.Plugins;
            _settings = new SettingsMainPanelViewModel(settings);
            _actionCenterViewModel = new ActionCenterViewModel(dispatcher, actionCenter);

            _analysePanel = new AnalyseMainPanelViewModel(_applicationSettings, dataSources, dispatcher, taskScheduler, analysisStorage, pluginLoader);
            _analysePanel.PropertyChanged += AnalysePanelOnPropertyChanged;

            _logViewPanel = new LogViewMainPanelViewModel(actionCenter,
                                                          dataSources,
                                                          quickFilters,
                                                          _applicationSettings);
            _logViewPanel.PropertyChanged += LogViewPanelOnPropertyChanged;

            _timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(100)
            };
            _timer.Tick += TimerOnTick;
            _timer.Start();

            _autoUpdater                   = new AutoUpdateViewModel(updater, settings.AutoUpdate, dispatcher);
            _showLogCommand                = new DelegateCommand(ShowLog);
            _showGoToLineCommand           = new DelegateCommand2(ShowGoToLine);
            _showQuickNavigationCommand    = new DelegateCommand2(ShowQuickNavigation);
            _goToNextDataSourceCommand     = new DelegateCommand2(GoToNextDataSource);
            _goToPreviousDataSourceCommand = new DelegateCommand2(GoToPreviousDataSource);

            _analyseEntry = new AnalyseMainPanelEntry();
            _rawEntry     = new LogViewMainPanelEntry();
            _topEntries   = new IMainPanelEntry[]
            {
                _rawEntry,
                _analyseEntry
            };

            _settingsEntry = new SettingsMainPanelEntry();
            _pluginsEntry  = new PluginsMainPanelEntry();
            _aboutEntry    = new AboutMainPanelEntry();
            _bottomEntries = new[]
            {
                _settingsEntry,
                _pluginsEntry,
                _aboutEntry
            };

            var selectedTopEntry    = _topEntries.FirstOrDefault(x => x.Id == _applicationSettings.MainWindow.SelectedMainPanel);
            var selectedBottomEntry = _bottomEntries.FirstOrDefault(x => x.Id == _applicationSettings.MainWindow.SelectedMainPanel);

            if (selectedTopEntry != null)
            {
                SelectedTopEntry = selectedTopEntry;
            }
            else if (selectedBottomEntry != null)
            {
                SelectedBottomEntry = selectedBottomEntry;
            }
            else
            {
                SelectedTopEntry = _rawEntry;
            }
        }
コード例 #2
0
        public MainWindowViewModel(IServiceContainer services,
                                   IApplicationSettings settings,
                                   DataSources dataSources,
                                   QuickFilters quickFilters,
                                   IActionCenter actionCenter,
                                   IAutoUpdater updater)
        {
            if (dataSources == null)
            {
                throw new ArgumentNullException(nameof(dataSources));
            }
            if (quickFilters == null)
            {
                throw new ArgumentNullException(nameof(quickFilters));
            }
            if (updater == null)
            {
                throw new ArgumentNullException(nameof(updater));
            }

            _services            = services;
            _applicationSettings = settings;

            _plugins  = services.Retrieve <IPluginLoader>().Plugins;
            _settings = new SettingsMainPanelViewModel(settings);
            _actionCenterViewModel = new ActionCenterViewModel(services.Retrieve <IDispatcher>(), actionCenter);

            _logViewPanel = new LogViewMainPanelViewModel(services,
                                                          actionCenter,
                                                          dataSources,
                                                          quickFilters,
                                                          services.Retrieve <IHighlighters>(),
                                                          _applicationSettings);
            ((NavigationService)services.Retrieve <INavigationService>()).LogViewer = _logViewPanel;

            _logViewPanel.PropertyChanged += LogViewPanelOnPropertyChanged;

            var timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(100)
            };

            timer.Tick += TimerOnTick;
            timer.Start();

            _autoUpdater                   = new AutoUpdateViewModel(updater, settings.AutoUpdate, services.Retrieve <IDispatcher>());
            _showLogCommand                = new DelegateCommand(ShowLog);
            _showGoToLineCommand           = new DelegateCommand2(ShowGoToLine);
            _showQuickNavigationCommand    = new DelegateCommand2(ShowQuickNavigation);
            _goToNextDataSourceCommand     = new DelegateCommand2(GoToNextDataSource);
            _goToPreviousDataSourceCommand = new DelegateCommand2(GoToPreviousDataSource);

            _rawEntry   = new LogViewMainPanelEntry();
            _topEntries = new IMainPanelEntry[]
            {
                _rawEntry
            };

            _settingsEntry = new SettingsMainPanelEntry();
            _pluginsEntry  = new PluginsMainPanelEntry();
            _aboutEntry    = new AboutMainPanelEntry();
            _bottomEntries = new[]
            {
                _settingsEntry,
                _pluginsEntry,
                _aboutEntry
            };

            var selectedTopEntry    = _topEntries.FirstOrDefault(x => x.Id == _applicationSettings.MainWindow.SelectedMainPanel);
            var selectedBottomEntry = _bottomEntries.FirstOrDefault(x => x.Id == _applicationSettings.MainWindow.SelectedMainPanel);

            if (selectedTopEntry != null)
            {
                SelectedTopEntry = selectedTopEntry;
            }
            else if (selectedBottomEntry != null)
            {
                SelectedBottomEntry = selectedBottomEntry;
            }
            else
            {
                SelectedTopEntry = _rawEntry;
            }

            _isLeftSidePanelVisible = settings.MainWindow.IsLeftSidePanelVisible;
            UpdateLeftSidePanelExpanderTooltip();
        }