public void TestCtor2() { _settings = new ApplicationSettings("foobar"); var group = new DataSource { Id = DataSourceId.CreateNew() }; var source = new DataSource("foo") { Id = DataSourceId.CreateNew(), ParentId = DataSourceId.CreateNew() }; _settings.DataSources.Add(group); _settings.DataSources.Add(source); _dataSources = new DataSources(_logFileFactory, _scheduler, _settings.DataSources); new Action(() => _model = new DataSourcesViewModel(_settings, _dataSources, _actionCenter.Object)).ShouldNotThrow(); _model.Observable.Count.Should().Be(2); var viewModel = _model.Observable[0]; viewModel.Should().NotBeNull(); viewModel.Should().BeOfType <MergedDataSourceViewModel>(); viewModel.DataSource.Id.Should().Be(group.Id); var merged = (MergedDataSourceViewModel)viewModel; merged.Observable.Should().BeEmpty(); viewModel = _model.Observable[1]; viewModel.Should().NotBeNull(); viewModel.Should().BeOfType <SingleDataSourceViewModel>(); }
public void SetUp() { _settings = new ApplicationSettings("adwad"); _bookmarks = new Bookmarks("aawdwa"); _dispatcher = new ManualDispatcher(); _scheduler = new ManualTaskScheduler(); _logFileFactory = new PluginLogFileFactory(_scheduler); _filesystem = new InMemoryFilesystem(); _dataSources = new DataSources(_logFileFactory, _scheduler, _filesystem, _settings.DataSources, _bookmarks); _quickFilters = new QuickFilters(_settings.QuickFilters); _actionCenter = new ActionCenter(); _updater = new Mock <IAutoUpdater>(); _services = new ServiceContainer(); _services.RegisterInstance <ITaskScheduler>(_scheduler); _services.RegisterInstance <IDispatcher>(_dispatcher); _services.RegisterInstance <IPluginLoader>(new PluginRegistry()); _services.RegisterInstance <IHighlighters>(new HighlighterCollection()); _services.RegisterInstance <INavigationService>(new NavigationService()); _mainWindow = new MainWindowViewModel(_services, _settings, _dataSources, _quickFilters, _actionCenter, _updater.Object); }
public void SetUp() { _settingsMock = new Mock <IApplicationSettings>(); _settingsMock.Setup(x => x.DataSources).Returns(new Tailviewer.Settings.DataSources()); _settings = _settingsMock.Object; _dataSources = new DataSources(_logFileFactory, _scheduler, _settings.DataSources); _model = new DataSourcesViewModel(_settings, _dataSources, _actionCenter.Object); }
public void SetUp() { _settingsMock = new Mock <IApplicationSettings>(); _settingsMock.Setup(x => x.DataSources).Returns(new DataSourceSettings()); _settings = _settingsMock.Object; _bookmarks = new Mock <IBookmarks>(); _dataSources = new DataSources(_logSourceFactory, _scheduler, _filesystem, _settings.DataSources, _bookmarks.Object); _model = new DataSourcesViewModel(_settings, _dataSources, _actionCenter.Object); }
public void SetUp() { _settings = new ApplicationSettings("adwad"); _dispatcher = new ManualDispatcher(); _scheduler = new ManualTaskScheduler(); _dataSources = new DataSources(_scheduler, _settings.DataSources); _quickFilters = new QuickFilters(_settings.QuickFilters); _actionCenter = new ActionCenter(); _updater = new Mock<IAutoUpdater>(); _mainWindow = new MainWindowViewModel(_settings, _dataSources, _quickFilters, _actionCenter, _updater.Object, _dispatcher); }
public void TestRemove3() { var source = new DataSource("foo") { Id = DataSourceId.CreateNew() }; _settings.DataSources.Add(source); _dataSources = new DataSources(_logFileFactory, _scheduler, _settings.DataSources); _model = new DataSourcesViewModel(_settings, _dataSources, _actionCenter.Object); var viewModel = _model.Observable[0]; _settingsMock.ResetCalls(); viewModel.RemoveCommand.Execute(null); _settingsMock.Verify(x => x.SaveAsync(), Times.Once); }
public void TestRemove1() { _settings = new ApplicationSettings("foobar"); var source = new DataSource("foo") { Id = DataSourceId.CreateNew() }; _settings.DataSources.Add(source); _dataSources = new DataSources(_logFileFactory, _scheduler, _settings.DataSources); _model = new DataSourcesViewModel(_settings, _dataSources, _actionCenter.Object); var viewModel = _model.Observable[0]; viewModel.RemoveCommand.Execute(null); _model.Observable.Should().BeEmpty(); _dataSources.Sources.Should().BeEmpty(); _settings.DataSources.Should().BeEmpty(); }
public void TestCtor1() { _settings = new ApplicationSettings("foobar"); var group = new DataSource { Id = DataSourceId.CreateNew() }; var source1 = new DataSource("foo") { Id = DataSourceId.CreateNew(), ParentId = group.Id }; var source2 = new DataSource("bar") { Id = DataSourceId.CreateNew(), ParentId = group.Id }; var source3 = new DataSource("clondyke") { Id = DataSourceId.CreateNew() }; _settings.DataSources.Add(group); _settings.DataSources.Add(source1); _settings.DataSources.Add(source2); _settings.DataSources.Add(source3); _dataSources = new DataSources(_logFileFactory, _scheduler, _settings.DataSources); _model = new DataSourcesViewModel(_settings, _dataSources, _actionCenter.Object); _model.Observable.Count.Should().Be(2); var viewModel = _model.Observable[0]; viewModel.Should().NotBeNull(); viewModel.Should().BeOfType <MergedDataSourceViewModel>(); viewModel.DataSource.Id.Should().Be(group.Id); var merged = (MergedDataSourceViewModel)viewModel; merged.Observable.Count().Should().Be(2); merged.Observable.ElementAt(0).DataSource.Id.Should().Be(source1.Id); merged.Observable.ElementAt(1).DataSource.Id.Should().Be(source2.Id); viewModel = _model.Observable[1]; viewModel.Should().NotBeNull(); viewModel.Should().BeOfType <SingleDataSourceViewModel>(); viewModel.DataSource.Id.Should().Be(source3.Id); }
public void SetUp() { _settings = new ApplicationSettings("adwad"); _dispatcher = new ManualDispatcher(); _scheduler = new ManualTaskScheduler(); _logFileFactory = new PluginLogFileFactory(_scheduler); _dataSources = new DataSources(_logFileFactory, _scheduler, _settings.DataSources); _quickFilters = new QuickFilters(_settings.QuickFilters); _actionCenter = new ActionCenter(); _updater = new Mock <IAutoUpdater>(); _analysisStorage = new Mock <IAnalysisStorage>(); _mainWindow = new MainWindowViewModel(_settings, _dataSources, _quickFilters, _actionCenter, _updater.Object, _scheduler, _analysisStorage.Object, _dispatcher, new PluginRegistry()); }
public void TestRemove2() { _settings = new ApplicationSettings("foobar"); var group = new DataSource { Id = DataSourceId.CreateNew() }; var source1 = new DataSource("foo") { Id = DataSourceId.CreateNew(), ParentId = group.Id }; var source2 = new DataSource("bar") { Id = DataSourceId.CreateNew(), ParentId = group.Id }; var source3 = new DataSource("clondyke") { Id = DataSourceId.CreateNew(), ParentId = group.Id }; _settings.DataSources.Add(source1); _settings.DataSources.Add(source2); _settings.DataSources.Add(source3); _settings.DataSources.Add(group); _dataSources = new DataSources(_logFileFactory, _scheduler, _settings.DataSources); _model = new DataSourcesViewModel(_settings, _dataSources, _actionCenter.Object); var merged = (MergedDataSourceViewModel)_model.Observable[0]; var viewModel1 = merged.Observable.ElementAt(0); var viewModel2 = merged.Observable.ElementAt(1); var viewModel3 = merged.Observable.ElementAt(2); viewModel1.RemoveCommand.Execute(null); merged.ChildCount.Should().Be(2); merged.Observable.Should().NotContain(viewModel1); _model.Observable.Should().Equal(new object[] { merged }); _dataSources.Sources.Should().Equal(new object[] { viewModel2.DataSource, viewModel3.DataSource, merged.DataSource }); _settings.DataSources.Should().Equal(new object[] { source2, source3, group }); }
public MainWindowViewModel(ApplicationSettings settings, DataSources dataSources, QuickFilters quickFilters, IActionCenter actionCenter, IAutoUpdater updater, IDispatcher dispatcher) { if (dataSources == null) throw new ArgumentNullException("dataSources"); if (quickFilters == null) throw new ArgumentNullException("quickFilters"); if (updater == null) throw new ArgumentNullException("updater"); if (dispatcher == null) throw new ArgumentNullException("dispatcher"); _dataSourcesViewModel = new DataSourcesViewModel(settings, dataSources); _dataSourcesViewModel.PropertyChanged += DataSourcesViewModelOnPropertyChanged; _quickFilters = new QuickFiltersViewModel(settings, quickFilters); _quickFilters.OnFiltersChanged += OnQuickFiltersChanged; _settings = new SettingsViewModel(settings); _actionCenter = new ActionCenterViewModel(dispatcher, actionCenter); _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(100) }; _timer.Tick += TimerOnTick; _timer.Start(); _autoUpdater = new AutoUpdateViewModel(updater, settings.AutoUpdate, dispatcher); _dispatcher = dispatcher; WindowTitle = Constants.MainWindowTitle; _selectNextDataSourceCommand = new DelegateCommand(SelectNextDataSource); _selectPreviousDataSourceCommand = new DelegateCommand(SelectPreviousDataSource); _addDataSourceCommand = new DelegateCommand(AddDataSource); ChangeDataSource(CurrentDataSource); }
public void TestCtor2() { _settings = new ApplicationSettings("foobar"); var group = new DataSource {Id = Guid.NewGuid()}; var source = new DataSource("foo") {Id = Guid.NewGuid(), ParentId = Guid.NewGuid()}; _settings.DataSources.Add(group); _settings.DataSources.Add(source); _dataSources = new DataSources(_scheduler, _settings.DataSources); new Action(() => _model = new DataSourcesViewModel(_settings, _dataSources)).ShouldNotThrow(); _model.Observable.Count.Should().Be(2); IDataSourceViewModel viewModel = _model.Observable[0]; viewModel.Should().NotBeNull(); viewModel.Should().BeOfType<MergedDataSourceViewModel>(); viewModel.DataSource.Id.Should().Be(group.Id); var merged = (MergedDataSourceViewModel) viewModel; merged.Observable.Should().BeEmpty(); viewModel = _model.Observable[1]; viewModel.Should().NotBeNull(); viewModel.Should().BeOfType<SingleDataSourceViewModel>(); }
public void SetUp() { _settings = new ApplicationSettings("dawddwa"); _dataSources = new DataSources(_scheduler, _settings.DataSources); _model = new DataSourcesViewModel(_settings, _dataSources); }
public void TestRemove2() { _settings = new ApplicationSettings("foobar"); var group = new DataSource {Id = Guid.NewGuid()}; var source1 = new DataSource("foo") {Id = Guid.NewGuid(), ParentId = group.Id}; var source2 = new DataSource("bar") {Id = Guid.NewGuid(), ParentId = group.Id}; var source3 = new DataSource("clondyke") {Id = Guid.NewGuid(), ParentId = group.Id}; _settings.DataSources.Add(source1); _settings.DataSources.Add(source2); _settings.DataSources.Add(source3); _settings.DataSources.Add(group); _dataSources = new DataSources(_scheduler, _settings.DataSources); _model = new DataSourcesViewModel(_settings, _dataSources); var merged = (MergedDataSourceViewModel) _model.Observable[0]; IDataSourceViewModel viewModel1 = merged.Observable.ElementAt(0); IDataSourceViewModel viewModel2 = merged.Observable.ElementAt(1); IDataSourceViewModel viewModel3 = merged.Observable.ElementAt(2); viewModel1.RemoveCommand.Execute(null); merged.ChildCount.Should().Be(2); merged.Observable.Should().NotContain(viewModel1); _model.Observable.Should().Equal(new object[] {merged}); _dataSources.Should().Equal(new object[] {viewModel2.DataSource, viewModel3.DataSource, merged.DataSource}); _settings.DataSources.Should().Equal(new object[] {source2, source3, group}); }
public void TestCtor1() { _settings = new ApplicationSettings("foobar"); var group = new DataSource {Id = Guid.NewGuid()}; var source1 = new DataSource("foo") {Id = Guid.NewGuid(), ParentId = group.Id}; var source2 = new DataSource("bar") {Id = Guid.NewGuid(), ParentId = group.Id}; var source3 = new DataSource("clondyke") {Id = Guid.NewGuid()}; _settings.DataSources.Add(group); _settings.DataSources.Add(source1); _settings.DataSources.Add(source2); _settings.DataSources.Add(source3); _dataSources = new DataSources(_scheduler, _settings.DataSources); _model = new DataSourcesViewModel(_settings, _dataSources); _model.Observable.Count.Should().Be(2); IDataSourceViewModel viewModel = _model.Observable[0]; viewModel.Should().NotBeNull(); viewModel.Should().BeOfType<MergedDataSourceViewModel>(); viewModel.DataSource.Id.Should().Be(group.Id); var merged = (MergedDataSourceViewModel) viewModel; merged.Observable.Count().Should().Be(2); merged.Observable.ElementAt(0).DataSource.Id.Should().Be(source1.Id); merged.Observable.ElementAt(1).DataSource.Id.Should().Be(source2.Id); viewModel = _model.Observable[1]; viewModel.Should().NotBeNull(); viewModel.Should().BeOfType<SingleDataSourceViewModel>(); viewModel.DataSource.Id.Should().Be(source3.Id); }
private static int StartApplication(SingleApplicationHelper.IMutex mutex, string fileToOpen, Stopwatch stopwatch) { ApplicationSettings settings = ApplicationSettings.Create(); settings.Restore(out var neededPatching); settings.AllowSave = false; //< We will allow saving once the app is fully booted if (neededPatching) { // TODO: Save settings right again to complete the upgrade // (maybe we should preserve an old version) } var bookmarks = Bookmarks.Create(); bookmarks.Restore(); var services = new ServiceContainer(); services.RegisterInstance <ILogFileSettings>(settings.LogFile); var actionCenter = new ActionCenter(); using (var taskScheduler = new DefaultTaskScheduler()) using (var serialTaskScheduler = new SerialTaskScheduler()) { services.RegisterInstance <ITaskScheduler>(taskScheduler); services.RegisterInstance <ISerialTaskScheduler>(serialTaskScheduler); var navigationService = new NavigationService(); services.RegisterInstance <INavigationService>(navigationService); var filesystem = new Filesystem(taskScheduler); services.RegisterInstance <IFilesystem>(filesystem); using (var pluginArchiveLoader = new PluginArchiveLoader(filesystem, Constants.PluginPath, Constants.DownloadedPluginsPath)) { var pluginUpdater = new PluginUpdater(pluginArchiveLoader); services.RegisterInstance <IPluginUpdater>(pluginUpdater); var pluginSystem = CreatePluginSystem(pluginArchiveLoader); services.RegisterInstance <IPluginLoader>(pluginSystem); var logFileFormatRegistry = new LogFileFormatRegistry(pluginSystem, settings.CustomFormats); services.RegisterInstance <ILogFileFormatRepository>(logFileFormatRegistry); services.RegisterInstance <ILogFileFormatRegistry>(logFileFormatRegistry); var logFileFormatMatcher = new LogFileFormatMatcher(services); services.RegisterInstance <ILogFileFormatMatcher>(logFileFormatMatcher); var textLogFileParserPlugin = new LogEntryParserFactory(services); services.RegisterInstance <ILogEntryParserPlugin>(textLogFileParserPlugin); var propertyPresenter = new PropertyPresenterRegistry(pluginSystem); services.RegisterInstance <IPropertyPresenterPlugin>(propertyPresenter); var fileLogSourceFactory = new StreamingTextLogSourceFactory(filesystem, taskScheduler); services.RegisterInstance <IRawFileLogSourceFactory>(fileLogSourceFactory); var parsingLogSourceFactory = new ParsingLogSourceFactory(services); services.RegisterInstance <ILogSourceParserPlugin>(parsingLogSourceFactory); var customDataSourcePlugins = pluginSystem.LoadAllOfTypeWithDescription <ICustomDataSourcePlugin>(); var logFileFactory = new PluginLogSourceFactory(services, customDataSourcePlugins); using (var dataSources = new DataSources(logFileFactory, taskScheduler, filesystem, settings.DataSources, bookmarks)) using (var updater = new AutoUpdater(actionCenter, settings.AutoUpdate)) { if (fileToOpen != null) { if (File.Exists(fileToOpen)) { // Not only do we want to add this file to the list of data sources, // but we also want to select it so the user can view it immediately, regardless // of what was selected previously. var dataSource = dataSources.AddFile(fileToOpen); settings.DataSources.SelectedItem = dataSource.Id; } else { Log.ErrorFormat("File '{0}' does not exist, won't open it!", fileToOpen); } } if (settings.AutoUpdate.CheckForUpdates) { // Our initial check for updates is not due to a user action // and therefore we don't need to show a notification when the // application is up-to-date. updater.CheckForUpdates(addNotificationWhenUpToDate: false); } var quickFilters = new QuickFilters(settings.QuickFilters); var highlighters = new HighlighterCollection(); services.RegisterInstance <IHighlighters>(highlighters); actionCenter.Add(Build.Current); actionCenter.Add(Change.Merge(Changelog.MostRecentPatches)); var application = new App(); var dispatcher = Dispatcher.CurrentDispatcher; var uiDispatcher = new UiDispatcher(dispatcher); services.RegisterInstance <IDispatcher>(uiDispatcher); dispatcher.UnhandledException += actionCenter.ReportUnhandledException; TaskScheduler.UnobservedTaskException += actionCenter.ReportUnhandledException; var windowViewModel = new MainWindowViewModel(services, settings, dataSources, quickFilters, actionCenter, updater); navigationService.MainWindow = windowViewModel; var window = new MainWindow(settings, windowViewModel); settings.MainWindow.ClipToBounds(Desktop.Current); settings.MainWindow.RestoreTo(window); settings.AllowSave = true; stopwatch.Stop(); Log.InfoFormat("Tailviewer started (took {0}ms), showing window...", stopwatch.ElapsedMilliseconds); window.Show(); mutex?.SetListener(window); return(application.Run()); } } } }
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; }
private static int StartInternal(SingleApplicationHelper.IMutex mutex, string[] args) { InstallExceptionHandlers(); Log.InfoFormat("Starting tailviewer..."); Log.InfoFormat("Commandline arguments: {0}", string.Join(" ", args)); LogEnvironment(); ApplicationSettings settings = ApplicationSettings.Create(); settings.Restore(out var neededPatching); if (neededPatching) { // TODO: Save settings right again to complete the upgrade // (maybe we should preserve an old version) } var actionCenter = new ActionCenter(); using (var taskScheduler = new DefaultTaskScheduler()) using (var serialTaskScheduler = new SerialTaskScheduler()) { var filesystem = new Filesystem(serialTaskScheduler); using (var pluginArchiveLoader = new PluginArchiveLoader(filesystem, Constants.PluginPath)) { var pluginSystem = CreatePluginSystem(pluginArchiveLoader); var fileFormatPlugins = pluginSystem.LoadAllOfType <IFileFormatPlugin>(); var logFileFactory = new PluginLogFileFactory(taskScheduler, fileFormatPlugins); using (var dataSources = new DataSources(logFileFactory, taskScheduler, settings.DataSources)) using (var updater = new AutoUpdater(actionCenter, settings.AutoUpdate)) using (var logAnalyserEngine = new LogAnalyserEngine(taskScheduler, pluginSystem)) using (var dataSourceAnalyserEngine = new DataSourceAnalyserEngine(taskScheduler, logAnalyserEngine, pluginSystem)) using (var analysisStorage = new AnalysisStorage(taskScheduler, filesystem, dataSourceAnalyserEngine, CreateTypeFactory(pluginSystem))) { var arguments = ArgumentParser.TryParse(args); if (arguments.FileToOpen != null) { if (File.Exists(arguments.FileToOpen)) { // Not only do we want to add this file to the list of data sources, // but we also want to select it so the user can view it immediately, regardless // of what was selected previously. var dataSource = dataSources.AddDataSource(arguments.FileToOpen); settings.DataSources.SelectedItem = dataSource.Id; } else { Log.ErrorFormat("File '{0}' does not exist, won't open it!", arguments.FileToOpen); } } if (settings.AutoUpdate.CheckForUpdates) { // Our initial check for updates is not due to a user action // and therefore we don't need to show a notification when the // application is up-to-date. updater.CheckForUpdates(addNotificationWhenUpToDate: false); } var quickFilters = new QuickFilters(settings.QuickFilters); actionCenter.Add(Build.Current); actionCenter.Add(Change.Merge(Changelog.MostRecentPatches)); var application = new App(); var dispatcher = Dispatcher.CurrentDispatcher; var uiDispatcher = new UiDispatcher(dispatcher); dispatcher.UnhandledException += actionCenter.ReportUnhandledException; TaskScheduler.UnobservedTaskException += actionCenter.ReportUnhandledException; var window = new MainWindow(settings) { DataContext = new MainWindowViewModel(settings, dataSources, quickFilters, actionCenter, updater, taskScheduler, analysisStorage, uiDispatcher, pluginSystem) }; settings.MainWindow.RestoreTo(window); window.Show(); mutex.SetListener(window); return(application.Run()); } } } }
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(); }
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; } }
public static int Start(string[] args) { InstallExceptionHandlers(); Log.InfoFormat("Starting tailviewer..."); Log.InfoFormat("Commandline arguments: {0}", string.Join(" ", args)); LogEnvironment(); ApplicationSettings settings = ApplicationSettings.Create(); bool neededPatching; settings.Restore(out neededPatching); if (neededPatching) { // TODO: Save settings right again to complete the upgrade // (maybe we should preserve an old version) } var actionCenter = new ActionCenter(); using (var taskScheduler = new DefaultTaskScheduler()) using (var dataSources = new DataSources(taskScheduler, settings.DataSources)) using (var updater = new AutoUpdater(actionCenter, settings.AutoUpdate)) { if (args.Length > 0) { var filePath = args[0]; if (File.Exists(filePath)) { // Not only do we want to add this file to the list of data sources, // but we also want to select it so the user can view it immediately, regardless // of what was selected previously. var dataSource = dataSources.AddDataSource(filePath); settings.DataSources.SelectedItem = dataSource.Id; } else { Log.ErrorFormat("File '{0}' does not exist, won't open it!", filePath); } } if (settings.AutoUpdate.CheckForUpdates) { // Our initial check for updates is not due to a user action // and therefore we don't need to show a notification when the // application is up-to-date. updater.CheckForUpdates(addNotificationWhenUpToDate: false); } var quickFilters = new QuickFilters(settings.QuickFilters); actionCenter.Add(Changelog.MostRecent); var application = new App(); Dispatcher dispatcher = Dispatcher.CurrentDispatcher; var uiDispatcher = new UiDispatcher(dispatcher); dispatcher.UnhandledException += actionCenter.ReportUnhandledException; TaskScheduler.UnobservedTaskException += actionCenter.ReportUnhandledException; var window = new MainWindow(settings) { DataContext = new MainWindowViewModel(settings, dataSources, quickFilters, actionCenter, updater, uiDispatcher) }; settings.MainWindow.RestoreTo(window); window.Show(); return application.Run(); } }
public void TestRemove1() { _settings = new ApplicationSettings("foobar"); var source = new DataSource("foo") {Id = Guid.NewGuid()}; _settings.DataSources.Add(source); _dataSources = new DataSources(_scheduler, _settings.DataSources); _model = new DataSourcesViewModel(_settings, _dataSources); IDataSourceViewModel viewModel = _model.Observable[0]; viewModel.RemoveCommand.Execute(null); _model.Observable.Should().BeEmpty(); _dataSources.Should().BeEmpty(); _settings.DataSources.Should().BeEmpty(); }