コード例 #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));
            }

            var services1           = services;
            var applicationSettings = settings;

            _plugins = new PluginsMainPanelViewModel(applicationSettings,
                                                     services1.Retrieve <IDispatcher>(),
                                                     services1.Retrieve <IPluginUpdater>(),
                                                     services1.Retrieve <IPluginLoader>().Plugins);
            _settings = new SettingsFlyoutViewModel(settings, services);
            _actionCenterViewModel = new ActionCenterViewModel(services.Retrieve <IDispatcher>(), actionCenter);

            _logViewPanel = new LogViewMainPanelViewModel(services,
                                                          actionCenter,
                                                          dataSources,
                                                          quickFilters,
                                                          services.Retrieve <IHighlighters>(),
                                                          applicationSettings);
            WindowTitle       = _logViewPanel.WindowTitle;
            WindowTitleSuffix = _logViewPanel.WindowTitleSuffix;

            ((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>());

            var fileMenuViewModel = new FileMenuViewModel(new DelegateCommand2(AddDataSourceFromFile),
                                                          new DelegateCommand2(AddDataSourceFromFolder),
                                                          _logViewPanel.DataSources.RemoveCurrentDataSourceCommand,
                                                          _logViewPanel.DataSources.RemoveAllDataSourcesCommand,
                                                          new DelegateCommand2(ShowPlugins),
                                                          new DelegateCommand2(ShowSettings),
                                                          new DelegateCommand2(Exit));
            var editMenu = new EditMenuViewModel(new DelegateCommand2(ShowGoToLine),
                                                 new DelegateCommand2(ShowGoToDataSource),
                                                 new DelegateCommand2(GoToNextDataSource),
                                                 new DelegateCommand2(GoToPreviousDataSource),
                                                 _logViewPanel);
            var viewMenu = new ViewMenuViewModel();
            var helpMenu = new HelpMenuViewModel(new DelegateCommand2(ReportIssue),
                                                 new DelegateCommand2(SuggestFeature),
                                                 new DelegateCommand2(AskQuestion),
                                                 AutoUpdater.CheckForUpdatesCommand,
                                                 new DelegateCommand(ShowLog),
                                                 new DelegateCommand2(ShowAboutFlyout));

            _mainMenu = new MainMenu(fileMenuViewModel,
                                     editMenu,
                                     viewMenu,
                                     helpMenu);
            _mainMenu.CurrentDataSource = _logViewPanel.CurrentDataSource;
        }
コード例 #3
0
 public void Setup()
 {
     _dispatcher   = new ManualDispatcher();
     _actionCenter = new Tailviewer.BusinessLogic.ActionCenter.ActionCenter();
     _viewModel    = new ActionCenterViewModel(_dispatcher, _actionCenter);
 }
コード例 #4
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();
        }